about summary refs log tree commit diff stats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/application_controller.rb10
-rw-r--r--app/controllers/blogs_controller.rb11
-rw-r--r--app/controllers/streams_controller.rb19
3 files changed, 32 insertions, 8 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0174cae..ad46fb9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb
@@ -1,9 +1,19 @@
1class ApplicationController < ActionController::Base 1class ApplicationController < ActionController::Base
2 protect_from_forgery with: :exception 2 protect_from_forgery with: :exception
3 before_action :choose_random_song
3 4
4 private 5 private
5 6
6 def after_sign_out_path_for(resource) 7 def after_sign_out_path_for(resource)
7 new_session_path(resource) 8 new_session_path(resource)
8 end 9 end
10
11 def choose_random_song
12 ids = Scrobble.ids
13 if ids.empty?
14 @random_song = nil
15 else
16 @random_song = Scrobble.find(ids.sample)
17 end
18 end
9end 19end
diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index 4f6d9ce..6e80754 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb
@@ -1,12 +1,7 @@
1require 'redcarpet/render_strip'
2 1
3class StrippedSummary < Redcarpet::Render::StripDown
4 def block_html(raw_html)
5 nil
6 end
7end
8 2
9class BlogsController < ApplicationController 3class BlogsController < ApplicationController
4 include ApplicationHelper
10 5
11 def summary 6 def summary
12 @blogs = Blog.where(published: true).order(published_at: :desc).paginate(page: params[:page], per_page: 10) 7 @blogs = Blog.where(published: true).order(published_at: :desc).paginate(page: params[:page], per_page: 10)
@@ -33,12 +28,12 @@ class BlogsController < ApplicationController
33 @prev = @blog.prev 28 @prev = @blog.prev
34 @next = @blog.next 29 @next = @blog.next
35 30
36 body = Redcarpet::Markdown.new(StrippedSummary).render(@blog.body) 31 body = stripped_markdown(@blog.body)
37 32
38 set_meta_tags(og: { 33 set_meta_tags(og: {
39 title: @blog.title, 34 title: @blog.title,
40 type: "article", 35 type: "article",
41 description: (body.length <= 300 ? body : body[0..299]), 36 description: body[0, 299],
42 url: blog_url(@blog, host: "www.fourisland.com"), 37 url: blog_url(@blog, host: "www.fourisland.com"),
43 article: { 38 article: {
44 published_time: @blog.published_at.iso8601, 39 published_time: @blog.published_at.iso8601,
diff --git a/app/controllers/streams_controller.rb b/app/controllers/streams_controller.rb index 664f533..ec4cee8 100644 --- a/app/controllers/streams_controller.rb +++ b/app/controllers/streams_controller.rb
@@ -1,7 +1,26 @@
1class StreamsController < ApplicationController 1class StreamsController < ApplicationController
2 include ApplicationHelper
3
4 def index
5 @streams = Stream.order(latest_post_at: :desc).paginate(page: params[:page], per_page: 10)
6 end
2 7
3 def show 8 def show
4 @stream = Stream.find_by_slug(params[:slug]) 9 @stream = Stream.find_by_slug(params[:slug])
10 @updates = @stream.updates.paginate(page: params[:page], per_page: 10)
11
12 body = stripped_markdown(@stream.body)
13
14 set_meta_tags(og: {
15 title: @stream.title,
16 type: "article",
17 description: body[0, 299],
18 url: stream_url(@stream, host: "www.fourisland.com"),
19 article: {
20 published_time: @stream.created_at.iso8601,
21 modified_time: @stream.latest_post_at.iso8601
22 }
23 })
5 end 24 end
6 25
7end 26end