Class: Blogo::PostsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/blogo/posts_controller.rb

Overview

Responsible for showing posts and atom feeds to visitors.

Constant Summary collapse

FEED_POSTS_LIMIT =

Number of posts shown in feed.

20

Instance Method Summary collapse

Instance Method Details

#feedObject

GET /posts/feed


41
42
43
44
45
46
# File 'app/controllers/blogo/posts_controller.rb', line 41

def feed
  @posts   = Post.published.limit(FEED_POSTS_LIMIT)
  @updated = @posts.first.try(:updated_at)

  render 'feed', layout: false
end

#indexObject

GET /posts


11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/blogo/posts_controller.rb', line 11

def index
  @tag = params[:tag]
  set_vars
  set_paginator

  @meta = {}
  @meta[:title]     = "#{Blogo.config.site_title} - #{Blogo.config.site_subtitle}"
  @meta[:site_name] = Blogo.config.site_title
  @meta[:keywords]  = Blogo.config.keywords
  @meta[:type]      = 'website'
end

#showObject

GET /posts/:permalink


25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/blogo/posts_controller.rb', line 25

def show
  @post = Post.published.where(:permalink => params[:permalink]).first!
  set_vars

  @meta = {}
  @meta[:title]       = "#{@post.title} - #{Blogo.config.site_title}"
  @meta[:description] = @post.meta_description
  @meta[:keywords]    = [@post.tags_string, Blogo.config.keywords].flatten.join(", ")
  @meta[:url]         = request.url
  @meta[:image]       = meta_image
  @meta[:type]        = 'article'
  @meta[:site_name]   = Blogo.config.site_title
end