Skip to content

Commit 0377f99

Browse files
committed
copy mdown from ipfs example
1 parent 789d9a3 commit 0377f99

25 files changed

+10606
-0
lines changed

Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
url="http://localhost:8080/ipfs/"
3+
4+
publish:
5+
@export hash=$(shell ipfs add -r -q . | tail -n1); \
6+
echo $$hash >published-version; \
7+
echo $(url)$$hash/mdown

lib/jquery.min.js

+26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/marked.min.js

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/mdown-style.css

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
body .navbar-static-top {
2+
width: inherit;
3+
}
4+
5+
body .navbar .navbar-inner {
6+
border: 0px;
7+
border-bottom: 1px solid #e6e6e6;
8+
box-shadow: none;
9+
background: none;
10+
}
11+
12+
body,
13+
body p {
14+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
15+
}
16+
17+
body h1,
18+
body h2,
19+
body h3,
20+
body h4 {
21+
margin: 30px 0px 15px;
22+
font-weight: 200;
23+
}

lib/params.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function getParameterByName(name) {
2+
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
3+
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
4+
results = regex.exec(location.search);
5+
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
6+
}

lib/prettify.min.js

+132
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/strapdown.css

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
2+
/*******************************************************************
3+
4+
This chunk is to fix Bootstrap so that the Markdown output looks good
5+
6+
*******************************************************************/
7+
8+
body {
9+
/*padding-top: 60px;*/
10+
padding-bottom: 40px;
11+
font-size: 15px;
12+
line-height: 150%;
13+
}
14+
15+
xmp, textarea {
16+
display: none;
17+
}
18+
19+
h1,h2,h3,h4 {
20+
margin: 15px 0;
21+
}
22+
23+
pre {
24+
margin: 20px 0;
25+
}
26+
27+
img {
28+
margin: 10px 0;
29+
}
30+
31+
.navbar {
32+
z-index: 1;
33+
}
34+
35+
.table {
36+
width: auto;
37+
}
38+
39+
/*******************************************************************
40+
41+
This chunk is for Google's Code Prettify:
42+
http://google-code-prettify.googlecode.com
43+
44+
*******************************************************************/
45+
46+
47+
/* Pretty printing styles. Used with prettify.js. */
48+
49+
/* SPAN elements with the classes below are added by prettyprint. */
50+
.pln { color: #000 } /* plain text */
51+
52+
@media screen {
53+
.str { color: #080 } /* string content */
54+
.kwd { color: #008 } /* a keyword */
55+
.com { color: #800 } /* a comment */
56+
.typ { color: #606 } /* a type name */
57+
.lit { color: #066 } /* a literal value */
58+
/* punctuation, lisp open bracket, lisp close bracket */
59+
.pun, .opn, .clo { color: #660 }
60+
.tag { color: #008 } /* a markup tag name */
61+
.atn { color: #606 } /* a markup attribute name */
62+
.atv { color: #080 } /* a markup attribute value */
63+
.dec, .var { color: #606 } /* a declaration; a variable name */
64+
.fun { color: red } /* a function name */
65+
}
66+
67+
/* Use higher contrast and text-weight for printable form. */
68+
@media print, projection {
69+
.str { color: #060 }
70+
.kwd { color: #006; font-weight: bold }
71+
.com { color: #600; font-style: italic }
72+
.typ { color: #404; font-weight: bold }
73+
.lit { color: #044 }
74+
.pun, .opn, .clo { color: #440 }
75+
.tag { color: #006; font-weight: bold }
76+
.atn { color: #404 }
77+
.atv { color: #060 }
78+
}
79+
80+
/* Put a border around prettyprinted code snippets. */
81+
pre.prettyprint { padding: 2px; border: 1px solid #888 }
82+
83+
/* Specify class=linenums on a pre to get line numbering */
84+
ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */
85+
li.L0,
86+
li.L1,
87+
li.L2,
88+
li.L3,
89+
li.L5,
90+
li.L6,
91+
li.L7,
92+
li.L8 { list-style-type: none }
93+
/* Alternate shading for lines */
94+
li.L1,
95+
li.L3,
96+
li.L5,
97+
li.L7,
98+
li.L9 { background: #eee }

lib/strapdown.js

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
function strapdown(window, document) {
2+
3+
// From: https://github.com/arturadib/strapdown/blob/gh-pages/src/strapdown.js
4+
5+
//////////////////////////////////////////////////////////////////////
6+
//
7+
// Shims for IE < 9
8+
//
9+
10+
document.head = document.getElementsByTagName('head')[0];
11+
12+
if (!('getElementsByClassName' in document)) {
13+
document.getElementsByClassName = function(name) {
14+
function getElementsByClassName(node, classname) {
15+
var a = [];
16+
var re = new RegExp('(^| )'+classname+'( |$)');
17+
var els = node.getElementsByTagName("*");
18+
for(var i=0,j=els.length; i<j; i++)
19+
if(re.test(els[i].className))a.push(els[i]);
20+
return a;
21+
}
22+
return getElementsByClassName(document.body, name);
23+
}
24+
}
25+
26+
//////////////////////////////////////////////////////////////////////
27+
//
28+
// Get user elements we need
29+
//
30+
31+
var markdownEl = document.getElementsByTagName('xmp')[0] || document.getElementsByTagName('textarea')[0],
32+
titleEl = document.getElementsByTagName('title')[0],
33+
scriptEls = document.getElementsByTagName('script'),
34+
navbarEl = document.getElementsByClassName('navbar')[0];
35+
36+
if (!markdownEl) {
37+
console.warn('No embedded Markdown found in this document for Strapdown.js to work on! Visit http://strapdownjs.com/ to learn more.');
38+
return;
39+
}
40+
41+
// Hide body until we're done fiddling with the DOM
42+
document.body.style.display = 'none';
43+
44+
//////////////////////////////////////////////////////////////////////
45+
//
46+
// <head> stuff
47+
//
48+
49+
// Use <meta> viewport so that Bootstrap is actually responsive on mobile
50+
var metaEl = document.createElement('meta');
51+
metaEl.name = 'viewport';
52+
metaEl.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0';
53+
if (document.head.firstChild)
54+
document.head.insertBefore(metaEl, document.head.firstChild);
55+
else
56+
document.head.appendChild(metaEl);
57+
58+
// Get origin of script
59+
var origin = '';
60+
for (var i = 0; i < scriptEls.length; i++) {
61+
if (scriptEls[i].src.match('strapdown')) {
62+
origin = scriptEls[i].src;
63+
}
64+
}
65+
var originBase = origin.substr(0, origin.lastIndexOf('/'));
66+
67+
// Get theme
68+
var theme = markdownEl.getAttribute('theme') || 'bootstrap';
69+
theme = theme.toLowerCase();
70+
71+
// Stylesheets
72+
var linkEl = document.createElement('link');
73+
linkEl.href = originBase + '/themes/'+theme+'.min.css';
74+
linkEl.rel = 'stylesheet';
75+
document.head.appendChild(linkEl);
76+
77+
var linkEl = document.createElement('link');
78+
linkEl.href = originBase + '/strapdown.css';
79+
linkEl.rel = 'stylesheet';
80+
document.head.appendChild(linkEl);
81+
82+
var linkEl = document.createElement('link');
83+
linkEl.href = originBase + '/themes/bootstrap-responsive.min.css';
84+
linkEl.rel = 'stylesheet';
85+
document.head.appendChild(linkEl);
86+
87+
//////////////////////////////////////////////////////////////////////
88+
//
89+
// <body> stuff
90+
//
91+
92+
var markdown = markdownEl.textContent || markdownEl.innerText;
93+
94+
var newNode = document.createElement('div');
95+
newNode.className = 'container';
96+
newNode.id = 'content';
97+
document.body.replaceChild(newNode, markdownEl);
98+
99+
// Insert navbar if there's none
100+
var newNode = document.createElement('div');
101+
newNode.className = 'navbar navbar-fixed-top';
102+
if (!navbarEl && titleEl) {
103+
newNode.innerHTML = '<div class="navbar-inner"> <div class="container"> <div id="headline" class="brand"> </div> </div> </div>';
104+
document.body.insertBefore(newNode, document.body.firstChild);
105+
var title = titleEl.innerHTML;
106+
var headlineEl = document.getElementById('headline');
107+
if (headlineEl)
108+
headlineEl.innerHTML = title;
109+
}
110+
111+
//////////////////////////////////////////////////////////////////////
112+
//
113+
// Markdown!
114+
//
115+
116+
// Generate Markdown
117+
var html = marked(markdown);
118+
document.getElementById('content').innerHTML = html;
119+
120+
// Prettify
121+
var codeEls = document.getElementsByTagName('code');
122+
for (var i=0, ii=codeEls.length; i<ii; i++) {
123+
var codeEl = codeEls[i];
124+
var lang = codeEl.className;
125+
codeEl.className = 'prettyprint lang-' + lang;
126+
}
127+
prettyPrint();
128+
129+
// Style tables
130+
var tableEls = document.getElementsByTagName('table');
131+
for (var i=0, ii=tableEls.length; i<ii; i++) {
132+
var tableEl = tableEls[i];
133+
tableEl.className = 'table table-striped table-bordered';
134+
}
135+
136+
// All done - show body
137+
document.body.style.display = '';
138+
139+
}

0 commit comments

Comments
 (0)