locomotivecms 3.0.0.pre.beta.1 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -3
  3. data/app/api/locomotive/api.rb +1 -0
  4. data/app/api/locomotive/api/entities/page_entity.rb +1 -1
  5. data/app/api/locomotive/api/entities/site_entity.rb +9 -1
  6. data/app/api/locomotive/api/exception_rescuers.rb +3 -5
  7. data/app/api/locomotive/api/forms/page_form.rb +1 -1
  8. data/app/api/locomotive/api/forms/site_form.rb +1 -2
  9. data/app/api/locomotive/api/helpers/authentication_helper.rb +6 -1
  10. data/app/api/locomotive/api/helpers/locales_helper.rb +15 -0
  11. data/app/api/locomotive/api/helpers/params_helper.rb +13 -0
  12. data/app/api/locomotive/api/middlewares/locale_middleware.rb +6 -1
  13. data/app/api/locomotive/api/resources/content_entry_resource.rb +2 -0
  14. data/app/api/locomotive/api/resources/content_type_resource.rb +2 -2
  15. data/app/api/locomotive/api/resources/current_site_resource.rb +2 -1
  16. data/app/api/locomotive/api/resources/membership_resource.rb +0 -4
  17. data/app/api/locomotive/api/resources/page_resource.rb +6 -1
  18. data/app/api/locomotive/api/resources/site_resource.rb +4 -2
  19. data/app/assets/javascripts/locomotive.js +1 -0
  20. data/app/assets/javascripts/locomotive/utils/nprogress.js.coffee +3 -1
  21. data/app/assets/javascripts/locomotive/views/editable_elements/index_view.js.coffee +10 -3
  22. data/app/assets/javascripts/locomotive/views/inputs/markdown_view.js.coffee +82 -0
  23. data/app/assets/javascripts/locomotive/views/inputs/rte/file_view.js.coffee +1 -1
  24. data/app/assets/javascripts/locomotive/views/inputs/rte/link_view.js.coffee +1 -1
  25. data/app/assets/javascripts/locomotive/views/inputs/rte_view.js.coffee.erb +1 -1
  26. data/app/assets/javascripts/locomotive/views/inputs/text_view.js.coffee +4 -1
  27. data/app/assets/javascripts/locomotive/views/pages/list_view.js.coffee +3 -0
  28. data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +22 -1
  29. data/app/assets/javascripts/locomotive/views/shared/header_view.js.coffee +2 -2
  30. data/app/assets/stylesheets/locomotive/application.scss +2 -0
  31. data/app/assets/stylesheets/locomotive/base/_form.scss +2 -0
  32. data/app/assets/stylesheets/locomotive/base/form/_api_key.scss +0 -1
  33. data/app/assets/stylesheets/locomotive/base/form/_array_input.scss +2 -0
  34. data/app/assets/stylesheets/locomotive/base/form/_base.scss +13 -2
  35. data/app/assets/stylesheets/locomotive/base/form/_color_input.scss +12 -0
  36. data/app/assets/stylesheets/locomotive/base/form/_markdown.scss +292 -0
  37. data/app/assets/stylesheets/locomotive/base/form/_popover.scss +22 -0
  38. data/app/assets/stylesheets/locomotive/base/form/_rte.scss +2 -1
  39. data/app/assets/stylesheets/locomotive/components/_activity_feed.scss +1 -0
  40. data/app/assets/stylesheets/locomotive/components/_dashboard.scss +29 -0
  41. data/app/assets/stylesheets/locomotive/components/_live_editing.scss +13 -1
  42. data/app/assets/stylesheets/locomotive/components/_main.scss +1 -1
  43. data/app/assets/stylesheets/locomotive/components/_transitions.scss +24 -3
  44. data/app/assets/stylesheets/locomotive/components/sidebar/_base.scss +1 -0
  45. data/app/assets/stylesheets/locomotive/globals/_bootstrap.scss +2 -2
  46. data/app/assets/stylesheets/locomotive/globals/_variables.scss +4 -3
  47. data/app/assets/stylesheets/locomotive/layouts/_live_editing.scss +4 -0
  48. data/app/controllers/locomotive/concerns/locale_helpers_controller.rb +1 -0
  49. data/app/controllers/locomotive/content_entries_controller.rb +10 -2
  50. data/app/controllers/locomotive/pages_controller.rb +2 -1
  51. data/app/controllers/locomotive/passwords_controller.rb +17 -1
  52. data/app/helpers/locomotive/base_helper.rb +19 -0
  53. data/app/helpers/locomotive/content_types_helper.rb +2 -1
  54. data/app/helpers/locomotive/custom_fields_helper.rb +14 -1
  55. data/app/helpers/locomotive/dashboard_helper.rb +12 -0
  56. data/app/helpers/locomotive/editable_elements_helper.rb +9 -4
  57. data/app/helpers/locomotive/pages_helper.rb +1 -14
  58. data/app/helpers/locomotive/shared/pages_helper.rb +17 -0
  59. data/app/helpers/locomotive/translations_helper.rb +0 -14
  60. data/app/inputs/locomotive/color_input.rb +18 -0
  61. data/app/inputs/locomotive/markdown_input.rb +19 -0
  62. data/app/models/locomotive/account.rb +2 -1
  63. data/app/models/locomotive/concerns/content_entry/file_size.rb +27 -0
  64. data/app/models/locomotive/concerns/content_type/group_by.rb +3 -1
  65. data/app/models/locomotive/concerns/page/layout.rb +63 -19
  66. data/app/models/locomotive/concerns/shared/site_scope.rb +37 -0
  67. data/app/models/locomotive/concerns/site/cache.rb +32 -0
  68. data/app/models/locomotive/concerns/theme_asset/plain_text.rb +85 -0
  69. data/app/models/locomotive/content_entry.rb +7 -7
  70. data/app/models/locomotive/content_type.rb +12 -6
  71. data/app/models/locomotive/page.rb +12 -14
  72. data/app/models/locomotive/site.rb +9 -3
  73. data/app/models/locomotive/snippet.rb +6 -4
  74. data/app/models/locomotive/theme_asset.rb +8 -73
  75. data/app/models/locomotive/translation.rb +6 -5
  76. data/app/policies/locomotive/site_policy.rb +2 -2
  77. data/app/services/locomotive/content_entry_service.rb +7 -6
  78. data/app/services/locomotive/site_service.rb +1 -0
  79. data/app/views/locomotive/content_entries/_entry.html.slim +1 -0
  80. data/app/views/locomotive/content_entries/edit.html.slim +1 -1
  81. data/app/views/locomotive/content_entries/new.html.slim +1 -1
  82. data/app/views/locomotive/current_site/_membership.html.slim +1 -0
  83. data/app/views/locomotive/current_site/edit.html.slim +1 -1
  84. data/app/views/locomotive/current_site/form/_access_points.html.slim +1 -1
  85. data/app/views/locomotive/current_site/form/_advanced.html.slim +2 -0
  86. data/app/views/locomotive/dashboard/_activity.html.slim +26 -0
  87. data/app/views/locomotive/dashboard/_url.html.slim +9 -0
  88. data/app/views/locomotive/dashboard/show.html.slim +3 -21
  89. data/app/views/locomotive/devise_mailer/reset_password_instructions.html.slim +1 -1
  90. data/app/views/locomotive/editable_elements/_edit.html.slim +8 -1
  91. data/app/views/locomotive/editable_elements/_form.html.slim +1 -1
  92. data/app/views/locomotive/editable_elements/index_without_preview.html.slim +24 -17
  93. data/app/views/locomotive/layouts/application.html.slim +6 -4
  94. data/app/views/locomotive/layouts/live_editing.html.slim +9 -0
  95. data/app/views/locomotive/layouts/not_logged_in.html.slim +1 -1
  96. data/app/views/locomotive/layouts/without_site.html.slim +2 -0
  97. data/app/views/locomotive/memberships/edit.html.slim +1 -1
  98. data/app/views/locomotive/memberships/new.html.slim +1 -1
  99. data/app/views/locomotive/my_account/edit.html.slim +7 -5
  100. data/app/views/locomotive/pages/_header.html.slim +7 -0
  101. data/app/views/locomotive/pages/edit.html.slim +2 -4
  102. data/app/views/locomotive/pages/form/_main.html.slim +4 -1
  103. data/app/views/locomotive/pages/form/_tabs.html.slim +4 -3
  104. data/app/views/locomotive/public_submission_accounts/_account.html.slim +1 -1
  105. data/app/views/locomotive/public_submission_accounts/edit.html.slim +1 -1
  106. data/app/views/locomotive/shared/_header.html.slim +25 -22
  107. data/app/views/locomotive/shared/_locale_picker_link.html.slim +3 -0
  108. data/app/views/locomotive/shared/_main_app_header.html.slim +1 -1
  109. data/app/views/locomotive/shared/_sidebar.html.slim +15 -11
  110. data/app/views/locomotive/shared/rte/_markdown_toolbar.html.slim +42 -0
  111. data/config/locales/admin_ui.en.yml +9 -4
  112. data/config/locales/default.en.yml +4 -0
  113. data/config/locales/devise.en.yml +1 -0
  114. data/config/locales/simple_form.en.yml +6 -2
  115. data/lib/locomotive/action_controller/responder.rb +5 -0
  116. data/lib/locomotive/engine.rb +5 -0
  117. data/lib/locomotive/middlewares/site.rb +39 -21
  118. data/lib/locomotive/simple_form.rb +3 -31
  119. data/lib/locomotive/steam/middlewares/cache.rb +62 -0
  120. data/lib/locomotive/steam/middlewares/page_editing.rb +9 -3
  121. data/lib/locomotive/steam/services/api_entry_submission_service.rb +6 -3
  122. data/lib/locomotive/steam/services/liquid_parser_with_cache_service.rb +74 -0
  123. data/lib/locomotive/steam_adaptor.rb +7 -1
  124. data/lib/locomotive/version.rb +1 -1
  125. data/lib/tasks/development.rake +4 -0
  126. data/lib/tasks/locomotive.rake +14 -0
  127. data/spec/lib/locomotive/steam/services/api_entry_submission_service_spec.rb +10 -1
  128. data/spec/lib/locomotive/steam/services/liquid_parser_with_cache_service_spec.rb +53 -0
  129. data/spec/models/locomotive/concerns/content_entry/file_size_spec.rb +40 -0
  130. data/spec/models/locomotive/concerns/page/layout_spec.rb +122 -17
  131. data/spec/models/locomotive/concerns/site/cache_spec.rb +60 -0
  132. data/spec/models/locomotive/content_entry_spec.rb +7 -0
  133. data/spec/models/locomotive/content_type_spec.rb +18 -11
  134. data/spec/models/locomotive/page_spec.rb +32 -8
  135. data/spec/models/locomotive/snippet_spec.rb +13 -4
  136. data/spec/models/locomotive/theme_asset_spec.rb +10 -3
  137. data/spec/models/locomotive/translation_spec.rb +28 -0
  138. data/spec/requests/locomotive/steam/cache_spec.rb +83 -0
  139. data/spec/requests/site_spec.rb +24 -0
  140. data/spec/support/capybara.rb +5 -13
  141. data/spec/support/factories.rb +9 -0
  142. data/spec/support/features/session_helpers.rb +19 -3
  143. data/spec/support/features/site_helpers.rb +27 -0
  144. data/spec/support/shared_examples/site_scope_examples.rb +27 -0
  145. data/vendor/assets/images/locomotive/bootstrap-colorpicker/alpha-horizontal.png +0 -0
  146. data/vendor/assets/images/locomotive/bootstrap-colorpicker/alpha.png +0 -0
  147. data/vendor/assets/images/locomotive/bootstrap-colorpicker/hue-horizontal.png +0 -0
  148. data/vendor/assets/images/locomotive/bootstrap-colorpicker/hue.png +0 -0
  149. data/vendor/assets/images/locomotive/bootstrap-colorpicker/saturation.png +0 -0
  150. data/vendor/assets/javascripts/locomotive/bootstrap-colorpicker.js +1 -0
  151. data/vendor/assets/javascripts/locomotive/datepicker_i18n.js.erb +6 -6
  152. data/vendor/assets/javascripts/locomotive/kramed.min.js +11 -0
  153. data/vendor/assets/stylesheets/locomotive/bootstrap-colorpicker.scss +9 -0
  154. metadata +59 -44
  155. data/app/controllers/locomotive/api/accounts_controller.rb +0 -60
  156. data/app/controllers/locomotive/api/base_controller.rb +0 -35
  157. data/app/controllers/locomotive/api/content_assets_controller.rb +0 -51
  158. data/app/controllers/locomotive/api/content_entries_controller.rb +0 -71
  159. data/app/controllers/locomotive/api/content_types_controller.rb +0 -52
  160. data/app/controllers/locomotive/api/current_site_controller.rb +0 -34
  161. data/app/controllers/locomotive/api/memberships_controller.rb +0 -52
  162. data/app/controllers/locomotive/api/my_account_controller.rb +0 -46
  163. data/app/controllers/locomotive/api/pages_controller.rb +0 -53
  164. data/app/controllers/locomotive/api/sites_controller.rb +0 -58
  165. data/app/controllers/locomotive/api/snippets_controller.rb +0 -52
  166. data/app/controllers/locomotive/api/theme_assets_controller.rb +0 -51
  167. data/app/controllers/locomotive/api/tokens_controller.rb +0 -36
  168. data/app/controllers/locomotive/api/translations_controller.rb +0 -51
  169. data/app/controllers/locomotive/api/version_controller.rb +0 -11
  170. data/spec/models/locomotive/editable_control_spec.rb +0 -79
  171. data/spec/models/locomotive/editable_file_spec.rb +0 -94
  172. data/spec/models/locomotive/editable_text_spec.rb +0 -219
  173. data/vendor/assets/images/select2-spinner.gif +0 -0
  174. data/vendor/assets/images/select2.png +0 -0
  175. data/vendor/assets/images/select2x2.png +0 -0
