bbs 0.1.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 (40) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/config/bbs_manifest.js +2 -0
  6. data/app/assets/javascripts/bbs/application.js +13 -0
  7. data/app/assets/stylesheets/bbs/application.css +15 -0
  8. data/app/cells/bbs/application_cell.rb +10 -0
  9. data/app/cells/bbs/category/show.haml +5 -0
  10. data/app/cells/bbs/category_cell.rb +9 -0
  11. data/app/cells/bbs/latest_topics/show.haml +5 -0
  12. data/app/cells/bbs/latest_topics_cell.rb +9 -0
  13. data/app/controllers/bbs/application_controller.rb +7 -0
  14. data/app/controllers/bbs/comments_controller.rb +15 -0
  15. data/app/controllers/bbs/topics_controller.rb +15 -0
  16. data/app/helpers/bbs/application_helper.rb +4 -0
  17. data/app/jobs/bbs/application_job.rb +4 -0
  18. data/app/mailers/bbs/application_mailer.rb +6 -0
  19. data/app/models/bbs/application_record.rb +5 -0
  20. data/app/models/bbs/category.rb +5 -0
  21. data/app/models/bbs/comment.rb +5 -0
  22. data/app/models/bbs/topic.rb +7 -0
  23. data/app/views/bbs/comments/index.html.haml +10 -0
  24. data/app/views/bbs/topics/index.html.haml +5 -0
  25. data/app/views/kaminari/_first_page.html.haml +9 -0
  26. data/app/views/kaminari/_gap.html.haml +8 -0
  27. data/app/views/kaminari/_last_page.html.haml +9 -0
  28. data/app/views/kaminari/_next_page.html.haml +9 -0
  29. data/app/views/kaminari/_page.html.haml +10 -0
  30. data/app/views/kaminari/_paginator.html.haml +18 -0
  31. data/app/views/kaminari/_prev_page.html.haml +9 -0
  32. data/config/routes.rb +7 -0
  33. data/db/migrate/20160815075807_create_bbs_categories.rb +9 -0
  34. data/db/migrate/20160815075844_create_bbs_topics.rb +13 -0
  35. data/db/migrate/20160815080614_create_bbs_comments.rb +13 -0
  36. data/lib/bbs.rb +5 -0
  37. data/lib/bbs/engine.rb +9 -0
  38. data/lib/bbs/version.rb +3 -0
  39. data/lib/tasks/bbs_tasks.rake +4 -0
  40. metadata +158 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2100329a330c79eb4eedc89a47574a54887f56d1
