alchemy_cms 3.0.4 → 3.1.0.beta1

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.
Files changed (210) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -6
  3. data/Gemfile +4 -7
  4. data/README.md +207 -115
  5. data/alchemy_cms.gemspec +10 -9
  6. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.coffee +2 -2
  7. data/app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee +2 -2
  8. data/app/assets/javascripts/alchemy/alchemy.js +6 -7
  9. data/app/assets/javascripts/alchemy/alchemy.translations.js.coffee +1 -43
  10. data/app/assets/javascripts/alchemy/alchemy.uploader.js.coffee +1 -1
  11. data/app/assets/stylesheets/alchemy/_mixins.scss +2 -1
  12. data/app/assets/stylesheets/alchemy/buttons.scss +0 -5
  13. data/app/assets/stylesheets/alchemy/dialogs.scss +1 -0
  14. data/app/assets/stylesheets/alchemy/frame.scss +9 -12
  15. data/app/assets/stylesheets/tinymce/skins/alchemy/content.min.css.scss +11 -2
  16. data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +9 -1
  17. data/app/controllers/alchemy/admin/attachments_controller.rb +2 -4
  18. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +34 -38
  19. data/app/controllers/alchemy/api/base_controller.rb +19 -0
  20. data/app/controllers/alchemy/api/contents_controller.rb +35 -0
  21. data/app/controllers/alchemy/api/elements_controller.rb +29 -0
  22. data/app/controllers/alchemy/api/pages_controller.rb +32 -0
  23. data/app/controllers/alchemy/contents_controller.rb +1 -0
  24. data/app/controllers/alchemy/elements_controller.rb +5 -2
  25. data/app/controllers/alchemy/pages_controller.rb +4 -1
  26. data/app/controllers/alchemy/pictures_controller.rb +4 -36
  27. data/app/helpers/alchemy/admin/essences_helper.rb +5 -2
  28. data/app/helpers/alchemy/essences_helper.rb +14 -1
  29. data/app/models/alchemy/content.rb +32 -4
  30. data/app/models/alchemy/element.rb +2 -16
  31. data/app/models/alchemy/element/presenters.rb +2 -2
  32. data/app/models/alchemy/essence_file.rb +5 -0
  33. data/app/models/alchemy/essence_picture.rb +12 -8
  34. data/app/models/alchemy/picture.rb +1 -74
  35. data/app/models/alchemy/picture/transformations.rb +249 -0
  36. data/app/serializers/alchemy/content_serializer.rb +3 -10
  37. data/app/serializers/alchemy/element_serializer.rb +6 -3
  38. data/app/serializers/alchemy/legacy_element_serializer.rb +17 -0
  39. data/app/views/alchemy/admin/dashboard/_sites.html.erb +14 -4
  40. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +8 -5
  41. data/app/views/alchemy/admin/pages/edit.html.erb +9 -9
  42. data/app/views/alchemy/admin/pictures/info.html.erb +2 -3
  43. data/app/views/alchemy/admin/tags/edit.html.erb +1 -1
  44. data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +8 -7
  45. data/app/views/alchemy/essences/_essence_boolean_view.html.erb +3 -3
  46. data/app/views/alchemy/essences/_essence_date_editor.html.erb +8 -2
  47. data/app/views/alchemy/essences/_essence_date_view.html.erb +10 -8
  48. data/app/views/alchemy/essences/_essence_file_editor.html.erb +48 -53
  49. data/app/views/alchemy/essences/_essence_file_view.html.erb +5 -5
  50. data/app/views/alchemy/essences/_essence_html_editor.html.erb +5 -4
  51. data/app/views/alchemy/essences/_essence_link_editor.html.erb +17 -15
  52. data/app/views/alchemy/essences/_essence_link_view.html.erb +11 -7
  53. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +4 -2
  54. data/app/views/alchemy/essences/_essence_picture_view.html.erb +4 -2
  55. data/app/views/alchemy/essences/_essence_richtext_view.html.erb +5 -4
  56. data/app/views/alchemy/essences/_essence_select_editor.html.erb +22 -32
  57. data/app/views/alchemy/essences/_essence_text_view.html.erb +7 -6
  58. data/app/views/alchemy/essences/shared/_essence_picture_tools.html.erb +1 -1
  59. data/app/views/layouts/alchemy/admin.html.erb +5 -3
  60. data/config/initializers/inflections.rb +3 -0
  61. data/config/initializers/simple_form.rb +1 -1
  62. data/config/locales/alchemy.en.yml +0 -1
  63. data/config/routes.rb +14 -0
  64. data/lib/alchemy/capistrano.rb +71 -0
  65. data/lib/alchemy/engine.rb +0 -3
  66. data/lib/alchemy/essence.rb +1 -1
  67. data/lib/alchemy/permissions.rb +19 -5
  68. data/lib/alchemy/picture_attributes.rb +1 -1
  69. data/lib/alchemy/test_support/auth_helpers.rb +1 -1
  70. data/lib/alchemy/test_support/essence_shared_examples.rb +37 -22
  71. data/lib/alchemy/test_support/integration_helpers.rb +1 -1
  72. data/lib/alchemy/tinymce.rb +21 -4
  73. data/lib/alchemy/upgrader/three_point_one.rb +43 -0
  74. data/lib/alchemy/upgrader/three_point_zero.rb +13 -0
  75. data/lib/alchemy/version.rb +2 -1
  76. data/lib/rails/generators/alchemy/module/module_generator.rb +30 -0
  77. data/lib/rails/generators/alchemy/module/templates/ability.rb.tt +11 -0
  78. data/lib/rails/generators/alchemy/module/templates/controller.rb.tt +2 -0
  79. data/lib/rails/generators/alchemy/module/templates/module_config.rb.tt +15 -0
  80. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +0 -1
  81. data/lib/rails/templates/alchemy.rb +2 -2
  82. data/lib/tasks/alchemy/db.rake +7 -1
  83. data/spec/controllers/admin/attachments_controller_spec.rb +38 -38
  84. data/spec/controllers/admin/base_controller_spec.rb +18 -18
  85. data/spec/controllers/admin/clipboard_controller_spec.rb +23 -18
  86. data/spec/controllers/admin/contents_controller_spec.rb +33 -27
  87. data/spec/controllers/admin/dashboard_controller_spec.rb +14 -14
  88. data/spec/controllers/admin/elements_controller_spec.rb +125 -105
  89. data/spec/controllers/admin/essence_files_controller_spec.rb +6 -7
  90. data/spec/controllers/admin/essence_pictures_controller_spec.rb +52 -42
  91. data/spec/controllers/admin/languages_controller_spec.rb +3 -3
  92. data/spec/controllers/admin/pages_controller_spec.rb +81 -71
  93. data/spec/controllers/admin/pictures_controller_spec.rb +69 -72
  94. data/spec/controllers/admin/resources_controller_spec.rb +5 -5
  95. data/spec/controllers/admin/trash_controller_spec.rb +15 -12
  96. data/spec/controllers/alchemy/admin/tags_controller_spec.rb +8 -8
  97. data/spec/controllers/alchemy/api/contents_controller_spec.rb +73 -0
  98. data/spec/controllers/alchemy/api/elements_controller_spec.rb +69 -0
  99. data/spec/controllers/alchemy/api/pages_controller_spec.rb +86 -0
  100. data/spec/controllers/attachments_controller_spec.rb +8 -8
  101. data/spec/controllers/contents_controller_spec.rb +22 -0
  102. data/spec/controllers/elements_controller_spec.rb +10 -4
  103. data/spec/controllers/messages_controller_spec.rb +35 -34
  104. data/spec/controllers/pages_controller_spec.rb +37 -28
  105. data/spec/controllers/pictures_controller_spec.rb +90 -23
  106. data/spec/dummy/app/models/dummy_user.rb +0 -4
  107. data/spec/dummy/app/views/alchemy/elements/_all_you_can_eat_editor.html.erb +11 -0
  108. data/spec/dummy/config/alchemy/elements.yml +22 -1
  109. data/spec/dummy/config/alchemy/page_layouts.yml +4 -0
  110. data/spec/dummy/config/application.rb +2 -1
  111. data/spec/dummy/config/environments/test.rb +3 -1
  112. data/spec/features/admin/dashboard_spec.rb +41 -6
  113. data/spec/features/admin/language_tree_feature_spec.rb +3 -3
  114. data/spec/features/admin/legacy_page_url_management_spec.rb +1 -1
  115. data/spec/features/admin/link_overlay_spec.rb +7 -7
  116. data/spec/features/admin/locale_select_feature_spec.rb +5 -2
  117. data/spec/features/admin/modules_integration_spec.rb +1 -1
  118. data/spec/features/admin/page_creation_feature_spec.rb +3 -2
  119. data/spec/features/admin/page_editing_feature_spec.rb +66 -79
  120. data/spec/features/admin/picture_library_integration_spec.rb +8 -8
  121. data/spec/features/admin/resources_integration_spec.rb +21 -21
  122. data/spec/features/admin/tinymce_feature_spec.rb +36 -0
  123. data/spec/features/navigation_spec.rb +1 -1
  124. data/spec/features/page_feature_spec.rb +34 -34
  125. data/spec/features/picture_security_spec.rb +4 -4
  126. data/spec/features/security_spec.rb +1 -1
  127. data/spec/features/translation_integration_spec.rb +7 -7
  128. data/spec/helpers/admin/base_helper_spec.rb +51 -49
  129. data/spec/helpers/admin/contents_helper_spec.rb +11 -11
  130. data/spec/helpers/admin/elements_helper_spec.rb +20 -17
  131. data/spec/helpers/admin/essences_helper_spec.rb +42 -11
  132. data/spec/helpers/admin/navigation_helper_spec.rb +64 -54
  133. data/spec/helpers/admin/pages_helper_spec.rb +10 -10
  134. data/spec/helpers/admin/tags_helper_spec.rb +16 -16
  135. data/spec/helpers/base_helper_spec.rb +11 -11
  136. data/spec/helpers/elements_block_helper_spec.rb +24 -24
  137. data/spec/helpers/elements_helper_spec.rb +46 -46
  138. data/spec/helpers/essences_helper_spec.rb +90 -17
  139. data/spec/helpers/pages_helper_spec.rb +53 -53
  140. data/spec/helpers/picture_url_helpers_spec.rb +6 -6
  141. data/spec/helpers/url_helper_spec.rb +32 -32
  142. data/spec/libraries/config_spec.rb +9 -9
  143. data/spec/libraries/controller_actions_spec.rb +14 -14
  144. data/spec/libraries/i18n_spec.rb +6 -6
  145. data/spec/libraries/kaminari/scoped_pagination_url_helper_spec.rb +4 -4
  146. data/spec/libraries/modules_spec.rb +4 -4
  147. data/spec/libraries/mount_point_spec.rb +13 -13
  148. data/spec/libraries/page_layout_spec.rb +24 -24
  149. data/spec/libraries/permissions_spec.rb +97 -80
  150. data/spec/libraries/resource_spec.rb +37 -37
  151. data/spec/libraries/resources_helper_spec.rb +19 -19
  152. data/spec/libraries/shell_spec.rb +17 -17
  153. data/spec/libraries/template_tracker_spec.rb +14 -14
  154. data/spec/libraries/tinymce_spec.rb +8 -8
  155. data/spec/libraries/userstamp_spec.rb +2 -2
  156. data/spec/mailers/messages_spec.rb +4 -4
  157. data/spec/models/attachment_spec.rb +86 -30
  158. data/spec/models/cell_spec.rb +10 -10
  159. data/spec/models/content_spec.rb +106 -46
  160. data/spec/models/element_spec.rb +94 -115
  161. data/spec/models/essence_date_spec.rb +1 -1
  162. data/spec/models/essence_file_spec.rb +4 -4
  163. data/spec/models/essence_picture_spec.rb +56 -25
  164. data/spec/models/essence_richtext_spec.rb +1 -1
  165. data/spec/models/essence_text_spec.rb +7 -7
  166. data/spec/models/language_spec.rb +12 -12
  167. data/spec/models/legacy_page_url_spec.rb +2 -2
  168. data/spec/models/message_spec.rb +12 -5
  169. data/spec/models/page_spec.rb +259 -235
  170. data/spec/models/picture_spec.rb +72 -166
  171. data/spec/models/site_spec.rb +41 -41
  172. data/spec/models/tag_spec.rb +7 -7
  173. data/spec/routing/api_routing_spec.rb +150 -0
  174. data/spec/routing/routing_spec.rb +28 -28
  175. data/spec/spec_helper.rb +6 -5
  176. data/spec/support/hint_examples.rb +5 -5
  177. data/spec/support/transformation_examples.rb +173 -0
  178. data/spec/tasks/helpers_spec.rb +29 -29
  179. data/spec/views/essences/essence_boolean_editor_spec.rb +32 -0
  180. data/spec/views/essences/essence_boolean_view_spec.rb +2 -2
  181. data/spec/views/essences/essence_date_view_spec.rb +1 -1
  182. data/spec/views/essences/essence_link_view_spec.rb +11 -0
  183. data/spec/views/essences/essence_picture_view_spec.rb +56 -11
  184. data/spec/views/essences/essence_richtext_view_spec.rb +12 -0
  185. data/spec/views/essences/essence_text_view_spec.rb +12 -0
  186. data/vendor/assets/javascripts/tinymce/langs/de.js +20 -2
  187. data/vendor/assets/javascripts/tinymce/langs/fr.js +14 -1
  188. data/vendor/assets/javascripts/tinymce/langs/nl.js +22 -4
  189. data/vendor/assets/javascripts/tinymce/plugins/anchor/plugin.min.js +1 -1
  190. data/vendor/assets/javascripts/tinymce/plugins/autoresize/plugin.min.js +1 -1
  191. data/vendor/assets/javascripts/tinymce/plugins/charmap/plugin.min.js +1 -1
  192. data/vendor/assets/javascripts/tinymce/plugins/code/plugin.min.js +1 -1
  193. data/vendor/assets/javascripts/tinymce/plugins/directionality/plugin.min.js +1 -1
  194. data/vendor/assets/javascripts/tinymce/plugins/fullscreen/plugin.min.js +1 -1
  195. data/vendor/assets/javascripts/tinymce/plugins/hr/plugin.min.js +1 -1
  196. data/vendor/assets/javascripts/tinymce/plugins/link/plugin.min.js +1 -1
  197. data/vendor/assets/javascripts/tinymce/plugins/paste/plugin.min.js +1 -1
  198. data/vendor/assets/javascripts/tinymce/plugins/tabfocus/plugin.min.js +1 -1
  199. data/vendor/assets/javascripts/tinymce/plugins/table/plugin.min.js +1 -1
  200. data/vendor/assets/javascripts/tinymce/themes/modern/theme.min.js +1 -1
  201. data/vendor/assets/javascripts/tinymce/tinymce.min.js +11 -10
  202. metadata +72 -42
  203. data/app/views/alchemy/messages/contact_form_mail.es.text.erb +0 -12
  204. data/config/locales/alchemy.es.yml +0 -958
  205. data/config/locales/alchemy.ru.yml +0 -837
  206. data/config/locales/simple_form.es.yml +0 -6
  207. data/config/locales/simple_form.ru.yml +0 -25
  208. data/lib/rails/generators/alchemy/scaffold/files/alchemy.es.yml +0 -31
  209. data/vendor/assets/javascripts/tinymce/langs/es.js +0 -197
  210. data/vendor/assets/javascripts/tinymce/langs/ru.js +0 -197
