blacksand 2.2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +27 -0
  4. data/app/assets/javascripts/blacksand/dashboard/navigations.form.js.erb +34 -0
  5. data/app/assets/javascripts/blacksand/dashboard/navigations.index.js +18 -0
  6. data/app/assets/javascripts/blacksand/dashboard/pages.form.js.erb +69 -0
  7. data/app/assets/javascripts/blacksand/dashboard/pages.index.js +17 -0
  8. data/app/assets/javascripts/blacksand/dashboard.js +14 -0
  9. data/app/assets/javascripts/blacksand/ie.js +2 -0
  10. data/app/assets/javascripts/bootstrap-datepicker.zh-CN.js +20 -0
  11. data/app/assets/stylesheets/blacksand/dashboard.scss +26 -0
  12. data/app/controllers/blacksand/dashboard/base_controller.rb +35 -0
  13. data/app/controllers/blacksand/dashboard/navigations_controller.rb +88 -0
  14. data/app/controllers/blacksand/dashboard/pages_controller.rb +176 -0
  15. data/app/controllers/blacksand/dashboard/prototypes_controller.rb +12 -0
  16. data/app/controllers/blacksand/dashboard/templates_controller.rb +8 -0
  17. data/app/controllers/blacksand/dashboard/users_controller.rb +78 -0
  18. data/app/controllers/blacksand_front/pages_controller.rb +17 -0
  19. data/app/helpers/blacksand/application_helper.rb +42 -0
  20. data/app/helpers/blacksand/page_helper.rb +11 -0
  21. data/app/helpers/blacksand_front/pages_helper.rb +20 -0
  22. data/app/models/blacksand/field.rb +35 -0
  23. data/app/models/blacksand/navigation.rb +24 -0
  24. data/app/models/blacksand/page.rb +194 -0
  25. data/app/models/blacksand/picture.rb +7 -0
  26. data/app/models/blacksand/property/as_array.rb +5 -0
  27. data/app/models/blacksand/property/file.rb +5 -0
  28. data/app/models/blacksand/property/gallery.rb +7 -0
  29. data/app/models/blacksand/property/slide.rb +5 -0
  30. data/app/models/blacksand/property.rb +76 -0
  31. data/app/models/blacksand/prototype.rb +11 -0
  32. data/app/models/blacksand/template.rb +9 -0
  33. data/app/models/kindeditor/asset.rb +14 -0
  34. data/app/models/kindeditor/file.rb +3 -0
  35. data/app/models/kindeditor/flash.rb +3 -0
  36. data/app/models/kindeditor/image.rb +3 -0
  37. data/app/models/kindeditor/media.rb +3 -0
  38. data/app/uploaders/blacksand/base_uploader.rb +16 -0
  39. data/app/uploaders/blacksand/file_uploader.rb +4 -0
  40. data/app/uploaders/blacksand/image_uploader.rb +78 -0
  41. data/app/uploaders/blacksand/slide_image_uploader.rb +66 -0
  42. data/app/views/blacksand/dashboard/navigations/_form.html.erb +23 -0
  43. data/app/views/blacksand/dashboard/navigations/edit.html.erb +3 -0
  44. data/app/views/blacksand/dashboard/navigations/index.html.erb +40 -0
  45. data/app/views/blacksand/dashboard/navigations/index.json.jbuilder +4 -0
  46. data/app/views/blacksand/dashboard/navigations/new.html.erb +3 -0
  47. data/app/views/blacksand/dashboard/navigations/reorder.js.erb +1 -0
  48. data/app/views/blacksand/dashboard/navigations/show.html.erb +4 -0
  49. data/app/views/blacksand/dashboard/navigations/show.json.jbuilder +1 -0
  50. data/app/views/blacksand/dashboard/pages/_fields.html.erb +89 -0
  51. data/app/views/blacksand/dashboard/pages/_form.html.erb +26 -0
  52. data/app/views/blacksand/dashboard/pages/_manage_list.html.erb +123 -0
  53. data/app/views/blacksand/dashboard/pages/_picture_fields.html.erb +18 -0
  54. data/app/views/blacksand/dashboard/pages/children_partial.js.erb +14 -0
  55. data/app/views/blacksand/dashboard/pages/edit.html.erb +20 -0
  56. data/app/views/blacksand/dashboard/pages/index.html.erb +27 -0
  57. data/app/views/blacksand/dashboard/pages/new.html.erb +20 -0
  58. data/app/views/blacksand/dashboard/pages/onchange_render.js.erb +14 -0
  59. data/app/views/blacksand/dashboard/pages/search.json.jbuilder +7 -0
  60. data/app/views/blacksand/dashboard/pages/show.html.erb +34 -0
  61. data/app/views/blacksand/dashboard/prototypes/index.html.erb +15 -0
  62. data/app/views/blacksand/dashboard/prototypes/show.html.erb +31 -0
  63. data/app/views/blacksand/dashboard/templates/index.html.erb +17 -0
  64. data/app/views/blacksand/dashboard/users/_form.html.erb +40 -0
  65. data/app/views/blacksand/dashboard/users/edit.html.erb +47 -0
  66. data/app/views/blacksand/dashboard/users/index.html.erb +37 -0
  67. data/app/views/blacksand/dashboard/users/index.json.jbuilder +4 -0
  68. data/app/views/blacksand/dashboard/users/new.html.erb +4 -0
  69. data/app/views/blacksand/dashboard/users/show.html.erb +2 -0
  70. data/app/views/blacksand/dashboard/users/show.json.jbuilder +1 -0
  71. data/app/views/layouts/blacksand/_navbar.html.erb +42 -0
  72. data/app/views/layouts/blacksand/dashboard.html.erb +33 -0
  73. data/config/locales/kaminari.zh-CN.yml +17 -0
  74. data/config/locales/nestable.zh-CN.yml +14 -0
  75. data/config/locales/zh-CN.yml +69 -0
  76. data/config/routes.rb +31 -0
  77. data/db/migrate/20151112055035_create_templates.rb +10 -0
  78. data/db/migrate/20151112055425_create_prototypes.rb +9 -0
  79. data/db/migrate/20151112055438_create_fields.rb +14 -0
  80. data/db/migrate/20151112055821_create_pages.rb +15 -0
  81. data/db/migrate/20151112060015_create_properties.rb +15 -0
  82. data/db/migrate/20151112060605_create_navigations.rb +13 -0
  83. data/db/migrate/20151209022305_create_kindeditor_assets.rb +17 -0
  84. data/db/migrate/20160513080702_create_pictures.rb +12 -0
  85. data/db/migrate/20170104014706_add_values_to_properties.rb +5 -0
  86. data/db/migrate/20170310092041_add_owner_type_to_kindeditor_asset.rb +5 -0
  87. data/db/migrate/20170322021913_add_options_to_template_and_prototype.rb +6 -0
  88. data/lib/blacksand/caching_pages.rb +16 -0
  89. data/lib/blacksand/cancancan.rb +19 -0
  90. data/lib/blacksand/controller_helper.rb +21 -0
  91. data/lib/blacksand/engine.rb +69 -0
  92. data/lib/blacksand/expire_pages.rb +21 -0
  93. data/lib/blacksand/my_json_type.rb +61 -0
  94. data/lib/blacksand/routing.rb +11 -0
  95. data/lib/blacksand/version.rb +3 -0
  96. data/lib/blacksand.rb +53 -0
  97. data/lib/generators/blacksand/install_generator.rb +30 -0
  98. data/lib/generators/blacksand/new_site_generator.rb +28 -0
  99. data/lib/tasks/blacksand_tasks.rake +72 -0
  100. data/lib/tasks/carrierwave_storage_migrate_to_qiniu.rake +25 -0
  101. metadata +541 -0
