locomotive_cms 2.1.4 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/Gemfile +1 -5
  2. data/app/assets/images/locomotive/icons/flags/zh-CN.png +0 -0
  3. data/app/assets/javascripts/aloha/plugins/custom/inputcontrol/css/inputcontrol.css +3 -0
  4. data/app/assets/javascripts/aloha/plugins/custom/inputcontrol/lib/inputcontrol-plugin.js +94 -0
  5. data/app/assets/javascripts/aloha/plugins/custom/inputcontrol/package.json +1 -0
  6. data/app/assets/javascripts/locomotive.js +2 -1
  7. data/app/assets/javascripts/locomotive/models/content_type.js.coffee +6 -2
  8. data/app/assets/javascripts/locomotive/models/page.js.coffee +1 -1
  9. data/app/assets/javascripts/locomotive/models/site.js.coffee +1 -1
  10. data/app/assets/javascripts/locomotive/utils/aloha_settings.js.coffee +17 -7
  11. data/app/assets/javascripts/locomotive/utils/tinymce_settings.js.coffee +6 -0
  12. data/app/assets/javascripts/locomotive/views/application_view.js.coffee +13 -2
  13. data/app/assets/javascripts/locomotive/views/content_entries/_form_view.js.coffee +19 -2
  14. data/app/assets/javascripts/locomotive/views/content_entries/_popup_form_view.js.coffee +1 -1
  15. data/app/assets/javascripts/locomotive/views/content_entries/index_view.js.coffee +2 -2
  16. data/app/assets/javascripts/locomotive/views/content_types/_form_view.js.coffee +2 -1
  17. data/app/assets/javascripts/locomotive/views/content_types/custom_field_entry_view.js.coffee +3 -0
  18. data/app/assets/javascripts/locomotive/views/current_site/edit_view.js.coffee +2 -1
  19. data/app/assets/javascripts/locomotive/views/editable_elements/edit_all_view.js.coffee +3 -6
  20. data/app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee +47 -0
  21. data/app/assets/javascripts/locomotive/views/inline_editor/toolbar_view.js.coffee +1 -1
  22. data/app/assets/javascripts/locomotive/views/pages/_form_view.js.coffee +2 -1
  23. data/app/assets/javascripts/locomotive/views/pages/list_view.js.coffee +2 -2
  24. data/app/assets/javascripts/locomotive/views/shared/fields/belongs_to_view.js.coffee +32 -0
  25. data/app/assets/javascripts/locomotive/views/shared/fields/has_many_view.js.coffee +2 -2
  26. data/app/assets/javascripts/locomotive/views/shared/fields/many_to_many_view.js.coffee +2 -2
  27. data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +2 -0
  28. data/app/assets/javascripts/locomotive/views/snippets/_form_view.js.coffee +2 -1
  29. data/app/assets/javascripts/locomotive/views/theme_assets/_form_view.js.coffee +2 -1
  30. data/app/assets/javascripts/locomotive/views/theme_assets/index_view.js.coffee +0 -1
  31. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/es.js +1 -0
  32. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/et.js +1 -0
  33. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/it.js +1 -0
  34. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/ja.js +1 -0
  35. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/nb.js +1 -0
  36. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/nl.js +1 -0
  37. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/no.js +1 -0
  38. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/pl.js +1 -0
  39. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/pt.js +1 -0
  40. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/zh-cn.js +1 -0
  41. data/app/assets/stylesheets/locomotive.css +1 -0
  42. data/app/assets/stylesheets/locomotive/backoffice/codemirror_changes.css.scss +2 -0
  43. data/app/assets/stylesheets/locomotive/backoffice/formtastic_changes.css.scss +17 -3
  44. data/app/controllers/locomotive/content_entries_controller.rb +6 -2
  45. data/app/controllers/locomotive/public/content_entries_controller.rb +6 -0
  46. data/app/helpers/locomotive/base_helper.rb +8 -0
  47. data/app/helpers/locomotive/sites_helper.rb +6 -0
  48. data/app/models/locomotive/content_entry.rb +35 -5
  49. data/app/models/locomotive/content_type.rb +26 -8
  50. data/app/models/locomotive/editable_element.rb +15 -1
  51. data/app/models/locomotive/editable_file.rb +0 -2
  52. data/app/models/locomotive/editable_long_text.rb +3 -3
  53. data/app/models/locomotive/editable_short_text.rb +3 -64
  54. data/app/models/locomotive/editable_text.rb +84 -0
  55. data/app/models/locomotive/extensions/content_entry/csv.rb +7 -3
  56. data/app/models/locomotive/extensions/page/editable_elements.rb +3 -5
  57. data/app/models/locomotive/extensions/site/locales.rb +20 -0
  58. data/app/models/locomotive/extensions/site/timezone.rb +35 -0
  59. data/app/models/locomotive/site.rb +20 -16
  60. data/app/models/locomotive/theme_asset.rb +1 -1
  61. data/app/presenters/locomotive/content_entry_presenter.rb +1 -1
  62. data/app/presenters/locomotive/{editable_short_text_presenter.rb → editable_text_presenter.rb} +14 -2
  63. data/app/views/locomotive/current_site/_form.html.haml +1 -0
  64. data/app/views/locomotive/custom_fields/types/_belongs_to.html.haml +6 -5
  65. data/app/views/locomotive/pages/_editable_elements.html.haml +1 -1
  66. data/app/views/locomotive/shared/_head.html.haml +2 -0
  67. data/app/views/locomotive/shared/_main_app_head_before_backbone.html.haml +1 -0
  68. data/config/locales/admin_ui.de.yml +1 -0
  69. data/config/locales/admin_ui.en.yml +1 -0
  70. data/config/locales/admin_ui.et.yml +1 -0
  71. data/config/locales/admin_ui.fr.yml +1 -0
  72. data/config/locales/admin_ui.ja.yml +1 -0
  73. data/config/locales/admin_ui.nb.yml +2 -0
  74. data/config/locales/admin_ui.pl.yml +1 -0
  75. data/config/locales/admin_ui.pt-BR.yml +2 -1
  76. data/config/locales/admin_ui.ru.yml +24 -4
  77. data/config/locales/admin_ui.zh-CN.yml +347 -0
  78. data/config/locales/carrierwave.zh-CN.yml +4 -0
  79. data/config/locales/default.zh-CN.yml +116 -0
  80. data/config/locales/devise.nb.yml +1 -0
  81. data/config/locales/devise.zh-CN.yml +64 -0
  82. data/config/locales/flash.zh-CN.yml +115 -0
  83. data/config/locales/formtastic.en.yml +1 -0
  84. data/config/locales/formtastic.ru.yml +4 -1
  85. data/config/locales/formtastic.zh-CN.yml +112 -0
  86. data/features/backoffice/content_types/localized.feature +63 -0
  87. data/features/backoffice/pages.feature +3 -1
  88. data/features/backoffice/site.feature +7 -0
  89. data/features/public/contact_form.feature +11 -0
  90. data/features/public/content_entries.feature +13 -0
  91. data/features/public/pages.feature +24 -0
  92. data/features/step_definitions/page_steps.rb +6 -0
  93. data/features/step_definitions/web_steps.rb +24 -7
  94. data/lib/generators/locomotive/install/templates/locomotive.rb +2 -2
  95. data/lib/generators/locomotive/install/templates/mongoid.yml +23 -29
  96. data/lib/locomotive.rb +1 -4
  97. data/lib/locomotive/configuration.rb +3 -3
  98. data/lib/locomotive/dependencies.rb +1 -0
  99. data/lib/locomotive/engine.rb +2 -1
  100. data/lib/locomotive/liquid/drops/page.rb +1 -1
  101. data/lib/locomotive/liquid/filters/date.rb +3 -1
  102. data/lib/locomotive/liquid/filters/misc.rb +4 -0
  103. data/lib/locomotive/liquid/filters/text.rb +4 -0
  104. data/lib/locomotive/liquid/tags/editable.rb +1 -2
  105. data/lib/locomotive/liquid/tags/editable/text.rb +79 -0
  106. data/lib/locomotive/liquid/tags/inline_editor.rb +1 -1
  107. data/lib/locomotive/liquid/tags/link_to.rb +72 -13
  108. data/lib/locomotive/liquid/tags/with_scope.rb +3 -3
  109. data/lib/locomotive/middlewares.rb +0 -1
  110. data/lib/locomotive/mongoid/patches.rb +0 -16
  111. data/lib/locomotive/render.rb +1 -1
  112. data/lib/locomotive/version.rb +1 -1
  113. data/lib/tasks/locomotive.rake +15 -9
  114. data/mongodb/migrate/20130326201349_rename_entry_to_content_entry.rb +1 -1
  115. data/mongodb/migrate/20130621135025_create_editable_texts.rb +42 -0
  116. data/mongodb/migrate/20130627101548_localize_slugs_of_content_entries.rb +43 -0
  117. data/spec/dummy/config/initializers/locomotive.rb +1 -1
  118. data/spec/dummy/config/initializers/session_store.rb +1 -1
  119. data/spec/lib/locomotive/liquid/drops/page_spec.rb +1 -1
  120. data/spec/lib/locomotive/liquid/filters/misc_spec.rb +26 -0
  121. data/spec/lib/locomotive/liquid/tags/editable/text_spec.rb +85 -0
  122. data/spec/lib/locomotive/liquid/tags/link_to_spec.rb +111 -0
  123. data/spec/lib/locomotive/liquid/tags/with_scope_spec.rb +6 -0
  124. data/spec/models/locomotive/content_entry_spec.rb +27 -7
  125. data/spec/models/locomotive/{editable_short_text_spec.rb → editable_text_spec.rb} +53 -8
  126. data/spec/models/locomotive/extensions/page/editable_elements_spec.rb +6 -6
  127. data/spec/models/locomotive/site_spec.rb +52 -32
  128. data/vendor/assets/images/select2-spinner.gif +0 -0
  129. data/vendor/assets/images/select2.png +0 -0
  130. data/vendor/assets/images/select2x2.png +0 -0
  131. data/vendor/assets/javascripts/locomotive/liquid_mode.js +1 -1
  132. data/vendor/assets/javascripts/select2/select2.js +3054 -0
  133. data/vendor/assets/stylesheets/select2/select2.css.scss +652 -0
  134. metadata +77 -33
  135. data/app/assets/javascripts/locomotive/views/editable_elements/long_text_view.js.coffee +0 -36
  136. data/app/assets/javascripts/locomotive/views/editable_elements/short_text_view.js.coffee +0 -22
  137. data/app/presenters/locomotive/editable_long_text_presenter.rb +0 -5
  138. data/lib/locomotive/liquid/tags/editable/long_text.rb +0 -33
  139. data/lib/locomotive/liquid/tags/editable/short_text.rb +0 -41
  140. data/lib/locomotive/middlewares/fonts.rb +0 -42
  141. data/lib/locomotive/session_store.rb +0 -64
  142. data/spec/lib/locomotive/liquid/tags/editable/short_text_spec.rb +0 -46
  143. data/spec/models/locomotive/editable_long_text_spec.rb +0 -50
