locomotive_cms 2.0.0.rc6 → 2.0.0.rc7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/Gemfile +3 -1
  2. data/app/assets/javascripts/aloha/plugins/custom/locomotive_media/css/image.css +3 -0
  3. data/app/assets/javascripts/aloha/plugins/custom/locomotive_media/img/image.gif +0 -0
  4. data/app/assets/javascripts/aloha/plugins/custom/locomotive_media/lib/locomotive_media-plugin.js +96 -0
  5. data/app/assets/javascripts/aloha/plugins/custom/locomotive_media/nls/fr/i18n.js +1 -0
  6. data/app/assets/javascripts/aloha/plugins/custom/locomotive_media/nls/i18n.js +4 -0
  7. data/app/assets/javascripts/aloha/plugins/custom/locomotive_media/package.json +1 -0
  8. data/app/assets/javascripts/locomotive/aloha.js.coffee +1 -1
  9. data/app/assets/javascripts/locomotive/inline_editor.js.coffee +1 -0
  10. data/app/assets/javascripts/locomotive/utils/aloha_settings.js.coffee +5 -0
  11. data/app/assets/javascripts/locomotive/views/editable_elements/file_view.js.coffee +2 -1
  12. data/app/assets/javascripts/locomotive/views/inline_editor/application_view.js.coffee +6 -4
  13. data/app/assets/javascripts/locomotive/views/inline_editor/toolbar_view.js.coffee +2 -2
  14. data/app/assets/stylesheets/locomotive/backoffice/application.css.scss +0 -34
  15. data/app/assets/stylesheets/locomotive/backoffice/content_assets.css.scss +4 -0
  16. data/app/assets/stylesheets/locomotive/inline_editor.css +3 -0
  17. data/app/assets/stylesheets/locomotive/shared/common.css.scss +34 -0
  18. data/app/models/locomotive/extensions/page/editable_elements.rb +5 -0
  19. data/app/presenters/locomotive/content_asset_presenter.rb +2 -2
  20. data/app/views/locomotive/public/pages/show_toolbar.html.haml +3 -1
  21. data/config/locales/admin_ui.ru.yml +62 -43
  22. data/config/locales/default.ru.yml +6 -8
  23. data/config/locales/devise.ru.yml +10 -10
  24. data/config/locales/formtastic.ru.yml +20 -16
  25. data/lib/locomotive/dragonfly.rb +2 -0
  26. data/lib/locomotive/liquid/drops/content_entry.rb +2 -5
  27. data/lib/locomotive/liquid/drops/current_user.rb +21 -0
  28. data/lib/locomotive/liquid/tags/extends.rb +3 -1
  29. data/lib/locomotive/liquid/tags/inline_editor.rb +1 -1
  30. data/lib/locomotive/render.rb +3 -2
  31. data/lib/locomotive/version.rb +1 -1
  32. metadata +83 -75
data/Gemfile CHANGED
@@ -9,7 +9,9 @@ gemspec # Include gemspec dependencies
9
9
 
10
10
  group :development do
11
11
  # gem 'custom_fields', :path => '../gems/custom_fields' # for Developers
12
- gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => '2.0.0.rc' # Branch on Github
12
+ # gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => '2.0.0.rc' # Branch on Github
13
+
14
+ # gem 'locomotive-aloha-rails', :path => '../gems/aloha-rails' # for Developers
13
15
 
14
16
  gem 'rspec-rails', '~> 2.8.0' # In order to have rspec tasks and generators
15
17
  gem 'rspec-cells'
