Sha256: d4e96fe1cae34789aa4e6b41781b047e5c20ea29e5e95b3e320629fadab36d0b
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
require_dependency "storytime/application_controller" module Storytime class PostsController < ApplicationController before_action :ensure_site, unless: ->{ params[:controller] == "storytime/dashboard/sites" } def index @posts = if params[:post_type] klass = Storytime.post_types.find{|post_type| post_type.constantize.type_name == params[:post_type].singularize } klass.constantize.all else Post.primary_feed end @posts = @posts.tagged_with(params[:tag]) if params[:tag] @posts = @posts.published.order(published_at: :desc).page(params[:page]) respond_to do |format| format.atom format.html end end def show @post = if params[:preview] post = Post.find_preview(params[:id]) post.content = post.autosave.content post.preview = true post else Post.published.friendly.find(params[:id]) end authorize @post content_for :title, "#{@site.title} | #{@post.title}" if params[:preview].nil? && ((@site.post_slug_style != "post_id") && (params[:id] != @post.slug)) return redirect_to @post, :status => :moved_permanently end @comments = @post.comments.order("created_at DESC") #allow overriding in the host app if lookup_context.template_exists?("storytime/#{@post.type_name.pluralize}/#{@post.slug}") render "storytime/#{@post.type_name.pluralize}/#{@post.slug}" elsif lookup_context.template_exists?("storytime/#{@post.type_name.pluralize}/show") render "storytime/#{@post.type_name.pluralize}/show" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
storytime-1.0.7 | app/controllers/storytime/posts_controller.rb |