active_admin_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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e66deb2ce489a1bdb497ca8523bd2eb1fad635ea
4
- data.tar.gz: 71adf616ae0af03f8f0ef2c3e173702d08b4585f
3
+ metadata.gz: fef6a9f7b4cfce745eeca0e63be8d550ac504807
4
+ data.tar.gz: 93b15a3a3505f157236fef7d5c8470d1b13cd791
5
5
  SHA512:
6
- metadata.gz: 8f011cec3a990bfe4bcc498260edaa87eba172bc571c02b407a1bd40a2f34ec3b61daba463533cd220cf8a763f49f7456ca4209a6a4f7cf2fb9e4939dbd95dac
7
- data.tar.gz: 20622f279fdff113f5f5467e192506f5f034a7d1b651171a8d1f0125389919c509d8ce048463e0b1f92e2d197bc68a79a7a9f8e8c6642cae08aadf53c8ff9ce0
6
+ metadata.gz: 5ee98dc526932c7122121c2e9c8e6a91a4048d3e3843a50760ecd158337490629b53614ecd5d7897adf8447532880956d04aa3779e0eae38c97d30c1b77f4fe7
7
+ data.tar.gz: 5eb2d539e60eb2ff305e198bfe09471d873ac1db2af9be0ae4c948478548f644cadca8aca946e8d2ced9542708df01a60953894cef07eaec6efe7fe9d73b69af
data/README.md CHANGED
@@ -1,12 +1,11 @@
1
1
  # ActiveAdminBbs
2
- Short description and motivation.
2
+ ActiveAdmin plugin for `bbs`.
3
3
 
4
- ## Usage
5
- How to use my plugin.
4
+ ## Requirements
5
+ This gem depends on `activeadmin`.
6
6
 
7
7
  ## Installation
8
8
  Add this line to your application's Gemfile:
9
-
10
9
  ```ruby
11
10
  gem 'active_admin_bbs'
12
11
  ```
@@ -21,8 +20,34 @@ Or install it yourself as:
21
20
  $ gem install active_admin_bbs
