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/javascripts/admin/records.coffee2
-rw-r--r--app/assets/javascripts/application.js1
-rw-r--r--app/assets/stylesheets/admin.css.scss1
-rw-r--r--app/assets/stylesheets/admin/layout.scss8
-rw-r--r--app/assets/stylesheets/main/records.scss2
-rw-r--r--app/controllers/admin/blogs_controller.rb2
-rw-r--r--app/controllers/admin/streams_controller.rb2
-rw-r--r--app/models/blog.rb6
-rw-r--r--app/models/stream.rb6
-rw-r--r--app/models/update.rb4
-rw-r--r--app/views/admin/blogs/_form.html.haml4
-rw-r--r--app/views/admin/streams/_form.html.haml4
-rw-r--r--app/views/records/_record.html.haml7
-rw-r--r--app/views/records/index.html.haml8
14 files changed, 48 insertions, 9 deletions
diff --git a/app/assets/javascripts/admin/records.coffee b/app/assets/javascripts/admin/records.coffee index 3a1ed51..7a11ce1 100644 --- a/app/assets/javascripts/admin/records.coffee +++ b/app/assets/javascripts/admin/records.coffee
@@ -23,3 +23,5 @@ $(document).on "turbolinks:load", ->
23 create_record_toggle($(this).prop("checked")) 23 create_record_toggle($(this).prop("checked"))
24 $(".published-field input[type=checkbox]").change -> 24 $(".published-field input[type=checkbox]").change ->
25 published_field_toggle($(this).prop("checked")) 25 published_field_toggle($(this).prop("checked"))
26 $("input[type=tags]").each ->
27 tagsInput(this)
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index f902906..a81b3b2 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js
@@ -14,4 +14,5 @@
14//= require jquery_ujs 14//= require jquery_ujs
15//= require turbolinks 15//= require turbolinks
16//= require ckeditor/init 16//= require ckeditor/init
17//= require tags-input
17//= require_tree ./admin 18//= require_tree ./admin
diff --git a/app/assets/stylesheets/admin.css.scss b/app/assets/stylesheets/admin.css.scss index 5235c4b..95d1ed0 100644 --- a/app/assets/stylesheets/admin.css.scss +++ b/app/assets/stylesheets/admin.css.scss
@@ -1,4 +1,5 @@
1/* 1/*
2 *= require normalize-rails 2 *= require normalize-rails
3 *= require tags-input
3 *= require_tree ./admin 4 *= require_tree ./admin
4 */ 5 */
diff --git a/app/assets/stylesheets/admin/layout.scss b/app/assets/stylesheets/admin/layout.scss index b825c25..220dcd5 100644 --- a/app/assets/stylesheets/admin/layout.scss +++ b/app/assets/stylesheets/admin/layout.scss
@@ -196,6 +196,14 @@ body {
196 } 196 }
197} 197}
198 198
199.tags-field {
200 label {
201 font-size: .75em;
202 display: block;
203 margin-bottom: 0.5em;
204 }
205}
206
199.record-description-field { 207.record-description-field {
200 display: none; 208 display: none;
201 margin-top: 1em; 209 margin-top: 1em;
diff --git a/app/assets/stylesheets/main/records.scss b/app/assets/stylesheets/main/records.scss index f57dded..350fb16 100644 --- a/app/assets/stylesheets/main/records.scss +++ b/app/assets/stylesheets/main/records.scss
@@ -31,6 +31,7 @@
31 .tags { 31 .tags {
32 margin: .25em; 32 margin: .25em;
33 display: flex; 33 display: flex;
34 flex-wrap: wrap;
34 padding-left: 0; 35 padding-left: 0;
35 36
36 li { 37 li {
@@ -58,6 +59,7 @@
58 } 59 }
59 } 60 }
60 61
62 &.entry-tag {
61 & + li { 63 & + li {
62 margin-left: 1em; 64 margin-left: 1em;
63 } 65 }
diff --git a/app/controllers/admin/blogs_controller.rb b/app/controllers/admin/blogs_controller.rb index 1035c12..e79dd81 100644 --- a/app/controllers/admin/blogs_controller.rb +++ b/app/controllers/admin/blogs_controller.rb
@@ -56,7 +56,7 @@ class Admin::BlogsController < Admin::AdminController
56 private 56 private
57 57
58 def blog_params 58 def blog_params
59 params.require(:blog).permit(:title, :body, :slug, :published, records_attributes: [:description, :_destroy]) 59 params.require(:blog).permit(:title, :body, :slug, :published, :tag_list, records_attributes: [:description, :_destroy])
60 end 60 end
61 61
62 def set_section 62 def set_section
diff --git a/app/controllers/admin/streams_controller.rb b/app/controllers/admin/streams_controller.rb index 86dec06..252ebfa 100644 --- a/app/controllers/admin/streams_controller.rb +++ b/app/controllers/admin/streams_controller.rb
@@ -42,7 +42,7 @@ class Admin::StreamsController < Admin::AdminController
42 private 42 private
43 43
44 def stream_params 44 def stream_params
45 params.require(:stream).permit(:title, :body, :slug, records_attributes: [:description, :_destroy]) 45 params.require(:stream).permit(:title, :body, :slug, :tag_list, records_attributes: [:description, :_destroy])
46 end 46 end
47 47
48 def set_section 48 def set_section
diff --git a/app/models/blog.rb b/app/models/blog.rb index 5742879..18f63f1 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb
@@ -1,6 +1,8 @@
1class Blog < ApplicationRecord 1class Blog < ApplicationRecord
2 include Recordable 2 include Recordable
3 3
4 acts_as_taggable
5
4 validates :title, presence: true 6 validates :title, presence: true
5 validates :body, presence: true, if: :published 7 validates :body, presence: true, if: :published
6 validates :slug, presence: true, format: /\A[-a-z0-9]+\z/, if: :published 8 validates :slug, presence: true, format: /\A[-a-z0-9]+\z/, if: :published
@@ -12,6 +14,10 @@ class Blog < ApplicationRecord
12 "/says/#{slug}" 14 "/says/#{slug}"
13 end 15 end
14 16
17 def taggable
18 self
19 end
20
15 private 21 private
16 def set_draft_title 22 def set_draft_title
17 if self.title.blank? and not self.published 23 if self.title.blank? and not self.published
diff --git a/app/models/stream.rb b/app/models/stream.rb index 1398b75..0773143 100644 --- a/app/models/stream.rb +++ b/app/models/stream.rb
@@ -1,6 +1,8 @@
1class Stream < ApplicationRecord 1class Stream < ApplicationRecord
2 include Recordable 2 include Recordable
3 3
4 acts_as_taggable
5
4 has_many :updates 6 has_many :updates
5 7
6 validates :title, presence: true 8 validates :title, presence: true
@@ -9,4 +11,8 @@ class Stream < ApplicationRecord
9 def path 11 def path
10 "/thinks/#{slug}" 12 "/thinks/#{slug}"
11 end 13 end
14
15 def taggable
16 self
17 end
12end 18end
diff --git a/app/models/update.rb b/app/models/update.rb index 73c4911..01907d8 100644 --- a/app/models/update.rb +++ b/app/models/update.rb
@@ -8,4 +8,8 @@ class Update < ApplicationRecord
8 def path 8 def path
9 "/thinks/#{stream.slug}\#update-#{id}" 9 "/thinks/#{stream.slug}\#update-#{id}"
10 end 10 end
11
12 def taggable
13 stream
14 end
11end 15end
diff --git a/app/views/admin/blogs/_form.html.haml b/app/views/admin/blogs/_form.html.haml index 12f7a82..36925af 100644 --- a/app/views/admin/blogs/_form.html.haml +++ b/app/views/admin/blogs/_form.html.haml
@@ -22,6 +22,10 @@
22 - else 22 - else
23 = link_to "Preview post", admin_blog_url(f.object), target: "entry-preview" 23 = link_to "Preview post", admin_blog_url(f.object), target: "entry-preview"
24 .details-module 24 .details-module
25 .tags-field
26 = f.label :tag_list, "Tags"
27 = f.text_field :tag_list, type: :tags, value: f.object.tag_list.join(",")
28 .details-module
25 .published-field 29 .published-field
26 = f.check_box :published 30 = f.check_box :published
27 = f.label :published 31 = f.label :published
diff --git a/app/views/admin/streams/_form.html.haml b/app/views/admin/streams/_form.html.haml index ce457cb..e04a3fb 100644 --- a/app/views/admin/streams/_form.html.haml +++ b/app/views/admin/streams/_form.html.haml
@@ -16,6 +16,10 @@
16 - f.object.errors.full_messages.each do |error| 16 - f.object.errors.full_messages.each do |error|
17 %li= error 17 %li= error
18 .details-module 18 .details-module
19 .tags-field
20 = f.label :tag_list, "Tags"
21 = f.text_field :tag_list, type: :tags, value: f.object.tag_list.join(",")
22 .details-module
19 = f.fields_for :records, Record.new do |builder| 23 = f.fields_for :records, Record.new do |builder|
20 .should-create-record-field 24 .should-create-record-field
21 = builder.check_box :_destroy, {checked: false}, "0", "1" 25 = builder.check_box :_destroy, {checked: false}, "0", "1"
diff --git a/app/views/records/_record.html.haml b/app/views/records/_record.html.haml new file mode 100644 index 0000000..80a365c --- /dev/null +++ b/app/views/records/_record.html.haml
@@ -0,0 +1,7 @@
1%li
2 %span.description= link_to record.description, record.recordable.path
3 %ul.tags
4 %li.record-date= record.created_at.strftime("%m.%d.%y")
5 %li.entry-type{ class: "entry-type-#{record.recordable_type.downcase}" }= record.recordable_type
6 - record.recordable.taggable.tag_list.each do |tag|
7 %li.entry-tag= tag
diff --git a/app/views/records/index.html.haml b/app/views/records/index.html.haml index 200321e..4ceed2c 100644 --- a/app/views/records/index.html.haml +++ b/app/views/records/index.html.haml
@@ -1,7 +1 @@
1%ul#records %ul#records= render @records
2 - @records.each do |record|
3 %li
4 %span.description= link_to record.description, record.recordable.path
5 %ul.tags
6 %li.record-date= record.created_at.strftime("%m.%d.%y")
7 %li.entry-type{ class: "entry-type-#{record.recordable_type.downcase}" }= record.recordable_type