@@ -1,22 +0,0 @@
1
- Locomotive.Views.EditableElements ||= {}
2
-
3
- class Locomotive.Views.EditableElements.ShortTextView extends Backbone.View
4
-
5
- tagName: 'li'
6
-
7
- className: 'text input short'
8
-
9
- render: ->
10
- $(@el).html(ich.editable_text_input(@model.toJSON()))
11
-
12
- @$('textarea').bind 'keyup', (event) =>
13
- input = $(event.target)
14
- @model.set(content: input.val())
15
-
16
- return @
17
-
18
- after_render: ->
19
- # do nothing
20
-
21
- refresh: ->
22
- # do nothing
@@ -1,5 +0,0 @@
1
- module Locomotive
2
- class EditableLongTextPresenter < EditableShortTextPresenter
3
-
4
- end
5
- end
@@ -1,33 +0,0 @@
1
- module Locomotive
2
- module Liquid
3
- module Tags
4
- module Editable
5
- class LongText < ShortText
6
-
7
- protected
8
-
9
- def render_element(context, element)
10
- content = element.default_content? ? render_default_content(context) : element.content
11
-
12
- if editable?(context, element)
13
- %{
14
- <div class='editable-long-text' data-element-id='#{element.id}' data-element-index='#{element._index}'>
15
- #{content}
16
- </div>
17
- }
18
- else
19
- content
20
- end
21
- end
22
-
23
- def document_type
24
- EditableLongText
25
- end
26
-
27
- end
28
-
29
- ::Liquid::Template.register_tag('editable_long_text', LongText)
30
- end
31
- end
32
- end
33
- end
@@ -1,41 +0,0 @@
1
- module Locomotive
2
- module Liquid
3
- module Tags
4
- module Editable
5
- class ShortText < Base
6
-
7
- protected
8
-
9
- def render_element(context, element)
10
- content = element.default_content? ? render_default_content(context) : element.content
11
-
12
- if editable?(context, element)
13
- %{
14
- <span class='editable-short-text' data-element-id='#{element.id}' data-element-index='#{element._index}'>
15
- #{content}
16
- </span>
17
- }
18
- else
19
- content
20
- end
21
- end
22
-
23
- def document_type
24
- EditableShortText
25
- end
26
-
27
- def editable?(context, element)
28
- context.registers[:inline_editor] && (!element.fixed? || (element.fixed? && !element.from_parent?))
29
- end
30
-
31
- def default_element_attributes
32
- super.merge(content_from_default: self.render_default_content(nil))
33
- end
34
-
35
- end
36
-
37
- ::Liquid::Template.register_tag('editable_short_text', ShortText)
38
- end
39
- end
40
- end
41
- end
@@ -1,42 +0,0 @@
1
- module Locomotive
2
- module Middlewares
3
- class Fonts
4
-
5
- def initialize(app, opts = {})
6
- @app = app
7
- @path_regexp = opts[:path] || %r{^/fonts/}
8
- @expires_in = opts[:expires_in] || 24.hour # varnish
9
- end
10
-
11
- def call(env)
12
- if env["PATH_INFO"] =~ @path_regexp
13
- if Locomotive.config.multi_sites?
14
- site = fetch_site(env['SERVER_NAME'])
15
- else
16
- site = Site.first
17
- end
18
-
19
- if site.nil?
20
- @app.call(env)
21
- else
22
- body = ThemeAssetUploader.build(site, env['PATH_INFO']).read.to_s
23
-
24
- [200, { 'Cache-Control' => "public; max-age=#{@expires_in}" }, [body]]
25
- end
26
- else
27
- @app.call(env)
28
- end
29
- end
30
-
31
- protected
32
-
33
- def fetch_site(domain_name)
34
- site_id = Rails.cache.fetch(domain_name, expires_in: @expires_in) do
35
- Site.match_domain(domain_name).only(:id).first._id.to_s rescue ''
36
- end
37
-
38
- site_id.blank? ? nil : Site.new.tap { |site| site._id = site_id }
39
- end
40
- end
41
- end
42
- end
@@ -1,64 +0,0 @@
1
- module ActionDispatch
2
- module Session
3
- class MongoidStore < AbstractStore
4
-
5
- class Session
6
- include Mongoid::Document
7
- include Mongoid::Timestamps
8
-
9
- field :data, type: String, default: [Marshal.dump({})].pack("m*")
10
-
11
- index updated_at: 1
12
- end
13
-
14
- # The class used for session storage.
15
- cattr_accessor :session_class
16
- self.session_class = Session
17
-
18
- SESSION_RECORD_KEY = 'rack.session.record'.freeze
19
-
20
- private
21
- def generate_sid
22
- Moped::BSON::ObjectId.new
23
- end
24
-
25
- def get_session(env, sid)
26
- sid ||= generate_sid
27
- session = find_session(sid)
28
- env[SESSION_RECORD_KEY] = session
29
- [sid, unpack(session.data)]
30
- end
31
-
32
- def set_session(env, sid, session_data, options)
33
- record = env[SESSION_RECORD_KEY] ||= find_session(sid)
34
- record.data = pack(session_data)
35
- # Rack spec dictates that set_session should return true or false
36
- # depending on whether or not the session was saved or not.
37
- # However, ActionPack seems to want a session id instead.
38
- record.save ? sid : false
39
- end
40
-
41
- def find_session(id)
42
- id = Moped::BSON::ObjectId.from_string(id.to_s)
43
- @@session_class.where(_id: id).first || @@session_class.new(id: id)
44
- end
45
-
46
- def pack(data)
47
- [Marshal.dump(data)].pack("m*")
48
- end
49
-
50
- def unpack(packed)
51
- return nil unless packed
52
- Marshal.load(packed.unpack("m*").first)
53
- end
54
-
55
- def destroy(env)
56
- session = @@session_class.first(conditions: { _id: env[SESSION_RECORD_KEY].id })
57
- session.try(:destroy)
58
-
59
- env[SESSION_RECORD_KEY] = nil
60
- end
61
-
62
- end
63
- end
64
- end
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Locomotive::Liquid::Tags::Editable::ShortText do
4
-
5
- it 'accepts a valid syntax' do
6
- markup = "'title', hint: 'Simple short text'"
7
- lambda do
8
- Locomotive::Liquid::Tags::Editable::ShortText.new('editable_short_text', markup, ["{% endeditable_short_text %}"], {})
9
- end.should_not raise_error
10
- end
11
-
12
- it 'requires a slug' do
13
- lambda do
14
- Locomotive::Liquid::Tags::Editable::ShortText.new('editable_short_text', '', ["{% endeditable_short_text %}"], {})
15
- end.should raise_error(::Liquid::SyntaxError, "Syntax Error in 'editable_xxx' - Valid syntax: editable_xxx <slug>(, <options>)")
16
- end
17
-
18
- describe '#default_element_attributes' do
19
-
20
- before(:each) do
21
- markup = "'title', hint: 'Simple short text'"
22
- @tag = Locomotive::Liquid::Tags::Editable::ShortText.new('editable_short_text', markup, ["{% endeditable_short_text %}"], {})
23
- end
24
-
25
- it 'returns a hash' do
26
- attributes = @tag.send(:default_element_attributes)
27
- attributes[:slug].should == 'title'
28
- attributes[:hint].should == 'Simple short text'
29
- attributes[:_type].should == 'Locomotive::EditableShortText'
30
- end
31
-
32
- it 'stores the default content' do
33
- @tag.instance_variable_set(:@nodelist, ['Lorem ipsum'])
34
- @tag.send(:default_element_attributes)[:content_from_default].should == 'Lorem ipsum'
35
- end
36
-
37
- it 'raises an exception if the default content contains liquid tags' do
38
- @tag.instance_variable_set(:@nodelist, ['hello ', ::Liquid::Variable.new("{{ 'world' }}")])
39
- lambda do
40
- @tag.send(:default_element_attributes)
41
- end.should raise_error(::Liquid::SyntaxError, "Error in the default block for the title editable_element - No liquid tags are allowed inside.")
42
- end
43
-
44
- end
45
-
46
- end
@@ -1,50 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Locomotive::EditableLongText do
4
-
5
- before(:each) do
6
- @site = FactoryGirl.create(:site)
7
- @home = @site.pages.root.first
8
-
9
- @home.update_attributes raw_template: "{% block body %}{% editable_long_text 'body' %}Lorem ipsum{% endeditable_long_text %}{% endblock %}"
10
-
11
- @sub_page_1 = FactoryGirl.create(:page, slug: 'sub_page_1', parent: @home, raw_template: "{% extends 'parent' %}")
12
- end
13
-
14
- it 'exists' do
15
- @sub_page_1.editable_elements.size.should == 1
16
- end
17
-
18
- it 'has a non-nil slug' do
19
- @sub_page_1.editable_elements.first.slug.should == 'body'
20
- end
21
-
22
- it 'has a default content at first' do
23
- @sub_page_1.editable_elements.first.default_content.should be_true
24
- @sub_page_1.editable_elements.first.content.should == 'Lorem ipsum'
25
- end
26
-
27
- it 'is still default when it gets modified by the exact same value' do
28
- @sub_page_1.editable_elements.first.content = 'Lorem ipsum'
29
- @sub_page_1.editable_elements.first.default_content.should be_true
30
- end
31
-
32
- describe 'when modifying the raw template' do
33
-
34
- it 'can update its content from the raw template if the user has not modified it' do
35
- @home.update_attributes raw_template: "{% block body %}{% editable_long_text 'body' %}Lorem ipsum v2{% endeditable_long_text %}{% endblock %}"
36
- @home.editable_elements.first.default_content.should be_true
37
- @home.editable_elements.first.content.should == 'Lorem ipsum v2'
38
- end
39
-
40
- it 'does not touch the content if the user has modified it before' do
41
- @home.editable_elements.first.content = 'Hello world'
42
- @home.raw_template = "{% block body %}{% editable_long_text 'body' %}Lorem ipsum v2{% endeditable_long_text %}{% endblock %}"
43
- @home.save
44
- @home.editable_elements.first.default_content.should be_false
45
- @home.editable_elements.first.content.should == 'Hello world'
46
- end
47
-
48
- end
49
-
50
- end