From 63fdb8b3f9b25c984273188cdc040f849552d7d1 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 27 Nov 2011 22:58:28 -0800 Subject: [PATCH] add blog archive, tweak styles --- assets/blog.css | 43 ++++++++----------- assets/blog.js | 10 ----- assets/mobile.css | 33 +++++---------- blog.rb | 17 +++++--- samhuri.net.tmproj | 82 ++++++++++++++++++++++++++++++++++-- templates/blog/archive.html | 41 ++++++++++++++++++ templates/blog/index.html | 18 +------- templates/blog/link.mustache | 5 +-- templates/blog/post.html | 20 +-------- templates/blog/post.mustache | 1 - 10 files changed, 163 insertions(+), 107 deletions(-) create mode 100644 templates/blog/archive.html diff --git a/assets/blog.css b/assets/blog.css index c3c2027..d66113a 100644 --- a/assets/blog.css +++ b/assets/blog.css @@ -1,5 +1,5 @@ body { margin: 0 - ; padding: 0 + ; padding: 0 0 3em } h1 { margin: 0 @@ -17,6 +17,8 @@ h1 { margin: 0 .hidden { display: none } +#archive { text-align: center } + #index { width: 80% ; min-width: 300px ; max-width: 800px @@ -26,13 +28,12 @@ h1 { margin: 0 ; border-radius: 10px ; background-color: #eee ; margin: 1em auto + ; padding: 1em ; font-size: 1.2em + ; line-height: 1.5em + ; list-style-type: none } -#index ul { padding: 0 1em - ; list-style-type: none - } - .date { float: right } article { width: 80% @@ -65,6 +66,7 @@ article h1 a:hover { text-shadow: #cc0 1px 1px 8px article h2 { font-size: 1.8em ; font-weight: normal + ; text-align: left ; margin: 1em 0 ; padding: 0 ; color: #222 @@ -78,26 +80,10 @@ time { color: #444 ; font-size: 1.2em } +#permalink { font-size: 1em } + .gist { font-size: 0.8em } -#around { width: 80% - ; min-width: 400px - ; max-width: 800px - ; margin: 1em auto - ; padding: 0 3em 1em - ; font-size: 1.2em - } - -#prev { float: left } -#next { float: right } -#around br { clear: both } - -.sep { text-align: center - ; font-size: 2em - ; color: #666 - ; display: none - } - /* show discussion */ #sd-container { margin: 3em 0 } @@ -174,14 +160,19 @@ input[type=submit] { font-size: 1.1em } footer { margin: 0 - ; padding: 1em 0 - ; background-color: #cdf + ; padding: 0.2em 0 + ; background-color: #def ; border-top: solid 1px #bbb ; clear: both + ; position: fixed + ; width: 100% + ; bottom: 0 } +footer p { margin: 0.5em } + footer a { border-bottom: none ; color: #25c - ; font-size: 1.3em + ; font-size: 1.2em ; text-decoration: none } diff --git a/assets/blog.js b/assets/blog.js index 00e5a58..e1bc4d9 100644 --- a/assets/blog.js +++ b/assets/blog.js @@ -37,15 +37,6 @@ jQuery(function($) { - var hidden = true - , index = $('#index') - - $('#index-toggle').click(function() { - index.toggle() - hidden = !hidden - $(this).html(hidden ? '↓ show posts ↓' : '↑ hide posts ↑') - }) - $('#need-js').remove() SJS.request({uri: countCommentsURL(SJS.filename)}, function(err, request, body) { @@ -65,7 +56,6 @@ $('#sd-container').remove() $('#comment-stuff').slideDown(1.5, function() { this.scrollIntoView(true) }) getComments() - return false }) var showdown = new Showdown.converter() diff --git a/assets/mobile.css b/assets/mobile.css index ca81af0..24b0f24 100644 --- a/assets/mobile.css +++ b/assets/mobile.css @@ -23,6 +23,8 @@ { /* common */ + body { padding-bottom: 0 } + h1 { font-size: 2em ; margin-top: 1em } @@ -50,18 +52,14 @@ #blog img { max-width: 100% } - nav#index { width: 90% - ; min-width: 310px - ; margin: 0.3em auto - ; padding-bottom: 0.3em - } + #index { width: 90% + ; min-width: 200px + ; margin: 0.3em auto 1em + ; padding: 0.5em + ; font-size: 1em + } - nav#index ul { font-size: 0.8em - ; padding-left: 2em - } - - nav#index li { list-style-type: disc } - nav#index li > span.date { display: none } + #index li > span.date { display: none } #blog article h1 { font-size: 1.6em ; margin-top: 0 @@ -77,18 +75,6 @@ pre, .gist { font-size: 0.8em } - .sep { font-size: 1em } - - #around { min-width: 310px - ; margin: 0 - ; padding: 0 0.2em - ; font-size: 0.8em - } - - #prev, #next { padding: 0.3em 0 - ; font-size: 0.95em - } - #comment-stuff { padding: 0 ; margin-top: 2em } @@ -123,6 +109,7 @@ footer { margin: 0 ; padding: 0.5em 0 + ; position: relative } } diff --git a/blog.rb b/blog.rb index a7355d8..359427a 100755 --- a/blog.rb +++ b/blog.rb @@ -44,6 +44,7 @@ class Blag generate_index generate_rss generate_posts_json + generate_archive end def generate_index @@ -51,8 +52,7 @@ class Blag index_template = File.read(File.join('templates', 'blog', 'index.html')) post = posts.first template = post[:link] ? link_template : post_template - values = { :posts => posts, - :post => post, + values = { :post => post, :article => Mustache.render(template, post), :previous => posts[1], :filename => post[:filename], @@ -66,8 +66,7 @@ class Blag page_template = File.read(File.join('templates', 'blog', 'post.html')) posts.each_with_index do |post, i| template = post[:link] ? link_template : post_template - values = { :posts => posts, - :title => post[:title], + values = { :title => post[:title], :link => post[:link], :article => Mustache.render(template, post), :previous => i < posts.length - 1 && posts[i + 1], @@ -86,6 +85,12 @@ class Blag File.open(File.join(@dest, 'posts.json'), 'w') { |f| f.puts(json) } end + def generate_archive + archive_template = File.read(File.join('templates', 'blog', 'archive.html')) + html = Mustache.render(archive_template, :posts => posts) + File.open(File.join(@dest, 'archive.html'), 'w') { |f| f.puts(html) } + end + def generate_rss # posts rss File.open(rss_file, 'w') { |f| f.puts(rss.target!) } @@ -170,14 +175,14 @@ class Blag xml.instruct! 'xml-stylesheet', :href => 'http://samhuri.net/assets/blog-all.min.css', :type => 'text/css' xml.rss :version => '2.0' do xml.channel do - xml.title post[:link] ? "→ #{title}" : title + xml.title title xml.description subtitle xml.link url xml.pubDate posts.first[:rfc822] posts.each do |post| xml.item do - xml.title post[:title] + xml.title post[:link] ? "→ #{post[:title]}" : post[:title] xml.description post[:rss_html] xml.pubDate post[:rfc822] xml.author post[:author] diff --git a/samhuri.net.tmproj b/samhuri.net.tmproj index 1c44dae..01e68ef 100644 --- a/samhuri.net.tmproj +++ b/samhuri.net.tmproj @@ -3,7 +3,7 @@ currentDocument - assets/mobile.css + blog.rb documents @@ -86,12 +86,12 @@ column 0 line - 73 + 172 firstVisibleColumn 0 firstVisibleLine - 33 + 140 combine.sh @@ -107,6 +107,34 @@ firstVisibleLine 0 + templates/blog/link.mustache + + caret + + column + 0 + line + 9 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + templates/blog/link.rss.html + + caret + + column + 0 + line + 10 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + templates/blog/post.html caret @@ -121,6 +149,50 @@ firstVisibleLine 0 + templates/blog/post.mustache + + caret + + column + 0 + line + 7 + + columnSelection + + firstVisibleColumn + 0 + firstVisibleLine + 0 + selectFrom + + column + 0 + line + 8 + + selectTo + + column + 0 + line + 7 + + + templates/blog/post.rss.html + + caret + + column + 0 + line + 9 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + templates/proj/index.html caret @@ -139,6 +211,10 @@ openDocuments assets/mobile.css + templates/blog/link.rss.html + templates/blog/post.mustache + templates/blog/link.mustache + templates/blog/post.rss.html templates/proj/index.html assets/request.js templates/blog/post.html diff --git a/templates/blog/archive.html b/templates/blog/archive.html new file mode 100644 index 0000000..b0f1756 --- /dev/null +++ b/templates/blog/archive.html @@ -0,0 +1,41 @@ + + + + +archive :: sjs' blog + + + + + + + +
+

sjs' blog

+
+
    + {{#posts}} +
  • {{title}} {{date}}
  • + {{/posts}} +
+ + + + diff --git a/templates/blog/index.html b/templates/blog/index.html index b0374ce..a5ef76b 100644 --- a/templates/blog/index.html +++ b/templates/blog/index.html @@ -12,24 +12,8 @@

sjs' blog

- - + {{{article}}} -
- {{#previous}} - - {{/previous}} - {{#next}} - - {{/next}} -
-
{{#comments}}

(discussion requires JavaScript)

diff --git a/templates/blog/link.mustache b/templates/blog/link.mustache index 4079aaa..373088b 100644 --- a/templates/blog/link.mustache +++ b/templates/blog/link.mustache @@ -1,9 +1,8 @@ -

diff --git a/templates/blog/post.html b/templates/blog/post.html index 9491243..cd008c0 100644 --- a/templates/blog/post.html +++ b/templates/blog/post.html @@ -9,28 +9,12 @@ - +

sjs' blog

- - + {{{article}}} -
- {{#previous}} - - {{/previous}} - {{#next}} - - {{/next}} -
-
{{#comments}}

(discussion requires JavaScript)

diff --git a/templates/blog/post.mustache b/templates/blog/post.mustache index 36b2f7f..40f644a 100644 --- a/templates/blog/post.mustache +++ b/templates/blog/post.mustache @@ -5,4 +5,3 @@ {{{body}}} -