Class: Dadablog::Blog
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Dadablog::Blog
- Defined in:
- lib/dadablog/blog.rb
Instance Method Summary collapse
- #deploy ⇒ Object
-
#initialize(root) ⇒ Blog
constructor
A new instance of Blog.
Constructor Details
Instance Method Details
#deploy ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/dadablog/blog.rb', line 46 def deploy articles = [] Dir.glob "#{settings.root}/articles/*md" do |file| , content = File.read(file, {:encoding => 'utf-8'}).split("\n\n", 2) article = OpenStruct.new YAML.load() article.date = Time.parse article.date.to_s article.content = content article.slug = File.basename(file, '.md') self.class.get "/articles/#{article.slug}" do erb :post, :locals => {:article => article} end articles << article end articles.sort_by! { |article| article.date } articles.reverse! self.class.set :articles, articles self.class.get '/' do erb :index end end |