@@ -0,0 +1,3 @@
1
+ button.aloha-locomotive-media-insert {
2
+ background: url(../img/image.gif) !important;
3
+ }
@@ -0,0 +1,96 @@
1
+ define(
2
+ ['aloha/jquery', 'aloha/plugin', 'aloha/floatingmenu', 'i18n!aloha/nls/i18n', 'i18n!locomotive_media/nls/i18n', 'css!locomotive_media/css/image.css'],
3
+ function(aQuery, Plugin, FloatingMenu, i18nCore, i18n) {
4
+ var jQuery = aQuery;
5
+ var $ = aQuery;
6
+ var GENTICS = window.GENTICS, Aloha = window.Aloha;
7
+
8
+ return Plugin.create('locomotive_media', {
9
+ init: function() {
10
+ FloatingMenu.createScope(this.name, 'Aloha.continuoustext');
11
+
12
+ this._addUIInsertButton(i18nCore.t('floatingmenu.tab.insert'));
13
+ },
14
+
15
+ openDialog: function() {
16
+ var that = this;
17
+ var picker = window.parent.application_view.content_assets_picker_view;
18
+
19
+ picker.options.on_select = function(asset) {
20
+ if (asset.get('image') == true)
21
+ that.insertImg(asset);
22
+ else
23
+ that.insertLink(asset);
24
+
25
+ picker.close();
26
+ }
27
+
28
+ picker.render()
29
+ },
30
+
31
+ /**
32
+ * This method will insert a new image dom element into the dom tree
33
+ */
34
+ insertImg: function(asset) {
35
+ var range = Aloha.Selection.getRangeObject(),
36
+ imageUrl = asset.get('url'),
37
+ imagestyle, imagetag, newImg;
38
+
39
+ if (range.isCollapsed()) {
40
+ imagestyle = "max-width: " + asset.get('width') + "; max-height: " + asset.get('height');
41
+ imagetag = '<img style="'+ imagestyle + '" src="' + imageUrl + '" title="" />';
42
+ newImg = jQuery(imagetag);
43
+ GENTICS.Utils.Dom.insertIntoDOM(newImg, range, jQuery(Aloha.activeEditable.obj));
44
+ } else {
45
+ Aloha.Log.error('media cannot markup a selection');
46
+ }
47
+ },
48
+
49
+ /**
50
+ * This method will insert a new link dom element into the dom tree
51
+ */
52
+ insertLink: function(asset) {
53
+ var range = Aloha.Selection.getRangeObject(),
54
+ linkText = asset.get('filename'),
55
+ linkUrl = asset.get('url'),
56
+ linktag, newLink;
57
+
58
+ if (range.isCollapsed()) {
59
+ linktag = '<a href="' + linkUrl + '">' + linkText + '</a>';
60
+ newLink = jQuery(linktag);
61
+ GENTICS.Utils.Dom.insertIntoDOM(newLink, range, jQuery(Aloha.activeEditable.obj));
62
+ range.startContainer = range.endContainer = newLink.contents().get(0);
63
+ range.startOffset = 0;
64
+ range.endOffset = linkText.length;
65
+ } else {
66
+ linktag = '<a href="' + linkUrl + '"></a>';
67
+ newLink = jQuery(linktag);
68
+ GENTICS.Utils.Dom.addMarkup(range, newLink, false);
69
+ }
70
+ },
71
+
72
+ /**
73
+ * Adds the insert button to the floating menu
74
+ */
75
+ _addUIInsertButton: function(tabId) {
76
+ var that = this;
77
+ this.insertMediaButton = new Aloha.ui.Button({
78
+ 'name' : 'insertlocomotivemedia',
79
+ 'iconClass': 'aloha-button aloha-locomotive-media-insert',
80
+ 'size' : 'small',
81
+ 'onclick' : function () { that.openDialog(); },
82
+ 'tooltip' : i18n.t('button.addimg.tooltip'),
83
+ 'toggle' : false
84
+ });
85
+
86
+ FloatingMenu.addButton(
87
+ 'Aloha.continuoustext',
88
+ this.insertMediaButton,
89
+ tabId,
90
+ 1
91
+ );
92
+ },
93
+
94
+ });
95
+ }
96
+ );
@@ -0,0 +1 @@
1
+ define({ 'button.addimg.tooltip': 'insérer média' });
@@ -0,0 +1,4 @@
1
+ define({
2
+ root: { "button.addimg.tooltip": "insert media" },
3
+ fr: true
4
+ });
@@ -1,2 +1,2 @@
1
1
  #= require ./utils/aloha_settings
2
- #= require aloha
2
+ #= require aloha
@@ -12,6 +12,7 @@
12
12
  #= require_self
13
13
  #= require_tree ./utils
14
14
  #= require_tree ./models
15
+ #= require_tree ./views/content_assets
15
16
  #= require_tree ./views/inline_editor