@@ -0,0 +1,23 @@
1
+ <%= bootstrap_form_for(@navigation) do |f| %>
2
+
3
+ <%= f.text_field :name %>
4
+ <%= f.text_field :url %>
5
+ <%= f.text_field :position %>
6
+
7
+ <!-- '无' 必须存在,要个 select2 allowClear 搭配使用才能生效 -->
8
+ <% if @navigation.page_id %>
9
+ <%= f.select :page_id, [['无', ''], [@navigation.page.title, @navigation.page_id]] %>
10
+ <% else %>
11
+ <%= f.select :page_id, [['无', '']] %>
12
+ <% end %>
13
+
14
+ <%= f.fields_for :options, @navigation.options do |ff| %>
15
+ <%= ff.check_box 'hover_submenus', { label: '悬停显示子菜单' } %>
16
+
17
+ <%= ff.check_box 'link_sub_page', { label: '导航到子页面' } %>
18
+ <% end %>
19
+
20
+ <%= f.form_group do %>
21
+ <%= f.primary %>
22
+ <% end %>
23
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <h3>编辑导航</h3>
2
+
3
+ <%= render 'form' %>
@@ -0,0 +1,40 @@
1
+ <div id="flash-here"></div>
2
+
3
+ <h3>导航</h3>
4
+
5
+ <% if visible?(:create, Blacksand::Navigation) %>
6
+ <%= link_to '新增导航', new_navigation_path, class: 'btn btn-default' %>
7
+ <% end %>
8
+
9
+ <p class="help-block">拖动排序</p>
10
+ <table id="nav-table" class="table table-bordered">
11
+ <thead>
12
+ <tr>
13
+ <th>名称</th>
14
+ <th>链接</th>
15
+ <th>页面</th>
16
+ <th></th>
17
+ </tr>
18
+ </thead>
19
+
20
+ <tbody data-update-url="<%= reorder_navigations_path(format: :js) %>">
21
+ <% @navigations.each do |navigation| %>
22
+ <tr data-navigation-id="<%= navigation.id %>">
23
+ <td><%= navigation.name %></td>
24
+ <td><%= navigation.url %></td>
25
+ <td><%= link_to navigation.page.title, navigation.page if navigation.page.present? %></td>
26
+ <td>
27
+ <% if visible?(:update, navigation) %>
28
+ <%= link_to '编辑', edit_navigation_path(navigation) %>
29
+ <% end %>
30
+
31
+ <% if visible?(:destroy, navigation) %>
32
+ <%= link_to '删除', navigation_path(navigation), method: :delete, data: { confirm: '确定删除导航?' } %>
33
+ <% end %>
34
+ </td>
35
+ </tr>
36
+ <% end %>
37
+ </tbody>
38
+ </table>
39
+
40
+
@@ -0,0 +1,4 @@
1
+ json.array!(@navigations) do |navigation|
2
+ json.extract! navigation, :id
3
+ json.url navigation_url(navigation, format: :json)
4
+ end
@@ -0,0 +1,3 @@
1
+ <h3>新增导航</h3>
2
+
3
+ <%= render 'form' %>
@@ -0,0 +1 @@
1
+ $('#flash-here').empty().append("<%= j render 'layouts/flash' %>");
@@ -0,0 +1,4 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <%= link_to 'Edit', edit_navigation_path(@navigation) %> |
4
+ <%= link_to 'Back', navigations_path %>
@@ -0,0 +1 @@
1
+ json.extract! @navigation, :id, :created_at, :updated_at
@@ -0,0 +1,89 @@
1
+ <% case f.object.field.field_type %>
2
+ <% when 'image' then %>
3
+ <%= f.file_field :image, filed_options(f) %>
4
+ <%= f.form_group do %>
5
+ <div class="row">
6
+ <% if f.object.image? %>
7
+ <div class="col-xs-6 col-md-3">
8
+ <div class="thumbnail">
9
+ <%= image_tag f.object.image_url %>
10
+ </div>
11
+ </div>
12
+ <% end %>
13
+ </div>
14
+ <% end %>
15
+ <% when 'slide' then %>
16
+ <%= f.hidden_field :type %>
17
+ <%= f.file_field :image, filed_options(f) %>
18
+ <%= f.form_group do %>
19
+ <div class="row">
20
+ <% if f.object.image? %>
21
+ <div class="col-xs-6 col-md-3">
22
+ <div class="thumbnail">
23
+ <%= image_tag f.object.image_url %>
24
+ </div>
25
+ </div>
26
+ <% end %>
27
+ </div>
28
+ <% end %>
29
+ <% when 'file' then %>
30
+ <%= f.hidden_field :type %>
31
+ <%= f.file_field :file, filed_options(f) %>
32
+ <%= f.form_group do %>
33
+ <div class="row">
34
+ <% if f.object.file? %>
35
+ <div class="col-xs-6 col-md-3">
36
+ <a target="_blank" href="<%= f.object.file_url %>"><%= File.basename f.object.file.path %></a>
37
+ </div>
38
+ <% end %>
39
+ </div>
40
+ <% end %>
41
+ <% when 'gallery' then %>
42
+ <%= f.form_group label: {text: "#{f.object.field.description}", class: "#{'required' if f.object.field.required?}"} do %>
43
+ <% end %>
44
+ <%= f.hidden_field :type %>
45
+ <%= f.fields_for :pictures do |picture| %>
46
+ <%= render 'picture_fields', f: picture %>
47
+ <% end %>
48
+
49
+ <%= f.form_group nil, class: 'add-picture' do %>
50
+ <%= link_to_add_association f, :pictures, 'data-association-insertion-node' => '.add-picture' do %>
51
+ <i class="fa fa-plus"></i> 添加图片
52
+ <% end %>
53
+ <% end %>
54
+ <% when 'array' then %>
55
+ <%= f.form_group label: {text: "#{f.object.field.description}", class: "#{'required' if f.object.field.required?}"} do %>
56
+ <% end %>
57
+ <%= f.hidden_field :type %>
58
+ <% f.object.values.each do |item| %>
59
+ <div class="form-group array-item">
60
+ <div class="col-md-offset-2 col-md-8">
61
+ <%= text_field_tag "page[properties_attributes][#{f.options[:child_index]}][values][]", item, class: 'form-control' %>
62
+ </div>
63
+ <div class="col-md-2">
64
+ <a class='btn btn-link btn-default btn-sm up-item-button'>上移</a>
65
+ <a class='btn btn-link btn-default btn-sm remove-item-button'>删除</a>
66
+ </div>
67
+ </div>
68
+ <% end %>
69
+
70
+ <%= f.form_group nil, class: 'add-item' do %>
71
+ <a class="add-item-button btn btn-link" data-child-index="<%= f.options[:child_index] %>">添加项目</a>
72
+ <% end %>
73
+
74
+ <% when 'rich_text' then %>
75
+ <%= f.form_group label: {text: "#{f.object.field.description}", class: "#{'required' if f.object.field.required?}"} do %>
76
+ <%= f.kindeditor :value, class: "rich_text" %>
77
+ <br />
78
+ <%= f.errors_on :value %>
79
+ <% end %>
80
+ <% when 'textarea' then %>
81
+ <%= f.text_area :value, filed_options(f) %>
82
+ <% when 'select' then %>
83
+ <%= f.select :value, f.object.field.options.map{|e| [e, e]}, filed_options(f) %>
84
+ <% when 'page' then %>
85
+ <!-- page select2 -->
86
+ <%= f.select :value, select_choices(f), filed_options(f), { data: { provide: 'page-select2' } } %>
87
+ <% else %>
88
+ <%= f.text_field :value, filed_options(f) %>
89
+ <% end %>
@@ -0,0 +1,26 @@
1
+ <%= bootstrap_form_for @page, url: url, layout: :horizontal, html: { multipart: true } do |f| %>
2
+
3
+ <%= f.select :prototype_id, @prototype_select, {:include_blank => true}, { :onchange => "onchange_render(this.value);", } %>
4
+ <%= f.select :template_id, @template_select, {:include_blank => true} %>
5
+
6
+ <!-- '无' 必须存在,要个 select2 allowClear 搭配使用才能生效 -->
7
+ <% if @page.parent_id %>
8
+ <%= f.select :parent_id, [['无', ''], [@page.parent.title, @page.parent_id]] %>
9
+ <% else %>
10
+ <%= f.select :parent_id, [['无', '']] %>
11
+ <% end %>
12
+
13
+ <%= f.text_field :title %>
14
+ <%= f.text_field :en_name %>
15
+ <%= f.fields_for :properties do |property_form| %>
16
+ <%= render partial: 'fields', locals: {f: property_form} %>
17
+ <%= property_form.hidden_field :field_id %>
18
+ <% end %>
19
+ <%= f.form_group label: { text: '内容' } do %>
20
+ <%= f.kindeditor :content, :owner => @page %>
21
+ <% end %>
22
+
23
+ <%= f.form_group do %>
24
+ <%= f.primary %>
25
+ <% end %>
26
+ <% end %>
@@ -0,0 +1,123 @@
1
+
2
+ <% if @parent_id %>
3
+ <div class="row m-v-10">
4
+ <div class="col-md-12 m-b-10">
5
+ <div class="row">
6
+ <div class="col-md-8">
7
+ <h4><%= @parent_page.title %></h4>
8
+ </div>
9
+ <div class="col-md-4 text-right" style="line-height: 39px;">
10
+ <% if visible?(:edit, @parent_page) %>
11
+ <%= link_to '编辑', edit_page_path(@parent_page) %> |
12
+ <% end %>
13
+
14
+ <% if visible?(:destroy, @parent_page) %>
15
+ <%= link_to '删除', page_path(@parent_page), method: :delete, data: { confirm: '确定要删除吗?' } %> |
16
+ <% end %>
17
+
18
+ <a href="<%= Rails.application.routes.url_helpers.page_path(@parent_page) %>" target="_blank">
19
+ <i class="glyphicon glyphicon-share"></i>预览
20
+ </a>
21
+ </div>
22
+ </div>
23
+ </div>
24
+
25
+ <div class="col-md-12">
26
+ <table class="table">
27
+ <tr class="text-muted">
28
+ <td> 标识: <strong><%= @parent_page.en_name %></strong></td>
29
+ <td>模板: <strong><%= @parent_page.template.try(:name) %></strong></td>
30
+ <td>原型: <strong><%= @parent_page.prototype.try(:name) %></strong></td>
31
+ <td>子页面推荐模板: <strong><%= @parent_page.preferred_child_template_name %></strong></td>
32
+ <td>子页面推荐原型: <strong><%= @parent_page.preferred_child_prototype_name %></strong></td>
33
+ </tr>
34
+ </table>
35
+ </div>
36
+ </div>
37
+ <% end %>
38
+
39
+ <div class="m-v-10">
40
+ <% if visible?(:create, Blacksand::Page) %>
41
+ <%= link_to new_page_path(parent_id: @parent_id), class: "btn btn-primary" do %>
42
+ <i class="glyphicon glyphicon-plus"></i> 新增页面
43
+ <% end %>
44
+ <% end %>
45
+
46
+ <% if visible?(:sort, Blacksand::Page) %>
47
+ <button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal"><i class="glyphicon glyphicon-align-justify"></i> 排序</button>
48
+ <% end %>
49
+ </div>
50
+
51
+ <div class="m-v-10">
52
+ <%= search_form_for(@q, url: children_partial_pages_path, remote: true) do |f| %>
53
+ <% if @parent_id.present? %>
54
+ <%= hidden_field_tag :parent_id, @parent_id %>
55
+ <% end %>
56
+ <%= f.label :title_cont %>
57
+ <%= f.text_field :title_cont %>
58
+ <%= f.submit class: 'btn btn-primary btn-sm' %>
59
+ <% end %>
60
+ </div>
61
+
62
+ <table class="table">
63
+ <thead>
64
+ <tr>
65
+ <th>#</th>
66
+ <th>标题</th>
67
+ <th>标识</th>
68
+ <th>模版</th>
69
+ <th>原型</th>
70
+ <th>操作</th>
71
+ </tr>
72
+ </thead>
73
+ <tbody>
74
+ <% @pages.each_with_index do |page, index| %>
75
+ <tr>
76
+ <th scope="row"><%= index+1 %></th>
77
+ <td><%= page.title %> </td>
78
+ <td><%= page.en_name %></td>
79
+ <td><%= page.template.try :name %></td>
80
+ <td><%= page.prototype.try(:name) %></td>
81
+ <td>
82
+ <% if visible?(:edit, page) %>
83
+ <%= link_to '编辑', edit_page_path(page) %> |
84
+ <% end %>
85
+
86
+ <% if visible?(:destroy, page) %>
87
+ <%= link_to '删除', page_path(page), method: :delete, data: { confirm: '确定要删除吗?' } %> |
88
+ <% end %>
89
+
90
+ <a href="<%= main_app.page_path(page) %>" target="_blank">
91
+ <i class="glyphicon glyphicon-share"></i>预览
92
+ </a>
93
+ </td>
94
+ </tr>
95
+ <% end %>
96
+ </tbody>
97
+ </table>
98
+ <div id="paginator">
99
+ <%= paginate @pages, :remote => true %>
100
+ </div>
101
+
102
+ <!-- Modal -->
103
+ <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
104
+ <div class="modal-dialog" role="document">
105
+ <div class="modal-content">
106
+ <div class="modal-header">
107
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
108
+ <h4 class="modal-title" id="myModalLabel">排序</h4>
109
+ </div>
110
+ <div class="modal-body">
111
+ <p class="help-block">拖动排序</p>
112
+ <ul id="modal-list" data-update-url="<%= sort_pages_path %>">
113
+ <% @all_children.each do |p| %>
114
+ <li data-id="<%= p.id %>"><%= p.title %></li>
115
+ <% end %>
116
+ </ul>
117
+ </div>
118
+ <div class="modal-footer">
119
+ <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
120
+ </div>
121
+ </div>
122
+ </div>
123
+ </div>
@@ -0,0 +1,18 @@
1
+ <div class="nested-fields">
2
+ <hr>
3
+ <%= f.text_field :name %>
4
+ <%= f.file_field :file %>
5
+
6
+ <%= f.form_group do %>
7
+ <% if f.object.file.present? %>
8
+ <%= image_tag f.object.file, class: 'img-responsive' %>
9
+ <%= File.basename f.object.file.path %>
10
+ <% end %>
11
+ <% end %>
12
+
13
+ <%= f.form_group do %>
14
+ <%= link_to_remove_association f, class: 'btn btn-link' do %>
15
+ <i class="fa fa-trash"></i> 删除
16
+ <% end %>
17
+ <% end %>
18
+ </div>
@@ -0,0 +1,14 @@
1
+ $('#manage_list').html('<%= j render('manage_list') %>');
2
+
3
+ // 排序
4
+ dragula([$('#modal-list')[0]]).on('drop', function(){
5
+ console.log('排序');
6
+
7
+ var newOrders = $('#modal-list').children().map(function(){
8
+ return $(this).data('id')
9
+ })
10
+ .get();
11
+
12
+ var update_url = $('#modal-list').data('update-url');
13
+ $.post(update_url, {page: newOrders})
14
+ });
@@ -0,0 +1,20 @@
1
+ <div id="page_form">
2
+ <%= render 'form', url: page_path(@page) %>
3
+ </div>
4
+
5
+ <script type="text/javascript">
6
+ var onchange_render = function(prototype_id) {
7
+ if(window.confirm('更换原型将删除这个页面下的所有信息,确定要更换原型吗?')){
8
+ $.ajax({
9
+ url: "<%= onchange_edit_page_path(@page) %>" + "?prototype_id=" + prototype_id
10
+ })
11
+ } else {
12
+ $.ajax({
13
+ url: "get_prototype_id",
14
+ dataType: "json"
15
+ }).done(function(prototype_id) {
16
+ $('#page_prototype_id').val(prototype_id)
17
+ })
18
+ }
19
+ }
20
+ </script>
@@ -0,0 +1,27 @@
1
+ <div class="row">
2
+ <div class="col-md-3">
3
+ <div id="manage_menu"></div>
4
+ </div>
5
+ <div class="col-md-9">
6
+ <div id="manage_list">
7
+ </div>
8
+ </div>
9
+
10
+ </div>
11
+
12
+ <% content_for :javascript do %>
13
+ <script>
14
+ // 排序
15
+ dragula([$('#modal-list')[0]]).on('drop', function(){
16
+ console.log('排序');
17
+
18
+ var newOrders = $('#modal-list').children().map(function(){
19
+ return $(this).data('id')
20
+ })
21
+ .get();
22
+
23
+ var update_url = $('#modal-list').data('update-url');
24
+ $.post(update_url, {page: newOrders})
25
+ });
26
+ </script>
27
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <ol class="breadcrumb" style="background-color: white;">
2
+ <li><a href="<%= pages_path %>">页面列表</a></li>
3
+ <li class="active">新增页面</li>
4
+ </ol>
5
+
6
+ <div id="page_form">
7
+ <%= render 'form', url: pages_path %>
8
+ </div>
9
+ <script type="text/javascript">
10
+ // TODO: using url helper method
11
+ var onchange_render = function(prototype_id) {
12
+ <% if params["parent_id"].present? %>
13
+ var url = "<%= onchange_new_pages_path(parent_id: params[:parent_id]) %>" + "&prototype_id=" + prototype_id;
14
+ <% else %>
15
+ var url = "<%= onchange_new_pages_path %>" + "?prototype_id=" + prototype_id;
16
+ <% end %>
17
+
18
+ $.ajax({ url: url });
19
+ }
20
+ </script>
@@ -0,0 +1,14 @@
1
+ $('#page_form').html('<%= j render partial: 'form', locals: { url: url_for_page(@page) } %>');
2
+
3
+ initSelect2();
4
+
5
+ KindEditor.create(
6
+ 'textarea[class="rich_text"]',
7
+ {
8
+ width: "100%",
9
+ height: 300,
10
+ allowFileManager: true,
11
+ uploadJson: '/kindeditor/upload',
12
+ fileManagerJson: '/kindeditor/filemanager'
13
+ }
14
+ );
@@ -0,0 +1,7 @@
1
+ json.page @pages.current_page
2
+ json.total_pages @pages.total_pages
3
+
4
+ json.pages @pages do |page|
5
+ json.extract! page, :id, :title
6
+ json.set! :text, "##{page.id} #{page.title} #{page.parent.present? ? ' / ' + page.parent.title : ''}"
7
+ end
@@ -0,0 +1,34 @@
1
+ <h3><%= @page.title %></h3>
2
+
3
+ <%= link_to '编辑', edit_dashboard_page_path(@page) %>
4
+ <%= link_to '删除', dashboard_page_path(@page), method: :delete, data: { confirm: '确定删除吗?' } %>
5
+
6
+ <table class="table table-bordered">
7
+ <caption>子页面</caption>
8
+ <thead>
9
+ <tr>
10
+ <th>#</th>
11
+ <th>标题</th>
12
+ <th>标识</th>
13
+ <th>模版</th>
14
+ <th>原型</th>
15
+ <th>操作</th>
16
+ </tr>
17
+ </thead>
18
+ <tbody>
19
+ <% @page.children.each_with_index do |page, index| %>
20
+ <tr>
21
+ <th scope="row"><%= index+1 %></th>
22
+ <td><%= link_to page.title, dashboard_page_path(page) %></td>
23
+ <td><%= page.en_name %></td>
24
+ <td><%= page.template.name %></td>
25
+ <td><%= page.prototype.try(:name) %></td>
26
+ <td><%= link_to '删除', dashboard_page_path(page), method: :delete, data: { confirm: '确定要删除吗?' } %> |
27
+ <%= link_to '编辑', edit_dashboard_page_path(page) %>
28
+ | <%= link_to '子页面', children_dashboard_page_path(page) %>
29
+ </td>
30
+
31
+ </tr>
32
+ <% end %>
33
+ </tbody>
34
+ </table>
@@ -0,0 +1,15 @@
1
+ <h3>原型</h3>
2
+ <table class="table table-bordered">
3
+ <thead>
4
+ <tr>
5
+ <td>名称</td>
6
+ </tr>
7
+ </thead>
8
+ <tbody>
9
+ <% @prototypes.each do |p| %>
10
+ <tr>
11
+ <td><%= link_to p.name, prototype_path(p) %></td>
12
+ </tr>
13
+ <% end %>
14
+ </tbody>
15
+ </table>
@@ -0,0 +1,31 @@
1
+ <h4><%= @prototype.name %></h4>
2
+
3
+ <h5>字段</h5>
4
+ <table class="table table-bordered">
5
+ <thead>
6
+ <tr>
7
+ <td>描述</td>
8
+ <td>名称</td>
9
+ <td>类型</td>
10
+ <th>选项</th>
11
+ <th>必填</th>
12
+ </tr>
13
+ </thead>
14
+ <tbody>
15
+ <% @prototype.fields.each do |field| %>
16
+ <tr>
17
+ <td>
18
+ <%= field.description %>
19
+ </td>
20
+ <td>
21
+ <%= field.name %>
22
+ </td>
23
+ <td>
24
+ <%= field.field_type %>
25
+ </td>
26
+ <td><%= field.options %></td>
27
+ <td><%= field.required ? '必填' : '可选' %></td>
28
+ </tr>
29
+ <% end %>
30
+ </tbody>
31
+ </table>
@@ -0,0 +1,17 @@
1
+ <h3>模板</h3>
2
+ <table class="table table-bordered">
3
+ <thead>
4
+ <tr>
5
+ <td>名称</td>
6
+ <td>路径</td>
7
+ </tr>
8
+ </thead>
9
+ <tbody>
10
+ <% @templates.each do |t| %>
11
+ <tr>
12
+ <td><%= t.name %></td>
13
+ <td><%= t.path %></td>
14
+ </tr>
15
+ <% end %>
16
+ </tbody>
17
+ </table>
@@ -0,0 +1,40 @@
1
+ <div class="row">
2
+ <div class="col-md-4">
3
+ <%= form_for(@user, url: dashboard_users_path) do |f| %>
4
+ <% if @user.errors.any? %>
5
+ <div id="error_explanation" class="red">
6
+ <ul>
7
+ <% @user.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="form-group">
15
+ <%= f.label :email %>
16
+ <%= f.text_field :email, class: 'form-control' %>
17
+ </div>
18
+
19
+ <div class="form-group">
20
+ <%= f.label :password %>
21
+ <%= f.password_field :password, class: 'form-control' %>
22
+ </div>
23
+
24
+ <div class="form-group">
25
+ <%= f.label :password_confirmation %>
26
+ <%= f.password_field :password_confirmation, class: 'form-control' %>
27
+ </div>
28
+
29
+ <div class="form-group">
30
+ <%= f.label :role %>
31
+ <%= f.select :role, User.role_types.map(&:reverse), {}, class: 'form-control' %>
32
+ </div>
33
+
34
+ <div class="actions">
35
+ <%= f.submit '保存', class: 'btn btn-primary' %>
36
+ <%= link_to '取消', dashboard_users_path, class: 'btn btn-link' %>
37
+ </div>
38
+ <% end %>
39
+ </div>
40
+ </div>
@@ -0,0 +1,47 @@
1
+ <div class="row">
2
+ <div class="col-md-4">
3
+
4
+ <h2>编辑用户</h2>
5
+
6
+ <%= form_for(@user, url: dashboard_user_path(@user)) do |f| %>
7
+ <% if @user.errors.any? %>
8
+ <div id="error_explanation">
9
+ <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
10
+
11
+ <ul>
12
+ <% @user.errors.full_messages.each do |message| %>
13
+ <li><%= message %></li>
14
+ <% end %>
15
+ </ul>
16
+ </div>
17
+ <% end %>
18
+
19
+ <div class="form-group">
20
+ <%= f.label :email %>
21
+ <p class="form-static-control"><%= @user.email %></p>
22
+ </div>
23
+
24
+ <div class="form-group">
25
+ <%= f.label :role %>
26
+ <%= f.select :role, User.role_types.map(&:reverse), {}, class: 'form-control' %>
27
+ </div>
28
+
29
+ <div class="form-group">
30
+ <%= f.label :page %>
31
+ <%= select_tag 'user[page_ids][]', options_for_select(Page.where(parent: nil).map{|p| [p.title, p.id]}, @user.page_ids), {multiple: true} %>
32
+ </div>
33
+
34
+ <%= f.submit '保存', class: 'btn btn-primary' %>
35
+ <%= link_to '取消', dashboard_users_path, class: 'btn btn-link' %>
36
+ <% end %>
37
+
38
+ </div>
39
+ </div>
40
+
41
+ <% content_for(:javascript) do %>
42
+ <script type="text/javascript" charset="utf-8">
43
+ $(function(){
44
+ $('#user_page_ids_').multiSelect({selectableHeader: '待选择', selectionHeader: '已选择'});
45
+ })
46
+ </script>
47
+ <% end %>