Sha256: 983c8b147ba5627d5026fa12c739e3d181479f39c21d0ccee782cd99282741b1
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
class Blog::BlogpostController < Blog::MainController LATEST_FOR_PREVIEW = 2 BLOGPOSTS_FOR_PREVIEW = 6 RELATED_FOR_PREVIEW = 3 def index # Fetch data as Json data = BlogpostParser.fetch_all_published categories = CategoryParser.fetch_all_categories # Build Blogposts by category @categories_with_blogposts = categories.map do |category| Blog::Category.new(category).build_n_blogposts_by_category(data, BLOGPOSTS_FOR_PREVIEW) end # Build latest Blogposts @latest_blogposts = data.first(LATEST_FOR_PREVIEW) .map { |attributes| Blog::Blogpost.new(attributes) } end def show @blogpost = Blog::Blogpost.build_blogpost_from_path(params[:blog_path], 'en') redirect_to blog_path unless @blogpost.published data = BlogpostParser.fetch_all_published @related_blogposts = data.select { |b| b['category']['slug'] == @blogpost.category.slug && b['title'] != @blogpost.title } .first(RELATED_FOR_PREVIEW) .sort_by { |b| b['updated_at'] }.reverse .map { |attributes| Blog::Blogpost.new attributes } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
station-0.5.4 | lib/nexmo_developer/app/controllers/blog/blogpost_controller.rb |
station-0.5.3 | lib/nexmo_developer/app/controllers/blog/blogpost_controller.rb |