16
17
 
17
18
  window.Locomotive =
@@ -23,6 +23,11 @@ window.Aloha.settings =
23
23
  editables:
24
24
  '.editable-short-text': [ ]
25
25
 
26
+ image:
27
+ ui:
28
+ insert: false
29
+ crop: false
30
+
26
31
  i18n:
27
32
  available: ['en', 'fr', 'pt-BR', 'es', 'de', 'no', 'ru', 'nl']
28
33
 
@@ -38,7 +38,8 @@ class Locomotive.Views.EditableElements.FileView extends Backbone.View
38
38
  on_change: =>
39
39
  @$('a:first').hide() & @$('input[type=file]').show() & @$('a.delete').hide()
40
40
  on_cancel: =>
41
- @$('a:first').show() & @$('input[type=file]').hide() & @$('a.delete').show()
41
+ @model.set(source: null)
42
+ @$('a:first').show() & @$('input[type=file]').val('').hide() & @$('a.delete').show()
42
43
 
43
44
  toggle_delete: (event) ->
44
45
  @_toggle event, 'delete',
@@ -1,8 +1,8 @@
1
- Locomotive.Views.InlinEditor ||= {}
1
+ Locomotive.Views.InlineEditor ||= {}
2
2
 
3
3
  #= require ./toolbar_view
4
4
 
5
- class Locomotive.Views.InlinEditor.ApplicationView extends Backbone.View
5
+ class Locomotive.Views.InlineEditor.ApplicationView extends Backbone.View
6
6
 
7
7
  el: 'body'
8
8
 
@@ -13,7 +13,9 @@ class Locomotive.Views.InlinEditor.ApplicationView extends Backbone.View
13
13
 
14
14
  _.bindAll(@, '_$')
15
15
 
16
- @toolbar_view = new Locomotive.Views.InlinEditor.ToolbarView(target: @iframe)
16
+ @toolbar_view = new Locomotive.Views.InlineEditor.ToolbarView(target: @iframe)
17
+
18
+ @content_assets_picker_view = new Locomotive.Views.ContentAssets.PickerView(collection: new Locomotive.Models.ContentAssetsCollection())
17
19
 
18
20
  render: ->
19
21
  super
@@ -74,7 +76,7 @@ class Locomotive.Views.InlinEditor.ApplicationView extends Backbone.View
74
76
  _jQuery('a').each ->
75
77
  link = _jQuery(this)
76
78
  url = link.attr('href')
77
- if url? && url.indexOf('#') != 0 && /^(www|http)/.exec(url) == null && /(\/_edit)$/.exec(url) == null
79
+ if url? && url.indexOf('#') != 0 && /^(www|http)/.exec(url) == null && /(\/_edit)$/.exec(url) == null && /^\/sites\//.exec(url) == null
78
80
  url = '/index' if url == '/'
79
81
 
80
82
  unless url.indexOf('_edit') > 0
@@ -1,6 +1,6 @@
1
- Locomotive.Views.InlinEditor ||= {}
1
+ Locomotive.Views.InlineEditor ||= {}
2
2
 
3
- class Locomotive.Views.InlinEditor.ToolbarView extends Backbone.View
3
+ class Locomotive.Views.InlineEditor.ToolbarView extends Backbone.View
4
4
 
5
5
  el: '#toolbar .inner'
6
6
 
@@ -33,24 +33,6 @@
33
33
 
34
34
  /* ___ list ___ */
35
35
 
