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 +4 -4
- data/README.md +30 -5
- data/app/admin/bbs_avatar.rb +48 -0
- data/app/admin/bbs_user.rb +1 -22
- data/lib/active_admin_bbs/dashboard.rb +71 -0
- data/lib/active_admin_bbs/locale/en.yml +11 -0
- data/lib/active_admin_bbs/locale/ja.yml +11 -0
- data/lib/active_admin_bbs/translate.rb +3 -0
- data/lib/active_admin_bbs/version.rb +1 -1
- data/lib/active_admin_bbs.rb +4 -0
- metadata +49 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fef6a9f7b4cfce745eeca0e63be8d550ac504807
|
4
|
+
data.tar.gz: 93b15a3a3505f157236fef7d5c8470d1b13cd791
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ee98dc526932c7122121c2e9c8e6a91a4048d3e3843a50760ecd158337490629b53614ecd5d7897adf8447532880956d04aa3779e0eae38c97d30c1b77f4fe7
|
7
|
+
data.tar.gz: 5eb2d539e60eb2ff305e198bfe09471d873ac1db2af9be0ae4c948478548f644cadca8aca946e8d2ced9542708df01a60953894cef07eaec6efe7fe9d73b69af
|
data/README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# ActiveAdminBbs
|
2
|
-
|
2
|
+
ActiveAdmin plugin for `bbs`.
|
3
3
|
|
4
|
-
##
|
5
|
-
|
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
|
-
|
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
|
data/app/admin/bbs_user.rb
CHANGED
@@ -1,24 +1,3 @@
|
|
1
1
|
ActiveAdmin.register Bbs::User do
|
2
|
-
|
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
|
data/lib/active_admin_bbs.rb
CHANGED
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:
|
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-
|
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
|