Skip to content

Commit

Permalink
Update tempalte engine
Browse files Browse the repository at this point in the history
  • Loading branch information
dafeng.xdf committed Oct 6, 2014
1 parent 2eb8e3e commit dcb448d
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 90 deletions.
9 changes: 9 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0.5.22 / 2014-10-06
===================

* Update tempalte engine

0.5.16 / 2014-10-03
===================

* Beautify Slider style
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ startserver
[download-image]: https://img.shields.io/npm/dm/startserver.svg?style=flat-square
[download-url]: https://npmjs.org/package/startserver


> A simple http server witch can be used like `python -m SimpleHTTPServer` and be more easy to generate a slider.
## Installment
Expand Down
28 changes: 12 additions & 16 deletions lib/middleware/directory/default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,35 @@
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
<style>
thead th{
height: 40px;
border-bottom: 1px #ccc solid;
}
td{
padding: 8px 12px 0 12px;
}
thead th{height: 40px;border-bottom: 1px #ccc solid;}
td{padding: 8px 12px 0 12px;}
</style>
</head>
<body>
<h1>Index of <#=$path#></h1>
<h1>Index of <#=path#></h1>
<table>
<thead>
<tr>
<th>Name</th>
<th>Last modified</th>
<th>Size</th>
</thead>
<#if $parentDir#>
<#if (parentDir) {#>
<tbody>
<tr>
<td colspan="3"><a href="<#=$parentDir#>">Parent Directory</a></td>
<td colspan="3"><a href="<#=parentDir#>">Parent Directory</a></td>
</tr>
</tbody>
<#/if#>
<#}#>
<tbody>
<#each val,index in $list#>
<#for (var i =0; i< list.length; i++) {#>
<#var item = list[i]#>
<tr>
<td><a href="<#=$val.path#>"><#=$val.name#></a></td>
<td><#=$val.lastModified#></td>
<td><#=$val.size#></td>
<td><a href="<#=item.path#>"><#=item.name#></a></td>
<td><#=item.lastModified#></td>
<td><#=item.size#></td>
</tr>
<#/each#>
<#}#>
</tbody>
</table>
</body>
Expand Down
6 changes: 3 additions & 3 deletions lib/middleware/directory/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var path = require('path');
var url = require('url');
var normalize = path.normalize;
var basename = path.basename;
var minitpl = require('minitpl');
var microtemplate = require('microtemplate');
var root = process.cwd();
var xutil = require('xutil');
var fileUtil = xutil.file;
Expand All @@ -28,7 +28,7 @@ var sep = path.sep;

var template = path.join(__dirname, 'default.tpl');
template = fs.readFileSync(template, 'utf-8');
template = minitpl.compile(template);
template = microtemplate.compile(template);

module.exports = Directory;

Expand Down Expand Up @@ -133,7 +133,7 @@ function indexRouter(res, next, localPath, standardPath) {
} else {
indexFile = fileUtil.readFile(indexPath, 'binary');
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(indexFile, "binary");
res.write(indexFile, 'binary');
next();
break;
}
Expand Down
20 changes: 10 additions & 10 deletions lib/middleware/markdown/default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
<title><#=$title#></title>
<title><#=title#></title>
<style>
body {padding: 0 20%; opacity: 0;transition: all 1s ease;}
.right-top {position: absolute; top: 20px; right: 20px;}
Expand Down Expand Up @@ -302,7 +302,7 @@ body {padding: 0 20%; opacity: 0;transition: all 1s ease;}
</head>
<body>
<div id="page" class="markdown">
<#=$content#>
<#=content#>
</div>
<div class="right-top" id="radios">
<label>normal</label>
Expand All @@ -312,21 +312,21 @@ body {padding: 0 20%; opacity: 0;transition: all 1s ease;}
</div>
<script>
(function(global, undefined) {
var invert = document.getElementById("invert");
var isSlide = document.getElementById("slide").checked;
var invert = document.getElementById('invert');
var isSlide = document.getElementById('slide').checked;
function setCookie(name, value, expiresHours) {
var cookieString = name + "=" + escape(value);
var cookieString = name + '=' + escape(value);
if ( expiresHours > 0 ) {
var date = new Date();
date.setTime( date.getTime + expiresHours * 3600 * 1000);
cookieString = cookieString + "; expires=" + date.toGMTString();
cookieString = cookieString + '; expires=' + date.toGMTString();
}
document.cookie = cookieString;
}
document.getElementById("radios").addEventListener("click", function(e) {
if (e.target.nodeName === "INPUT" && e.target.value === "false") {
setCookie("startserver-slide", true, 240);
location.href = "";
document.getElementById('radios').addEventListener('click', function(e) {
if (e.target.nodeName === 'INPUT' && e.target.value === 'false') {
setCookie('startserver-slide', true, 240);
location.href = '';
}
});
setTimeout(function() {
Expand Down
4 changes: 2 additions & 2 deletions lib/middleware/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var path = require('path');
var url = require('url');
var fs = require('fs');
var xutil = require('xutil');
var minitpl = require('minitpl');
var microtemplate = require('microtemplate');
var fileUtil = xutil.file;
var parse = url.parse;
var join = path.join;
Expand All @@ -28,7 +28,7 @@ var normalize = path.normalize;
function render(type, data) {
var template = path.join(__dirname, type + '.tpl');
template = fs.readFileSync(template, 'utf-8');
template = minitpl.compile(template);
template = microtemplate.compile(template);
return template(data);
}

Expand Down
Loading

0 comments on commit dcb448d

Please sign in to comment.