bbs 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +68 -5
  3. data/app/assets/stylesheets/bbs/_article.css.sass +20 -0
  4. data/app/assets/stylesheets/bbs/_bbs-list.css.sass +3 -0
  5. data/app/assets/stylesheets/bbs/_button.css.sass +2 -0
  6. data/app/assets/stylesheets/bbs/_form.css.sass +16 -0
  7. data/app/assets/stylesheets/bbs/_new-topic.css.sass +6 -0
  8. data/app/assets/stylesheets/bbs/application.css +0 -11
  9. data/app/cells/bbs/application_cell.rb +12 -3
  10. data/app/cells/bbs/article/show.haml +14 -0
  11. data/app/cells/bbs/article_cell.rb +26 -0
  12. data/app/cells/bbs/category/show.haml +6 -4
  13. data/app/cells/bbs/latest_topics/show.haml +5 -4
  14. data/app/cells/bbs/latest_topics_cell.rb +1 -1
  15. data/app/controllers/bbs/application_controller.rb +7 -1
  16. data/app/controllers/bbs/comments_controller.rb +23 -2
  17. data/app/controllers/bbs/concerns/authenticatable.rb +21 -0
  18. data/app/controllers/bbs/profiles_controller.rb +35 -0
  19. data/app/controllers/bbs/topics_controller.rb +22 -2
  20. data/app/models/bbs/application_record.rb +4 -0
  21. data/app/models/bbs/avatar.rb +9 -0
  22. data/app/models/bbs/category.rb +2 -2
  23. data/app/models/bbs/comment.rb +5 -2
  24. data/app/models/bbs/topic.rb +6 -3
  25. data/app/models/bbs/user.rb +10 -0
  26. data/app/models/bbs/user_profile.rb +8 -0
  27. data/app/views/bbs/comments/index.html.haml +17 -8
  28. data/app/views/bbs/profiles/edit.html.haml +12 -0
  29. data/app/views/bbs/shared/_comment_form.html.haml +10 -0
  30. data/app/views/bbs/topics/index.html.haml +19 -4
  31. data/app/views/bbs/topics/new.html.haml +16 -0
  32. data/config/breadcrumbs.rb +13 -0
  33. data/config/locales/bbs.en.yml +56 -0
  34. data/config/locales/bbs.ja.yml +56 -0
  35. data/config/routes.rb +2 -0
  36. data/db/migrate/20160817082220_add_author_id.rb +6 -0
  37. data/db/migrate/20160902071411_create_bbs_users.rb +8 -0
  38. data/db/migrate/20160902071450_create_bbs_user_profiles.rb +13 -0
  39. data/db/migrate/20160928082713_create_bbs_avatars.rb +9 -0
  40. data/db/migrate/20160930093905_add_avatar_id_to_user.rb +7 -0
  41. data/db/migrate/20161028081055_rename_avatar_column.rb +8 -0
  42. data/lib/bbs.rb +13 -2
  43. data/lib/bbs/configuration.rb +35 -0
  44. data/lib/bbs/engine.rb +11 -0
  45. data/lib/bbs/version.rb +1 -1
  46. data/lib/generators/bbs/config_generator.rb +32 -0
  47. data/lib/generators/bbs/templates/bbs.rb +26 -0
  48. data/lib/generators/bbs/views_generator.rb +15 -0
  49. metadata +130 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2100329a330c79eb4eedc89a47574a54887f56d1
4
- data.tar.gz: b18085a0560819163c76c3eaf2562a1b923a7e3e
3
+ metadata.gz: 090859437ceb4d0c72eba0956b05e6830057579e
4
+ data.tar.gz: 8cf36a74c50266e44496bbbef76ff25ebf79c4e1
5
5
  SHA512:
6
- metadata.gz: dcbf62293e5889f2f3aea37041b7490b72e1fdf73babbb28c57dee300afafb3a01365dc7e5c09df6b623340658c8bfa48648c9441a26f7f3447ab23a9b4cc286
7
- data.tar.gz: cf18c0493f809ff6d38ce2f8e6540fb5deffc42979c198ae9604a9304f066cdde81e658b98f9b574e452d79737e938bf7a39218493ce5850b087bed1fefba9d3
6
+ metadata.gz: 46fd87f5a2664447715423efe71d12771a687ac90f51da86294dfcad2fc2ca7cf5f74d6cb488bd327540cad504d6b5075508caf738432e3eecb528ef3cb79198
7
+ data.tar.gz: c11d6e7003edd66d725398be23e6380c5ae313d0778fa5d3ed5b3883bfe79f2f4dbb43c0a04da913a242b932ca91b46367180e0d43b85532c553bb228895c581
data/README.md CHANGED
@@ -1,8 +1,5 @@
1
1
  # Bbs
