about summary refs log tree commit diff stats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/main/entries.scss54
-rw-r--r--app/assets/stylesheets/main/layout.scss11
-rw-r--r--app/controllers/application_controller.rb10
-rw-r--r--app/controllers/blogs_controller.rb11
-rw-r--r--app/controllers/streams_controller.rb19
-rw-r--r--app/helpers/application_helper.rb11
-rw-r--r--app/models/scrobble.rb2
-rw-r--r--app/models/stream.rb11
-rw-r--r--app/models/update.rb8
-rw-r--r--app/views/admin/streams/edit.html.haml2
-rw-r--r--app/views/admin/streams/index.html.haml4
-rw-r--r--app/views/admin/updates/edit.html.haml2
-rw-r--r--app/views/blogs/_blog.html.haml2
-rw-r--r--app/views/layouts/application.html.haml10
-rw-r--r--app/views/layouts/quotes.html.haml5
-rw-r--r--app/views/streams/_stream.html.haml8
-rw-r--r--app/views/streams/index.html.haml19
-rw-r--r--app/views/streams/show.html.haml2
-rw-r--r--app/views/updates/_update.html.haml7
19 files changed, 176 insertions, 22 deletions
diff --git a/app/assets/stylesheets/main/entries.scss b/app/assets/stylesheets/main/entries.scss index 4afd15d..d67ae67 100644 --- a/app/assets/stylesheets/main/entries.scss +++ b/app/assets/stylesheets/main/entries.scss
@@ -153,7 +153,6 @@
153 153
154 .update-posted { 154 .update-posted {
155 display: block; 155 display: block;
156 font-style: italic;
157 background-color: #EAADEA; 156 background-color: #EAADEA;
158 font-size: 16px; 157 font-size: 16px;
159 margin: .5em -20px; 158 margin: .5em -20px;
@@ -161,6 +160,16 @@
161 border-width: 1px 0 1px 0; 160 border-width: 1px 0 1px 0;
162 border-style: solid; 161 border-style: solid;
163 border-color: #DB70DB; 162 border-color: #DB70DB;
163
164 time {
165 font-style: italic;
166 }
167
168 .update-edit-link {
169 float: right;
170 color: blue;
171 font-weight: normal;
172 }
164 } 173 }
165 } 174 }
166} 175}
@@ -463,3 +472,46 @@
463.next-post { 472.next-post {
464 float: right; 473 float: right;
465} 474}
475
476#streams-index {
477 width: 100%;
478 border-collapse: collapse;
479
480 #streams-index-header-row {
481 th {
482 background-color: #bdbdbd;
483 padding-left: 0.5em;
484 border-top: 1px solid #848484;
485 border-bottom: 1px solid #848484;
486 }
487 }
488
489 th {
490 padding-bottom: 0.5em;
491 padding-top: 0.5em;
492 text-align: left;
493 }
494
495 td {
496 padding-top: 1em;
497 padding-left: 0.5em;
498
499 time {
500 font-size: .75em;
501 }
502
503 .stream-link {
504 font-weight: bold;
505 text-decoration: none;
506
507 &, &:visited {
508 color: #ee2c2c;
509 }
510
511 &:hover {
512 text-decoration: underline;
513 color: #9ea1ad;
514 }
515 }
516 }
517}
diff --git a/app/assets/stylesheets/main/layout.scss b/app/assets/stylesheets/main/layout.scss index ef31ada..d5fe7a7 100644 --- a/app/assets/stylesheets/main/layout.scss +++ b/app/assets/stylesheets/main/layout.scss
@@ -228,3 +228,14 @@ h2.centered {
228 text-decoration: none; 228 text-decoration: none;
229 } 229 }
230} 230}
231
232#scrobble-box {
233 img {
234 margin: 0 auto;
235 display: block;
236 }
237
238 p {
239 text-align: center;
240 }
241}
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
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 97a897f..a51f1a1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb
@@ -1,6 +1,7 @@
1require 'redcarpet' 1require 'redcarpet'
2require 'rouge' 2require 'rouge'
3require 'rouge/plugins/redcarpet' 3require 'rouge/plugins/redcarpet'
4require 'redcarpet/render_strip'
4 5
5module ApplicationHelper 6module ApplicationHelper
6 7
@@ -45,4 +46,14 @@ module ApplicationHelper
45 ] 46 ]
46 end 47 end
47 48
49 class StrippedSummary < Redcarpet::Render::StripDown
50 def block_html(raw_html)
51 nil
52 end
53 end
54
55 def stripped_markdown(text)
56 Redcarpet::Markdown.new(StrippedSummary).render(text)
57 end
58
48end 59end
diff --git a/app/models/scrobble.rb b/app/models/scrobble.rb new file mode 100644 index 0000000..f527612 --- /dev/null +++ b/app/models/scrobble.rb
@@ -0,0 +1,2 @@
1class Scrobble < ApplicationRecord
2end
diff --git a/app/models/stream.rb b/app/models/stream.rb index 0773143..6a738e2 100644 --- a/app/models/stream.rb +++ b/app/models/stream.rb
@@ -8,11 +8,22 @@ class Stream < ApplicationRecord
8 validates :title, presence: true 8 validates :title, presence: true
9 validates :slug, presence: true, format: /\A[-a-z0-9]+\z/ 9 validates :slug, presence: true, format: /\A[-a-z0-9]+\z/
10 10
11 before_create :set_post_timestamp
12
11 def path 13 def path
12 "/thinks/#{slug}" 14 "/thinks/#{slug}"
13 end 15 end
14 16
17 def to_param
18 slug
19 end
20
15 def taggable 21 def taggable
16 self 22 self
17 end 23 end
24
25 private
26 def set_post_timestamp
27 self.latest_post_at = self.created_at
28 end
18end 29end
diff --git a/app/models/update.rb b/app/models/update.rb index 01907d8..a98a5d4 100644 --- a/app/models/update.rb +++ b/app/models/update.rb
@@ -5,6 +5,8 @@ class Update < ApplicationRecord
5 5
6 validates :stream, :body, presence: true 6 validates :stream, :body, presence: true
7 7
8 after_create :set_latest_timestamp
9
8 def path 10 def path
9 "/thinks/#{stream.slug}\#update-#{id}" 11 "/thinks/#{stream.slug}\#update-#{id}"
10 end 12 end
@@ -12,4 +14,10 @@ class Update < ApplicationRecord
12 def taggable 14 def taggable
13 stream 15 stream
14 end 16 end
17
18 private
19 def set_latest_timestamp
20 self.stream.latest_post_at = self.created_at
21 self.stream.save!
22 end
15end 23end
diff --git a/app/views/admin/streams/edit.html.haml b/app/views/admin/streams/edit.html.haml index 8d910fe..8c250e2 100644 --- a/app/views/admin/streams/edit.html.haml +++ b/app/views/admin/streams/edit.html.haml
@@ -1,3 +1,3 @@
1- title "Editing #{@stream.title}" 1- title "Editing #{@stream.title}"
2= form_for @stream, url: admin_stream_url(@stream), html: { id: "entry-form" } do |f| 2= form_for @stream, url: admin_stream_url(@stream.id), html: { id: "entry-form" } do |f|
3 = render partial: "form", locals: { f: f } 3 = render partial: "form", locals: { f: f }
diff --git a/app/views/admin/streams/index.html.haml b/app/views/admin/streams/index.html.haml index 6903fd1..a2a25d7 100644 --- a/app/views/admin/streams/index.html.haml +++ b/app/views/admin/streams/index.html.haml
@@ -10,5 +10,5 @@
10 %td= stream.created_at.strftime("%B %d, %Y, %l:%M%P") 10 %td= stream.created_at.strftime("%B %d, %Y, %l:%M%P")
11 %td 11 %td
12 %ul.admin-actions 12 %ul.admin-actions
13 %li= link_to "Edit", edit_admin_stream_url(stream) 13 %li= link_to "Edit", edit_admin_stream_url(stream.id)
14 %li= link_to "Add Update", new_admin_stream_update_url(stream) 14 %li= link_to "Add Update", new_admin_stream_update_url(stream.id)
diff --git a/app/views/admin/updates/edit.html.haml b/app/views/admin/updates/edit.html.haml index 75a9957..3cab0b6 100644 --- a/app/views/admin/updates/edit.html.haml +++ b/app/views/admin/updates/edit.html.haml
@@ -1,3 +1,3 @@
1- title "Editing stream update" 1- title "Editing stream update"
2= form_for @update, url: admin_stream_update_url(@stream, @update), html: { id: "entry-form" } do |f| 2= form_for @update, url: admin_stream_update_url(@stream.id, @update), html: { id: "entry-form" } do |f|
3 = render partial: "form", locals: { f: f } 3 = render partial: "form", locals: { f: f }
diff --git a/app/views/blogs/_blog.html.haml b/app/views/blogs/_blog.html.haml index 878b1a2..34b343f 100644 --- a/app/views/blogs/_blog.html.haml +++ b/app/views/blogs/_blog.html.haml
@@ -24,5 +24,5 @@
24 %time.dt-published{ datetime: blog.visible_date.strftime("%Y-%m-%dT%H:%M:%SZ%z") }= blog.visible_date.strftime("%B #{blog.visible_date.day.ordinalize}, %Y at %-I:%M:%S%P") 24 %time.dt-published{ datetime: blog.visible_date.strftime("%Y-%m-%dT%H:%M:%SZ%z") }= blog.visible_date.strftime("%B #{blog.visible_date.day.ordinalize}, %Y at %-I:%M:%S%P")
25 .post-vote{ id: "blog-vote-section-#{blog.id}" } 25 .post-vote{ id: "blog-vote-section-#{blog.id}" }
26 %span.vote-link{ id: "blog-upvote-link-#{blog.id}" }= link_to_unless (not blog.published or blog.already_upvoted?(request.remote_ip)), "👍", upvote_blog_path(blog), remote: true, rel: "nofollow", class: "blog-upvote-link", method: :post 26 %span.vote-link{ id: "blog-upvote-link-#{blog.id}" }= link_to_unless (not blog.published or blog.already_upvoted?(request.remote_ip)), "👍", upvote_blog_path(blog), remote: true, rel: "nofollow", class: "blog-upvote-link", method: :post
27 %span.post-rating{ id: "blog-rating-#{blog.id}" }= blog.upvotes - blog.downvotes 27 %span.post-rating{ id: "blog-rating-#{blog.id}" }= blog.upvotes
28 %span.vote-link{ id: "blog-downvote-link-#{blog.id}" }= link_to_unless (not blog.published or blog.already_downvoted?(request.remote_ip)), "👎", downvote_blog_path(blog), remote: true, rel: "nofollow", class: "blog-downvote-link", method: :post 28 %span.vote-link{ id: "blog-downvote-link-#{blog.id}" }= link_to_unless (not blog.published or blog.already_downvoted?(request.remote_ip)), "👎", downvote_blog_path(blog), remote: true, rel: "nofollow", class: "blog-downvote-link", method: :post
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 1d0bea3..6bc7041 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml
@@ -73,6 +73,16 @@
73 %li 73 %li
74 = image_tag "feed.png" 74 = image_tag "feed.png"
75 = link_to "Atom feed", blogs_url(format: :atom) 75 = link_to "Atom feed", blogs_url(format: :atom)
76 - unless @random_song.nil?
77 .sidebar-module#scrobble-box
78 .bubble.rounded
79 %h2 Listening to
80 = image_tag @random_song.image, width: "174px"
81 %p
82 %strong= @random_song.title
83 by
84 = @random_song.artist
85 %p= @random_song.album
76 .sidebar-module 86 .sidebar-module
77 .bubble.rounded 87 .bubble.rounded
78 %h2 Meta 88 %h2 Meta
diff --git a/app/views/layouts/quotes.html.haml b/app/views/layouts/quotes.html.haml index 4a7681e..040fdfe 100644 --- a/app/views/layouts/quotes.html.haml +++ b/app/views/layouts/quotes.html.haml
@@ -21,11 +21,12 @@
21 %li= link_to_unless_current "Home", quotes_url 21 %li= link_to_unless_current "Home", quotes_url
22 %li= link_to_unless_current "Latest", latest_quotes_url 22 %li= link_to_unless_current "Latest", latest_quotes_url
23 %li= link_to_unless_current "Top", top_quotes_url 23 %li= link_to_unless_current "Top", top_quotes_url
24 %li= link_to "Random", random_quotes_url 24 %li{"data-turbolinks" => "false"}= link_to "Random", random_quotes_url
25 - if user_signed_in? 25 - if user_signed_in?
26 %li= link_to_unless_current "Submit", new_quote_url 26 %li= link_to_unless_current "Submit", new_quote_url
27 %li= link_to_unless_current "Tags", tags_quotes_url 27 %li= link_to_unless_current "Tags", tags_quotes_url
28 %li= link_to_unless_current "Stats", stats_quotes_url 28 %li= link_to_unless_current "Search", search_form_quotes_url
29 %li{"data-turbolinks" => "false"}= link_to_unless_current "Stats", stats_quotes_url
29 %li= link_to_unless_current "Feed", latest_quotes_url(:atom) 30 %li= link_to_unless_current "Feed", latest_quotes_url(:atom)
30 - if user_signed_in? 31 - if user_signed_in?
31 %li= link_to_unless_current "Admin", admin_url 32 %li= link_to_unless_current "Admin", admin_url
diff --git a/app/views/streams/_stream.html.haml b/app/views/streams/_stream.html.haml index 84a6478..97d4813 100644 --- a/app/views/streams/_stream.html.haml +++ b/app/views/streams/_stream.html.haml
@@ -1,6 +1,8 @@
1%article#stream-post 1%article#stream-post
2 %h2#stream-title= stream.title 2 %h2#stream-title= stream.title
3 - unless stream.body.blank? 3 - unless stream.body.blank?
4 %header#stream-intro.entry-content= stream.body.html_safe 4 %header#stream-intro.entry-content= markdown(stream.body)
5 - unless stream.updates.empty? 5 = will_paginate @updates
6 = render stream.updates 6 - unless @updates.empty?
7 = render @updates
8 = will_paginate @updates
diff --git a/app/views/streams/index.html.haml b/app/views/streams/index.html.haml new file mode 100644 index 0000000..bf5073f --- /dev/null +++ b/app/views/streams/index.html.haml
@@ -0,0 +1,19 @@
1%table#streams-index
2 %tr#streams-index-header-row
3 %th Stream Topic
4 %th Updates
5 %th Last Post
6 - @streams.each do |stream|
7 %tr
8 %td
9 = link_to stream.title, stream, class: "stream-link"
10 %br
11 %time= stream.created_at.strftime("%B #{stream.created_at.day.ordinalize}, %Y at %-I:%M:%S%P")
12 %td= stream.updates.size
13 %td
14 - unless stream.updates.empty?
15 - latest_post = stream.updates.order(created_at: :desc).first
16 = link_to (stripped_markdown(latest_post.body)[0, 30] + "..."), stream
17 %br
18 %time= latest_post.created_at.strftime("%B #{latest_post.created_at.day.ordinalize}, %Y at %-I:%M:%S%P")
19= will_paginate @streams
diff --git a/app/views/streams/show.html.haml b/app/views/streams/show.html.haml index 8365556..8d58f62 100644 --- a/app/views/streams/show.html.haml +++ b/app/views/streams/show.html.haml
@@ -1,3 +1,3 @@
1- title @stream.title 1- title @stream.title
2.breadcrumb= link_to "← Back to home page", root_path 2.breadcrumb= link_to "← Back to streams", streams_path
3= render @stream 3= render @stream
diff --git a/app/views/updates/_update.html.haml b/app/views/updates/_update.html.haml index 57f4158..ceb7d8f 100644 --- a/app/views/updates/_update.html.haml +++ b/app/views/updates/_update.html.haml
@@ -1,3 +1,6 @@
1%section.stream-update.entry-content{ id: "update-#{update.id}" } 1%section.stream-update.entry-content{ id: "update-#{update.id}" }
2 %time.update-posted= update.created_at.strftime("%B #{update.created_at.day.ordinalize}, %Y at %-I:%M:%S%P") 2 %header.update-posted
3 = update.body.html_safe 3 %time= update.created_at.strftime("%B #{update.created_at.day.ordinalize}, %Y at %-I:%M:%S%P")
4 - if user_signed_in? and !update.new_record?
5 = link_to "Edit", edit_admin_stream_update_path(update.stream.id, update), :class => "update-edit-link"
6 = markdown(update.body)