Class: Integral::PostsController

Inherits:
BlogController show all
Defined in:
app/controllers/integral/posts_controller.rb

Overview

Posts controller

Instance Method Summary collapse

Instance Method Details

#indexObject

GET / List blog posts



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/integral/posts_controller.rb', line 10

def index
  add_breadcrumb I18n.t('integral.breadcrumbs.blog'), nil

  @latest_post = Integral::Post.published.where(locale: I18n.locale).order('published_at DESC').first&.decorate
  @posts = Integral::Post.published.where(locale: I18n.locale).includes(:image, :user).order('published_at DESC').paginate(page: params[:page])
  @posts = @posts.where.not(id: @latest_post.id) if @latest_post

  page_title = t('integral.posts.index.title')
  page_description = t('integral.posts.index.description')
  if params[:page].present?
    page_title += " - Page #{params[:page]}"
    page_description += " - Page #{params[:page]}"
  end

  @meta_data = {
    page_title: page_title,
    page_description: page_description
  }
end

#showObject

GET /<post.slug> Presents blog postings



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/integral/posts_controller.rb', line 32

def show
  add_breadcrumb I18n.t('integral.breadcrumbs.blog'), integral.posts_url
  add_breadcrumb @resource.title, nil

  @meta_data = {
    page_title: @resource.title,
    page_description: @resource.description,
    open_graph: {
      image: @resource.preview_image_url(size: :large)
    }
  }
  template = 'default' # TODO: Implement post templates
  render "integral/posts/templates/#{template}"
end