Class: Storytime::BlogsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/storytime/blogs_controller.rb

Direct Known Subclasses

BlogHomepageController

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_user!, #current_user, #setup, #user_signed_in?

Methods included from Concerns::CurrentSite

#current_storytime_site

Methods included from Concerns::ControllerContentFor

#content_for, #content_for?, #view_context

Instance Method Details

#showObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/storytime/blogs_controller.rb', line 7

def show
  if params[:preview].nil? && params[:id].present? && params[:id] != @page.slug
    return redirect_to @page, :status => :moved_permanently
  end

  @posts = @page.posts
  @posts = Storytime.search_adapter.search(params[:search], get_search_type) if (params[:search] && params[:search].length > 0)
  @posts = @posts.tagged_with(params[:tag]) if params[:tag]
  @posts = @posts.published.order(published_at: :desc).page(params[:page_number])

  #allow overriding in the host app
  render "storytime/#{@current_storytime_site.custom_view_path}/blogs/#{@page.slug}" if lookup_context.template_exists?("storytime/#{@current_storytime_site.custom_view_path}/blogs/#{@page.slug}")
end