@@ -1,9 +1,11 @@
1
- <% cache(content) do %>
2
- <% if content.ingredient.present? %>
3
- <% if options[:date_format].to_s == 'rfc822' %>
1
+ <%- cache(content) do -%>
2
+ <%- date_format = content_settings_value(content, :date_format,
3
+ local_assigns.fetch(:options, {})) -%>
4
+ <%- if content.ingredient.present? -%>
5
+ <%- if date_format == 'rfc822' -%>
4
6
  <%= content.ingredient.to_s(:rfc822) %>
5
- <% else %>
6
- <%= l(content.ingredient, format: options[:date_format]) %>
7
- <% end %>
8
- <% end %>
9
- <% end %>
7
+ <%- else -%>
8
+ <%= l(content.ingredient, format: date_format) %>
9
+ <%- end -%>
10
+ <%- end -%>
11
+ <%- end -%>
@@ -1,66 +1,61 @@
1
- <div class="content_editor essence_file" id="<%= content.dom_id %>">
2
- <label style="display: inline">
3
- <%= render_content_name(content) %>
4
- <%= delete_content_link(content) %>
5
- </label>
1
+ <% cache(content) do %>
2
+
3
+ <% dialog_link = link_to_dialog('',
4
+ alchemy.admin_attachments_path(
5
+ content_id: content.id,
6
+ only: content_settings_value(content,
7
+ :file_assign_show_only,
8
+ local_assigns.fetch(:options, {})),
9
+ except: content_settings_value(content,
10
+ :file_assign_do_not_show,
11
+ local_assigns.fetch(:options, {})),
12
+ options: local_assigns.fetch(:options, {}).to_json
13
+ ),
14
+ {
15
+ title: _t(:assign_file),
16
+ size: '780x585',
17
+ padding: false
18
+ },
19
+ {
20
+ class: 'assign_file',
21
+ title: _t(:assign_file)
22
+ }
23
+ ) %>
24
+
25
+ <div class="content_editor essence_file" id="<%= content.dom_id %>" data-content-id="<%= content.id %>">
26
+ <%= label_and_remove_link(content) %>
6
27
  <div class="file" id="file_<%= content.id %>">
