xonecas.io
818
Du

dustymarkdown / commit c0d6862

if this was a version it would be 0.001 :-)

xonecas2011-04-28 c0d68625439c32e3a587f4b4e094a07dfcb02ecf parent daaba70

16 files changed

build.js+42−19
@@ -14,50 +14,67 @@ function readTemplates (callback) {
1414 fs.readdir('./templates', function (err, templates) {
1515 if (err) throw err;
1616
17+ var tmpls = [];
1718 templates.forEach(function (template, index) {
18- if (template.match(/\.dust$/)) {
19+ if (template.match(/\.dust$/) && !template.match(/(^|\/)\./)) {
1920 fs.readFile('./templates/'+template, 'utf8', function (err2, file) {
2021 if (err) throw err;
2122
2223 template = template.replace('.dust', '');
2324 var compiled = dust.compile(file, template);
2425 dust.loadSource(compiled);
26+ tmpls.push(template+'.dust');
2527
26- if (index === templates.length-1)
27- callback(templates);
28+ if (index === templates.length-1) {
29+ callback(tmpls);
30+ }
2831 });
2932 }
3033 });
3134 });
3235 };
3336
34-/*
35-function getStats(dir, files, callback) {
36- var result = [];
37- files.forEach(function (file, index) {
38- fs.stat(dir+file, function (err, stats) {
39- result.push(stats);
40-
41- if (index === files.length-1)
42- callback(result);
37+// reads the filenames and stats from a dir
38+function readdir(dir, callback) {
39+ fs.readdir(dir, function (err, files) {
40+ if (err) throw err;
41+
42+ var result = [];
43+ files.forEach(function (file, index) {
44+ if (/^\.|\/\./.test(file)) return;
45+
46+ fs.stat(dir+'/'+file, function (err2, stats) {
47+ if (err2) throw err2;
48+
49+ stats.name = file;
50+ result.push(stats);
51+
52+ // sort files by creation date
53+ if (index === files.length-1) {
54+ result.sort(function (a, b) {
55+ return a.ctime - b.ctime;
56+ });
57+ callback(result.reverse());
58+ }
59+ });
4360 });
4461 });
4562 }
46-*/
4763
4864 // get all markdown files and parse them
4965 function readMarkdown (callback) {
5066 var htmlContent = {};
5167
52- fs.readdir('./markdown', function (err, files) {
53- if (err) throw err;
54-
55- files.forEach(function (filename, index) {
68+ readdir('./markdown', function (files) {
69+ var counter = files.length;
70+ files.forEach(function (fileStats, index) {
71+ var filename = fileStats.name;
5672 if (filename.match(/\.md$/)) {
5773 fs.readFile('./markdown/'+filename, 'utf8', function (err, file) {
74+ if (err) throw err;
75+
5876 // look for section pieces
5977 if (filename.match(/.+\_.+/)) {
60- // @TODO need to sort files by create date
6178 // its a section piece
6279 var split = filename.split('_'), section = split[0];
6380
@@ -69,8 +86,10 @@ function readMarkdown (callback) {
6986 htmlContent[filename] = markdown(file);
7087 }
7188
72- if (index === files.length-1)
89+ counter--;
90+ if (counter === 0) {
7391 callback(htmlContent);
92+ }
7493 });
7594 }
7695 });
@@ -80,8 +99,12 @@ function readMarkdown (callback) {
8099 // write the files to static folder.
81100 function writeFiles (tmpls, html) {
82101 tmpls.forEach(function (filename, index) {
102+ if (filename === undefined) return;
103+
83104 var templateName = filename.replace('.dust', '');
84105 dust.render(templateName, html, function (err, htmlFile) {
106+ if (err) throw err;
107+
85108 filename = './htdocs/'+filename.replace('.dust', '.html');
86109 fs.writeFile(filename, htmlFile, function (err) {
87110 if (err) throw err;
htdocs/about.html+4−2
@@ -1,3 +1,5 @@
1-<!doctype html><!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ --><!--[if lt IE 7]> <html class="no-js ie6" lang="en"> <![endif]--><!--[if IE 7]> <html class="no-js ie7" lang="en"> <![endif]--><!--[if IE 8]> <html class="no-js ie8" lang="en"> <![endif]--><!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--><head><meta charset="utf-8"><title></title><meta name="description" content=""><meta name="author" content=""><!-- Mobile viewport optimized …
1+<!doctype html><!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ --><!--[if lt IE 7]> <html class="no-js ie6" lang="en"> <![endif]--><!--[if IE 7]> <html class="no-js ie7" lang="en"> <![endif]--><!--[if IE 8]> <html class="no-js ie8" lang="en"> <![endif]--><!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--><head><meta charset="utf-8"><title></title><meta name="description" content=""><meta name="author" content=""><!-- Mobile viewport optimized …
22
3-<p>Don't be alarmed, this is just a test :-)</p><!-- JavaScript at the bottom for fast page loading --><script src="js/libs/ender.js"></script><!-- scripts concatenated and minified via ant build script--><script src="js/script.js"></script><!-- end scripts--><!-- simple uniques and page requests tracker, see server.js --><script>Modernizr.localstorage || document.write('<script src="js/libs/storage.js">\x3C/script>')</script><script>var s = localStorage, key = s.getItem('key');if (key === null) …
3+<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with deskto …
4+
5+<p>Click <a href="/">here</a> to go back.</p></section><!-- JavaScript at the bottom for fast page loading --><script src="js/libs/ender.js"></script><!-- scripts concatenated and minified via ant build script--><script src="js/script.js"></script><!-- end scripts--><!-- simple uniques and page requests tracker, see server.js --><script>Modernizr.localstorage || document.write('<script src="js/libs/storage.js">\x3C/script>')</script><script>var s = localStorage, key = s.getItem('key');if (key == …
htdocs/css/style.css+20−6
@@ -157,21 +157,35 @@ body, select, input, textarea {
157157 /* #444 looks better than black: twitter.com/H_FJ/statuses/11800719859 */
158158 color: #444;
159159 /* Set your base font here, to apply evenly */
160- /* font-family: Georgia, serif; */
160+ font-family: 'Oswald', Helvetica, arial, serif;
161161 }
162162
163163 /* Headers (h1, h2, etc) have no default font-size or margin; define those yourself */
164-h1, h2, h3, h4, h5, h6 { font-weight: bold; }
164+h1, h2, h3, h4, h5, h6 { font-weight: bold; margin: 1em 0; }
165165
166166
167167 /**
168168 * Primary styles
169169 *
170- * Author:
170+ * Author: @xonecas
171171 */
172+body {
173+ font-size: 1.230769230769231em;
174+ text-shadow: 0 2px 0 #ccc;
175+ }
176+
177+header { width: 100%; text-align: center; margin-bottom:1em; }
178+h1 {
179+ margin-top: 0;
180+ font-size: 2.25em;
181+ border-bottom: 5px solid #444;
182+ padding:5px 0;
183+}
184+ul { margin-bottom: 1em; }
185+em { font-weight: bold; }
186+footer { font-size: 0.875em; }
172187
173-
174-
188+.center { width: 75%; margin: 2em auto; }
175189
176190
177191
@@ -259,4 +273,4 @@ h1, h2, h3, h4, h5, h6 { font-weight: bold; }
259273 @page { margin: 0.5cm; }
260274 p, h2, h3 { orphans: 3; widows: 3; }
261275 h2, h3{ page-break-after: avoid; }
262-}
276+}
htdocs/index.html+14−18
@@ -1,23 +1,19 @@
1-<!doctype html><!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ --><!--[if lt IE 7]> <html class="no-js ie6" lang="en"> <![endif]--><!--[if IE 7]> <html class="no-js ie7" lang="en"> <![endif]--><!--[if IE 8]> <html class="no-js ie8" lang="en"> <![endif]--><!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--><head><meta charset="utf-8"><title></title><meta name="description" content=""><meta name="author" content=""><!-- Mobile viewport optimized …
1+<!doctype html><!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ --><!--[if lt IE 7]> <html class="no-js ie6" lang="en"> <![endif]--><!--[if IE 7]> <html class="no-js ie7" lang="en"> <![endif]--><!--[if IE 8]> <html class="no-js ie8" lang="en"> <![endif]--><!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--><head><meta charset="utf-8"><title></title><meta name="description" content=""><meta name="author" content=""><!-- Mobile viewport optimized …
2+It's very minimal and light, developer friendly. The idea
3+is that you can write the dynamic content in markdown and
4+use dust to combine static and dynamic.</p>
25
3-<p>this is a test paragraph</p>
6+<h2>This app is only possible thanks to:</h2>
47
5-<h2>here is a list</h2>
8+<ul>
9+<li>HTML5 Boilerplate</li>
10+<li>Ender <em>no-library</em></li>
11+<li>Dust.js</li>
12+<li>Markdown</li>
13+</ul>
614
7-<ol>
8-<li>Hello</li>
9-<li>World</li>
10-</ol>
15+<p>See the example page <a href="/about">here</a>.</p></section><footer class="center"><h3>Thu, 28 of April, 2011</h3>
1116
12-<blockquote>
13- <p>He said something
14- Yep he did.</p>
15-</blockquote><h1>Hi BEN!</h1>
17+<p>First cleaned up. Added defult pages. Things look pretty now.</p> <h3>Thu, 28 of April, 2011</h3>
1618
17-<p>How are you today?</p> <h2>check out new code!!</h2>
18-
19-<p><code>this + that</code></p> <h2>HI!</h2>
20-
21-<blockquote>
22- <p>This is a quote</p>
23-</blockquote> <!-- JavaScript at the bottom for fast page loading --><script src="js/libs/ender.js"></script><!-- scripts concatenated and minified via ant build script--><script src="js/script.js"></script><!-- end scripts--><!-- simple uniques and page requests tracker, see server.js --><script>Modernizr.localstorage || document.write('<script src="js/libs/storage.js">\x3C/script>')</script><script>var s = localStorage, key = s.getItem('key');if (key === null) { key = +new Date(); s.setItem('k …
19+<p>This is an example entry so that I now it's working.</p> </footer><!-- JavaScript at the bottom for fast page loading --><script src="js/libs/ender.js"></script><!-- scripts concatenated and minified via ant build script--><script src="js/script.js"></script><!-- end scripts--><!-- simple uniques and page requests tracker, see server.js --><script>Modernizr.localstorage || document.write('<script src="js/libs/storage.js">\x3C/script>')</script><script>var s = localStorage, key = s.getItem('ke …
markdown/about.md+11−10
@@ -1,14 +1,15 @@
1-## Test
1+This project is the new content manager under xonecas.com.
2+It's very minimal and light, developer friendly. The idea
3+is that you can write the dynamic content in markdown and
4+use dust to combine static and dynamic.
25
3-this is a test paragraph
6+This app is only possible thanks to:
7+------------------------------------
48
5-here is a list
6---------------
7-
8-1. Hello
9-2. World
10-
11-> He said something
12-> Yep he did.
9+* HTML5 Boilerplate
10+* Ender *no-library*
11+* Dust.js
12+* Markdown
1313
14+See the example page [here](/about).
1415
markdown/ahah.md+0−0
markdown/blabla.md+0−3
@@ -1,3 +0,0 @@
1-# die die die!!!
2-
3-Don't be alarmed, this is just a test :-)
markdown/changelog_1.md+3−0
@@ -0,0 +1,3 @@
1+### Thu, 28 of April, 2011
2+
3+First cleaned up. Added defult pages. Things look pretty now.
markdown/changelog_2.md+3−0
@@ -0,0 +1,3 @@
1+### Thu, 28 of April, 2011
2+
3+This is an example entry so that I now it's working.
markdown/example.md+5−0
@@ -0,0 +1,5 @@
1+## This is just an example page.
2+
3+Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop p …
4+
5+Click [here](/) to go back.
markdown/header.md+3−0
@@ -0,0 +1,3 @@
1+Dusty Markdown
2+==============
3+
markdown/posts_blabla.md+0−3
@@ -1,3 +0,0 @@
1-# Hi BEN!
2-
3-How are you today?
markdown/posts_code.md+0−3
@@ -1,3 +0,0 @@
1-## check out new code!!
2-
3-`this + that`
markdown/posts_hello.md+0−3
@@ -1,3 +0,0 @@
1-## HI!
2-
3-> This is a quote
templates/about.dust+5−2
@@ -16,6 +16,7 @@
1616
1717 <!-- CSS: implied media="all" -->
1818 <link rel="stylesheet" href="css/style.css">
19+ <link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
1920
2021 <!-- All JavaScript at the bottom, except for Modernizr which enables HTML5 elements & feature detects -->
2122 <script src="js/libs/modernizr.js"></script>
@@ -23,8 +24,10 @@
2324 </head>
2425
2526 <body>
26-
27-{blabla_md|s}
27+ <header>{header_md|s}</header>
28+ <section id="main">
29+ {example_md|s}
30+ </section>
2831
2932 <!-- JavaScript at the bottom for fast page loading -->
3033 <script src="js/libs/ender.js"></script>
templates/index.dust+11−3
@@ -16,6 +16,8 @@
1616
1717 <!-- CSS: implied media="all" -->
1818 <link rel="stylesheet" href="css/style.css">
19+ <link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
20+
1921
2022 <!-- All JavaScript at the bottom, except for Modernizr which enables HTML5 elements & feature detects -->
2123 <script src="js/libs/modernizr.js"></script>
@@ -23,10 +25,16 @@
2325 </head>
2426
2527 <body>
28+ <header>
29+ {header_md|s}
30+ </header>
31+ <section id="main" class="center">
32+ {about_md|s}
33+ </section>
34+ <footer class="center">
35+ {#changelog}{.|s} {/changelog}
36+ </footer>
2637
27-{about_md|s}
28-
29-{#posts}{.|s} {/posts}
3038
3139
3240 <!-- JavaScript at the bottom for fast page loading -->