36
- p.no-items {
37
- background: #fffbe6;
38
- border: 5px solid #eee3a8;
39
- @include border-radius(25px);
40
-
41
- padding: 15px 0px;
42
-
43
- text-align: center;
44
- color: #9d8963;
45
- font-size: 16px !important;
46
- @include single-text-shadow(rgba(255, 255, 255, 1), 1px, 1px, 1px);
47
-
48
- a {
49
- @include hover-link;
50
- color: #ff2900;
51
- }
52
- }
53
-
54
36
  ul.list {
55
37
  background: #fff;
56
38
  list-style: none;
@@ -346,19 +328,3 @@ p span.code {
346
328
  color: #8B8D9A;
347
329
  @include single-text-shadow(#fff, 0px, 0px, 1px);
348
330
  }
349
-
350
- /* ___ quick upload ___ */
351
-
352
- form.quick-upload {
353
- display: inline;
354
-
355
- input[type=file] {
356
- visibility: hidden;
357
- }
358
-
359
- }
360
-
361
-
362
-
363
-
364
-
@@ -6,6 +6,10 @@
6
6
 
7
7
  ul.content-assets {
8
8
 
9
+ list-style: none;
10
+ margin: 0px;
11
+ padding: 0px;
12
+
9
13
  li.asset {
10
14
  position: relative;
11
15
  float: left;
@@ -3,7 +3,10 @@
3
3
  * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
4
  * the top of the compiled file, but it's generally better to create a new file per style scope.
5
5
  *= require locomotive/blueprint/screen.css
6
+ *= require locomotive/jquery
6
7
  *= require locomotive/toggle.css
8
+ *= require locomotive/backoffice/dialog_changes.css
9
+ *= require locomotive/backoffice/content_assets.css
7
10
  *= require_tree ./shared
8
11
  *= require_tree ./inline_editor
9
12
  */
@@ -0,0 +1,34 @@
1
+ @import "compass/css3/border-radius";
2
+ @import "compass/css3/text-shadow";
3
+ @import "locomotive/shared/helpers";
4
+
5
+ /* ___ quick upload ___ */
6
+
7
+ form.quick-upload {
8
+ display: inline;
9
+
10
+ input[type=file] {
11
+ visibility: hidden;
12
+ }
13
+
14
+ }
15
+
16
+ /* ___ list ___ */
17
+
18
+ p.no-items {
19
+ background: #fffbe6;
20
+ border: 5px solid #eee3a8;
21
+ @include border-radius(25px);
22
+
23
+ padding: 15px 0px;
24
+
25
+ text-align: center;
26
+ color: #9d8963;
27
+ font-size: 16px !important;
28
+ @include single-text-shadow(rgba(255, 255, 255, 1), 1px, 1px, 1px);
29
+
30
+ a {
31
+ @include hover-link;
32
+ color: #ff2900;
33
+ }
34
+ }
@@ -71,6 +71,11 @@ module Locomotive
71
71
  new_el.copy_attributes_from(el)
72
72
  else
73
73
  existing_el.disabled = false
74
+
75
+ # only the type and hint properties can be modified from the parent element
76
+ %w(_type hint).each do |attr|
77
+ existing_el.send(:"#{attr}=", el.send(attr.to_sym))
78
+ end
74
79
  end
75
80
  end
76
81
  end
@@ -1,7 +1,7 @@
1
1
  module Locomotive
2
2
  class ContentAssetPresenter < BasePresenter
3
3
 
4
- delegate :content_type, :vignette_url, :to => :source
4
+ delegate :content_type, :width, :height, :vignette_url, :to => :source
5
5
 
6
6
  def full_filename
7
7
  self.source.source_filename
@@ -29,7 +29,7 @@ module Locomotive
29
29
  end
30
30
 
31
31
  def included_methods
32
- super + %w(full_filename filename short_name extname content_type content_type_text url vignette_url)
32
+ super + %w(full_filename filename short_name extname content_type content_type_text url vignette_url width height)
33
33
  end
34
34
 
35
35
  end
@@ -25,11 +25,13 @@
25
25
 
26
26
  $(document).ready(function() {
27
27
 
28
- window.application_view = new Locomotive.Views.InlinEditor.ApplicationView();
28
+ window.application_view = new Locomotive.Views.InlineEditor.ApplicationView();
29
29
  window.application_view.render();
30
30
 
31
31
  });
32
32
 
33
+ = render '/locomotive/content_assets/picker'
34
+
33
35
  %body
34
36
  #page
35
37
  %iframe{ :src => request.fullpath.gsub('_admin', '_edit'), :scrolling => 'no', :frameborder => '0' }
@@ -7,9 +7,22 @@ ru:
7
7
  new_item: "+ добавить"
8
8
  switch_to_site: Сайт
9
9
  delete: "Удалить"
10
+ close: "Закрыть"
11
+
12
+ locales:
13
+ en: Английский
14
+ de: Немецкий
15
+ fr: Французский
16
+ pt-BR: "Браз. - Португальский"
17
+ it: Итальянский
18
+ nl: Голландский
19
+ "no": Норвежский
20
+ es: Испанский
21
+ ru: Русский
10
22
 
11
23
  messages:
12
24
  confirm: Вы уверены ?
25
+ sending_form: Ваша форма отправляется
13
26
 
14
27
  shared:
15
28
  header:
@@ -27,6 +40,10 @@ ru:
27
40
  account: Аккаунт
28
41
  site: Сайт
29
42
  theme_assets: Файлы темы
43
+ form:
44
+ change_file: изменить
45
+ delete_file: удалить
46
+ cancel: отменить
30
47
  footer:
31
48
  who_is_behind: "Service developed by %{development} and designed by <a href=\"http://www.sachagreif.com\">Sacha Greif</a>"
32
49
  form_actions:
@@ -34,7 +51,9 @@ ru:
34
51
  create: Создать
35
52
  update: Сохранить
36
53
  send: Отправить
37
- disable_with: "locomotive.disable_with.form_actions"
54
+ disable_with: В ожидании...
55
+ list:
56
+ untranslated: непереведено
38
57
 
39
58
  errors:
40
59
  "500":
@@ -66,9 +85,15 @@ ru:
66
85
  delete_file: Удалить файл
67
86
  has_many:
68
87
  empty: Пусто
69
- index:
70
- is_required: является обязательным
88
+ new_entry: + Добавить новый элемент
89
+ many_to_many:
90
+ empty: Список пуст. Добавьте элемент из селекта ниже.
91
+ form:
92
+ required: Обязательное
93
+ optional: Опциональное
71
94
  default_label: Название поля
95
+ select_options:
96
+ ask_name: "Введите название элемента"
72
97
 
73
98
  sessions:
74
99
  new:
@@ -105,7 +130,9 @@ ru:
105
130
  help: "Заголовок страницы может быть изменен, если кликнуть на нем. Чтобы применить изменения, нажмите кнопку \"Сохранить\"."
106
131
  ask_for_title: "Пожалуйста введите новое имя страницы"
107
132
  form:
133
+ change_file: Изменить
108
134
  delete_file: Удалить файл
135
+ cancel: Отмена
109
136
  default_block: По умолчанию
110
137
  cache_strategy:
111
138
  none: Нет
@@ -134,11 +161,11 @@ ru:
134
161
  new:
135
162
  title: Новый сайт
136
163
  help: "Заполните форму, приведенную ниже, чтобы создать новый сайт."
164
+ domains:
165
+ empty: "Пока нет ни одного домена, привязанного к этому сайту. Просто добавьте домены ниже. <b>Не забудьте обновить ваши DNS.</b>"
137
166
 
138
167
  current_site:
139
168
  edit:
140
- export: экспорт
141
- import: импорт
142
169
  new_membership: добавить аккаунт
143
170
  help: "Название сайта может быть изменено, если кликнуть на нем. Чтобы применить изменения, нажмите кнопку \"Save\"."
144
171
  ask_for_name: "Пожалуйста введите новое имя сайта"
@@ -161,20 +188,13 @@ ru:
161
188
  edit:
162
189
  help: "Вы можете изменить логин просто кликнув на нем. Чтобы применить изменения, нажмите кнопку \"Сохранить\"."
163
190
  new_site: новый сайт
164
- en: Английский
165
- de: Немецкий
166
- fr: Французский
167
- pt-BR: "Бразильский - Португальский"
168
- it: Итальянский
169
- nl: Голландский
170
- "no": норвежский
171
- es: Испанский
172
191
  ask_for_name: "Пожалуйста введите ваш новый логин"
173
192
 
174
193
  theme_assets:
175
194
  index:
176
195
  title: Список файлов темы
177
196
  help: "Секция файлов темы это место, где вы можете управлять файлами, необходимыми для вашего шаблона, сниппетов и т.д. Если вам необходимо управление галереей изображений, создайте новый тип контента.<br/><b>Внимание:</b> вы можете не увидеть всех файлов - в зависимости от ваших прав."
197
+ quick_upload: Быстрая загрузка
178
198
  new: новый файл
179
199
  snippets: Сниппеты
180
200
  css_and_js: Стили и javascript
@@ -197,29 +217,29 @@ ru:
197
217
  picker_link: Вставить файл в код
198
218
  choose_file: Выбрать файл
199
219
  choose_plain_text: Выбрать простой текст
200
- images:
201
- title: Список изображений
202
- no_items: "Пока нет ни одного файла."
220
+ image_picker:
221
+ title: "Вставить изображение"
222
+ no_items: "Нет ни одного изображения."
223
+ upload: "Upload theme images"
203
224
 
204
- assets:
205
- new:
206
- title: Новый файл
207
- help: "Заполните форму, приведенную ниже, для создания файла (asset)."
208
- edit:
209
- title: Редактировать файл
210
- help: "Заполните форму, приведенную ниже, для изменения файла."
225
+ content_assets:
226
+ picker:
227
+ title: "Вставьте медиа-файл"
228
+ no_items: "Нет ни одного медиа-файла."
229
+ upload: "Загрузить медиа"
211
230
 
212
231
  content_types:
213
232
  index:
214
233
  new: новая модель
234
+ edit: редактировать модель
215
235
  new:
216
236
  title: Новая модель
217
237
  help: "Создайте ваши собственные модели данных (Проекты, Персоны, ...и т.д.). Модель должна иметь по крайней мере одно поле. Элементы, созданные из этого типа содержимого, будут иметь первое поле как обязательное."
218
238
  edit:
219
239
  title: Редактирование модели
220
240
  help: "Ваша модель должна иметь по крайней мере одно поле. Элементы, созданные из этого типа содержимого, будут иметь это поле как обязательное."
221
- show_items: смотреть элементы
222
- new_item: новый элемент
241
+ show_entries: смотреть элементы
242
+ new_entry: новый элемент
223
243
  form:
224
244
  order_by:
225
245
  created_at: 'По дате создания'
@@ -257,23 +277,6 @@ ru:
257
277
  title: Кроссдоменная аутентификация
258
278
  notice: Вы будете перенаправлены на вебсайт в течение нескольких секунд.
259
279
 
260
- import:
261
- new:
262
- title: Импортировать шаблон сайта
263
- help: "Будьте осторожны при загрузке нового шаблона для существующего сайта, ваши текущие данные могут быть изменены или даже удалены."
264
- show:
265
- title: Выполняется импорт
266
- help: "Ваш сайт обновляется из zip файла темы, который вы только что загрузили. Это займет несколько секунд."
267
- steps:
268
- site: Информация сайта
269
- content_types: Пользовательские типы содержимого
270
- assets: Файлы темы
271
- snippets: Сниппеты
272
- pages: Страницы
273
- messages:
274
- success: "Ваш сайт был успешно обновлен."
275
- failure: "Импорт не работает."
276
-
277
280
  installation:
278
281
  common:
279
282
  title: Первая установка Locomotive
@@ -289,5 +292,21 @@ ru:
289
292
  step_2:
290
293
  title: "Шаг 2/2 &mdash; Создайте первый сайт"
291
294
  explanations: "Если вы уже загрузили шаблон сайта по умолчанию (см. инструкцию), вы можете использовать его прямо сейчас. Или вы можете загрузить шаблон сайта как zip файл (доступные бесплатные шаблоны <a href=\"http://www.locomotivecms.com/support/themes\">здесь</a>)."
292
- back_to_default_template: "Нажмите <a href='#'>здесь</a> для выбора шаблона сайта по умолчанию"
295
+ default_site_locale: Локаль сайта по умолчанию
296
+ default_site_locales_hints: Вы всегда можете добавить больше локалей в разделе Настройки.
293
297
  next: Создать сайт
298
+
299
+ public:
300
+ pages:
301
+ show_toolbar:
302
+ statuses:
303
+ loading: "Загрузка...."
304
+ disabled: "Встроенный редактор отключен"
305
+ labels:
306
+ save_changes: "Сохранить изменения: "
307
+ editing_mode: "Режим редактирования: "
308
+ lang: "Язык: "
309
+ buttons:
310
+ back: Назад в админку
311
+ confirm: Подтвердить
312
+ cancel: Отменить