-
Notifications
You must be signed in to change notification settings - Fork 17
/
README.md.html
395 lines (375 loc) · 15 KB
/
README.md.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
<title>server</title>
<style>
/* invert */
.invert {background: #fff;}
.invert #page .page {background: #fff;color: #000;}
.invert .right-top {color: #000;}
.invert .inner blockquote p,
.invert .inner pre,
.invert .inner code {color: #fff;background:#000;margin-left: 6px;}
.invert .inner pre,
.invert .inner ul,
.invert .inner ol {color:#fff;}
.invert .inner li {color:#000;}
/* base */
html{margin:0;padding:0;height:100%;}
body {margin:0;padding:0;height:100%;background: #000;-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;opacity:
1;color:#fff;font-family: Helvetica, arial, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";}
#page {width:100%;height:100%;position:relative;overflow-x:hidden;overflow-y:auto;}
.page{color:white;width:100%;height:100%;overflow:hidden;text-align:left;position:absolute;opacity:0;transition:transform
.8s ease;background:black;}
.prev {opacity:0.2;transform: translate(-100%, 0);}
.current {opacity:1;z-index:999;}
.next {opacity:0.2;transform: translate(100%, 0);}
.right-top {transition:all .5s ease;position: absolute;top: 20px;right:
20px;z-index: 99999;opacity: 0.4;}
.right-top:hover {opacity: 0.8;}
.switcher {background-color: rgba(123, 123, 123, 0.1);border: none;top:
0;font-size: 40px;margin: 0;max-width: 150px;min-width: 80px;outline:
none;padding: 0;position: absolute;top: 0;z-index: 9999;color: rgba(158, 158,
158, 0.5);height:100%;}
.switcher:hover, .switcher:focus {cursor: pointer;background-color: rgba(123, 123, 123, 0.2);}
#copyright { position: absolute; bottom: 20px; left: 50%; margin-left: -192px;
display: none;width: 384px;font-weight:bold;}
#copyright a {text-decoration: none;color: #D1C556;font-weight:bold;}
/* inner */
.inner {margin: 40px 100px;}
.inner a {text-decoration: none;color: #e7ad52;cursor:pointer;font-weight: bold;}
.inner h1 {font-size:55px;padding-bottom: 8px;}
.inner h2 {font-size:40px;padding-bottom: 20px;}
.inner h3 {font-size:30px;padding-bottom: 10px;}
.inner h4 {font-size:25px;padding-bottom: 5px;}
.inner p,
.inner blockquote,
.inner pre {margin: 0;font-size: 26px;line-height: 1.4em;margin-top:30px;}
.inner blockquote,
.inner pre,
.inner code {background: #2f3129;border-radius: 4px;padding: 2px
4px;margin-right:10px;margin-top:30px;font-weight:bold;overflow:hidden;word-wrap: break-word;}
.inner blockquote p {margin-top:0;word-spacing: 4px;padding: 4px;}
.inner pre
.inner ul,
.inner ol{font-size: 26px;line-height:1.4em;background:rgb(47, 47, 47);border-radius: 10px;padding: 10px 50px;}
.inner li {color: #fff;padding: 10px 4px;font-size: 22px;}
.inner hr {display:none;margin-top:10px;}
.inner table { table-layout:fixed; empty-cells:show; border-collapse:
collapse;margin:0 auto; border:2px solid #666; }
.inner table th,
.inner table td{text-align: left; border:1px solid #666; padding: 0.8em 1em;}
.inner table th { background: rgba(244, 253, 255, 0.24);font-weight: bold;padding: 1em;}
.inner img{transition: all 1s linear;width:auto;}
.inner img:hover {width: 100%!important;}
/* thumbnail */
.thumbnail {background: #000;}
.thumbnail .page {position: static;display: inline-block;overflow:
hidden;cursor: pointer;width: 20%;height: 20%;background: rgba(128, 128, 128,
0.35);margin-left: 30px;margin-top: 20px; transform: none; border-radius:
10px;opacity:1;}
.thumbnail .page .inner {padding: 4px 10px; margin: 0;text-align: center;}
.thumbnail .page .inner h1,
.thumbnail .page .inner h2 {font-size: 22px; text-align: center;}
.thumbnail .page .inner ul,
.thumbnail .page .inner li,
.thumbnail .page .inner ol,
.thumbnail .page .inner pre,
.thumbnail .page .inner img,
.thumbnail .page .inner p,
.thumbnail .page .inner code,
.thumbnail .page .inner h3,
.thumbnail .page .inner h4,
.thumbnail .page .inner h5,
.thumbnail .page .inner h6,
.thumbnail .page .inner table,
.thumbnail .page .inner i,
.thumbnail .page .inner strong,
.thumbnail .page .inner b,
.thumbnail .page .inner hr,
.thumbnail .page .inner blockquote{display: none;}
.thumbnail #copyright {display: block;}
.thumbnail .switcher {display: none!important;}
/* highlight */
.hljs{display:block;overflow-x:auto;padding:.5em;background:#fdf6e3;color:#657b83;-webkit-text-size-adjust:none}.hljs-comment,.hljs-template_comment,.diff .hljs-header,.hljs-doctype,.hljs-pi,.lisp .hljs-string,.hljs-javadoc{color:#93a1a1}.hljs-keyword,.hljs-winutils,.method,.hljs-addition,.css .hljs-tag,.hljs-request,.hljs-status,.nginx .hljs-title{color:#859900}.hljs-number,.hljs-command,.hljs-string,.hljs-tag .hljs-value,.hljs-rules .hljs-value,.hljs-phpdoc,.hljs-dartdoc,.tex .hljs-formula,.hljs-regexp,.hljs-hexcolor,.hljs-link_url{color:#2aa198}.hljs-title,.hljs-localvars,.hljs-chunk,.hljs-decorator,.hljs-built_in,.hljs-identifier,.vhdl .hljs-literal,.hljs-id,.css .hljs-function{color:#268bd2}.hljs-attribute,.hljs-variable,.lisp .hljs-body,.smalltalk .hljs-number,.hljs-constant,.hljs-class .hljs-title,.hljs-parent,.hljs-type,.hljs-link_reference{color:#b58900}.hljs-preprocessor,.hljs-preprocessor .hljs-keyword,.hljs-pragma,.hljs-shebang,.hljs-symbol,.hljs-symbol .hljs-string,.diff .hljs-change,.hljs-special,.hljs-attr_selector,.hljs-subst,.hljs-cdata,.css .hljs-pseudo,.hljs-header{color:#cb4b16}.hljs-deletion,.hljs-important{color:#dc322f}.hljs-link_label{color:#6c71c4}.tex .hljs-formula{background:#eee8d5}
</style>
<base target="_blank"/>
</head>
<body>
<input type="hidden" id="mode" value=""/>
<div id="page">
<h1 id="startserver">startserver</h1>
<p><a href="https://npmjs.org/package/startserver"><img src="https://img.shields.io/npm/v/startserver.svg?style=flat-square" alt="NPM version"></a>
<a href="https://travis-ci.org/xudafeng/startserver"><img src="https://img.shields.io/travis/xudafeng/startserver.svg?style=flat-square" alt="build status"></a>
<a href="https://coveralls.io/r/xudafeng/startserver?branch=master"><img src="https://img.shields.io/coveralls/xudafeng/startserver.svg?style=flat-square" alt="Test coverage"></a>
<a href="http://nodejs.org/download/"><img src="https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square" alt="node version"></a>
<a href="https://npmjs.org/package/startserver"><img src="https://img.shields.io/npm/dm/startserver.svg?style=flat-square" alt="npm download"></a></p>
<blockquote>
<p>Yet another http server.</p>
</blockquote>
<h2 id="installation">Installation</h2>
<h3 id="node-requirement">Node requirement</h3>
<p>>= 0.10.x</p>
<h3 id="install-from-npm">Install from npm</h3>
<pre><code class="lang-bash">$ npm <span class="hljs-tag">i</span> startserver -g
</code></pre>
<p>Use it for generator support, add this alias to your <code>.bash_profile</code>:</p>
<pre><code><span class="hljs-literal">alias</span> <span class="hljs-keyword">node</span>=<span class="hljs-string">'node --harmony'</span>
</code></pre><p>Or you'd better use <a href="https://iojs.org/cn/index.html">io.js</a> as an alternative.</p>
<h2 id="quick-start">Quick Start</h2>
<pre><code class="lang-bash"><span class="hljs-variable">$ </span>startserver
</code></pre>
<p>It also can be use it like this:</p>
<pre><code class="lang-base"><span class="hljs-variable">$ </span>startserver <span class="hljs-number">6789</span>
</code></pre>
<p>There are more shorter alias for it:</p>
<pre><code class="lang-base"><span class="hljs-variable">$ </span>ss
</code></pre>
<h2 id="features">Features</h2>
<h3 id="server-everywhere">Server Everywhere</h3>
<p>Run it at every directory under the root.</p>
<ul>
<li>Automatic detection of unoccupied port.</li>
</ul>
<h3 id="slider-revolution">Slider Revolution</h3>
<p>Generate slider with <code>README.md</code> file or other markdown file.</p>
<ul>
<li>Suppor a inverse color style.</li>
<li>Double click for temporary modifications, again to restore.</li>
<li>Normal to read makedown.</li>
<li>Highlight for your code block.</li>
<li>Thumbnail mode provided.</li>
</ul>
<h3 id="others">Others</h3>
<ul>
<li>Generator support and compatible runtime.</li>
<li>Original javascript source code.</li>
</ul>
<h2 id="commands">Commands</h2>
<h4 id="plugins">plugins</h4>
<p>show plugin list</p>
<h4 id="generate">generate</h4>
<pre><code class="lang-bash">$ startsever generate README.<span class="hljs-built_in">md</span>
</code></pre>
<p>generate static slide file to markdown <a href="https://rawgit.com/xudafeng/startserver/master/README.md.html">[sample]</a></p>
<h2 id="plugins">Plugins</h2>
<p><img src="https://avatars3.githubusercontent.com/u/9607546?v=3&s=100" alt="logo"></p>
<p><a href="https://github.com/startserver">plugins list</a></p>
<h2 id="options">Options</h2>
<h4 id="-s-silent">-s, --silent</h4>
<p>start http server without opening browser</p>
<h4 id="-m-markdown">-m, --markdown</h4>
<p>auto parse and render markdown file</p>
<h4 id="-f-pdf">-f, --pdf</h4>
<p>render markdown file with pdf style</p>
<h4 id="-p-port">-p, --port</h4>
<p>port to use (8080 default)</p>
<h4 id="-d-disable">-d, --disable</h4>
<p>disable default index router</p>
<h4 id="-v-version">-v, --version</h4>
<p>output version infomation</p>
<h2 id="help">Help</h2>
<pre><code class="lang-bash"><span class="hljs-variable">$ </span>startserver -h
</code></pre>
<h2 id="license">License</h2>
<p>The MIT License (MIT)</p>
<p>Copyright (c) 2013 xdf</p>
</div>
<div class="right-top" id="radios">
<label>invert</label>
<input type="checkbox" id="invert"/>
<label>normal</label>
<input type="radio" name="slide" value="true" />
<label>slide</label>
<input id="slide" type="radio" name="slide" checked value="false"/>
</div>
<button id="left" class="switcher" style="left: 0px;">‹</button>
<button id="right" class="switcher" style="right: 0px;">›</button>
<div id="copyright">Thank you for enjoy. © <a href="https://github.com/xudafeng/startserver"
target="_blank">Startserver</a> <iframe
src="http://ghbtns.com/github-btn.html?user=xudafeng&repo=startserver&type=watch&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="80px" height="20px"></iframe></div>
<script>
+function(global, undefined) {
var isSlide = document.getElementById('slide').checked;
var mode = document.getElementById('mode');
var ispdf = mode.value === 'pdf';
var index = location.hash.split('=')[1] || 1;
var left = document.getElementById('left');
var right = document.getElementById('right');
var page = document.getElementById('page');
var invert = document.getElementById('invert');
var isThumbnail = false;
var isInvert = false;
page.designMode = 'on';
var pages = page.children;
var radios = document.getElementById('radios');
function setCookie(name, value, expiresHours) {
var cookieString = name + '=' + escape(value);
if (expiresHours > 0) {
var date = new Date();
date.setTime( date.getTime + expiresHours * 3600 * 1000);
cookieString = cookieString + ';expires=' + date.toGMTString();
}
document.cookie = cookieString;
}
function addClass(index, name) {
if (!pages[index]) return;
pages[index].className += ' ' + name;
}
function removeClass() {
for (var i = 0; i < pages.length; i++) {
pages[i].className = 'page';
}
}
function direct(target) {
left.style.display = 'block';
right.style.display = 'block';
if (index == 1) left.style.display = 'none';
if (index == pages.length) right.style.display = 'none';
location.href = target || '';
}
function prev() {
if (index == 1) return;
index --;
direct('#page=' + index);
}
function next() {
if (index == pages.length) return;
index ++;
direct('#page=' + index);
}
function thumbnail() {
isThumbnail = !isThumbnail;
editAble(isThumbnail ? 'false' : 'true');
var cls = '';
if (isInvert) cls += ' invert';
if (isThumbnail) cls += ' thumbnail';
document.body.className = cls;
}
function editAble(r) {
page.contentEditable = r;
}
function slider() {
if (index == 0) {
return thumbnail();
};
removeClass();
addClass(index - 1, 'current');
setTimeout(function() {
addClass(index, 'next');
addClass(index - 2, 'prev');
}, 16);
}
var temp = '';
var counter = 0;
for (var i = 0;i < pages.length; i++) {
var current = pages[i];
var tagName = current.tagName;
var nextTag = pages[i + 1];
var nextTagName = nextTag ? nextTag.tagName : null;
if (i === 0 || tagName === 'H1' || tagName === 'H2') {
temp += '<article class="page"';
if (ispdf) {
temp += ' style= "transform: translate(0, ' + 100 * counter + '%);"';
}
temp += '><div class="inner">';
counter ++;
}
temp += current.outerHTML;
if (nextTagName === 'H1' || nextTagName === 'H2') {
temp += '<\/div><\/article>';
}
}
page.innerHTML = temp + '<\/div><\/article>';
pages = page.querySelectorAll('.page');
if (ispdf) {
return;
}
function delegate(target) {
return target.nodeName && target.nodeName.toLowerCase() === 'article' ? target : delegate(target.parentElement);
}
function getIndex(e) {
var p = e.parentNode;
var c = p.children;
for (var i=0; i < c.length; i++) {
if (c[i] == e) {
return i;
};
}
}
radios.addEventListener('click', function(e) {
if (e.target.nodeName === 'INPUT' && e.target.value === 'true') {
setCookie('startserver-slide', false, 240);
direct();
}
});
page.addEventListener('click', function(e) {
if (!isThumbnail) return;
var target = delegate(e.target);
var index = getIndex(target) + 1;
thumbnail();
direct('#page=' + index);
});
global.addEventListener('hashchange', function() {
index = location.hash.split('=')[1] || 1;
slider();
});
global.addEventListener('mousewheel', function(e) {
if (isThumbnail) return;
var target = pages[index - 1];
var delta = e.wheelDelta / 120;
target.scrollTop += delta > 0 ? -10 : 10;
});
left.addEventListener('click', function() {
prev();
});
right.addEventListener('click', function() {
next();
});
page.addEventListener('dblclick', function() {
if (isThumbnail) return;
editAble(page.contentEditable === 'true' ? 'false' : 'true');
});
invert.addEventListener('change', function(e) {
var target = e.target;
isInvert = target.checked;
var cls = '';
if (isInvert) cls += ' invert';
if (isThumbnail) cls += ' thumbnail';
document.body.className = cls;
});
document.addEventListener('keydown', function(e) {
switch (e.keyCode) {
case 39:
case 40:
e.preventDefault();
next();
break;
case 37:
case 38:
e.preventDefault();
prev();
break;
case 27:
e.preventDefault();
direct('#page=' + 0);
break;
}
});
setTimeout(function() {
var images = document.querySelectorAll('img');
for (var i = 0; i < images.length; i ++) {
images[i].setAttribute('style', 'width:' + images[i].width + 'px;');
}
}, 5000);
setTimeout(function() {
direct('#page=' + index);
document.body.style.opacity = 1;
}, 16);
}(this);
</script>
</body>
</html>