Skip to content
Browse files

New features: added an archive page. Made the blog page show only the…

… last 6 post (1 post expanded & 5 previous posts title-only). Made the date element for the posts,index,archives a span instead of a div or just text. Wrapped the title of the posts in a span element.
  • Loading branch information...
1 parent 6e42116 commit d98403794a14b56e829538cd7fba5d8e07f31cf0 @nicolasH committed Jul 21, 2011
Showing with 93 additions and 47 deletions.
  1. +21 −21 ___.sh
  2. +8 −0 _archives-body
  3. +2 −2 _both-footer
  4. +48 −14 _common-css.css
  5. +3 −2 _index-body
  6. +3 −2 _index-middle
  7. +8 −6 _post-body
View
42 ___.sh
@@ -1,42 +1,42 @@
#!/bin/bash
if [ "$1" = "init" ];then
- echo " init : Creates the blog directory and copies all the 'templates' files (_files) there."
+ echo " init : Creates the blog directory and copies all the 'templates' files (_files) there."
mkdir blog; ls _*-* | sed 's:_\(.*\):mv _\1 blog/\1:'| bash
- echo "You can now add the 'blog' directory to a git repository and save it."
- exit
+ echo "You can now add the 'blog' directory to a git repository and save it.";exit
fi
if [ "$1" = "new" ];then
- echo " new [title] : Creates an blog post at blog/`date +%Y_%m_%d`.[prettified title].md ."
- echo "$2" >> blog/`date +%Y_%m_%d.``echo $2 |sed 's:[\ \" \, \.\:\?_]:\-:g' | sed -e "s:':\-:g" | sed -e 's:\-\-*:\-:g'| sed -e 's:\-$::;s:^\-::'`.md
- exit
+ echo " new [title] : Creates an blog post at blog/`date +%Y_%m_%d`.[prettified title].md ."
+ echo "$2" >> blog/`date +%Y_%m_%d.``echo $2 |sed 's:[\ \" \, \.\:\?_]:\-:g' | sed -e "s:':\-:g" | sed -e 's:\-\-*:\-:g'| sed -e 's:\-$::;s:^\-::'`.md;exit
fi
if [ "$1" = "clean" ];then
- cd blog
- echo " clean : Removes the generated html files by removing the date directories"
- rm -r `ls *.md | cut -c 1-4 | sort | uniq`;rm index.html
- exit
+ echo " clean : Removes the generated html files by removing the date directories"
+ cd blog; rm -r `ls *.md | cut -c 1-4 | sort | uniq`;rm index.html archives.html;exit
fi
if [ "$1" = "gen" ];then
- echo " gen : Generates the blog"
- cd blog
+ echo " gen : Generates the blog"
echo "0 - Removing the generated html files by removing the year directories"
- rm -r `ls *.md | cut -c 1-4 | sort | uniq`;rm index.html
+ cd blog; rm -r `ls *.md | cut -c 1-4 | sort | uniq`;rm index.html archives.html
echo "1 - Creating the year/month/day directories"
mkdir -p `ls *.md | cut -c 1-10 | sed 's#_#/#g'|sort | uniq`
echo "2 - Creating the posts"
- ls *.md|sort -r| sed 's#\(.\{10\}\)\.\(.*\)\.md#echo \1 \1.\2.html >> titles;head -n 1 TK\1.\2.md|sed "s:\#\*::g" >> titles;cat both-header >> \1.\2.html;head -n 1 TK\1.\2.md |sed "s:\#\*::g" >> \1.\2.html;cat post-body >> \1.\2\.html;echo "<div class=\\"date\\">\1</div><a href=\\"\2.html\\"> ">> \1.\2.html;multimarkdown TK\1.\2.md | sed "1 s:>$:></a>:" >> \1.\2\.html;cat both-footer >> \1.\2\.html;#' |sed 's#_#\/#g'|sed 's# TK\(....\)\/\(..\)\/\(..\)\.# \1_\2_\3.#g' | sed 's: \(....\/..\/..\)\.: \1\/:g'|bash
- echo "3 - Creating the index"
+ ls *.md|sort -r| sed 's#\(.\{10\}\)\.\(.*\)\.md#echo \1 \1.\2.html >> titles;head -n 1 TK\1.\2.md|sed "s:\#\*::g" >> titles;cat both-header >> \1.\2.html;head -n 1 TK\1.\2.md |sed "s:\#\*::g" >> \1.\2.html;cat post-body >> \1.\2\.html;echo "<span class=\\"date\\">\1</span> <a href=\\"\2.html\\"> ">> \1.\2.html;multimarkdown TK\1.\2.md | sed "1 s:>$:></a>:" >> \1.\2\.html;cat both-footer >> \1.\2\.html;#' |sed 's#_#\/#g'|sed 's# TK\(....\)\/\(..\)\/\(..\)\.# \1_\2_\3.#g' | sed 's: \(....\/..\/..\)\.: \1\/:g'|bash
+ echo "3 - Creating the blog home page"
cat both-header index-body >> index.html
- ls *.md|sort -r|head -n 1|sed 's#\(....\).\(..\).\(..\).\(.*\).md#echo "<div class=\"date\">\1\/\2\/\3</div><a href=\\"\1\/\2\/\3\/\4.html\\">";multimarkdown \1\_\2\_\3.\4.md|sed "1 s:>$:></a>:"#'|bash >> index.html
+ ls *.md|sort -r|head -n 1|sed 's#\(....\).\(..\).\(..\).\(.*\).md#echo "<span class=\"date\">\1\/\2\/\3</span> <a href=\\"\1\/\2\/\3\/\4.html\\">";multimarkdown \1\_\2\_\3.\4.md|sed "1 s:>$:></a>:"#'|bash >> index.html
cat index-middle >>index.html
- #Transform the lines of the titles file into the Date Link Title format.
- sed -e :a -e '1,2d; /\(\.*\.html\)$/N; s/\n/\"\>/; ta' titles | sed 's:\(.\{11\}\)\.*\(.*\):\<div class=\"index_item\"\>\1 \&raquo\; <a href\=\"\2\<\/a\>\<\/div\>:'>>index.html
- cat both-footer >> index.html;rm titles
- echo "And voila!"
- exit
+ #Transform last 5 previous posts into the Date Link Title format.
+ head -n 12 titles | sed -e :a -e '1,2d; /\(\.*\.html\)$/N; s/\n/\"\>/; ta' | sed 's:\(.\{11\}\)\.*\(.*\):\<div class=\"index_item\"\><span class=\"date\">\1</span> <span class=\"date_sep\"> \&raquo\;</span> <span class=\"title\"><a href\=\"\2\<\/a\></span>\<\/div\>:'>>index.html
+ cat both-footer >> index.html
+ echo "4 - Creating the blog archive page"
+ cat both-header >> archives.html
+ cat archives-body >> archives.html
+ #Transform all the lines of the titles file into the Date Link Title format.
+ sed -e :a -e '/\(\.*\.html\)$/N; s/\n/\"\>/; ta' titles | sed 's:\(.\{11\}\)\.*\(.*\):\<div class=\"index_item\"\><span class=\"date\">\1</span> <span class=\"date_sep\"> \&raquo\;</span> <span class=\"title\"><a href\=\"\2\<\/a\></span>\<\/div\>:'>> archives.html
+ cat both-footer >> archives.html;rm titles
+ echo "And voila!";exit
fi
echo "usage : ___.sh init new [title] clean gen";cat ___.sh | grep "echo \" " |bash
View
8 _archives-body
@@ -0,0 +1,8 @@
+Archives for - My Blog Name Goes Here -</title>
+<!-- This will be prepended between the title and the list of posts -->
+<link rel="stylesheet" type="text/css" href="common-css.css">
+</head>
+<body>
+<div class="content">
+ <h1>All my posts</h1>
+ <div class="post">
View
4 _both-footer
@@ -1,7 +1,7 @@
</div><!-- closes the "index" or "post" div -->
</div><!-- closes the "content" div -->
<!-- this will be appended at the end of the individual pages for each post and to the generated index file -->
-<div class="copy">This blog brought to you by ___ , available at <a href="https://github.com/nicolasH/frankensteins/">https://github.com/nicolasH/frankensteins/</a></div>
-<!-- you might want to put your analytics script here. -->
+<div class="copy">This blog brought to you by <code>___.sh</code> , available at <a href="https://github.com/nicolasH/frankensteins/">https://github.com/nicolasH/frankensteins/</a></div>
+<!-- you might want to put the import of your scripts for analytics and social buttons here. -->
</body>
</html>
View
62 _common-css.css
@@ -15,6 +15,14 @@ body {
background-color: whitesmoke;
}
+
+.content{
+ width: 800px;
+ padding-left: 8em;
+ margin: -0px auto;
+ overflow: hidden;
+}
+
.nav {
width: 900px;
margin: -0px auto;
@@ -24,33 +32,59 @@ body {
height: 4em;
}
-.date{
- margin-left: -6em;
- float: left;
- font-size: 1.3em;
- color: #aaa;
+.nav li {
+ display: inline;
+ float: right;
+ padding: 0;
+ margin: 0;
}
-.content{
- width: 800px;
- padding-left: 8em;
- margin: -0px auto;
- overflow: hidden;
+
+div.nav li a
+{
+ text-align: center;
+ display: block;
+ min-width: 45px;
+ padding: 1px 15px 2px 15px;
+ margin: 0;
+ margin-left: -1px;
+
}
+.date {
+ color: #aaa;
+}
.post{
-
+ margin-top: 2em;
+}
+.post span.date{
+ margin-left: -6em;
+ font-size: 1.3em;
+}
+.post h2{
+ display: inline;
+ margin-left: 0.5em;
}
.index {
border-top: 1px solid darkgray;
padding: 2em 0em 1em 0em;
}
+.index_item span.date{
+ margin-left: -5.5em;
+ font-size: 1em;
+}
+
.copy{
- padding: 5em 0em 5em 0em;
+ padding: 5em 0em 1em 0em;
text-align: center;
- font-size: 0.8em;
- display:hidden;
+ font-size: 0.7em;
+ color: #aaa;
+ margin: -0px auto;
+}
+
+.copy a{
+ color: #aaa;
}
View
5 _index-body
@@ -1,7 +1,8 @@
-- My Blog Name Goes Here</title>
+- My Blog Name Goes Here -</title>
<!-- This will be prepended between the title and the list of posts -->
<link rel="stylesheet" type="text/css" href="common-css.css">
</head>
<body>
<div class="content">
-<div class="post">
+ <h1>My blog</h1>
+ <div class="post">
View
5 _index-middle
@@ -1,3 +1,4 @@
-</div><!-- close the "post" div -->
+</div>
<div class="index">
-<h2>The other blog posts</h2>
+<h2>Earlier posts</h2>
+<p>Here are the previous few posts. A complete list of all the posts on this blog is available in the <a href="archives.html">archives</a>.</p>
View
14 _post-body
@@ -1,13 +1,15 @@
-- My Blog Name Goes Here
+- blog for Displayator
</title>
<!-- This will be prepended to each of the post's content -->
<link rel="stylesheet" type="text/css" href="../../../common-css.css">
</head>
<body>
-<div class="content">
<div class="nav">
- <a href="../../../">Posts List</a>
- <a href="../../../../">Home</a>
+ <ul>
+ <li><a href="../../../archives.html">blog archives</a></li>
+ <li><a href="../../../">blog index</a></li>
+ </ul>
</div>
-<div class="post">
-
+<div class="content">
+<h1>My Blog</h1>
+ <div class="post">

0 comments on commit d984037

Please sign in to comment.
Something went wrong with that request. Please try again.