7
28
  <div class="file_icon">
8
29
  <% if content.ingredient.nil? %>
9
- <%= link_to_dialog '',
10
- alchemy.admin_attachments_path(
11
- content_id: content.id,
12
- only: options[:file_assign_show_only],
13
- except: options[:file_assign_do_not_show],
14
- options: options.to_json
15
- ),
16
- {
17
- title: _t(:assign_file),
18
- size: '780x585',
19
- padding: false
20
- },
21
- class: 'assign_file',
22
- title: _t(:assign_file)
23
- %>
30
+ <%= dialog_link %>
24
31
  <% else %>
25
32
  <%= render_icon(content.ingredient.icon_css_class) %>
26
33
  <% end %>
27
34
  </div>
28
35
  <div class="file_name">
29
- <%= content.ingredient.name rescue ("&#x2190;" + _t(:assign_file_from_archive)).html_safe %>
36
+ <%= content.ingredient.try(:name) ||
37
+ ("&#x2190;" + _t(:assign_file_from_archive)).html_safe %>
30
38
  </div>
31
39
  <% unless content.ingredient.nil? %>
32
- <%= hidden_field_tag content.form_field_name(:attachment_id), content.ingredient.id %>
33
- <div class="essence_file_tools">
34
- <%= link_to_dialog '',
35
- alchemy.admin_attachments_path(
36
- content_id: content.id,
37
- only: options[:file_assign_show_only],
38
- except: options[:file_assign_do_not_show],
39
- options: options.to_json
40
- ),
41
- {
42
- title: _t(:assign_file),
43
- size: '780x585',
44
- padding: false
45
- },
46
- class: 'assign_file',
47
- title: _t(:assign_file)
48
- %>
49
- <%= link_to_dialog '',
50
- url_for(
51
- controller: 'essence_files',
52
- action: 'edit',
53
- options: options.to_json,
54
- id: content
55
- ),
56
- {
57
- title: _t(:edit_file_properties),
58
- size: '400x165'
59
- },
60
- class: 'edit_file',
61
- title: _t(:edit_file_properties)
62
- %>
63
- </div>
40
+ <%= hidden_field_tag content.form_field_name(:attachment_id),
41
+ content.ingredient.id %>
42
+ <div class="essence_file_tools">
43
+ <%= dialog_link %>
44
+ <%= link_to_dialog '',
45
+ url_for(
46
+ controller: 'essence_files',
47
+ action: 'edit',
48
+ options: local_assigns.fetch(:options, {}).to_json,
49
+ id: content
50
+ ),
51
+ {
52
+ title: _t(:edit_file_properties),
53
+ size: '400x165'
54
+ },
55
+ class: 'edit_file',
56
+ title: _t(:edit_file_properties) %>
57
+ </div>
64
58
  <% end %>
