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 42 43 44 45 46 47 |
# 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 = Lines::Article.published.tagged_with(params[:tag]).page(params[:page].to_i) else @articles = Lines::Article.published.page(params[:page].to_i).padding(1) end if @articles.first_page? if @first_article = Article.published.first @first_article. = nil unless @first_article..present? end end title: SITE_TITLE, description: CONFIG[:meta_description], keywords: KEYWORDS, open_graph: { title: SITE_TITLE, type: 'website', url: articles_url, site_name: SITE_TITLE, image: CONFIG[:og_logo] } } format.atom{ @articles = Lines::Article.published } end end |
#show ⇒ Object
Shows specific article
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/lines/articles_controller.rb', line 50 def show @first_page = true @article = Lines::Article.published.find(params[:id]) @article. = nil unless @article..present? = { title: @article.title, type: 'article', url: url_for(@article), 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 @related_articles = Lines::Article.published.where('id != ?', @article.id).order('').limit(2) end |