@@ -34,6 +34,28 @@
34
34
  }
35
35
  }
36
36
  }
37
+
38
+ &.select {
39
+ .form-wrapper {
40
+ border: none;
41
+ .form-control {
42
+ border-width: 3px;
43
+ height: 28px;
44
+ line-height: 28px;
45
+
46
+ .select2-choice {
47
+ padding-left: 0px;
48
+ height: 28px;
49
+ line-height: 14px;
50
+
51
+ .select2-arrow {
52
+ top: -8px;
53
+ height: 28px;
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
37
59
  }
38
60
  }
39
61
 
@@ -1,6 +1,6 @@
1
1
  .simple_form {
2
2
 
3
- fieldset .input.rte {
3
+ fieldset .input.rte, fieldset .input.markdown {
4
4
 
5
5
  .form-wrapper {
6
6
 
@@ -15,6 +15,7 @@
15
15
  font-size: $form_input_rte_command_font_size;
16
16
  color: $form_input_rte_command_color;
17
17
  margin-right: 6px;
18
+ cursor: pointer;
18
19
 
19
20
  &.wysihtml5-command-active {
20
21
  color: $form_input_rte_command_active_color;
@@ -5,6 +5,7 @@ $activity_feed_time_color: #949999;
5
5
  .activity-feed {
6
6
  list-style: none;
7
7
  border-left: 1px solid #ddd;
8
+ padding-top: 1px;
8
9
  padding-left: 50px;
9
10
 
10
11
  margin-left: 40px;
@@ -0,0 +1,29 @@
1
+ body.dashboard {
2
+
3
+ .main {
4
+ h3 {
5
+ color: $main_title_color;
6
+ font-size: 16px;
7
+
8
+ &.url {
9
+ strong {
10
+ display: inline-block;
11
+ margin-left: 10px;
12
+ font-size: 18px;
13
+ color: $paragraph_color;
14
+ font-weight: bold;
15
+ }
16
+ }
17
+
18
+ .btn {
19
+ margin-left: 10px;
20
+ }
21
+ }
22
+
23
+ .activity-feed {
24
+ margin-top: 30px;
25
+ }
26
+
27
+ }
28
+
29
+ }
@@ -1,5 +1,17 @@
1
1
  body.live-editing {
2
2
 
3
+ .slide-sidebar {
4
+ position: fixed;
5
+ background: #383838;
6
+ height: 100%;
7
+ width: $live_editing_expand_bar_width;
8
+ z-index: 999;
9
+
10
+ .bar {
11
+ @include control-window-button;
12
+ }
13
+ }
14
+
3
15
  .content .close-button, .content .expand-button {
4
16
  @include control-window-button;
5
17
  z-index: 995;
@@ -29,7 +41,7 @@ body.live-editing {
29
41
 
30
42
  .preview {
31
43
  border-left: $live_editing_content_width solid #fff;
32
- left: -$live_editing_content_width;
44
+ left: -$live_editing_content_width + $live_editing_expand_bar_width;
33
45
  }
34
46
 
35
47
  .content {
@@ -2,7 +2,7 @@
2
2
 
3
3
  background: $main_background_color;
4
4
 
5
- > .row:first-child, .header-row {
5
+ .header-row {
6
6
 
7
7
  padding: 20px 0px;
8
8
 
@@ -28,6 +28,27 @@ body.slide-right-sidebar {
28
28
 
29
29
  body.live-editing {
30
30
 
31
+ // SIDEBAR
32
+ .slide-sidebar {
33
+ .bar {
34
+ @include transition(opacity 0.3s ease-in-out);
35
+ }
36
+ .sidebar {
37
+ @include transform(translate3d(0, 0, 0));
38
+ @include transition(transform 0.2s ease-in-out);
39
+ }
40
+
41
+ &:hover {
42
+ .bar {
43
+ @include opacity(0);
44
+ }
45
+ .sidebar {
46
+ @include transform(translate3d($sidebar_width, 0, 0));
47
+ }
48
+ }
49
+ }
50
+
51
+
31
52
  // STATE: SHRINKED
32
53
 
33
54
  .content {
@@ -53,7 +74,7 @@ body.live-editing {
53
74
  // STATE: EXPANDED
54
75
 
55
76
  .content {
56
- @include transform(translate3d($live_editing_content_width - 2em, 0, 0));
77
+ @include transform(translate3d($live_editing_content_width - $live_editing_expand_bar_width, 0, 0));
57
78
 
58
79
  @include transition(transform 0.3s ease-in-out, background-color 0.1s ease-in-out 0.2s);
59
80
  > .inner {
@@ -66,8 +87,8 @@ body.live-editing {
66
87
  }
67
88
 
68
89
  .preview {
69
- @include transform(translate3d($live_editing_content_width - 2em, 0, 0));
70
- border-left-width: 2em;
90
+ @include transform(translate3d($live_editing_content_width - $live_editing_expand_bar_width, 0, 0));
91
+ border-left-width: $live_editing_expand_bar_width;
71
92
  @include transition(transform 0.3s ease-in-out);
72
93
  }
73
94
 
@@ -9,6 +9,7 @@
9
9
 
10
10
  section {
11
11
  border-bottom: 1px solid $sidebar_section_border_color;
12
+ -webkit-font-smoothing: subpixel-antialiased; // avoid thin fonts in Safari when the sidebar is sliding
12
13
 
13
14
  h1 {
14
15
  font-size: $sidebar_title_font_size;
@@ -464,8 +464,8 @@ $nav-tabs-active-link-hover-border-color: $brand-primary !default; // #5199
464
464
  // $state-info-bg: #d9edf7 !default;
465
465
  // $state-info-border: darken(adjust-hue($state-info-bg, -10), 7%) !default;
466
466
 
467
- $state-warning-text: #8a6d3b !default;
468
- $state-warning-bg: #fcf8e3 !default;
467
+ $state-warning-text: #8a6d3b !default; /*#8a6d3b !default;*/
468
+ $state-warning-bg: #fcf8e3 !default; /* #fcf8e3 !default; */
469
469
  // $state-warning-border: darken(adjust-hue($state-warning-bg, -10), 5%) !default;
470
470
 
471
471
  // $state-danger-text: #a94442 !default;
@@ -37,13 +37,14 @@ $drawer_background_color: white;
37
37
  $drawer_title_color: #666;
38
38
 
39
39
  $control_window_button_size: 30px;
40
- $control_window_button_color: #fff; //#333;
41
- $control_window_background_color: #333;
40
+ $control_window_button_color: #fff;
41
+ $control_window_background_color: #383838;
42
42
 
43
43
  $live_editing_content_width: 40em;
44
44
  $live_editing_content_border_color: $navbar-default-bg;
45
45
  $live_editing_content_background_color: #fff;
46
- $live_editing_content_alt_background_color: #333;
46
+ $live_editing_content_alt_background_color: #383838;
47
+ $live_editing_expand_bar_width: 2em;
47
48
 
48
49
  $form_input_background_color: #f7f7f7;
49
50
  $form_input_hovered_background_color: #f7f8d1;
@@ -1,5 +1,9 @@
1
1
  body.live-editing {
2
2
 
3
+ .slide-sidebar {
4
+
5
+ }
6
+
3
7
  .preview {
4
8
  position: absolute;
5
9
  top: 0px;
@@ -36,6 +36,7 @@ module Locomotive
36
36
  end
37
37
 
38
38
  def setup_i18n_fallbacks
39
+ ::Mongoid::Fields::I18n.clear_fallbacks
39
40
  (current_site.try(:locales) || []).each do |locale|
40
41
  ::Mongoid::Fields::I18n.fallbacks_for(locale, current_site.locale_fallbacks(locale))
41
42
  end
@@ -18,7 +18,7 @@ module Locomotive
18
18
 
19
19
  def index
20
20
  authorize ContentEntry
21
- @content_entries = service.all(params.slice(:page, :per_page, :q, :where))
21
+ @content_entries = service.all(list_params)
22
22
  respond_with @content_entries
23
23
  end
24
24
 
@@ -45,7 +45,7 @@ module Locomotive
45
45
  end
46
46
 
47
47
  def new
48
- @content_entry = @content_type.entries.build(params[:content_entry])
48
+ @content_entry = @content_type.entries.build(params[:content_entry] ? content_entry_params : {})
49
49
  respond_with @content_entry
50
50
  end
51
51
 
@@ -92,6 +92,14 @@ module Locomotive
92
92
  @service ||= Locomotive::ContentEntryService.new(load_content_type, current_locomotive_account)
93
93
  end
94
94
 
95
+ def list_params
96
+ if @content_type.order_manually?
97
+ params.slice(:q, :where).merge(no_pagination: true)
98
+ else
99
+ params.slice(:page, :per_page, :q, :where)
100
+ end
101
+ end
102
+
95
103
  def content_entry_params
96
104
  params.require(:content_entry).permit(service.permitted_attributes)
97
105
  end
@@ -25,6 +25,7 @@ module Locomotive
25
25
 
26
26
  def edit
27
27
  authorize @page
28
+ @page.find_layout
28
29
  respond_with @page
29
30
  end
30
31
 
@@ -53,7 +54,7 @@ module Locomotive
53
54
  end
54
55
 
55
56
  def page_params
56
- params.require(:page).permit(:title, :layout_id, :slug, :parent_id, :listed, :published, :redirect, :redirect_url, :redirect_type, :seo_title, :meta_description, :meta_keywords)
57
+ params.require(:page).permit(:title, :layout_id, :slug, :parent_id, :listed, :published, :redirect, :redirect_url, :redirect_type, :seo_title, :meta_description, :meta_keywords, :cache_enabled)
57
58
  end
58
59
 
59
60
  def service
@@ -3,17 +3,33 @@ module Locomotive
3
3
 
4
4
  include Locomotive::Concerns::WithinSiteController
5
5
 
6
- within_site_only_if_existing
6
+ within_site_only_if_existing true
7
7
 
8
8
  layout '/locomotive/layouts/not_logged_in'
9
9
 
10
10
  helper Locomotive::BaseHelper
11
11
 
12
+ before_filter :set_locale
13
+
14
+ def update
15
+ super do |resource|
16
+ if params[:locomotive_account].try(:[], 'password').blank?
17
+ resource.errors.add_on_blank(:password)
18
+ end
19
+ end
20
+ end
21
+
12
22
  private
13
23
 
14
24
  def after_sending_reset_password_instructions_path_for(resource_name)
15
25
  new_locomotive_account_session_path
16
26
  end
17
27
 
28
+ def set_locale
29
+ if current_site?
30
+ I18n.locale = current_site.accounts.first.locale
31
+ end
32
+ end
33
+
18
34
  end
19
35
  end
@@ -37,6 +37,7 @@ module Locomotive
37
37
  def locomotive_form_for(object, *args, &block)
38
38
  options = args.extract_options!
39
39
  options[:wrapper] = :locomotive
40
+ (options[:data] ||= {})[:blank_required_fields_message] = t(:blank_required_fields, scope: 'simple_form')
40
41
  simple_form_for(object, *(args << options.merge(builder: Locomotive::FormBuilder)), &block)
41
42
  end
42
43
 
@@ -220,5 +221,23 @@ module Locomotive
220
221
  end
221
222
  end
222
223
 
224
+ # cache keys
225
+
226
+ def cache_key_for_sidebar
227
+ "#{Locomotive::VERSION}/site/#{current_site._id}/sidebar/#{current_site.last_modified_at.to_i}/role/#{current_membership.role}/locale/#{::Mongoid::Fields::I18n.locale}"
228
+ end
229
+
230
+ def cache_key_for_sidebar_pages
231
+ count = current_site.pages.count
232
+ max_updated_at = current_site.pages.max(:updated_at).try(:utc).try(:to_s, :number).to_i
233
+ "#{Locomotive::VERSION}/site/#{current_site._id}/sidebar/pages-#{count}-#{max_updated_at}/locale/#{::Mongoid::Fields::I18n.locale}"
234
+ end
235
+
236
+ def cache_key_for_sidebar_content_types
237
+ count = current_site.content_types.count
238
+ max_updated_at = current_site.content_entries.max(:updated_at).try(:utc).try(:to_s, :number).to_i
239
+ "#{Locomotive::VERSION}/site/#{current_site._id}/sidebar/content_types-#{count}-#{max_updated_at}"
240
+ end
241
+
223
242
  end
224
243
  end
@@ -14,7 +14,8 @@ module Locomotive
14
14
  link = edit_content_entry_path(current_site, content_type.slug, entry)
15
15
 
16
16
  if content_type.entry_template.blank?
17
- link_to entry._label, link # default one
17
+ label = entry._label(content_type).presence || t(:untranslated, scope: 'locomotive.shared.list')
18
+ link_to label, link # default one
18
19
  else
19
20
  assigns = { 'site' => current_site, 'entry' => entry.to_liquid(content_type), 'link' => link, 'today' => Date.today, 'now' => Time.zone.now }
20
21
  registers = { site: current_site, locale: ::Mongoid::Fields::I18n.locale.to_s, services: Locomotive::Steam::Services.build_instance }
@@ -164,12 +164,25 @@ module Locomotive
164
164
  { as: :string }
165
165
  end
166
166
 
167
+ def color_custom_field_options(field, entry)
168
+ {
169
+ as: :color,
170
+ wrapper_html: { class: 'color' }
171
+ }
172
+ end
173
+
167
174
  def tags_custom_field_options(field, entry)
168
175
  { wrapper_html: { class: 'tags' } }
169
176
  end
170
177
 
171
178
  def text_custom_field_options(field, entry)
172
- { as: field.text_formatting ? :rte : :text }
179
+ type = case field.text_formatting
180
+ when 'html', nil, '' then :rte
181
+ when 'markdown' then :markdown
182
+ else :text
183
+ end
184
+
185
+ { as: type }
173
186
  end
174
187
 
175
188
  def custom_field_picker_options(field, slug)
@@ -1,6 +1,18 @@
1
1
  module Locomotive
2
2
  module DashboardHelper
3
3
 
4
+ def current_site_url
5
+ if current_site.domains.blank?
6
+ preview_url(current_site)
7
+ else
8
+ URI.join('http://' + current_site.domains.first).tap do |uri|
9
+ uri.port = request.port if request.port != 80 && request.port != 443
10
+ end.to_s
11
+ end
12
+ end
13
+
14
+ # Activity
15
+
4
16
  def activity_to_icon(activity)
5
17
  case activity.domain
6
18
  when 'site' then 'fa-cog'
@@ -10,6 +10,14 @@ module Locomotive
10
10
  end
11
11
  end
12
12
 
13
+ def editable_text_format_to_input_type(editable_element)
14
+ case editable_element.format
15
+ when 'html' then :rte
16
+ when 'markdown' then :markdown
17
+ else :text
18
+ end
19
+ end
20
+
13
21
  def editable_element_input_options(editable_element, index, options = {})
14
22
  {
15
23
  label: editable_element_label(editable_element),
@@ -33,10 +41,7 @@ module Locomotive
33
41
  end
34
42
 
35
43
  def nice_editable_elements_path
36
- _path = params[:preview_path] || current_site.localized_page_fullpath(@page, current_content_locale)
37
- _path = 'index' if _path.blank?
38
-
39
- truncate('/' + _path, length: 50)
44
+ preview_page_path(@page)
40
45
  end
41
46
 
42
47
  def options_for_page_blocks(blocks)
@@ -34,18 +34,9 @@ module Locomotive
34
34
  layouts = current_site.pages.layouts.map do |_layout|
35
35
  [_layout.title, _layout._id]
36
36
  end
37
- [[t(:no_layout, scope: 'locomotive.pages.form'), 'parent']] + layouts
37
+ @page.index? ? layouts : [[t(:no_layout, scope: 'locomotive.pages.form'), 'parent']] + layouts
38
38
  end
39
39
 
40
- # def options_for_page_response_type
41
- # [
42
- # ['HTML', 'text/html'],
43
- # ['RSS', 'application/rss+xml'],
44
- # ['XML', 'text/xml'],
45
- # ['JSON', 'application/json']
46
- # ]
47
- # end
48
-
49
40
  def options_for_page_redirect_type
50
41
  [
51
42
  [t('.redirect_type.permanent'), 301],
@@ -53,9 +44,5 @@ module Locomotive
53
44
  ]
54
45
  end
55
46
 
56
- # def page_response_type_to_string(page)
57
- # options_for_page_response_type.detect { |t| t.last == page.response_type }.try(:first) || '&mdash;'
58
- # end
59
-
60
47
  end
61
48
  end