65
59
  </div>
66
60
  </div>
61
+ <% end %>
@@ -1,10 +1,10 @@
1
- <% cache(content) do %>
2
- <% if attachment = content.ingredient %>
1
+ <%- cache(content) do -%>
2
+ <%- if attachment = content.ingredient -%>
3
3
  <%= link_to(
4
4
  h(attachment.name),
5
5
  alchemy.download_attachment_path(attachment),
6
6
  class: "file_link #{content.essence.css_class.blank? ? "" : content.essence.css_class}",
7
7
  title: "#{content.essence.title.blank? ? attachment.file_name : content.essence.title}"
8
- ) %>
9
- <% end %>
10
- <% end %>
8
+ ) -%>
9
+ <%- end -%>
10
+ <%- end -%>
@@ -1,8 +1,9 @@
1
- <div class="content_editor essence_html_editor"<%= " style=\"float: left;\"" if options[:css_class] == "text_short" %>>
1
+ <% cache(content) do %>
2
+ <div class="content_editor essence_html_editor" data-content-id="<%= content.id %>">
2
3
  <%= label_and_remove_link(content) %>
3
4
  <%= text_area_tag(
4
5
  content.form_field_name,
5
- content.ingredient,
6
- :class => 'thin_border'
6
+ content.ingredient
7
7
  ) %>