4
+ data.tar.gz: b18085a0560819163c76c3eaf2562a1b923a7e3e
5
+ SHA512:
6
+ metadata.gz: dcbf62293e5889f2f3aea37041b7490b72e1fdf73babbb28c57dee300afafb3a01365dc7e5c09df6b623340658c8bfa48648c9441a26f7f3447ab23a9b4cc286
7
+ data.tar.gz: cf18c0493f809ff6d38ce2f8e6540fb5deffc42979c198ae9604a9304f066cdde81e658b98f9b574e452d79737e938bf7a39218493ce5850b087bed1fefba9d3
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 kajisha
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Bbs
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'bbs'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install bbs
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Bbs'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/bbs .js
2
+ //= link_directory ../stylesheets/bbs .css
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
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
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,10 @@
1
+ module Bbs
2
+ class ApplicationCell < Cell::ViewModel
3
+ include Cell::Hamlit
4
+ include ActionView::Helpers::UrlHelper
5
+
6
+ delegate :bbs, :main_app, to: :parent_controller
7
+
8
+ self.view_paths = [Bbs::Engine.root.join('app/cells').to_s]
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ %h1 Categories
2
+
3
+ %ol.bbs-category
4
+ - @categories.each do |category|
5
+ %li.bbs-category__name= link_to category.name, bbs.category_topics_path(category)
@@ -0,0 +1,9 @@
1
+ module Bbs
2
+ class CategoryCell < ApplicationCell
3
+ def show
4
+ @categories = Bbs::Category.all
5
+
6
+ render
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ %h1 Latest Topics
2
+
3
+ %ol
4
+ - @topics.each do |topic|
5
+ %li= link_to topic.title, bbs.topic_comments_path(topic)
@@ -0,0 +1,9 @@
1
+ module Bbs
2
+ class LatestTopicsCell < ApplicationCell
3
+ def show
4
+ @topics = Bbs::Topic.order(:created_at).limit(10)
5
+
6
+ render
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module Bbs
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+
5
+ layout 'layouts/application'
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ module Bbs
2
+ class CommentsController < ApplicationController
3
+ before_action :set_topic
4
+
5
+ def index
6
+ @comments = @topic.comments.order(:created_at).page(params[:page]).per(5)
7
+ end
8
+
9
+ private
10
+
11
+ def set_topic
12
+ @topic = Bbs::Topic.find(params[:topic_id])
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Bbs
2
+ class TopicsController < ApplicationController
3
+ before_action :set_category
4
+
5
+ def index
6
+ @topics = @category.topics
7
+ end
8
+
9
+ private
10
+
11
+ def set_category
12
+ @category = Bbs::Category.find(params[:category_id])
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ module Bbs
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Bbs
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Bbs
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Bbs
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Bbs
2
+ class Category < ApplicationRecord
3
+ has_many :topics
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Bbs
2
+ class Comment < ApplicationRecord
3
+ belongs_to :topic
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module Bbs
2
+ class Topic < ApplicationRecord
3
+ has_many :comments
4
+
5
+ belongs_to :category
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ %h1 comments
2
+
3
+ %ol
4
+ - @comments.each do |comment|
5
+ %li
6
+ %article
7
+ %header= comment.title
8
+ = comment.body
9
+
10
+ = paginate @comments
@@ -0,0 +1,5 @@
1
+ %h1 Topics
2
+
3
+ %ol
4
+ - @topics.each do |topic|
5
+ %li= link_to topic.title, bbs.topic_comments_path(topic)
@@ -0,0 +1,9 @@
1
+ -# Link to the "First" page
2
+ -# available local variables
3
+ -# url: url to the first page
4
+ -# current_page: a page object for the currently displayed page
5
+ -# total_pages: total number of pages
6
+ -# per_page: number of items to fetch per page
7
+ -# remote: data-remote
8
+ %span.pagination__first
9
+ = link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, remote: remote
@@ -0,0 +1,8 @@
1
+ -# Non-link tag that stands for skipped pages...
2
+ -# available local variables
3
+ -# current_page: a page object for the currently displayed page
4
+ -# total_pages: total number of pages
5
+ -# per_page: number of items to fetch per page
6
+ -# remote: data-remote
7
+ %span.pagination__page.pagination__page--gap
8
+ = t('views.pagination.truncate').html_safe
@@ -0,0 +1,9 @@
1
+ -# Link to the "Last" page
2
+ -# available local variables
3
+ -# url: url to the last page
4
+ -# current_page: a page object for the currently displayed page
5
+ -# total_pages: total number of pages
6
+ -# per_page: number of items to fetch per page
7
+ -# remote: data-remote
8
+ %span.pagination__last
9
+ = link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, remote: remote
@@ -0,0 +1,9 @@
1
+ -# Link to the "Next" page
2
+ -# available local variables
3
+ -# url: url to the next page
4
+ -# current_page: a page object for the currently displayed page
5
+ -# total_pages: total number of pages
6
+ -# per_page: number of items to fetch per page
7
+ -# remote: data-remote
8
+ %span.pagination__next
9
+ = link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, rel: 'next', remote: remote
@@ -0,0 +1,10 @@
1
+ -# Link showing page number
2
+ -# available local variables
3
+ -# page: a page object for "this" page
4
+ -# url: url to this page
5
+ -# current_page: a page object for the currently displayed page
6
+ -# total_pages: total number of pages
7
+ -# per_page: number of items to fetch per page
8
+ -# remote: data-remote
9
+ %span{class: "pagination__page#{' current' if page.current?}"}
10
+ = link_to_unless page.current?, page, url, {remote: remote, rel: page.next? ? 'next' : page.prev? ? 'prev' : nil}
@@ -0,0 +1,18 @@
1
+ -# The container tag
2
+ -# available local variables
3
+ -# current_page: a page object for the currently displayed page
4
+ -# total_pages: total number of pages
5
+ -# per_page: number of items to fetch per page
6
+ -# remote: data-remote
7
+ -# paginator: the paginator that renders the pagination tags inside
8
+ = paginator.render do
9
+ %nav.pagination
10
+ = first_page_tag unless current_page.first?
11
+ = prev_page_tag unless current_page.first?
12
+ - each_page do |page|
13
+ - if page.left_outer? || page.right_outer? || page.inside_window?
14
+ = page_tag page
15
+ - elsif !page.was_truncated?
16
+ = gap_tag
17
+ = next_page_tag unless current_page.last?
18
+ = last_page_tag unless current_page.last?
@@ -0,0 +1,9 @@
1
+ -# Link to the "Previous" page
2
+ -# available local variables
3
+ -# url: url to the previous page
4
+ -# current_page: a page object for the currently displayed page
5
+ -# total_pages: total number of pages
6
+ -# per_page: number of items to fetch per page
7
+ -# remote: data-remote
8
+ %span.pagination__prev
9
+ = link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, rel: 'prev', remote: remote
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ Bbs::Engine.routes.draw do
2
+ resources :categories do
3
+ resources :topics, shallow: true do
4
+ resources :comments, shallow: true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ class CreateBbsCategories < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :bbs_categories do |t|
4
+ t.string :name, null: false
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class CreateBbsTopics < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :bbs_topics do |t|
4
+ t.string :title, null: false
5
+ t.text :body, null: false
6
+ t.integer :category_id, null: false
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ add_foreign_key :bbs_topics, :bbs_categories, column: :category_id
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class CreateBbsComments < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :bbs_comments do |t|
4
+ t.integer :topic_id, null: false
5
+ t.string :title, null: false
6
+ t.text :body, null: false
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ add_foreign_key :bbs_comments, :bbs_topics, column: :topic_id
12
+ end
13
+ end
data/lib/bbs.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "bbs/engine"
2
+
3
+ module Bbs
4
+ # Your code goes here...
5
+ end
data/lib/bbs/engine.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'cells-rails'
2
+ require 'cells-hamlit'
3
+ require 'kaminari'
4
+
5
+ module Bbs
6
+ class Engine < ::Rails::Engine
7
+ isolate_namespace Bbs
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Bbs
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :bbs do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bbs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - nobody
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.0
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.0.0.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 5.0.0
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.0.0.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: cells-hamlit
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'
47
+ - !ruby/object:Gem::Dependency
48
+ name: cells-rails
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: kaminari
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: pg
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ description: Description of Bbs.
90
+ email:
91
+ - nobody@bm-sms.co.jp
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - MIT-LICENSE
97
+ - README.md
98
+ - Rakefile
99
+ - app/assets/config/bbs_manifest.js
100
+ - app/assets/javascripts/bbs/application.js
101
+ - app/assets/stylesheets/bbs/application.css
102
+ - app/cells/bbs/application_cell.rb
103
+ - app/cells/bbs/category/show.haml
104
+ - app/cells/bbs/category_cell.rb
105
+ - app/cells/bbs/latest_topics/show.haml
106
+ - app/cells/bbs/latest_topics_cell.rb
107
+ - app/controllers/bbs/application_controller.rb
108
+ - app/controllers/bbs/comments_controller.rb
109
+ - app/controllers/bbs/topics_controller.rb
110
+ - app/helpers/bbs/application_helper.rb
111
+ - app/jobs/bbs/application_job.rb
112
+ - app/mailers/bbs/application_mailer.rb
113
+ - app/models/bbs/application_record.rb
114
+ - app/models/bbs/category.rb
115
+ - app/models/bbs/comment.rb
116
+ - app/models/bbs/topic.rb
117
+ - app/views/bbs/comments/index.html.haml
118
+ - app/views/bbs/topics/index.html.haml
119
+ - app/views/kaminari/_first_page.html.haml
120
+ - app/views/kaminari/_gap.html.haml
121
+ - app/views/kaminari/_last_page.html.haml
122
+ - app/views/kaminari/_next_page.html.haml
123
+ - app/views/kaminari/_page.html.haml
124
+ - app/views/kaminari/_paginator.html.haml
125
+ - app/views/kaminari/_prev_page.html.haml
126
+ - config/routes.rb
127
+ - db/migrate/20160815075807_create_bbs_categories.rb
128
+ - db/migrate/20160815075844_create_bbs_topics.rb
129
+ - db/migrate/20160815080614_create_bbs_comments.rb
130
+ - lib/bbs.rb
131
+ - lib/bbs/engine.rb
132
+ - lib/bbs/version.rb
133
+ - lib/tasks/bbs_tasks.rake
134
+ homepage: ''
135
+ licenses:
136
+ - MIT
137
+ metadata: {}
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubyforge_project:
154
+ rubygems_version: 2.5.1
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: Summary of Bbs.
158
+ test_files: []