22
21
  ```
23
22
 
23
+ ## Features
24
+ ### Bbs provided resources maintenance
25
+ Following resources were registered:
26
+ - Bbs::Avatar
27
+ - Bbs::Category
28
+ - Bbs::Comment
29
+ - Bbs::Topic
30
+ - Bbs::User
31
+
32
+ ### Dashboard
33
+ Include `ActiveAdminBbs::Dashboard` module into your ActiveAdmin
34
+ dashboard, basically located at `app/admin/dashboard.rb`. For example:
35
+
36
+ ```ruby
37
+ ActiveAdmin.register_page 'Dashboard' do
38
+ include ActiveAdminBbs::Dashboard
39
+ end
40
+ ```
41
+
42
+ Note that the charts of Dashboard module query database directly.
43
+ When your database is getting much the records, you should reconcider another way of drawing charts.
44
+
24
45
  ## Contributing
25
- Contribution directions go here.
46
+ 1. Fork it ( https://github.com/bm-sms/active_admin_bbs )
47
+ 2. Create your feature branch (git checkout -b my-new-feature)
48
+ 3. Commit your changes (git commit -am 'Add some feature')
49
+ 4. Push to the branch (git push origin my-new-feature)
50
+ 5. Create new Pull Request
26
51
 
27
52
  ## License
28
53
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,48 @@
1
+ ActiveAdmin.register Bbs::Avatar do
2
+ index do
3
+ column 'ID', :id
4
+ column 'avatar', :avatar do |o|
5
+ image_tag(o.image.url(:medium))
6
+ end
7
+
8
+ actions
9
+ end
10
+
11
+ show do |r|
12
+ attributes_table do
13
+ row :avatar do
14
+ image_tag(r.image.url(:medium))
15
+ end
16
+
17
+ row :url do
18
+ r.image.url
19
+ end
20
+
21
+ row :url_medium do
22
+ r.image.url(:medium)
23
+ end
24
+
25
+ row :url_thumb do
26
+ r.image.url(:thumb)
27
+ end
28
+
29
+ active_admin_comments
30
+ end
31
+ end
32
+
33
+ form multipart: true, as: 'bbs_avatar' do |f|
34
+ f.semantic_errors
35
+ f.inputs Bbs::Avatar do
36
+ f.input :image, as: :file
37
+ f.actions
38
+ end
39
+ end
40
+
41
+ controller do
42
+ private
43
+
44
+ def permitted_params
45
+ params.permit bbs_avatar: [:image]
46
+ end
47
+ end
48
+ end
@@ -1,24 +1,3 @@
1
1
  ActiveAdmin.register Bbs::User do
2
- form as: 'bbs_user' do |f|
3
- f.semantic_errors
4
-
5
- f.input :email
6
-
7
- f.inputs do
8
- f.has_many :profile, new_record: false do |p|
9
- p.input :avatar_url
10
- p.input :nickname
11
- end
12
- end
13
-
14
- f.actions
15
- end
16
-
17
- controller do
18
- private
19
-
20
- def permitted_params
21
- params.permit bbs_user: [:email, profile_attributes: [:avatar_url, :nickname]]
22
- end
23
- end
2
+ actions :all, except: %i(new)
24
3
  end
@@ -0,0 +1,71 @@
1
+ module ActiveAdminBbs
2
+ module Dashboard
3
+ def self.included(dsl)
4
+ dsl.instance_eval do
5
+ content title: I18n.t('active_admin_bbs.dashboard.chart.title') do
6
+ columns do
7
+ column do
8
+ panel I18n.t('active_admin_bbs.dashboard.chart.user_count') do
9
+ div do
10
+ span Bbs::User.count
11
+ end
12
+ end
13
+ end
14
+
15
+ column do
16
+ panel I18n.t('active_admin_bbs.dashboard.chart.topic_count') do
17
+ div do
18
+ span Bbs::Topic.count
19
+ end
20
+ end
21
+ end
22
+
23
+ column do
24
+ panel I18n.t('active_admin_bbs.dashboard.chart.comment_count') do
25
+ div do
26
+ span Bbs::Comment.count
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ columns do
33
+ column do
34
+ panel I18n.t('active_admin_bbs.dashboard.chart.user_count_by_day') do
35
+ line_chart ActiveAdminBbs::Dashboard::cumulate(Bbs::User.group_by_day(:created_at).count)
36
+ end
37
+ end
38
+ end
39
+
40
+ columns do
41
+ column do
42
+ panel I18n.t('active_admin_bbs.dashboard.chart.topic_count_by_day') do
43
+ line_chart ActiveAdminBbs::Dashboard::cumulate(Bbs::Topic.group_by_day(:created_at).count)
44
+ end
45
+ end
46
+ end
47
+
48
+ columns do
49
+ column do
50
+ panel I18n.t('active_admin_bbs.dashboard.chart.comment_count_by_day') do
51
+ line_chart ActiveAdminBbs::Dashboard::cumulate(Bbs::Comment.group_by_day(:created_at).count)
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ private
60
+
61
+ def cumulate(count)
62
+ total = 0
63
+
64
+ count.to_a.sort {|day, value| day[0] <=> value[0] }
65
+ .map {|day, value| {day => (total += value)}}
66
+ .reduce({}, :merge)
67
+ end
68
+
69
+ module_function :cumulate
70
+ end
71
+ end
@@ -0,0 +1,11 @@
1
+ en:
2
+ active_admin_bbs:
3
+ dashboard:
4
+ chart:
5
+ title: chart
6
+ user_count: total users
7
+ topic_count: total topics
8
+ comment_count: total comments
9
+ user_count_by_day: cumulative users by day
10
+ topic_count_by_day: cumulative topics by day
11
+ comment_count_by_day: cumulative comments by day
@@ -0,0 +1,11 @@
1
+ ja:
2
+ active_admin_bbs:
3
+ dashboard:
4
+ chart:
5
+ title: チャート
6
+ user_count: ユーザ総数
7
+ topic_count: トピック総数
8
+ comment_count: コメント総数
9
+ user_count_by_day: ユーザ数(日累計)
10
+ topic_count_by_day: トピック数(日累計)
11
+ comment_count_by_day: コメント数(日累計)
@@ -0,0 +1,3 @@
1
+ require 'i18n'
2
+
3
+ I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'locale', '*.yml')]
@@ -1,3 +1,3 @@
1
1
  module ActiveAdminBbs
2
- VERSION = '0.1.0'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -1,4 +1,8 @@
1
1
  require 'active_admin_bbs/version'
2
+ require 'active_admin_bbs/translate'
3
+ require 'active_admin_bbs/dashboard'
4
+ require 'chartkick'
5
+ require 'groupdate'
2
6
  require 'rails/active_admin_bbs/railtie'
3
7
 
4
8
  module ActiveAdminBbs
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_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
7
  - ''
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-15 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
@@ -32,6 +32,48 @@ dependencies:
32
32
  version: 5.0.0.1
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bbs
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 1.0.0
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 1.0.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: chartkick
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: groupdate
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: i18n
35
77
  requirement: !ruby/object:Gem::Requirement
36
78
  requirements:
37
79
  - - ">="
@@ -96,11 +138,16 @@ files:
96
138
  - MIT-LICENSE
97
139
  - README.md
98
140
  - Rakefile
141
+ - app/admin/bbs_avatar.rb
99
142
  - app/admin/bbs_category.rb
100
143
  - app/admin/bbs_comment.rb
101
144
  - app/admin/bbs_topic.rb
102
145
  - app/admin/bbs_user.rb
103
146
  - lib/active_admin_bbs.rb
147
+ - lib/active_admin_bbs/dashboard.rb
148
+ - lib/active_admin_bbs/locale/en.yml
149
+ - lib/active_admin_bbs/locale/ja.yml
150
+ - lib/active_admin_bbs/translate.rb
104
151
  - lib/active_admin_bbs/version.rb
105
152
  - lib/rails/active_admin_bbs/railtie.rb
106
153
  - lib/tasks/active_admin_bbs_tasks.rake