Class: Lines::ArticlesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Lines::ArticlesController
- Defined in:
- app/controllers/lines/articles_controller.rb
Constant Summary collapse
- KEYWORDS =
CONFIG[:keywords]
- SITE_TITLE =
CONFIG[:title]
Instance Method Summary collapse
-
#index ⇒ Object
Lists all published articles.
-
#show ⇒ Object
Shows specific article.
Instance Method Details
#index ⇒ Object
Lists all published articles. Responds to html and atom
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/lines/articles_controller.rb', line 16 def index respond_to do |format| format.html { @first_page = (params[:page] and params[:page].to_i > 0) ? false : true if params[:tag] @articles = Article.published.tagged_with(params[:tag]).page(params[:page].to_i) else @articles = Article.published.page(params[:page].to_i).padding(1) end @first_article = Article.published.first if @articles.first_page? title: SITE_TITLE, description: CONFIG[:meta_description], keywords: KEYWORDS, open_graph: { title: SITE_TITLE, type: 'website', url: 'meta_og_url', site_name: SITE_TITLE, image: CONFIG[:og_logo] } } format.atom{ @articles = Article.published } end end |
#show ⇒ Object
Shows specific article
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/lines/articles_controller.rb', line 44 def show @first_page = true @article = Article.published.find(params[:id]) = { title: SITE_TITLE, type: 'article', url: 'meta_og_url', site_name: SITE_TITLE, } [:image] = CONFIG[:host] + @article.image_url if @article.image_url.present? title: @article.title, keywords: KEYWORDS + @article.tag_list.to_s, open_graph: if request.path != article_path(@article) return redirect_to @article, status: :moved_permanently end end |