8
- </div>
8
+ </div>
9
+ <% end %>
@@ -1,19 +1,21 @@
1
1
  <% cache(content) do %>
2
- <div class="content_editor essence_link" id="<%= content.dom_id %>">
3
- <label><%= render_content_name(content) %></label>
4
- <%= text_field_tag(
5
- '',
6
- content.ingredient,
7
- :class => "thin_border text_with_icon disabled",
8
- :name => nil,
9
- :id => nil,
10
- :disabled => true
11
- ) %>
12
- <%= hidden_field_tag content.form_field_name(:link), content.essence.link %>
13
- <%= hidden_field_tag content.form_field_name(:link_title), content.essence.link_title %>
14
- <%= hidden_field_tag content.form_field_name(:link_class_name), content.essence.link_class_name %>
15
- <%= hidden_field_tag content.form_field_name(:link_target), content.essence.link_target %>
16
- <%= render 'alchemy/essences/shared/linkable_essence_tools', :content => content %>
2
+ <div class="content_editor essence_link" id="<%= content.dom_id %>" data-content-id="<%= content.id %>">
3
+ <%= label_and_remove_link(content) %>
4
+ <%= text_field_tag '', content.ingredient,
5
+ class: "thin_border text_with_icon disabled",
6
+ name: nil,
7
+ id: nil,
8
+ disabled: true
9
+ %>
10
+ <%= hidden_field_tag content.form_field_name(:link),
11
+ content.essence.link %>
12
+ <%= hidden_field_tag content.form_field_name(:link_title),
13
+ content.essence.link_title %>
14
+ <%= hidden_field_tag content.form_field_name(:link_class_name),
15
+ content.essence.link_class_name %>
16
+ <%= hidden_field_tag content.form_field_name(:link_target),
17
+ content.essence.link_target %>
18
+ <%= render 'alchemy/essences/shared/linkable_essence_tools', content: content %>
17
19
  </div>
