Created
January 14, 2016 08:28
-
-
Save DamirSvrtan/889133405cf02e4327e0 to your computer and use it in GitHub Desktop.
This file contains 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 characters
def index | |
@posts = Post.published | |
fresh_when @posts # Sets the etag, last_modified, or both on the response and renders a "304 Not Modified" response if the request is already fresh. | |
@is_first_page = (params[:page] == 1 || params[:page] == nil) | |
is_first_paginating_page = @is_first_page | |
if params[:tag].present? | |
first_page_size = 12 | |
@posts = @posts.tagged_with(params[:tag].underscore.humanize) | |
@tag = params[:tag].underscore.humanize == "shameless" ? "Shameless plug " : params[:tag].underscore.humanize | |
@blog_title = "Capsized Eight" | |
@blog_tag_name = "#{@tag}" | |
@page_title = "#{@tag}" | |
add_breadcrumb params[:tag].underscore.humanize, blog_tag_path(params[:tag]) | |
@is_first_page = false | |
else | |
first_page_size = 13 | |
@blog_title = @page_title = "Capsized Eight" | |
end | |
if is_first_paginating_page | |
@show_pagination = @posts.size > first_page_size | |
@posts = @posts.page(params[:page]).per(first_page_size) | |
else | |
@show_pagination = @posts.size > PAGE_SIZE | |
@posts = @posts.page(params[:page]).per(PAGE_SIZE).padding(first_page_size - PAGE_SIZE) | |
end | |
@next_post_page = @posts.next_page | |
@page_description = "Read articles about design, programming and business." | |
set_meta_tags open_graph: {description: stripped_markdown(@page_description)} | |
@page_footer = 'hire_us' | |
set_meta_tags og: { | |
title: "Capsized Eight - Infinum blog" | |
}, | |
twitter: { | |
title: "Capsized Eight - Infinum blog" | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment