Class: Virgo::PostsController
Instance Method Summary
collapse
#render_content, #with_format
#action?, #admin?, #admin_access?, #admin_view?, #alerts, #base_errors, #category_timestamp, #column_timestamp, #compact_html, #controller?, #decode_html_entities, #expanded_post_url, #is_admin_view?, #page_url, #post_time_format, #post_timestamp, #production?, #redis_timestamp_key_for, #site, #site_key, #superuser?, #tabbed_param, #word_count
Instance Method Details
#index ⇒ Object
16
17
18
|
# File 'app/controllers/virgo/posts_controller.rb', line 16
def index
@posts = Post.posts.publicly_viewable.order(publish_at: :desc).page(params[:page])
end
|
#latest ⇒ Object
27
28
29
|
# File 'app/controllers/virgo/posts_controller.rb', line 27
def latest
@posts = Post.posts.publicly_viewable.order(publish_at: :desc).page(params[:page])
end
|
#more ⇒ Object
20
21
22
23
24
25
|
# File 'app/controllers/virgo/posts_controller.rb', line 20
def more
@posts = Post.order(publish_at: :desc).page(params[:page]).per(6).padding(6)
render json: {
html: render_content('/virgo/posts/more', layout: false)
}
end
|
#popular ⇒ Object
47
48
49
|
# File 'app/controllers/virgo/posts_controller.rb', line 47
def popular
render json: {html: render_content(partial: "/virgo/page_modules/popular_posts")}
end
|
51
52
53
54
55
|
# File 'app/controllers/virgo/posts_controller.rb', line 51
def
@limit = Rails.env.production? ? 50 : 5
render 'rss.xml', layout: false, content_type: Mime::XML
end
|
#show ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/virgo/posts_controller.rb', line 31
def show
set_post
if old_path?
redirect_to(post_detail_path(@post), status: :moved_permanently) and return
end
if @post.page?
@page = @post
render "/virgo/pages/show", layout: "virgo/application"
else
render layout: '/virgo/posts'
end
end
|
#track ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'app/controllers/virgo/posts_controller.rb', line 57
def track
tracked = JSON::load(Rails.cache.fetch("tracks[#{client_id}]") || '{}')
unless tracked[params[:id]]
set_post
@post.track_view!
tracked[@post.id.to_s] = 1
Rails.cache.write("tracks[#{client_id}]", JSON::dump(tracked))
end
head :ok
end
|