18
20
  <script type="text/javascript" charset="utf-8">
19
21
  $('#<%= content.form_field_id(:link) %>').on('change', function() {
@@ -1,7 +1,11 @@
1
- <% cache(content) do %>
2
- <% if content.ingredient %>
3
- <%- options[:text] ||= content.ingredient %>
4
- <%- html_options = { target: content.essence.link_target == "blank" ? "_blank" : nil }.merge(html_options) %>
5
- <%= link_to options[:text], content.ingredient, html_options -%>
6
- <% end %>
7
- <% end %>
1
+ <%- cache(content) do -%>
2
+ <%- if content.ingredient.present? -%>
3
+ <%- html_options = {
4
+ target: content.essence.link_target == "blank" ? "_blank" : nil
5
+ }.merge(local_assigns.fetch(:html_options, {})) -%>
6
+ <%= link_to(content.ingredient, html_options) do -%>
7
+ <%= content_settings_value(content, :text, local_assigns.fetch(:options, {})) ||
8
+ content.ingredient -%>
9
+ <%- end -%>
10
+ <%- end -%>
11
+ <%- end -%>
@@ -1,4 +1,5 @@
1
- <div id="<%= content.dom_id %>" class="essence_picture_editor<%= ' dragable_picture' if options[:dragable] %><%= ' content_editor' unless options[:grouped] %>">
1
+ <% cache(content) do %>
2
+ <div id="<%= content.dom_id %>" class="essence_picture_editor<%= ' dragable_picture' if options[:dragable] %><%= ' content_editor' unless options[:grouped] %>" data-content-id="<%= content.id %>">
2
3
  <% unless options[:grouped] %>
3
4
  <%= label_and_remove_link(content) %>
4
5
  <% end %>
@@ -35,7 +36,7 @@
35
36
  <% end %>
36
37
  </div>
37
38
  </div>
38
- <%- unless options[:css_class].blank? || content.essence.css_class.blank? -%>
39
+ <%- if content.essence.css_class.present? -%>
39
40
  <div class="essence_picture_css_class">
40
41
  <%= _t("alchemy.essence_pictures.css_classes.#{content.essence.css_class}", default: content.essence.css_class.camelcase) %>
41
42
  </div>
@@ -55,3 +56,4 @@
55
56
  <%= hidden_field_tag content.form_field_name(:link_class_name), content.essence.link_class_name %>
56
57
  <%= hidden_field_tag content.form_field_name(:link_target), content.essence.link_target %>
57
58
  </div>
59
+ <% end %>
@@ -1,3 +1,5 @@
1
1
  <% cache(content) do %>
2
- <%= render_essence_picture_view(content, options, html_options) %>
3
- <% end %>
2
+ <%= render_essence_picture_view content,
3
+ local_assigns.fetch(:options, {}),
4
+ local_assigns.fetch(:html_options, {}) %>
5
+ <% end %>
@@ -1,4 +1,5 @@
1
- <% cache(content) do %>
2
- <% options = local_assigns.fetch(:options, {}) %>
3
- <%= raw content.essence.send(options[:plain_text] ? :stripped_body : :body) %>
4
- <% end %>
1
+ <%- cache(content) do -%>
2
+ <%- options = local_assigns.fetch(:options, {}) -%>
3
+ <%- plain_text = !!content_settings_value(content, :plain_text, options) -%>
4
+ <%= raw content.essence.send(plain_text ? :stripped_body : :body) -%>
5
+ <%- end -%>
@@ -1,35 +1,25 @@
1
1
  <% cache(content) do %>
2
- <div class="content_editor essence_select<%= options[:display_inline].to_s == 'true' ? ' display_inline' : '' %>" id="<%= content.dom_id %>">
3
-
4
- <%= label_and_remove_link(content) %>
5
-
6
- <% if options[:select_values].nil? %>
7
-
8
- <%= warning('options[:select_values] is nil', "No select values given. Please provide :select_values as argument to render_essence_editor_by_name() helper inside this element editor view.") %>
9
-
10
- <% else %>
11
-
12
- <%
13
- if options[:select_values].is_a?(Hash)
14
- options_tags = grouped_options_for_select(
15
- options[:select_values],
16
- content.ingredient,
17
- ''
18
- )
19
- else
20
- options_tags = options_for_select(
21
- options[:select_values],
22
- content.ingredient
23
- )
24
- end
25
- %>
26
-
27
- <%= select_tag(content.form_field_name, options_tags, {
28
- :class => ["alchemy_selectbox", "essence_editor_select", html_options[:class]].join(' '),
29
- :style => html_options[:style]
30
- }) %>
31
-
32
- <% end %>
33
-
2
+ <%- select_values = content_settings_value(content,
3
+ :select_values, local_assigns.fetch(:options, {})) -%>
4
+
5
+ <div class="content_editor essence_select<%= options[:display_inline].to_s == 'true' ? ' display_inline' : '' %>" id="<%= content.dom_id %>" data-content-id="<%= content.id %>">
6
+ <%= label_and_remove_link(content) %>
7
+
8
+ <% if select_values.nil? %>
9
+ <%= warning(':select_values is nil', "<strong>No select values given.</strong><br>Please provide :<code>select_values</code> either as argument to <code>render_essence_editor</code> helper or as setting on the content definition in <code>elements.yml</code>.".html_safe) %>
10
+ <% else %>
11
+ <% if select_values.is_a?(Hash)
12
+ options_tags = grouped_options_for_select select_values,
13
+ content.ingredient, ''
14
+ else
15
+ options_tags = options_for_select select_values,
16
+ content.ingredient
17
+ end %>
18
+
19
+ <%= select_tag content.form_field_name, options_tags, {
20
+ class: ["alchemy_selectbox", "essence_editor_select", html_options[:class]].join(' '),
21
+ style: html_options[:style]
22
+ } %>
23
+ <% end %>
34
24
  </div>
35
25
  <% end %>
@@ -1,7 +1,8 @@
1
- <% cache(content) do %>
2
- <% options = local_assigns.fetch(:options, {}) %>
3
- <% html_options = local_assigns.fetch(:html_options, {}) %>
4
- <%- if content.essence.link.blank? || options[:disable_link] -%>
1
+ <%- cache(content) do -%>
2
+ <%- options = local_assigns.fetch(:options, {}) -%>
3
+ <%- html_options = local_assigns.fetch(:html_options, {}) -%>
4
+ <%- if content.essence.link.blank? ||
5
+ content_settings_value(content, :disable_link, options) -%>
5
6
  <%= content.ingredient -%>
6
7
  <%- else -%>
7
8
  <%= link_to(
@@ -12,6 +13,6 @@
12
13
  target: (content.essence.link_target == "blank" ? "_blank" : nil),
13
14
  'data-link-target' => content.essence.link_target
14
15
  }.merge(html_options)
15
- ) %>
16
+ ) -%>
16
17
  <%- end -%>
