sofav 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +35 -0
  4. data/Rakefile +34 -0
  5. data/app/builders/admin/form_builder.rb +250 -0
  6. data/app/controllers/application_controller.rb +23 -0
  7. data/app/decorators/base_decorator.rb +172 -0
  8. data/app/helpers/admin/core_helper.rb +237 -0
  9. data/app/helpers/admin/show_view_helper.rb +69 -0
  10. data/app/helpers/admin/tags_helper.rb +104 -0
  11. data/app/services/active_record/search_service.rb +121 -0
  12. data/app/views/admin/application/_breadcrumb_nav.html.erb +10 -0
  13. data/app/views/admin/application/_collection.html.erb +79 -0
  14. data/app/views/admin/application/_save_js.js.erb +20 -0
  15. data/app/views/admin/application/_sidebar.html.erb +62 -0
  16. data/app/views/admin/application/_topbar.html.erb +32 -0
  17. data/app/views/admin/application/actions/charge.html.erb +3 -0
  18. data/app/views/admin/application/actions/destroy.html.erb +5 -0
  19. data/app/views/admin/application/actions/edit.html.erb +1 -0
  20. data/app/views/admin/application/actions/edit_sights.html.erb +1 -0
  21. data/app/views/admin/application/actions/feedback.html.erb +4 -0
  22. data/app/views/admin/application/actions/index_charge.html.erb +1 -0
  23. data/app/views/admin/application/actions/index_destroy.html.erb +1 -0
  24. data/app/views/admin/application/actions/index_edit.html.erb +1 -0
  25. data/app/views/admin/application/actions/index_edit_sights.html.erb +1 -0
  26. data/app/views/admin/application/actions/index_show.html.erb +1 -0
  27. data/app/views/admin/application/actions/new.html.erb +1 -0
  28. data/app/views/admin/application/create.js.erb +1 -0
  29. data/app/views/admin/application/destroy.js.erb +6 -0
  30. data/app/views/admin/application/edit.html.erb +18 -0
  31. data/app/views/admin/application/index.html.erb +23 -0
  32. data/app/views/admin/application/new.html.erb +18 -0
  33. data/app/views/admin/application/partials/_map_pos_picker.html.erb +101 -0
  34. data/app/views/admin/application/partials/_sort_script.html.erb +32 -0
  35. data/app/views/admin/application/show.html.erb +16 -0
  36. data/app/views/admin/application/update.js.erb +1 -0
  37. data/app/views/admin/dashboard/index.html.erb +8 -0
  38. data/app/views/layouts/admin.html.erb +30 -0
  39. data/config/locales/devise.en.yml +64 -0
  40. data/config/locales/devise.zh-CN.yml +120 -0
  41. data/config/locales/doorkeeper.en.yml +124 -0
  42. data/config/locales/doorkeeper.zh-CN.yml +132 -0
  43. data/config/locales/en.yml +23 -0
  44. data/config/locales/enumerize/defaults.zh-CN.yml +7 -0
  45. data/config/locales/kaminari.zh-CN.yml +17 -0
  46. data/config/locales/rails.zh-CN.yml +204 -0
  47. data/config/locales/views/actions.zh-CN.yml +21 -0
  48. data/config/locales/views/attributes.zh-CN.yml +15 -0
  49. data/config/locales/views/breadcrumb.zh-CN.yml +5 -0
  50. data/config/locales/views/common.zh-CN.yml +7 -0
  51. data/config/locales/views/enums.zh-CN.yml +13 -0
  52. data/config/locales/views/profiles.zh-CN.yml +3 -0
  53. data/lib/generators/sofav/USAGE +0 -0
  54. data/lib/generators/sofav/sofav_generator.rb +50 -0
  55. data/lib/generators/sofav/templates/activerecord.zh-CN.yml +4 -0
  56. data/lib/generators/sofav/templates/attribute_types.zh-CN.yml +2 -0
  57. data/lib/sofav.rb +6 -0
  58. data/lib/sofav/decorator.rb +47 -0
  59. data/lib/sofav/local.rb +52 -0
  60. data/lib/sofav/version.rb +3 -0
  61. data/lib/tasks/sofa_tasks.rake +4 -0
  62. data/vendor/assets/javascripts/admin/here.js +0 -0
  63. data/vendor/assets/javascripts/bootbox.js +1020 -0
  64. data/vendor/assets/javascripts/bootstrap.js +2377 -0
  65. data/vendor/assets/javascripts/jquery-ui.js +5169 -0
  66. data/vendor/assets/javascripts/select2.js +5725 -0
  67. data/vendor/assets/stylesheets/bootstrap.css +6800 -0
  68. data/vendor/assets/stylesheets/bootstrap.css.map +1 -0
  69. data/vendor/assets/stylesheets/jquery-ui.css +453 -0
  70. data/vendor/assets/stylesheets/select2.css +484 -0
  71. metadata +211 -0
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,7 @@
1
+ zh-CN:
2
+ enumerize:
3
+ defaults:
4
+ # 性别
5
+ gender:
6
+ M: 男
7
+ F: 女
@@ -0,0 +1,17 @@
1
+ zh-CN:
2
+ views:
3
+ pagination:
4
+ first: 第一页
5
+ previous: '&lt;'
6
+ truncate: ...
7
+ next: '&gt;'
8
+ last: 最后一页
9
+ helpers:
10
+ page_entries_info:
11
+ one_page:
12
+ display_entries:
13
+ zero: "暂时还没有内容喔"
14
+ one: "显示仅有的 <span class='text-primary'>1</span> 条记录"
15
+ other: "显示第 <span class='text-primary'>1&nbsp;-&nbsp;%{count}</span> 条, 共 <span class='text-primary'>%{count}</span> 条记录"
16
+ more_pages:
17
+ display_entries: "显示第 <span class='text-primary'>%{first}&nbsp;-&nbsp;%{last}</span> 条, 共 <span class='text-primary'>%{total}</span> 条记录"
@@ -0,0 +1,204 @@
1
+ ---
2
+ zh-CN:
3
+ date:
4
+ abbr_day_names:
5
+ - 周日
6
+ - 周一
7
+ - 周二
8
+ - 周三
9
+ - 周四
10
+ - 周五
11
+ - 周六
12
+ abbr_month_names:
13
+ -
14
+ - 1月
15
+ - 2月
16
+ - 3月
17
+ - 4月
18
+ - 5月
19
+ - 6月
20
+ - 7月
21
+ - 8月
22
+ - 9月
23
+ - 10月
24
+ - 11月
25
+ - 12月
26
+ day_names:
27
+ - 星期日
28
+ - 星期一
29
+ - 星期二
30
+ - 星期三
31
+ - 星期四
32
+ - 星期五
33
+ - 星期六
34
+ formats:
35
+ default: "%Y-%m-%d"
36
+ long: "%Y年%b%d日"
37
+ short: "%b%d日"
38
+ month_names:
39
+ -
40
+ - 一月
41
+ - 二月
42
+ - 三月
43
+ - 四月
44
+ - 五月
45
+ - 六月
46
+ - 七月
47
+ - 八月
48
+ - 九月
49
+ - 十月
50
+ - 十一月
51
+ - 十二月
52
+ order:
53
+ - :year
54
+ - :month
55
+ - :day
56
+ datetime:
57
+ distance_in_words:
58
+ about_x_hours:
59
+ one: 大约一小时
60
+ other: 大约%{count}小时
61
+ about_x_months:
62
+ one: 大约一个月
63
+ other: 大约%{count}个月
64
+ about_x_years:
65
+ one: 大约一年
66
+ other: 大约%{count}年
67
+ almost_x_years:
68
+ one: 接近一年
69
+ other: 接近%{count}年
70
+ half_a_minute: 半分钟
71
+ less_than_x_minutes:
72
+ one: 不到一分钟
73
+ other: 不到%{count}分钟
74
+ less_than_x_seconds:
75
+ one: 不到一秒
76
+ other: 不到%{count}秒
77
+ over_x_years:
78
+ one: 一年多
79
+ other: "%{count}年多"
80
+ x_days:
81
+ one: 一天
82
+ other: "%{count}天"
83
+ x_minutes:
84
+ one: 一分钟
85
+ other: "%{count}分钟"
86
+ x_months:
87
+ one: 一个月
88
+ other: "%{count}个月"
89
+ x_seconds:
90
+ one: 一秒
91
+ other: "%{count}秒"
92
+ prompts:
93
+ day: 日
94
+ hour: 时
95
+ minute: 分
96
+ month: 月
97
+ second: 秒
98
+ year: 年
99
+ errors:
100
+ format: "%{attribute}%{message}"
101
+ messages:
102
+ accepted: 必须是可被接受的
103
+ blank: 不能为空
104
+ present: 必须是空白
105
+ confirmation: 与确认值不匹配
106
+ empty: 不能留空
107
+ equal_to: 必须等于%{count}
108
+ even: 必须为双数
109
+ exclusion: 是保留关键字
110
+ greater_than: 必须大于%{count}
111
+ greater_than_or_equal_to: 必须大于或等于%{count}
112
+ inclusion: 不包含于列表中
113
+ invalid: 是无效的
114
+ less_than: 必须小于%{count}
115
+ less_than_or_equal_to: 必须小于或等于%{count}
116
+ not_a_number: 不是数字
117
+ not_an_integer: 必须是整数
118
+ odd: 必须为单数
119
+ record_invalid: '验证失败:%{errors}'
120
+ restrict_dependent_destroy:
121
+ one: 由于%{record}需要此记录,所以无法移除记录
122
+ many: 由于%{record}需要此记录,所以无法移除记录
123
+ taken: 已经被使用
124
+ too_long:
125
+ one: 过长(最长为一个字符)
126
+ other: 过长(最长为%{count}个字符)
127
+ too_short:
128
+ one: 过短(最短为一个字符)
129
+ other: 过短(最短为%{count}个字符)
130
+ wrong_length:
131
+ one: 长度非法(必须为一个字符)
132
+ other: 长度非法(必须为%{count}个字符)
133
+ other_than: 长度非法(不可为%{count}个字符
134
+ template:
135
+ body: 如下字段出现错误:
136
+ header:
137
+ one: 有 1 个错误发生导致「%{model}」无法被保存。
138
+ other: 有%{count}个错误发生导致「%{model}」无法被保存。
139
+ helpers:
140
+ select:
141
+ prompt: 请选择
142
+ submit:
143
+ create: 新增%{model}
144
+ submit: 储存%{model}
145
+ update: 更新%{model}
146
+ number:
147
+ currency:
148
+ format:
149
+ delimiter: ","
150
+ format: "%u%n"
151
+ precision: 2
152
+ separator: "."
153
+ significant: false
154
+ strip_insignificant_zeros: false
155
+ unit: CN¥
156
+ format:
157
+ delimiter: ","
158
+ precision: 3
159
+ separator: "."
160
+ significant: false
161
+ strip_insignificant_zeros: false
162
+ human:
163
+ decimal_units:
164
+ format: "%n%u"
165
+ units:
166
+ billion: 十亿
167
+ million: 百万
168
+ quadrillion: 千兆
169
+ thousand: 千
170
+ trillion: 兆
171
+ unit: ''
172
+ format:
173
+ delimiter: ''
174
+ precision: 1
175
+ significant: false
176
+ strip_insignificant_zeros: false
177
+ storage_units:
178
+ format: "%n%u"
179
+ units:
180
+ byte:
181
+ one: Byte
182
+ other: Bytes
183
+ gb: GB
184
+ kb: KB
185
+ mb: MB
186
+ tb: TB
187
+ percentage:
188
+ format:
189
+ delimiter: ''
190
+ precision:
191
+ format:
192
+ delimiter: ''
193
+ support:
194
+ array:
195
+ last_word_connector: ", 和 "
196
+ two_words_connector: " 和 "
197
+ words_connector: ", "
198
+ time:
199
+ am: 上午
200
+ formats:
201
+ default: "%Y年%b%d日%A%H:%M:%S%Z"
202
+ long: "%Y年%b%d日 %H:%M"
203
+ short: "%b%d日%H:%M"
204
+ pm: 下午
@@ -0,0 +1,21 @@
1
+ zh-CN:
2
+ actions:
3
+ index: 列表
4
+ show: 查看详情
5
+ new: 添加
6
+ create: 创建
7
+ edit: 编辑
8
+ reset_password: 重置密码
9
+ recharge: 充值
10
+ update: 更新
11
+ disable: 禁用
12
+ enable: 启用
13
+ delete: 删除
14
+ destroy: 删除
15
+ submit: 提交
16
+ search: 搜索
17
+ reset: 清空条件
18
+ back: 返回
19
+ back_to_list: 返回列表
20
+ feedback: 添加评论
21
+ edit_sights: 编辑景点
@@ -0,0 +1,15 @@
1
+ zh-CN:
2
+ attributes:
3
+ id: ID
4
+ name: 姓名
5
+ email: 邮箱
6
+ mobile: 手机号
7
+ password: 密码
8
+ weixin: 微信号码
9
+ qq: QQ号码
10
+ created_at: 添加时间
11
+ updated_at: 更新时间
12
+ status: 状态
13
+ result: 状态
14
+ disabled: 状态
15
+ actions: 操作
@@ -0,0 +1,5 @@
1
+ zh-CN:
2
+ breadcrumb:
3
+ admin/users: 用户系统
4
+ admin/tour_groups: 旅游团报备
5
+ admin/contacts: 执法部门
@@ -0,0 +1,7 @@
1
+ zh-CN:
2
+ action: 操作
3
+ successful: 成功
4
+ failed: 失败
5
+ completed: 完成
6
+ confirm: 确定要继续%{action}吗?
7
+ no_data: 暂时还没有数据,马上添加吧!
@@ -0,0 +1,13 @@
1
+ zh-CN:
2
+ disabled:
3
+ true_html: <span class="label label-warning">禁用</span>
4
+ false_html: <span class="label label-success">可用</span>
5
+ excellent:
6
+ true_html: <span class="label label-danger">置顶</span>
7
+ false_html: <span class="label label-success">未置顶</span>
8
+ canbeignore:
9
+ true_html: <span class="label label-danger">是</span>
10
+ false_html: <span class="label label-success">否</span>
11
+ reviewed:
12
+ true_html: <span class="label label-success">是</span>
13
+ false_html: <span class="label label-danger">否</span>
@@ -0,0 +1,3 @@
1
+ zh-CN:
2
+ profiles:
3
+ base_info: 基本信息
File without changes
@@ -0,0 +1,50 @@
1
+ require 'rails/generators/named_base'
2
+ require 'rails/generators/active_record'
3
+ require 'sofav/local'
4
+ require 'sofav/decorator'
5
+
6
+ module Sofav
7
+ module Generators
8
+ class SofavGenerator < Rails::Generators::NamedBase
9
+ source_root File.expand_path('../templates', __FILE__)
10
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
11
+ include Sofav::Local
12
+ include Sofav::Decorator
13
+
14
+ def create_model
15
+ @agruments = "#{file_name}"
16
+
17
+ attributes.each do |a|
18
+ @agruments += " #{a.name}:#{a.type}"
19
+ end
20
+
21
+ generate "model", @agruments
22
+ end
23
+
24
+ def create_controller
25
+ generate "controller", "Admin::#{file_name} --skip-routes"
26
+ end
27
+
28
+ def create_kaminari
29
+ generate "kaminari:views", "default --views-prefix admin"
30
+ end
31
+
32
+ def create_locales_activerecord
33
+ @record = Array.new
34
+ attributes.each do |a|
35
+ @record << a.name
36
+ end
37
+
38
+ create_config_record(file_name, @record)
39
+ end
40
+
41
+ def create_locales_attribute_types
42
+ create_config_attribute(file_name, attributes)
43
+ end
44
+
45
+ def create_model_decorator
46
+ create_decorator(file_name, class_name, attributes)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,4 @@
1
+ zh-CN:
2
+ activerecord:
3
+ models:
4
+ attributes:
@@ -0,0 +1,2 @@
1
+ zh-CN:
2
+ attribute_types:
data/lib/sofav.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'rails'
2
+
3
+ module Sofav
4
+ autoload :Local, 'sofav/local'
5
+ autoload :Decorator, 'sofav/decorator'
6
+ end
@@ -0,0 +1,47 @@
1
+ module Sofav
2
+ module Decorator
3
+ def create_decorator(file_name, class_name, attributes)
4
+ @attr = ''
5
+
6
+ attributes.each do |a|
7
+ @attr += "#{a.name} "
8
+ end
9
+
10
+ create_file "app/decorator/#{file_name}_decorator.rb", <<-FILE
11
+ class #{class_name}Decorator < BaseDecorator
12
+ include EnumerizeConcern
13
+
14
+ collection_search do
15
+ {name: "q", search_in: [], placeholder: '', action: '/admin/#{class_name}', fuzzy: true}
16
+ end
17
+
18
+ collection_attributes do
19
+ ["#", ]
20
+ end
21
+
22
+ permitted_class_methods do
23
+ {index: ["new"]}
24
+ end
25
+
26
+ permitted_instance_methods do
27
+ {index: ["show", "edit", "destroy"], show: ["edit"]}
28
+ end
29
+
30
+ form_attributes do
31
+ {
32
+ profiles: %w{base_info},
33
+ base_info: %w{#{@attr}}
34
+ }
35
+ end
36
+
37
+ show_page_attributes do
38
+ {
39
+ profiles: %w{base_info},
40
+ base_info: %w{#{@attr}}
41
+ }
42
+ end
43
+ end
44
+ FILE
45
+ end
46
+ end
47
+ end