Class: SimpleBlog
- Inherits:
-
Object
- Object
- SimpleBlog
- Defined in:
- lib/simpleblog.rb
Class Method Summary collapse
Class Method Details
.list_posts(tag = "", in_progress = "true") ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/simpleblog.rb', line 34 def self.list_posts(tag = "", in_progress = "true") posts_yml_result = YAML.load_file("app/posts/posts.yml")["posts"] posts = Post.build_list_of_posts(posts_yml_result) if tag.present? posts = posts.filter { |post| post..include?(tag) } end posts = if in_progress == "true" posts.filter { |post| post.in_progress } else posts.filter { |post| !post.in_progress } end posts.sort_by(&:id).reverse! end |
.render_post(id) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/simpleblog.rb', line 27 def self.render_post(id) post_content = File.open("app/posts/#{id.to_i}.md").read markdown = Redcarpet::Markdown.new(PostHTMLRender, fenced_code_blocks: true) markdown.render(post_content) end |