Last active
August 29, 2015 14:07
-
-
Save chrismytton/cb500e0947d673fd7d5d to your computer and use it in GitHub Desktop.
Revisions
-
chrismytton revised this gist
Oct 13, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,8 +15,8 @@ def content end end POSTS_PATH = File.join(ARGV[0], '*.md') POSTS = Dir.glob(POSTS_PATH).sort.reverse.map { |path| Post.new(path) } puts ERB.new(DATA.read).result -
chrismytton renamed this gist
Oct 13, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
chrismytton renamed this gist
Oct 13, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
chrismytton revised this gist
Oct 13, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ require 'kramdown' require 'erb' abort "Usage: #$0 <posts_path>" if ARGV.empty? Post = Struct.new(:path) do def title @@ -15,6 +15,7 @@ def content end end POSTS_PATH = ARGV[0] POSTS = Dir.glob(POSTS_PATH + '/*.md').map { |path| Post.new(path) } puts ERB.new(DATA.read).result -
chrismytton created this gist
Oct 13, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ #!/usr/bin/env ruby require 'date' require 'kramdown' require 'erb' POSTS_PATH = File.expand_path('../../posts', __FILE__) Post = Struct.new(:path) do def title Date.strptime(File.basename(path, '.md'), '%Y-%m-%d').strftime('%d %B %Y') end def content Kramdown::Document.new(File.read(path)).to_html end end POSTS = Dir.glob(POSTS_PATH + '/*.md').map { |path| Post.new(path) } puts ERB.new(DATA.read).result __END__ <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>~crm</title> <style> body { max-width: 600px; margin: 0 auto; padding: 10px; } </style> </head> <body> <h1>~crm</h1> <% POSTS.each do |post| %> <h2><%= post.title %></h2> <div><%= post.content %></div> <% end %> </body> </html>