17
- <% end %>
18
+ <%- end -%>
@@ -1,4 +1,4 @@
1
- <% if options[:crop] && content.ingredient %>
1
+ <% if options[:crop] && content.ingredient && content.ingredient.can_be_cropped_to(options[:image_size], options[:upsample]) %>
2
2
  <%= link_to_dialog(
3
3
  render_icon('crop'),
4
4
  alchemy.crop_admin_essence_picture_path(content.essence, options: options.to_json),
@@ -14,7 +14,11 @@
14
14
  var Alchemy = {};
15
15
  // Setting TinyMCE path.
16
16
  var tinyMCEPreInit = {
17
- base: '<%= Rails.application.config.assets.prefix %>/tinymce',
17
+ <% if ActionController::Base.config.asset_host_set? %>
18
+ base: '<%= asset_url(assets_prefix + '/tinymce') %>',
19
+ <% else %>
20
+ base: '<%= asset_path(assets_prefix + '/tinymce') %>',
21
+ <% end %>
18
22
  suffix: '.min'
19
23
  };
20
24
  // Store regular expression for external link url matching.
@@ -92,8 +96,6 @@
92
96
  <script>
93
97
  // Store current locale for javascript translations.
94
98
  Alchemy.locale = '<%= ::I18n.locale %>';
95
- // Setting the correct locale for select2 dropdown replacement.
96
- $.extend($.fn.select2.defaults, $.fn.select2.locales['<%= ::I18n.locale %>']);
97
99
  </script>
98
100
  <%= yield(:javascripts) %>
99
101
  </body>
@@ -0,0 +1,3 @@
1
+ ActiveSupport::Inflector.inflections(:en) do |inflect|
2
+ inflect.acronym 'API'
3
+ end
@@ -94,7 +94,7 @@ SimpleForm.setup do |config|
94
94
  # config.item_wrapper_class = nil
95
95
 
96
96
  # How the label text should be generated altogether with the required text.
97
- config.label_text = lambda { |label, required| "#{label}#{required}" }
97
+ config.label_text = proc { |label, required| "#{label}#{required}" }
98
98
 
99
99
  # You can define the class to use on all labels. Default is nil.
100
100
  config.label_class = 'control-label'
@@ -501,7 +501,6 @@ en:
501
501
  last_upload: "from last upload"
502
502
  recent: "that where recently uploaded"
503
503
  without_tag: "without tag"
504
- pictures_in_page: "%{page} in %{pictures}"
505
504
  place_link: "Link text"
506
505
  player_version: "Flash Player version"
507
506
  "please enter subject and mail address": "Please enter recipient and subject."
@@ -36,6 +36,20 @@ Alchemy::Engine.routes.draw do
36
36
  resources :elements, :only => :show
37
37
  resources :contents, :only => :show
38
38
 
39
+ namespace :api, defaults: {format: 'json'} do
40
+ resources :contents, only: [:index, :show]
41
+ resources :elements, only: [:index, :show] do
42
+ get '/contents' => 'contents#index', as: 'contents'
43
+ get '/contents/:name' => 'contents#show', as: 'content'
44
+ end
45
+ resources :pages, only: [:index] do
46
+ get 'elements' => 'elements#index', as: 'elements'
47
+ get 'elements/:named' => 'elements#index', as: 'named_elements'
48
+ end
49
+ get '/pages/*urlname(.:format)' => 'pages#show', as: 'page'
50
+ get '/admin/pages/:id(.:format)' => 'pages#show', as: 'preview_page'
51
+ end
52
+
39
53
  namespace :admin do
40
54
 
41
55
  resources :contents do
@@ -156,6 +156,77 @@ EOF
156
156
  end
157
157
  end
158
158
 
159
+ namespace :export do
160
+ desc "Sends all data (Pictures, attachments and the database) to your remote machine."
161
+ task :all, :roles => [:app, :db] do
162
+ pictures
163
+ attachments
164
+ database
165
+ end
166
+
167
+ desc "Imports the server database into your local development machine."
168
+ task :database, :roles => [:db], :only => {:primary => true} do
169
+ if Capistrano::CLI.ui.agree('WARNING: This task will override your remote database. Do you want me to make a backup? (y/n)')
170
+ backup_database
171
+ export_database
172
+ else
173
+ if Capistrano::CLI.ui.agree('Are you sure? (y/n)')
174
+ export_database
175
+ else
176
+ backup_database
177
+ export_database
178
+ end
179
+ end
180
+ end
181
+
182
+ desc "Sends attachments to your remote machine using rsync."
183
+ task :attachments, :roles => [:app] do
184
+ send_files :attachments
185
+ end
186
+
187
+ desc "Sends pictures to your remote machine using rsync."
188
+ task :pictures, :roles => [:app] do
189
+ send_files :pictures
190
+ end
191
+
192
+ # Makes a backup of the remote database and stores it in db/ folder
193
+ def backup_database
194
+ Capistrano::CLI.ui.say('Backing up database')
195
+ timestamp = Time.now.strftime('%Y-%m-%d-%H-%M')
196
+ run "cd #{current_path} && #{rake} RAILS_ENV=#{fetch(:rails_env, 'production')} alchemy:db:dump DUMP_FILENAME=db/dump-#{timestamp}.sql"
197
+ end
198
+
199
+ # Sends the database via ssh to the server
200
+ def export_database
201
+ require 'spinner'
202
+ server = find_servers_for_task(current_task).first
203
+ spinner = Spinner.new
204
+ print "\n"
205
+ spinner.task("Exporting the database. Please wait...") do
206
+ system db_export_cmd(server)
207
+ end
208
+ spinner.spin!
209
+ end
210
+
211
+ # The actual export command that sends the data
212
+ def db_export_cmd(server)
213
+ import_cmd = "cd #{current_path} && #{rake} RAILS_ENV=#{fetch(:rails_env, 'production')} alchemy:db:import"
214
+ ssh_cmd = "ssh -p #{fetch(:port, 22)} #{user}@#{server} '#{import_cmd}'"
215
+ "#{database_dump_command(database_config['adapter'])} | #{ssh_cmd}"
216
+ end
217
+
218
+ # Sends files of given type via rsync to server
219
+ def send_files(type)
220
+ FileUtils.mkdir_p "./uploads/#{type}"
221
+ server = find_servers_for_task(current_task).first
222
+ if server
223
+ system "rsync --progress -rue 'ssh -p #{fetch(:port, 22)}' uploads/#{type} #{user}@#{server}:#{shared_path}/uploads/"
224
+ else
225
+ raise "No server found"
226
+ end
227
+ end
228
+ end
229
+
159
230
  end
160
231
 
161
232
  end