tida_template 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +38 -0
- data/lib/generators/tida_template/install_generator.rb +60 -0
- data/lib/generators/tida_template/templates/app/views/devise/sessions/new.html.erb +19 -0
- data/lib/generators/tida_template/templates/app/views/layouts/application.html.erb +49 -0
- data/lib/generators/tida_template/templates/app/views/layouts/single.html.erb +27 -0
- data/lib/generators/tida_template/templates/app/views/shared/components/_article_title.html.erb +10 -0
- data/lib/generators/tida_template/templates/app/views/shared/components/_date_jumper.html.erb +20 -0
- data/lib/generators/tida_template/templates/app/views/shared/components/_modal.html.erb +7 -0
- data/lib/generators/tida_template/templates/app/views/shared/components/_notification.html.erb +12 -0
- data/lib/generators/tida_template/templates/app/views/shared/components/_page_menu.html.erb +29 -0
- data/lib/generators/tida_template/templates/app/views/shared/components/_page_title.html.erb +10 -0
- data/lib/generators/tida_template/templates/app/views/shared/components/_toolbar.html.erb +5 -0
- data/lib/generators/tida_template/templates/config/application.yml +13 -0
- data/lib/generators/tida_template/templates/config/initializers/navigation_renderers.rb +2 -0
- data/lib/generators/tida_template/templates/config/initializers/quiet_assets.rb +13 -0
- data/lib/generators/tida_template/templates/config/locales/devise.zh-CN.yml +65 -0
- data/lib/generators/tida_template/templates/config/locales/simple_form.zh-CN.yml +27 -0
- data/lib/generators/tida_template/templates/config/locales/zh-CN.yml +150 -0
- data/lib/generators/tida_template/templates/paperclip/attachment_access_token.rb +24 -0
- data/lib/generators/tida_template/templates/rails_templates/erb/scaffold/_form.html.erb +16 -0
- data/lib/generators/tida_template/templates/rails_templates/erb/scaffold/edit.html.erb +8 -0
- data/lib/generators/tida_template/templates/rails_templates/erb/scaffold/index.html.erb +23 -0
- data/lib/generators/tida_template/templates/rails_templates/erb/scaffold/new.html.erb +8 -0
- data/lib/generators/tida_template/templates/rails_templates/erb/scaffold/show.html.erb +35 -0
- data/lib/generators/tida_template/templates/rails_templates/rails/scaffold_controller/controller.rb +89 -0
- data/lib/generators/tida_template/templates/renderers/sub_navigation_bar_renderer.rb +72 -0
- data/lib/generators/tida_template/templates/renderers/top_navigation_bar_renderer.rb +37 -0
- data/lib/generators/tida_template/templates/settingslogic/settings.rb +5 -0
- data/lib/tasks/tida_template_tasks.rake +4 -0
- data/lib/tida_template.rb +4 -0
- data/lib/tida_template/engine.rb +7 -0
- data/lib/tida_template/version.rb +3 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/test_helper.rb +15 -0
- data/test/tida_template_test.rb +7 -0
- metadata +401 -0
@@ -0,0 +1,150 @@
|
|
1
|
+
zh-CN:
|
2
|
+
retrieve: 撷取%{model}
|
3
|
+
retrieve:
|
4
|
+
data: 撷取数据
|
5
|
+
re-retrieve: 完全撷取%{model}
|
6
|
+
import: 导入%{model}
|
7
|
+
import_urls: 导入URLs
|
8
|
+
build:
|
9
|
+
report: 生成报告
|
10
|
+
model:
|
11
|
+
show: "%{model}详细信息"
|
12
|
+
create: "创建%{model}"
|
13
|
+
add: "添加%{model}"
|
14
|
+
list: "%{model}列表"
|
15
|
+
edit: "编辑%{model}"
|
16
|
+
delete: "删除%{model}"
|
17
|
+
generate: "生成%{model}"
|
18
|
+
import: "导入%{model}"
|
19
|
+
batch_import: "批量导入%{model}"
|
20
|
+
export: "导出%{model}"
|
21
|
+
remove: "移除%{model}"
|
22
|
+
upload: "上传%{model}"
|
23
|
+
labels:
|
24
|
+
welcome: '欢迎'
|
25
|
+
duration: "时间区段"
|
26
|
+
loading: "正在载入..."
|
27
|
+
kpi: "KPI"
|
28
|
+
untitled: "未命名"
|
29
|
+
detail:
|
30
|
+
day_kpi_plan: "细化每日KPI要求"
|
31
|
+
grab:
|
32
|
+
weibo_user: "刷新"
|
33
|
+
kols: "刷新所有KOL资料"
|
34
|
+
back_to: "返回"
|
35
|
+
official:
|
36
|
+
weibo_users: "微博活动账号"
|
37
|
+
add: "添加微博活动账号"
|
38
|
+
list: "微博活动账号列表"
|
39
|
+
capture:
|
40
|
+
weibo_posts: "官方微博截图"
|
41
|
+
weibo_posts_file_name: "官方微博截图%{seq}"
|
42
|
+
kol10w_reposts: "10万级KOL转发截图"
|
43
|
+
kol10w_reposts_file_name: "官方微博-%{post_seq}-KOL%{kol_seq}"
|
44
|
+
kol30w_reposts: "30万级KOL转发截图"
|
45
|
+
snapshots: "创建网页截图"
|
46
|
+
renew:
|
47
|
+
cookies: "更新Cookies"
|
48
|
+
change:
|
49
|
+
kol:
|
50
|
+
vendor: "归属供应商"
|
51
|
+
buttons:
|
52
|
+
ok: "确定"
|
53
|
+
renew: '刷新'
|
54
|
+
edit: '编辑'
|
55
|
+
delete: '删除'
|
56
|
+
reset_form: "重置表单"
|
57
|
+
remove: "移除"
|
58
|
+
sign_in: "登录"
|
59
|
+
sign_up: "注册"
|
60
|
+
sign_out: 注销
|
61
|
+
choose: "选择"
|
62
|
+
forgot_password: "忘记密码了?"
|
63
|
+
send: '发送'
|
64
|
+
add_plan: "添加项目内容"
|
65
|
+
capture: "截图"
|
66
|
+
check:
|
67
|
+
effect: "更新效果进度"
|
68
|
+
repost:
|
69
|
+
effect: "转发计划"
|
70
|
+
comment:
|
71
|
+
effect: "评论计划"
|
72
|
+
upload:
|
73
|
+
effects: "上传预编辑效果数据"
|
74
|
+
import:
|
75
|
+
weibo_post: "导入"
|
76
|
+
url: "导入URL"
|
77
|
+
redirect:
|
78
|
+
weibo_post_url: "原微博"
|
79
|
+
weibo_post:
|
80
|
+
effects: "效果列表"
|
81
|
+
create: 创建
|
82
|
+
publish_article: 发布文章
|
83
|
+
batch_capture: 批量截图
|
84
|
+
miscs:
|
85
|
+
or: "或者"
|
86
|
+
confirms:
|
87
|
+
delete: '你确定要删除这个项目吗?'
|
88
|
+
remove:
|
89
|
+
kol: "你确定要移除这个KOL吗?"
|
90
|
+
alerts:
|
91
|
+
weibo_user:
|
92
|
+
url_incorrect: "没有在给定的URL中找到合适的UID"
|
93
|
+
url_import_failed: "URL导入失败"
|
94
|
+
vendor_types:
|
95
|
+
kol: "KOL"
|
96
|
+
provinces:
|
97
|
+
beijing: 北京
|
98
|
+
tianjin: 天津
|
99
|
+
shanghai: 上海
|
100
|
+
chongqing: 重庆
|
101
|
+
hongkong: 香港
|
102
|
+
macau: 澳门
|
103
|
+
hebei: 河北
|
104
|
+
shanxi: 山西
|
105
|
+
neimenggu: 内蒙古
|
106
|
+
liaoning: 辽宁
|
107
|
+
jilin: 吉林
|
108
|
+
helongjiang: 黑龙江
|
109
|
+
jiangsu: 江苏
|
110
|
+
zhejiang: 浙江
|
111
|
+
anhui: 安徽
|
112
|
+
fujian: 福建
|
113
|
+
jiangxi: 江西
|
114
|
+
shandong: 山东
|
115
|
+
henan: 河南
|
116
|
+
hubei: 湖北
|
117
|
+
hunan: 湖南
|
118
|
+
guangdong: 广东
|
119
|
+
guangxi: 广西
|
120
|
+
hainan: 海南
|
121
|
+
sichuan: 四川
|
122
|
+
guizhou: 贵州
|
123
|
+
yunnan: 云南
|
124
|
+
xizang: 西藏
|
125
|
+
shaanxi: 陕西
|
126
|
+
gansu: 甘肃
|
127
|
+
qinghai: 青海
|
128
|
+
ningxia: 宁夏
|
129
|
+
xinjiang: 新疆
|
130
|
+
taiwan: 台湾
|
131
|
+
regions:
|
132
|
+
all: 全国
|
133
|
+
north: 北区
|
134
|
+
south: 南区
|
135
|
+
east: 东区
|
136
|
+
west: 西区
|
137
|
+
center: 中区
|
138
|
+
media_positions:
|
139
|
+
home: 首页
|
140
|
+
section_home: 版块首页
|
141
|
+
others: 其他版面
|
142
|
+
media_ad_styles:
|
143
|
+
important_focus_pic: 要闻区焦点图
|
144
|
+
important_text_link: 要闻区文字链
|
145
|
+
other_text_link: 文字链
|
146
|
+
media_levels:
|
147
|
+
top: 重点媒体
|
148
|
+
national: 全国媒体
|
149
|
+
region_important: 地区重要媒体
|
150
|
+
others: 其他媒体
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Tida
|
2
|
+
module Paperclip
|
3
|
+
module AttachmentAccessToken
|
4
|
+
private
|
5
|
+
# simple random salt
|
6
|
+
def random_salt(len = 20)
|
7
|
+
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
|
8
|
+
salt = ""
|
9
|
+
1.upto(len) { |i| salt << chars[rand(chars.size-1)] }
|
10
|
+
return salt
|
11
|
+
end
|
12
|
+
|
13
|
+
# SHA1 from random salt and time
|
14
|
+
def generate_access_token
|
15
|
+
self.attachment_access_token = Digest::SHA1.hexdigest("#{random_salt}#{Time.now.to_i}")
|
16
|
+
end
|
17
|
+
|
18
|
+
# interpolate in paperclip
|
19
|
+
Paperclip.interpolates :attachment_access_token do |attachment, style|
|
20
|
+
attachment.instance.attachment_access_token
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
<%%= simple_form_for(<% if class_name.split('::').count > 1 %> ['<%= class_name.split('::').first.underscore.downcase %>', @<%= class_name.split('::').last.underscore.downcase %>]<% else %>@<%= class_name.split('::').last.underscore.downcase %> <% end %>, :html => {:class => 'form-horizontal' }) do |f| %>
|
3
|
+
<%%= f.error_notification %>
|
4
|
+
|
5
|
+
<div class="form-inputs">
|
6
|
+
<% for attribute in class_name.split('::').last.constantize.columns -%>
|
7
|
+
<% if attribute.name != "id" && attribute.name !="created_at" && attribute.name !="updated_at" %>
|
8
|
+
<%%= f.input :<%= attribute.name %> %>
|
9
|
+
<% end -%>
|
10
|
+
<% end -%>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="form-actions">
|
14
|
+
<%%= f.button :submit, class: 'button button-primary' %>
|
15
|
+
</div>
|
16
|
+
<%% end %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%%= render_page_title "#{t('model.edit', model: <%= class_name.split('::').last %>.model_name.human)} <small>#{t('simple_form.required.text') }</small>" do |toolbar|
|
2
|
+
toolbar << {
|
3
|
+
name: "#{t('labels.back_to')}#{t('model.list', :model => <%= class_name.split('::').last %>.model_name.human)}",
|
4
|
+
url: <%= class_name.split('::').last.underscore.downcase.pluralize %>_path,
|
5
|
+
options: {class: 'button'}
|
6
|
+
}
|
7
|
+
end %>
|
8
|
+
<%%= render 'form' %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%%= render_page_title "#{t('model.list', model: <%= class_name.split('::').last %>.model_name.human)}" do |toolbar|
|
2
|
+
toolbar << {
|
3
|
+
name: render_icon_and_text_content('icon-plus-sign', t('model.create', :model => <%= class_name.split('::').last %>.model_name.human)),
|
4
|
+
url: new_<%= class_name.split('::').last.underscore.downcase %>_path,
|
5
|
+
options: {class: 'button button-primary'}
|
6
|
+
}
|
7
|
+
end %>
|
8
|
+
|
9
|
+
<%%= grid(@<%= class_name.split('::').last.underscore.downcase.pluralize %>_grid, :show_filters => :always) do |g|
|
10
|
+
<% attributes.each do |attribute| -%>
|
11
|
+
g.column :name => t('activerecord.attributes.<%= class_name.split('::').last.underscore.downcase %>.<%= attribute.name %>'), :html => {:class => "grid-cell"} do |<%= class_name.split('::').last.underscore.downcase %>|
|
12
|
+
<%= class_name.split('::').last.underscore.downcase %>.<%= attribute.name %>
|
13
|
+
end
|
14
|
+
<% end -%>
|
15
|
+
|
16
|
+
g.column :html => {class: 'buttons'} do |<%= class_name.split('::').last.underscore.downcase %>|
|
17
|
+
link_to(render_icon_content('icon-edit'), edit_<%= singular_table_name %>_path(<%= class_name.split('::').last.underscore.downcase %>), :class => 'button', :rel => 'tooltip', :title => t('buttons.edit'))
|
18
|
+
end
|
19
|
+
|
20
|
+
g.column :html => {class: 'buttons'} do |<%= class_name.split('::').last.underscore.downcase %>|
|
21
|
+
link_to(render_icon_content('icon-trash'), <%= singular_table_name %>_path(<%= class_name.split('::').last.underscore.downcase %>), :method => :delete, :confirm => t("confirms.delete"), :class => 'button', :rel => 'tooltip', :title => t('buttons.delete'))
|
22
|
+
end
|
23
|
+
end -%>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%%= render_page_title "#{t('model.create', model: <%= class_name.split('::').last %>.model_name.human)} <small>#{t('simple_form.required.text') }</small>" do |toolbar|
|
2
|
+
toolbar << {
|
3
|
+
name: "#{t('labels.back_to')}#{t('model.list', :model => <%= class_name.split('::').last %>.model_name.human)}",
|
4
|
+
url: <%= class_name.split('::').last.underscore.downcase.pluralize %>_path,
|
5
|
+
options: {class: 'button'}
|
6
|
+
}
|
7
|
+
end %>
|
8
|
+
<%%= render 'form' %>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<%%= render_page_title "#{@<%= class_name.split('::').last.underscore.downcase %>.name}" do |toolbar|
|
2
|
+
toolbar << {
|
3
|
+
name: "#{t('labels.back_to')}#{t('model.list', :model => <%= class_name.split('::').last %>.model_name.human)}",
|
4
|
+
url: <%= class_name.split('::').last.underscore.downcase.pluralize %>_path,
|
5
|
+
options: {class: 'button'}
|
6
|
+
}
|
7
|
+
end %>
|
8
|
+
|
9
|
+
<table class="table table-striped table-bordered">
|
10
|
+
<thead>
|
11
|
+
<tr>
|
12
|
+
<th>
|
13
|
+
属性
|
14
|
+
</th>
|
15
|
+
<th>
|
16
|
+
值
|
17
|
+
</th>
|
18
|
+
</tr>
|
19
|
+
</thead>
|
20
|
+
<tbody>
|
21
|
+
<% attributes.each do |attribute| -%>
|
22
|
+
<tr>
|
23
|
+
<td>
|
24
|
+
<%%= t('activerecord.attributes.<%= class_name.split('::').last.underscore.downcase %>.<%= attribute.name %>') %>
|
25
|
+
</td>
|
26
|
+
<td>
|
27
|
+
<%%= <%= class_name.split('::').last.underscore.downcase %>.<%= attribute.name %> %>
|
28
|
+
</td>
|
29
|
+
</tr>
|
30
|
+
<% end -%>
|
31
|
+
</tbody>
|
32
|
+
<tfoot>
|
33
|
+
|
34
|
+
</tfoot>
|
35
|
+
</table>
|
data/lib/generators/tida_template/templates/rails_templates/rails/scaffold_controller/controller.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
<% if namespaced? -%>
|
2
|
+
require_dependency "<%= namespaced_file_path %>/application_controller"
|
3
|
+
|
4
|
+
<% end -%>
|
5
|
+
<% module_namespacing do -%>
|
6
|
+
class <%= controller_class_name %>Controller < ApplicationController
|
7
|
+
# GET <%= route_url %>
|
8
|
+
# GET <%= route_url %>.json
|
9
|
+
def index
|
10
|
+
@<%= class_name.split('::').last.underscore.downcase.pluralize %>_grid = initialize_grid(<%= class_name.split('::').last %>)
|
11
|
+
|
12
|
+
respond_to do |format|
|
13
|
+
format.html # index.html.erb
|
14
|
+
format.json { render json: <%= "@#{class_name.split('::').last.underscore.downcase.pluralize}_grid" %> }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# GET <%= route_url %>/1
|
19
|
+
# GET <%= route_url %>/1.json
|
20
|
+
def show
|
21
|
+
@<%= class_name.split('::').last.underscore.downcase %> = <%= orm_class.find(class_name.split('::').last, "params[:id]") %>
|
22
|
+
|
23
|
+
respond_to do |format|
|
24
|
+
format.html # show.html.erb
|
25
|
+
format.json { render json: <%= "@#{class_name.split('::').last.underscore.downcase}" %> }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# GET <%= route_url %>/new
|
30
|
+
# GET <%= route_url %>/new.json
|
31
|
+
def new
|
32
|
+
@<%= class_name.split('::').last.underscore.downcase %> = <%= orm_class.build(class_name.split('::').last) %>
|
33
|
+
|
34
|
+
respond_to do |format|
|
35
|
+
format.html # new.html.erb
|
36
|
+
format.json { render json: <%= "@#{class_name.split('::').last.underscore.downcase}" %> }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# GET <%= route_url %>/1/edit
|
41
|
+
def edit
|
42
|
+
@<%= class_name.split('::').last.underscore.downcase %> = <%= orm_class.find(class_name.split('::').last, "params[:id]") %>
|
43
|
+
end
|
44
|
+
|
45
|
+
# POST <%= route_url %>
|
46
|
+
# POST <%= route_url %>.json
|
47
|
+
def create
|
48
|
+
@<%= class_name.split('::').last.underscore.downcase %> = <%= orm_class.build(class_name.split('::').last, "params[:#{class_name.split('::').last.underscore.downcase}]") %>
|
49
|
+
|
50
|
+
respond_to do |format|
|
51
|
+
if @<%= class_name.split('::').last.underscore.downcase %>.save
|
52
|
+
format.html { redirect_to <%= singular_table_name %>_path(@<%= class_name.split('::').last.underscore.downcase %>), notice: <%= "'#{human_name} was successfully created.'" %> }
|
53
|
+
format.json { render json: <%= "@#{class_name.split('::').last.underscore.downcase}" %>, status: :created, location: <%= "@#{class_name.split('::').last.underscore.downcase}" %> }
|
54
|
+
else
|
55
|
+
format.html { render action: "new" }
|
56
|
+
format.json { render json: <%= "@#{class_name.split('::').last.underscore.downcase}.errors" %>, status: :unprocessable_entity }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# PATCH/PUT <%= route_url %>/1
|
62
|
+
# PATCH/PUT <%= route_url %>/1.json
|
63
|
+
def update
|
64
|
+
@<%= class_name.split('::').last.underscore.downcase %> = <%= orm_class.find(class_name.split('::').last, "params[:id]") %>
|
65
|
+
|
66
|
+
respond_to do |format|
|
67
|
+
if @<%= class_name.split('::').last.underscore.downcase %>.update_attributes(params[:<%= class_name.split('::').last.underscore.downcase %>])
|
68
|
+
format.html { redirect_to <%= singular_table_name %>_path(@<%= class_name.split('::').last.underscore.downcase %>), notice: <%= "'#{human_name} was successfully updated.'" %> }
|
69
|
+
format.json { head :no_content }
|
70
|
+
else
|
71
|
+
format.html { render action: "edit" }
|
72
|
+
format.json { render json: <%= "@#{class_name.split('::').last.underscore.downcase}.errors" %>, status: :unprocessable_entity }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# DELETE <%= route_url %>/1
|
78
|
+
# DELETE <%= route_url %>/1.json
|
79
|
+
def destroy
|
80
|
+
@<%= class_name.split('::').last.underscore.downcase %> = <%= orm_class.find(class_name.split('::').last, "params[:id]") %>
|
81
|
+
@<%= class_name.split('::').last.underscore.downcase %>.destroy
|
82
|
+
|
83
|
+
respond_to do |format|
|
84
|
+
format.html { redirect_to <%= index_helper %>_url }
|
85
|
+
format.json { head :no_content }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
<% end -%>
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Tida
|
2
|
+
module Renderers
|
3
|
+
class SubNavigationBarRenderer < ::SimpleNavigation::Renderer::Base
|
4
|
+
def render(item_container)
|
5
|
+
# header_content = content_tag :div, content_tag(:h3, item_container.selected_item ? item_container.selected_item.name : item_container.items.first.name), class: 'header'
|
6
|
+
list_content = []
|
7
|
+
if item_container.selected_item && include_sub_navigation?(item_container.selected_item)
|
8
|
+
list_content = item_container.selected_item.sub_navigation.items.inject([]) do |list, item|
|
9
|
+
Rails.logger.debug include_sub_navigation?(item)
|
10
|
+
content = []
|
11
|
+
content << tag_for_level_1(item)
|
12
|
+
content << tag_for_level_2(item) if include_sub_navigation?(item)
|
13
|
+
list << content_tag(:li, content_tag(:div, content.join, {class: 'accordion-group'}))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
menu_content = content_tag(:ul, list_content.join, {class: 'accordion'})
|
17
|
+
div_content = []
|
18
|
+
# div_content << header_content
|
19
|
+
# div_content << menu_content
|
20
|
+
content_tag(:div, menu_content, {id: 'sub-navigation-bar'})
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def tag_for_level_1(item)
|
26
|
+
item_content = nil
|
27
|
+
options = options_for(item)
|
28
|
+
icon = options.delete(:icon)
|
29
|
+
if suppress_link?(item)
|
30
|
+
content = []
|
31
|
+
content << content_tag(:i, nil, class: icon) if icon
|
32
|
+
content << content_tag(:span, item.name)
|
33
|
+
content << content_tag(:b, nil, class: 'caret')
|
34
|
+
if options[:class] && options[:class].include?('active')
|
35
|
+
options[:class] = [options[:class], 'accordion-toggle in'].flatten.compact.join(' ')
|
36
|
+
else
|
37
|
+
options[:class] = [options[:class], 'accordion-toggle collapsed'].flatten.compact.join(' ')
|
38
|
+
end
|
39
|
+
options = options.merge('data-toggle' => "collapse", 'data-parent' => "#page-menu")
|
40
|
+
item_content = link_to(content.join(' '), "#collapse_#{item.key}", options)
|
41
|
+
else
|
42
|
+
options[:class] = [options[:class], 'accordion-toggle'].flatten.compact.join(' ')
|
43
|
+
content = []
|
44
|
+
content << content_tag(:i, nil, class: icon) if icon
|
45
|
+
content << content_tag(:span, item.name)
|
46
|
+
item_content = link_to(content.join(' '), item.url, options)
|
47
|
+
end
|
48
|
+
li_content = content_tag :div, item_content, class: 'accordion-heading'
|
49
|
+
end
|
50
|
+
|
51
|
+
def tag_for_level_2(item)
|
52
|
+
Rails.logger.debug "sub_navigation"
|
53
|
+
sub_list_content = item.sub_navigation.items.inject([]) do |list, sub_item|
|
54
|
+
options = link_options_for(sub_item)
|
55
|
+
icon = options.delete(:icon)
|
56
|
+
content = []
|
57
|
+
content << content_tag(:i, nil, class: icon) if icon
|
58
|
+
content << content_tag(:span, sub_item.name)
|
59
|
+
li_content = link_to(content.join(' '), sub_item.url, options)
|
60
|
+
list << content_tag(:li, li_content)
|
61
|
+
end.join
|
62
|
+
sub_list = content_tag(:ul, sub_list_content)
|
63
|
+
inner_container = content_tag(:div, sub_list, class: 'accordion-inner')
|
64
|
+
if item.selected?
|
65
|
+
content_tag(:div, inner_container, {:class => 'accordion-body in collapse active', 'id' => "collapse_#{item.key}"})
|
66
|
+
else
|
67
|
+
content_tag(:div, inner_container, {:class => 'accordion-body collapse', 'id' => "collapse_#{item.key}"})
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Tida
|
2
|
+
module Renderers
|
3
|
+
class TopNavigationBarRenderer < ::SimpleNavigation::Renderer::Base
|
4
|
+
def render(item_container)
|
5
|
+
ul_content = item_container.items.inject([]) do |list, item|
|
6
|
+
list << item_content(item)
|
7
|
+
end.join
|
8
|
+
div_content = content_tag :ul, ul_content
|
9
|
+
content_tag(:div, div_content, {id: "top-navigation-bar"})
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def item_content(item)
|
15
|
+
content_tag :li, tag_for(item)
|
16
|
+
end
|
17
|
+
|
18
|
+
def tag_for(item)
|
19
|
+
options = options_for(item)
|
20
|
+
icon = options.delete(:icon)
|
21
|
+
stack_icon = options.delete(:stack_icon)
|
22
|
+
content = []
|
23
|
+
if stack_icon
|
24
|
+
stack_content = []
|
25
|
+
stack_content << content_tag(:i, nil, class: "icon-stack-base #{stack_icon[:base]}")
|
26
|
+
stack_content << content_tag(:i, nil, class: stack_icon[:icon])
|
27
|
+
stack = content_tag(:span, stack_content.join(), class: 'icon-stack')
|
28
|
+
content << stack
|
29
|
+
else
|
30
|
+
content << content_tag(:i, nil, class: "#{icon} icon-2x")
|
31
|
+
end
|
32
|
+
content << content_tag(:span, item.name)
|
33
|
+
link_to content.join('<br>'), item.url, options
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|