2
- Short description and motivation.
3
-
4
- ## Usage
5
- How to use my plugin.
2
+ A Rails Engine for BBS(Bulletin Board System).
6
3
 
7
4
  ## Installation
8
5
  Add this line to your application's Gemfile:
@@ -21,8 +18,74 @@ Or install it yourself as:
21
18
  $ gem install bbs
22
19
  ```
23
20
 
21
+ ## Getting started
22
+ ### copy migrations
23
+
24
+ ```bash
25
+ $ bin/rails bbs:install:migrations
26
+ ```
27
+
28
+ ### Mount
29
+
30
+ Edit `config/routes.rb`:
31
+
32
+ ```ruby
33
+ Rails.application.routes.draw do
34
+ mount Bbs::Engnie => '/bbs' # choose your mount point arbitrarylly
35
+ end
36
+ ```
37
+
38
+ ### Copy configurations to your application
39
+
40
+ ```bash
41
+ $ bin/rails g bbs:config
42
+ ```
43
+
44
+ Execute the above command will copy following files into your
45
+ `config/initializers`.
46
+
47
+ * config/initializers/bbs.rb
48
+ * config/locales/bbs.ja.yml
49
+ * config/locales/bbs.en.yml
50
+
51
+ ## View Components
52
+ ### List categories
53
+
54
+ Component that list all categories.
55
+ In view, you have to call the cell object:
56
+
57
+ ```haml
58
+ = cell('bbs/category')
59
+ ```
60
+
61
+ ### List latest topics
62
+
63
+ Component that list latest topics.
64
+ In view, you have to call the cell object:
65
+ ```haml
66
+ = cell('bbs/latest_topics')
67
+ ```
68
+ To change the number of displayed topics, change the value `config.latest_topics_count` in `config/initializers/bbs.rb` (The default is 10).
69
+
70
+ ## Customization
71
+ ### Copy views to your application
72
+
73
+ If you want to customize bbs views, you can copy view templates provided by this
74
+ gem using generator.
75
+
76
+ ```bash
77
+ $ bin/rails g bbs:views
78
+ ```
79
+
80
+ Execute the above command will copy view templates to `app/views/bbs/`.
81
+
82
+
24
83
  ## Contributing
25
- Contribution directions go here.
84
+ 1. Fork it ( http://github.com/bm-sms/bbs )
85
+ 2. Create your feature branch (git checkout -b my-new-feature)
86
+ 3. Commit your changes (git commit -am 'Add some feature')
87
+ 4. Push to the branch (git push origin my-new-feature)
88
+ 5. Create new Pull Request
26
89
 
27
90
  ## License
28
91
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,20 @@
1
+ .bbs-avatar
2
+ img
3
+ width: 48px
4
+ height: 48px
5
+
6
+ .bbs-article
7
+ &__body
8
+ margin-top: 15px
9
+ white-space: pre-line
10
+
11
+ &__posted-at
12
+ margin: auto
13
+ margin-right: 0
14
+
15
+ &__title
16
+ font-size: 2rem
17
+
18
+ .bbs-article-creation
19
+ display: flex
20
+ align-items: center
@@ -0,0 +1,3 @@
1
+ .bbs-list
2
+ list-style-type: none
3
+ padding-left: 0
@@ -0,0 +1,2 @@
1
+ .bbs-button
2
+ width: 100%
@@ -0,0 +1,16 @@
1
+ .bbs-form
2
+ width: 100%
3
+
4
+ &--vertical
5
+ display: flex
6
+ flex-direction: column
7
+
8
+ .bbs-form-group
9
+ margin-bottom: 15px
10
+
11
+ label
12
+ font-weight: 700
13
+ max-width: 100%
14
+
15
+ input, textarea
16
+ width: 100%
@@ -0,0 +1,6 @@
1
+ .bbs-new-topic
2
+ margin-top: 15px
3
+ margin-bottom: 15px
4
+
5
+ > .bbs-button
6
+ width: 100%
@@ -1,15 +1,4 @@
1
1
  /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
2
  *= require_tree .
14
3
  *= require_self
15
4
  */
@@ -1,10 +1,19 @@
1
1
  module Bbs
2
2
  class ApplicationCell < Cell::ViewModel
3
- include Cell::Hamlit
3
+ include ActionView::Helpers::FormHelper
4
+ include ActionView::Helpers::FormOptionsHelper
5
+ include ActionView::Helpers::TranslationHelper
4
6
  include ActionView::Helpers::UrlHelper
5
-
6
- delegate :bbs, :main_app, to: :parent_controller
7
+ include ActionView::RecordIdentifier
8
+ include Cell::Hamlit
9
+ include Cell::Translation
7
10
 
8
11
  self.view_paths = [Bbs::Engine.root.join('app/cells').to_s]
12
+
13
+ def method_missing(method, *args, &block)
14
+ super and return unless parent_controller.respond_to?(method)
15
+
16
+ parent_controller.__send__ method, *args, &block
17
+ end
9
18
  end
10
19
  end
@@ -0,0 +1,14 @@
1
+ %article.bbs-article
2
+ %header.bbs-article__header
3
+ %h1.bbs-article__title= sanitize(title)
4
+
5
+ .bbs-article-container
6
+ .bbs-article-creation
7
+ %span.bbs-avatar
8
+ %img(src="#{avatar_url}")
9
+
10
+ %span.bbs-article__author-name= sanitize(nickname)
11
+
12
+ %time.bbs-article__posted-at= l(created_at)
13
+
14
+ %p.bbs-article__body= sanitize(article_body)
@@ -0,0 +1,26 @@
1
+ module Bbs
2
+ class ArticleCell < ApplicationCell
3
+ property :author
4
+ property :title
5
+ property :body
6
+ property :created_at
7
+
8
+ def show
9
+ render
10
+ end
11
+
12
+ def article_body
13
+ return body if logged_in? || !Bbs.config.clamp_article_body
14
+
15
+ body.truncate([body.truncate_words(1).length, Bbs.config.clamp_article_body].min)
16
+ end
17
+
18
+ def nickname
19
+ author.profile.nickname
20
+ end
21
+
22
+ def avatar_url
23
+ author.profile.avatar.image.url(:medium)
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,7 @@
1
- %h1 Categories
1
+ %article.bbs-categories
2
+ %h1.bbs-categories__title= t('.title')
2
3
 
3
- %ol.bbs-category
4
- - @categories.each do |category|
5
- %li.bbs-category__name= link_to category.name, bbs.category_topics_path(category)
4
+ %ol.bbs-category-list
5
+ - @categories.each do |category|
6
+ %li.bbs-category-item{data: {category: "#{category.name}"}}
7
+ = link_to category.name, bbs.category_topics_path(category)
@@ -1,5 +1,6 @@
1
- %h1 Latest Topics
1
+ %article.latest-topics
2
+ %h1= t('.title')
2
3
 
3
- %ol
4
- - @topics.each do |topic|
5
- %li= link_to topic.title, bbs.topic_comments_path(topic)
4
+ %ol.latest-topic-list
5
+ - @topics.each do |topic|
6
+ %li.latest-topic-item= link_to sanitize(topic.title), bbs.topic_comments_path(topic)
@@ -1,7 +1,7 @@
1
1
  module Bbs
2
2
  class LatestTopicsCell < ApplicationCell
3
3
  def show
4
- @topics = Bbs::Topic.order(:created_at).limit(10)
4
+ @topics = Bbs::Topic.order(created_at: :desc).limit(Bbs.config.latest_topics_count)
5
5
 
6
6
  render
7
7
  end
@@ -1,7 +1,13 @@
1
1
  module Bbs
2
- class ApplicationController < ActionController::Base
2
+ class ApplicationController < ::ApplicationController
3
+ include Bbs::Concerns::Authenticatable
4
+
3
5
  protect_from_forgery with: :exception
4
6
 
5
7
  layout 'layouts/application'
8
+
9
+ def logged_in?; current_user end
10
+
11
+ helper_method :logged_in?
6
12
  end
7
13
  end
@@ -1,9 +1,21 @@
1
1
  module Bbs
2
- class CommentsController < ApplicationController
2
+ class CommentsController < Bbs::ApplicationController
3
+ before_action :authenticate_user!, only: %i(create)
3
4
  before_action :set_topic
4
5
 
6
+ def create
7
+ @comment = @topic.comments.build(comment_params)
8
+
9
+ if @comment.save
10
+ redirect_to bbs.topic_comments_path(@topic), notice: t('.success')
11
+ else
12
+ redirect_back fallback_location: bbs.topic_comments_path(@topic), alert: @comment.errors.full_messages
13
+ end
14
+ end
15
+
5
16
  def index
6
- @comments = @topic.comments.order(:created_at).page(params[:page]).per(5)
17
+ @comment = @topic.comments.build
18
+ @comments = comments
7
19
  end
8
20
 
9
21
  private
@@ -11,5 +23,14 @@ module Bbs
11
23
  def set_topic
12
24
  @topic = Bbs::Topic.find(params[:topic_id])
13
25
  end
26
+
27
+ def comment_params
28
+ params.require(:comment).permit(Bbs::Comment.permitted_attributes)
29
+ .merge(author: current_user)
30
+ end
31
+
32
+ def comments
33
+ @topic.comments.order(:updated_at).page(params[:page]).per(Bbs.config.comments_per_page)
34
+ end
14
35
  end
15
36
  end
@@ -0,0 +1,21 @@
1
+ module Bbs
2
+ module Concerns
3
+ module Authenticatable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ unless public_instance_methods.include?(Bbs.config.current_user)
8
+ define_method(:current_user) do
9
+ __send__ Bbs.config.current_user
10
+ end
11
+ end
12
+
13
+ unless public_instance_methods.include?(Bbs.config.authenticate_user)
14
+ define_method(:authenticate_user!) do
15
+ __send__ Bbs.config.authenticate_user
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,35 @@
1
+ module Bbs
2
+ class ProfilesController < Bbs::ApplicationController
3
+ before_action :authenticate_user!
4
+
5
+ def edit
6
+ current_user.build_profile unless current_user.profile
7
+ end
8
+
9
+ def create
10
+ if current_user.create_profile(profile_params)
11
+ redirect_to edit_profile_path, notice: t('.success')
12
+ else
13
+ flash.now[:alert] = current_user.profile.errors.full_messages
14
+
15
+ render :edit
16
+ end
17
+ end
18
+
19
+ def update
20
+ if current_user.profile.update(profile_params)
21
+ redirect_to edit_profile_path, notice: t('.success')
22
+ else
23
+ flash.now[:alert] = current_user.profile.errors.full_messages
24
+
25
+ render :edit
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def profile_params
32
+ params.require(:user_profile).permit(Bbs::UserProfile.permitted_attributes)
33
+ end
34
+ end
35
+ end
@@ -1,9 +1,24 @@
1
1
  module Bbs
2
- class TopicsController < ApplicationController
2
+ class TopicsController < Bbs::ApplicationController
3
+ before_action :authenticate_user!, only: %i(create)
3
4
  before_action :set_category
4
5
 
6
+ def new
7
+ @topic = @category.topics.build
8
+ end
9
+
10
+ def create
11
+ @topic = @category.topics.build(topic_params)
12
+
13
+ if @topic.save
14
+ redirect_to bbs.category_topics_path(@category), notice: t('.success')
15
+ else
16
+ redirect_back fallback_location: main_app.root_path, alert: @topic.errors.full_messages
17
+ end
18
+ end
19
+
5
20
  def index
6
- @topics = @category.topics
21
+ @topics = @category.topics.order(:created_at).page(params[:page]).per(Bbs.config.topics_per_page)
7
22
  end
8
23
 
9
24
  private
@@ -11,5 +26,10 @@ module Bbs
11
26
  def set_category
12
27
  @category = Bbs::Category.find(params[:category_id])
13
28
  end
29
+
30
+ def topic_params
31
+ params.require(:topic).permit(Bbs::Topic.permitted_attributes)
32
+ .merge(author: current_user)
33
+ end
14
34
  end
15
35
  end
@@ -1,5 +1,9 @@
1
1
  module Bbs
2
2
  class ApplicationRecord < ActiveRecord::Base
3
3
  self.abstract_class = true
4
+
5
+ def self.permitted_attributes
6
+ self.attribute_names.without('id', 'created_at', 'updated_at')
7
+ end
4
8
  end
5
9
  end
@@ -0,0 +1,9 @@
1
+ module Bbs
2
+ class Avatar < ApplicationRecord
3
+ has_many :user_profiles, class_name: 'Bbs::UserProfile'
4
+
5
+ has_attached_file :image, styles: {medium: '48x48>', thumb: '48x48>'}
6
+
7
+ validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  module Bbs
2
- class Category < ApplicationRecord
3
- has_many :topics
2
+ class Category < ::Bbs::ApplicationRecord
3
+ has_many :topics, class_name: 'Bbs::Topic'
4
4
  end
5
5
  end
@@ -1,5 +1,8 @@
1
1
  module Bbs
2
- class Comment < ApplicationRecord
3
- belongs_to :topic
2
+ class Comment < ::Bbs::ApplicationRecord
3
+ belongs_to :topic, class_name: 'Bbs::Topic'
4
+ belongs_to :author, class_name: 'Bbs::User'
5
+
6
+ validates :title, :body, presence: true, allow_blank: false
4
7
  end
5
8
  end
@@ -1,7 +1,10 @@
1
1
  module Bbs
2
- class Topic < ApplicationRecord
3
- has_many :comments
2
+ class Topic < ::Bbs::ApplicationRecord
3
+ has_many :comments, class_name: 'Bbs::Comment', dependent: :delete_all
4
4
 
5
- belongs_to :category
5
+ belongs_to :category, class_name: 'Bbs::Category'
6
+ belongs_to :author, class_name: 'Bbs::User'
7
+
8
+ validates :title, :body, presence: true, allow_blank: false
6
9
  end
7
10
  end
@@ -0,0 +1,10 @@
1
+ module Bbs
2
+ class User < ApplicationRecord
3
+ has_one :profile, class_name: 'Bbs::UserProfile', dependent: :destroy
4
+
5
+ accepts_nested_attributes_for :profile
6
+
7
+ validates_associated :profile
8
+ validates_presence_of :profile
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module Bbs
2
+ class UserProfile < ApplicationRecord
3
+ belongs_to :user, class_name: 'Bbs::User'
4
+ belongs_to :avatar, class_name: 'Bbs::Avatar'
5
+
6
+ validates :avatar_id, :nickname, presence: true, allow_blank: false
7
+ end
8
+ end
@@ -1,10 +1,19 @@
1
- %h1 comments
1
+ - breadcrumb :comments, @topic
2
2
 
3
- %ol
4
- - @comments.each do |comment|
5
- %li
6
- %article
7
- %header= comment.title
8
- = comment.body
3
+ = cell('bbs/article', @topic)
9
4
 
10
- = paginate @comments
5
+ %hr
6
+
7
+ - @comments.each do |comment|
8
+ = cell('bbs/article', comment)
9
+
10
+ .bbs-pagination
11
+ = paginate @comments
12
+
13
+ - content_for :head do
14
+ = rel_next_prev_link_tags @comments
15
+
16
+ - if logged_in?
17
+ = render partial: 'bbs/shared/comment_form', locals: {topic: @topic, comment: @comment}
18
+ - else
19
+ = link_to t('.require_login'), Bbs.config.login_path, class: 'bbs-button'
@@ -0,0 +1,12 @@
1
+ = form_for current_user.profile, url: bbs.profile_path, html: {class: 'bbs-form bbs-form--vertical'} do |f|
2
+ .bbs-form-group
3
+ = f.label :avatar_url
4
+
5
+ = f.collection_radio_buttons :avatar_id, Bbs::Avatar.all, :id, :id do |r|
6
+ = r.label { r.radio_button(style: 'width: 1em') + image_tag(r.object.image.url(:medium)) }
7
+
8
+ .bbs-form-group
9
+ = f.label :nickname
10
+ = f.text_field :nickname
11
+
12
+ = f.submit class: 'bbs-button'
@@ -0,0 +1,10 @@
1
+ = form_for [bbs, topic, comment], html: {class: 'bbs-form bbs-form--vertical'} do |f|
2
+ .bbs-form-group
3
+ = f.label :title
4
+ = f.text_field :title
5
+
6
+ .bbs-form-group
7
+ = f.label :body
8
+ = f.text_area :body
9
+
10
+ = f.submit class: 'bbs-button'
@@ -1,5 +1,20 @@
1
- %h1 Topics
1
+ %article.bbs-topic
2
+ %h1.bbs-topic__title= t('.title', category: @category.name)
2
3
 
3
- %ol
4
- - @topics.each do |topic|
5
- %li= link_to topic.title, bbs.topic_comments_path(topic)
4
+ .bbs-new-topic
5
+ - if logged_in?
6
+ = link_to t('.new_topic'), new_category_topic_path(@category), class: 'bbs-button'
7
+ - else
8
+ = link_to t('.require_login'), Bbs.config.login_path, class: 'bbs-button'
9
+
10
+ %ol.bbs-topic-list
11
+ - @topics.each do |topic|
12
+ %li.bbs-topic-item
13
+ %span= link_to sanitize(topic.title), bbs.topic_comments_path(topic)
14
+ %span= t('.comment_count', count: topic.comments.count)
15
+
16
+ .bbs-pagination
17
+ = paginate @topics
18
+
19
+ - content_for :head do
20
+ = rel_next_prev_link_tags @topics
@@ -0,0 +1,16 @@
1
+ %h1
2
+ カテゴリ
3
+ = @category.name
4
+
5
+ = t('.create')
6
+
7
+ = form_for [bbs, @category, @topic], html: {class: 'bbs-form bbs-form--vertical'} do |f|
8
+ .bbs-form-group
9
+ = f.label :title
10
+ = f.text_field :title
11
+
12
+ .bbs-form-group
13
+ = f.label :body
14
+ = f.text_area :body
15
+
16
+ = f.submit class: 'bbs-button'
@@ -0,0 +1,13 @@
1
+ crumb :root do
2
+ link t('bbs.breadcrumbs.home'), main_app.root_path
3
+ end
4
+
5
+ crumb :category do |category|
6
+ link category.name, bbs.category_topics_path(category)
7
+ end
8
+
9
+ crumb :comments do |topic|
10
+ link topic.title, bbs.topic_comments_path(topic)
11
+
12
+ parent :category, topic.category
13
+ end
@@ -0,0 +1,56 @@
1
+ en:
2
+ activerecord:
3
+ errors:
4
+ models:
5
+ bbs/topic:
6
+ attributes:
7
+ author:
8
+ required: Login required.
9
+ bbs/comment:
10
+ attributes:
11
+ author:
12
+ required: Login required.
13
+ attributes:
14
+ bbs/topic:
15
+ title: Title
16
+ body: Topic body
17
+ bbs/comment:
18
+ title: Title
19
+ body: Comment body
20
+ bbs/user_profile:
21
+ avatar_url: Avatar
22
+ nickname: Nickname
23
+ helpers:
24
+ submit:
25
+ topic:
26
+ create: Create new topic
27
+ comment:
28
+ create: Post new comment
29
+ bbs:
30
+ topics:
31
+ index:
32
+ title: topics for %{category}
33
+ new_topic: create a new topic
34
+ comment_count: (%{count} comments)
35
+ require_login: login required before create a new topic
36
+ new:
37
+ create: Create new topic
38
+ create:
39
+ success: new topic created
40
+ comments:
41
+ index:
42
+ posted_at: posted at
43
+ require_login: to view comments you must be logged
44
+ create:
45
+ success: commented
46
+ category:
47
+ title: Categories
48
+ latest_topics:
49
+ title: Latest topics
50
+ breadcrumbs:
51
+ home: Home
52
+ profiles:
53
+ create:
54
+ success: profile successfully created
55
+ update:
56
+ success: profile successfully updated
@@ -0,0 +1,56 @@
1
+ ja:
2
+ activerecord:
3
+ errors:
4
+ models:
5
+ bbs/topic:
6
+ attributes:
7
+ author:
8
+ required: 投稿者がありません。
9
+ bbs/comment:
10
+ attributes:
11
+ author:
12
+ required: 投稿者がありません。
13
+ attributes:
14
+ bbs/topic:
15
+ title: タイトル
16
+ body: 本文
17
+ bbs/comment:
18
+ title: タイトル
19
+ body: 本文
20
+ bbs/user_profile:
21
+ avatar_url: アバター
22
+ nickname: ニックネーム
23
+ helpers:
24
+ submit:
25
+ topic:
26
+ create: トピックを作成する
27
+ comment:
28
+ create: 投稿する
29
+ bbs:
30
+ topics:
31
+ index:
32
+ title: '%{category}のトピック'
33
+ new_topic: 新しいトピックを立てる
34
+ comment_count: (コメント %{count} 件)
35
+ require_login: トピックを立てるにはログインしてください
36
+ new:
37
+ create: 新しいトピックを作成します
38
+ create:
39
+ success: トピックを立てました
40
+ comments:
41
+ index:
42
+ posted_at: 投稿日時
43
+ require_login: コメントを閲覧するにはログインしてください
44
+ create:
45
+ success: コメントしました
46
+ category:
47
+ title: カテゴリ
48
+ latest_topics:
49
+ title: 最新トピック
50
+ breadcrumbs:
51
+ home: ホーム
52
+ profiles:
53
+ create:
54
+ success: プロフィールを作成しました
55
+ update:
56
+ success: プロフィールを更新しました
data/config/routes.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  Bbs::Engine.routes.draw do
2
+ resource :profile, only: %i(edit create update)
3
+
2
4
  resources :categories do
3
5
  resources :topics, shallow: true do
4
6
  resources :comments, shallow: true
@@ -0,0 +1,6 @@
1
+ class AddAuthorId < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :bbs_topics, :author_id, :integer
4
+ add_column :bbs_comments, :author_id, :integer
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ class CreateBbsUsers < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :bbs_users do |t|
4
+
5
+ t.timestamps
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ class CreateBbsUserProfiles < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :bbs_user_profiles do |t|
4
+ t.integer :user_id, null: false
5
+ t.string :avatar_url
6
+ t.string :nickname
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ add_foreign_key :bbs_user_profiles, :bbs_users, column: :user_id
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ class CreateBbsAvatars < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :bbs_avatars do |t|
4
+ t.attachment :avatar
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ class AddAvatarIdToUser < ActiveRecord::Migration[5.0]
2
+ def change
3
+ remove_column :bbs_user_profiles, :avatar_url, :string
4
+
5
+ add_column :bbs_user_profiles, :avatar_id, :integer
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ class RenameAvatarColumn < ActiveRecord::Migration[5.0]
2
+ def change
3
+ rename_column :bbs_avatars, :avatar_file_name, :image_file_name
4
+ rename_column :bbs_avatars, :avatar_content_type, :image_content_type
5
+ rename_column :bbs_avatars, :avatar_file_size, :image_file_size
6
+ rename_column :bbs_avatars, :avatar_updated_at, :image_updated_at
7
+ end
8
+ end
data/lib/bbs.rb CHANGED
@@ -1,5 +1,16 @@
1
- require "bbs/engine"
1
+ require 'bbs/engine'
2
+ require 'bbs/configuration'
2
3
 
3
4
  module Bbs
4
- # Your code goes here...
5
+ mattr_accessor :config
6
+
7
+ def config
8
+ @config ||= Bbs::Configuration.new
9
+ end
10
+
11
+ def configure
12
+ yield(config)
13
+ end
14
+
15
+ module_function :config, :configure
5
16
  end
@@ -0,0 +1,35 @@
1
+ module Bbs
2
+ class Configuration
3
+ attr_accessor :clamp_article_body, :login_path, :latest_topics_count,
4
+ :topics_per_page, :comments_per_page, :current_user,
5
+ :authenticate_user
6
+
7
+ def clamp_article_body
8
+ @clamp_article_body ||= 100
9
+ end
10
+
11
+ def login_path
12
+ @login_path ||= '/'
13
+ end
14
+
15
+ def latest_topics_count
16
+ @latest_topics_count ||= 10
17
+ end
18
+
19
+ def topics_per_page
20
+ @topics_per_page ||= 10
21
+ end
22
+
23
+ def comments_per_page
24
+ @comments_per_page ||= 10
25
+ end
26
+
27
+ def current_user
28
+ @current_user ||= :current_user
29
+ end
30
+
31
+ def authenticate_user
32
+ @authenticate_user ||= :authenticate_user!
33
+ end
34
+ end
35
+ end
data/lib/bbs/engine.rb CHANGED
@@ -1,9 +1,20 @@
1
1
  require 'cells-rails'
2
2
  require 'cells-hamlit'
3
+ require 'gretel'
3
4
  require 'kaminari'
5
+ require 'paperclip'
6
+ require 'rails-i18n'
4
7
 
5
8
  module Bbs
6
9
  class Engine < ::Rails::Engine
7
10
  isolate_namespace Bbs
11
+
12
+ config.to_prepare do
13
+ Dir.glob(Rails.root + 'app/engines/**/*.rb').each do |c|
14
+ require_dependency(c)
15
+ end
16
+ end
17
+
18
+ ActiveSupport.run_load_hooks :bbs_engine, Bbs::Engine
8
19
  end
9
20
  end
data/lib/bbs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bbs
2
- VERSION = '0.1.0'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -0,0 +1,32 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Bbs
4
+ module Generators
5
+ class InitializerGenerator < Rails::Generators::Base
6
+ hide!
7
+
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ def copy_initialier
11
+ copy_file 'bbs.rb', 'config/initializers/bbs.rb'
12
+ end
13
+ end
14
+
15
+ class LocaleGenerator < Rails::Generators::Base
16
+ hide!
17
+
18
+ source_root Bbs::Engine.root.join('config/locales').to_s
19
+
20
+ def copy_locales
21
+ %w(bbs.en.yml bbs.ja.yml).each do |locale|
22
+ copy_file locale, "config/locales/#{locale}"
23
+ end
24
+ end
25
+ end
26
+
27
+ class ConfigGenerator < Rails::Generators::Base
28
+ invoke InitializerGenerator
29
+ invoke LocaleGenerator
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,26 @@
1
+ Bbs.configure do |config|
2
+ # clamp line specified words.
3
+ # for example, if you set `config.clamp_article_body` to `10`,
4
+ # comment or topics body will clamp 10 words when user does not logged in.
5
+ #
6
+ # If you set value `false`, never clamp line.
7
+ #config.clamp_article_body = 10
8
+
9
+ # spedify sign in path
10
+ #config.login_path = '/users/sign_in'
11
+
12
+ # set number of latest topics inside component
13
+ #config.latest_topics_count = 10
14
+
15
+ # set number of topics per page
16
+ #config.topics_per_page = 10
17
+
18
+ # set number of topics per page
19
+ #config.comments_per_page = 10
20
+
21
+ # set current_user method
22
+ config.current_user = :current_user
23
+
24
+ # set authenticate user method
25
+ config.authenticate_user = :authenticate_user!
26
+ end
@@ -0,0 +1,15 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Bbs
4
+ module Generators
5
+ class ViewsGenerator < Rails::Generators::Base
6
+ source_root Bbs::Engine.root.join('app/views/bbs').to_s
7
+
8
+ def copy_views
9
+ %w(comments profiles shared topics).each do |resource|
10
+ directory resource, "app/views/bbs/#{resource}"
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - nobody
7
+ - ''
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-17 00:00:00.000000000 Z
11
+ date: 2016-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 5.0.0.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: bourbon
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: cells-hamlit
35
49
  requirement: !ruby/object:Gem::Requirement
@@ -58,6 +72,20 @@ dependencies:
58
72
  - - ">="
59
73
  - !ruby/object:Gem::Version
60
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: gretel
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
61
89
  - !ruby/object:Gem::Dependency
62
90
  name: kaminari
63
91
  requirement: !ruby/object:Gem::Requirement
@@ -72,6 +100,48 @@ dependencies:
72
100
  - - ">="
73
101
  - !ruby/object:Gem::Version
74
102
  version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: paperclip
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: rails-i18n
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :runtime
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: minitest-rails-capybara
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
75
145
  - !ruby/object:Gem::Dependency
76
146
  name: pg
77
147
  requirement: !ruby/object:Gem::Requirement
@@ -86,9 +156,37 @@ dependencies:
86
156
  - - ">="
87
157
  - !ruby/object:Gem::Version
88
158
  version: '0'
159
+ - !ruby/object:Gem::Dependency
160
+ name: pry-byebug
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ - !ruby/object:Gem::Dependency
174
+ name: simplecov
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ type: :development
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
89
187
  description: Description of Bbs.
90
188
  email:
91
- - nobody@bm-sms.co.jp
189
+ - jp.bm-sms.developers@bm-sms.jp
92
190
  executables: []
93
191
  extensions: []
94
192
  extra_rdoc_files: []
@@ -98,24 +196,39 @@ files:
98
196
  - Rakefile
99
197
  - app/assets/config/bbs_manifest.js
100
198
  - app/assets/javascripts/bbs/application.js
199
+ - app/assets/stylesheets/bbs/_article.css.sass
200
+ - app/assets/stylesheets/bbs/_bbs-list.css.sass
201
+ - app/assets/stylesheets/bbs/_button.css.sass
202
+ - app/assets/stylesheets/bbs/_form.css.sass
203
+ - app/assets/stylesheets/bbs/_new-topic.css.sass
101
204
  - app/assets/stylesheets/bbs/application.css
102
205
  - app/cells/bbs/application_cell.rb
206
+ - app/cells/bbs/article/show.haml
207
+ - app/cells/bbs/article_cell.rb
103
208
  - app/cells/bbs/category/show.haml
104
209
  - app/cells/bbs/category_cell.rb
105
210
  - app/cells/bbs/latest_topics/show.haml
106
211
  - app/cells/bbs/latest_topics_cell.rb
107
212
  - app/controllers/bbs/application_controller.rb
108
213
  - app/controllers/bbs/comments_controller.rb
214
+ - app/controllers/bbs/concerns/authenticatable.rb
215
+ - app/controllers/bbs/profiles_controller.rb
109
216
  - app/controllers/bbs/topics_controller.rb
110
217
  - app/helpers/bbs/application_helper.rb
111
218
  - app/jobs/bbs/application_job.rb
112
219
  - app/mailers/bbs/application_mailer.rb
113
220
  - app/models/bbs/application_record.rb
221
+ - app/models/bbs/avatar.rb
114
222
  - app/models/bbs/category.rb
115
223
  - app/models/bbs/comment.rb
116
224
  - app/models/bbs/topic.rb
225
+ - app/models/bbs/user.rb
226
+ - app/models/bbs/user_profile.rb
117
227
  - app/views/bbs/comments/index.html.haml
228
+ - app/views/bbs/profiles/edit.html.haml
229
+ - app/views/bbs/shared/_comment_form.html.haml
118
230
  - app/views/bbs/topics/index.html.haml
231
+ - app/views/bbs/topics/new.html.haml
119
232
  - app/views/kaminari/_first_page.html.haml
120
233
  - app/views/kaminari/_gap.html.haml
121
234
  - app/views/kaminari/_last_page.html.haml
@@ -123,13 +236,26 @@ files:
123
236
  - app/views/kaminari/_page.html.haml
124
237
  - app/views/kaminari/_paginator.html.haml
125
238
  - app/views/kaminari/_prev_page.html.haml
239
+ - config/breadcrumbs.rb
240
+ - config/locales/bbs.en.yml
241
+ - config/locales/bbs.ja.yml
126
242
  - config/routes.rb
127
243
  - db/migrate/20160815075807_create_bbs_categories.rb
128
244
  - db/migrate/20160815075844_create_bbs_topics.rb
129
245
  - db/migrate/20160815080614_create_bbs_comments.rb
246
+ - db/migrate/20160817082220_add_author_id.rb
247
+ - db/migrate/20160902071411_create_bbs_users.rb
248
+ - db/migrate/20160902071450_create_bbs_user_profiles.rb
249
+ - db/migrate/20160928082713_create_bbs_avatars.rb
250
+ - db/migrate/20160930093905_add_avatar_id_to_user.rb
251
+ - db/migrate/20161028081055_rename_avatar_column.rb
130
252
  - lib/bbs.rb
253
+ - lib/bbs/configuration.rb
131
254
  - lib/bbs/engine.rb
132
255
  - lib/bbs/version.rb
256
+ - lib/generators/bbs/config_generator.rb
257
+ - lib/generators/bbs/templates/bbs.rb
258
+ - lib/generators/bbs/views_generator.rb
133
259
  - lib/tasks/bbs_tasks.rake
134
260
  homepage: ''
135
261
  licenses: