comfortable_mexican_sofa 1.2.8 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/Gemfile +1 -1
  2. data/README.md +1 -1
  3. data/VERSION +1 -1
  4. data/app/assets/javascripts/comfortable_mexican_sofa/application.js +3 -3
  5. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.cms.js +1 -1
  6. data/app/assets/stylesheets/comfortable_mexican_sofa/structure.css +1 -1
  7. data/app/controllers/cms_admin/base_controller.rb +22 -25
  8. data/app/controllers/cms_admin/layouts_controller.rb +21 -21
  9. data/app/controllers/cms_admin/pages_controller.rb +29 -29
  10. data/app/controllers/cms_admin/revisions_controller.rb +6 -6
  11. data/app/controllers/cms_admin/sites_controller.rb +21 -20
  12. data/app/controllers/cms_admin/snippets_controller.rb +19 -20
  13. data/app/controllers/cms_admin/uploads_controller.rb +6 -6
  14. data/app/controllers/cms_content_controller.rb +30 -16
  15. data/app/models/cms/layout.rb +2 -9
  16. data/app/models/cms/site.rb +11 -6
  17. data/app/views/cms_admin/layouts/_form.html.erb +6 -6
  18. data/app/views/cms_admin/layouts/_index_branch.html.erb +10 -10
  19. data/app/views/cms_admin/layouts/edit.html.erb +6 -5
  20. data/app/views/cms_admin/layouts/index.html.erb +3 -3
  21. data/app/views/cms_admin/layouts/new.html.erb +3 -3
  22. data/app/views/cms_admin/pages/_form.html.erb +11 -11
  23. data/app/views/cms_admin/pages/_form_blocks.html.erb +3 -4
  24. data/app/views/cms_admin/pages/_index_branch.html.erb +15 -15
  25. data/app/views/cms_admin/pages/edit.html.erb +6 -5
  26. data/app/views/cms_admin/pages/index.html.erb +4 -4
  27. data/app/views/cms_admin/pages/new.html.erb +3 -3
  28. data/app/views/cms_admin/pages/toggle_branch.js.erb +3 -3
  29. data/app/views/cms_admin/revisions/show.html.erb +4 -4
  30. data/app/views/cms_admin/sites/_form.html.erb +5 -2
  31. data/app/views/cms_admin/sites/_mirrors.html.erb +6 -6
  32. data/app/views/cms_admin/sites/edit.html.erb +3 -3
  33. data/app/views/cms_admin/sites/index.html.erb +9 -9
  34. data/app/views/cms_admin/sites/new.html.erb +3 -3
  35. data/app/views/cms_admin/snippets/_form.html.erb +3 -3
  36. data/app/views/cms_admin/snippets/edit.html.erb +5 -5
  37. data/app/views/cms_admin/snippets/index.html.erb +9 -9
  38. data/app/views/cms_admin/snippets/new.html.erb +3 -3
  39. data/app/views/cms_admin/uploads/_file.html.erb +1 -1
  40. data/app/views/cms_admin/uploads/_index.html.erb +2 -2
  41. data/app/views/cms_admin/uploads/destroy.js.erb +1 -1
  42. data/app/views/layouts/cms_admin/_head.html.erb +2 -0
  43. data/app/views/layouts/cms_admin/_left.html.erb +6 -6
  44. data/comfortable_mexican_sofa.gemspec +10 -6
  45. data/config/boot.rb +3 -10
  46. data/config/initializers/comfortable_mexican_sofa.rb +14 -22
  47. data/config/locales/en.yml +179 -4
  48. data/config/locales/es.yml +179 -0
  49. data/config/routes.rb +25 -27
  50. data/db/migrate/01_create_cms.rb +8 -1
  51. data/db/migrate/upgrades/04_upgrade_to_1_3_0.rb +23 -0
  52. data/lib/comfortable_mexican_sofa/configuration.rb +15 -19
  53. data/lib/comfortable_mexican_sofa/fixtures.rb +12 -3
  54. data/lib/comfortable_mexican_sofa/form_builder.rb +7 -6
  55. data/lib/comfortable_mexican_sofa/is_mirrored.rb +9 -11
  56. data/lib/comfortable_mexican_sofa/tags/asset.rb +2 -2
  57. data/test/fixtures/cms/sites.yml +3 -1
  58. data/test/functional/cms_admin/base_controller_test.rb +18 -0
  59. data/test/functional/cms_admin/layouts_controller_test.rb +20 -19
  60. data/test/functional/cms_admin/pages_controller_test.rb +73 -71
  61. data/test/functional/cms_admin/revisions_controller_test.rb +23 -20
  62. data/test/functional/cms_admin/sites_controller_test.rb +8 -8
  63. data/test/functional/cms_admin/snippets_controller_test.rb +17 -16
  64. data/test/functional/cms_admin/uploads_controller_test.rb +3 -3
  65. data/test/integration/authentication_test.rb +4 -4
  66. data/test/integration/fixtures_test.rb +1 -1
  67. data/test/integration/mirrors_test.rb +15 -18
  68. data/test/integration/routing_extensions_test.rb +4 -19
  69. data/test/integration/sites_test.rb +67 -48
  70. data/test/test_helper.rb +26 -6
  71. data/test/unit/configuration_test.rb +5 -5
  72. data/test/unit/form_builder_test.rb +69 -0
  73. data/test/unit/mirrors_test.rb +2 -6
  74. data/test/unit/models/site_test.rb +30 -3
  75. metadata +55 -56
@@ -0,0 +1,179 @@
1
+ # encoding: utf-8
2
+ es:
3
+ # -- Models ---------------------------------------------------------------
4
+ attributes:
5
+ label: Nombre
6
+ slug: Identificador
7
+ parent_id: Padre
8
+ content: Contenido
9
+ activerecord:
10
+ models:
11
+ cms/site: Sitio
12
+ cms/layout: Plantilla
13
+ cms/page: Página
14
+ cms/snippet: Fragmento
15
+ attributes:
16
+ cms/site:
17
+ hostname: Dirección
18
+ path: Ruta
19
+ locale: Lengua
20
+ is_mirrored: Espejo
21
+ cms/layout:
22
+ label: Nombre de Plantilla
23
+ app_layout: Plantilla Base
24
+ parent_id: Plantilla Padre
25
+ css: Hoja de Estilo
26
+ js: Javascript
27
+ cms/page:
28
+ label: Título
29
+ layout_id: Plantilla
30
+ slug: Ruta
31
+ target_page_id: Redirigir a
32
+ is_published: Publicada
33
+
34
+ # -- Controllers ----------------------------------------------------------
35
+ cms:
36
+ base:
37
+ site_not_found: Sitio no encontrado
38
+ fixtures_enabled: CMS Fixtures habilitadas. Todos los cambios realizados serán descartados.
39
+
40
+ sites:
41
+ created: Sitio creado
42
+ creation_failure: El sitio no ha podido ser creado
43
+ updated: Sitio actualizado
44
+ update_failure: El sitio no ha podido ser actualizado
45
+ deleted: Sitio eliminado
46
+ not_found: Sitio no encontrado
47
+
48
+ layouts:
49
+ created: Diseño Creado
50
+ creation_failure: El diseño NO ha podido ser Creado
51
+ updated: Diseño Actualizado"
52
+ update_failure: El diseño NO ha podido ser Actualizado
53
+ deleted: Diseñó Eliminado
54
+ not_found: Diseño no encontrado
55
+
56
+ pages:
57
+ created: Página creada
58
+ creation_failure: La página no ha podido ser creada
59
+ updated: Página actualizada
60
+ update_failure: La página no ha podido ser actualizada
61
+ deleted: Página eliminada
62
+ not_found: Página no encontrada
63
+ layout_not_found: No se ha encontrado una plantilla. Cree una primero.
64
+
65
+ snippets:
66
+ created: Fragmento creado
67
+ creation_failure: El fragmento no ha podido ser creado
68
+ updated: Fragmento actualizado
69
+ update_failure: El fragmento no ha podido ser actualizado
70
+ deleted: Fragmento eliminado
71
+ not_found: Fragmento no encontrado
72
+
73
+ revisions:
74
+ reverted: Contenido revertido
75
+ record_not_found: Registro no encontrado
76
+ not_found: Revisión no encontrada
77
+
78
+ uploads:
79
+
80
+ content:
81
+ site_not_found: Sitio no encontrado
82
+ layout_not_found: Diseño no encontrado
83
+ page_not_found: Página no encontrada
84
+
85
+ # -- Views ----------------------------------------------------------------
86
+ cms_admin:
87
+ base:
88
+ sites: Sitios
89
+ layouts: Diseños
90
+ pages: Páginas
91
+ snippets: Fragmentos
92
+
93
+ sites:
94
+ index:
95
+ title: Listado de Sitios
96
+ new_link: Crear nuevo Sitio
97
+ edit: Editar
98
+ delete: Eliminar
99
+ are_you_sure: ¿Está seguro de que desea eliminar este sitio?
100
+ new:
101
+ title: Creando Sitio
102
+ edit:
103
+ title: Editando Sitio
104
+ form:
105
+ create: Crear Sitio
106
+ update: Actualizar Sitio
107
+
108
+ layouts:
109
+ index:
110
+ title: Diseños
111
+ new_link: Crear Nuevo Diseño
112
+ index_branch:
113
+ add_child_layout: Añadir diseño hijo
114
+ edit: Editar
115
+ delete: Eliminar
116
+ are_you_sure: ¿Está seguro?
117
+ new:
118
+ title: Nuevo Diseño
119
+ edit:
120
+ title: Editando Diseño
121
+ revision: Revisión
122
+ form:
123
+ select_parent_layout: Seleccionar diseño padre
124
+ select_app_layout: Seleccionar diseño (App)
125
+ create: Crear Diseño
126
+ update: Actualizar Diseño
127
+
128
+ pages:
129
+ index:
130
+ title: Páginas
131
+ new_link: Crear Nueva Página
132
+ index_branch:
133
+ toggle: Cambiar
134
+ add_child_page: Añadir página hija
135
+ edit: Editar
136
+ delete: Eliminar
137
+ are_you_sure: ¿Está seguro?
138
+ new:
139
+ title: Nueva Página
140
+ edit:
141
+ title: Editando Página
142
+ revision: Revision
143
+ form:
144
+ select_target_page: No Redirigir
145
+ preview: Vista Previa
146
+ create: Crear Página
147
+ update: Actualizar Página
148
+ form_blocks:
149
+ no_tags: |-
150
+ La plantilla no tiene etiquetas de contenido definidas.<br/>
151
+ Edite el contenido para incluir alguna etiqueta de página o campo, por ejemplo: <code>{{cms:page:content}}</code>
152
+
153
+ snippets:
154
+ index:
155
+ title: Fragmentos
156
+ new_link: Crear nuevo Fragmento
157
+ edit: Editar
158
+ delete: Eliminar
159
+ are_you_sure: ¿Está seguro?
160
+ new:
161
+ title: Nuevo Fragmento
162
+ edit:
163
+ title: Editando Fragmento
164
+ revision: Revisión
165
+ form:
166
+ create: Crear Fragmento
167
+ update: Actualizar Fragmento
168
+
169
+ revisions:
170
+ show:
171
+ title: Revisiones de
172
+ revision: Revisión
173
+ full_path: Ruta completa
174
+ slug: Identificador
175
+ update: Actualizar a esta versión
176
+
177
+ uploads:
178
+ index:
179
+ button: Cargar Archivos
data/config/routes.rb CHANGED
@@ -1,40 +1,38 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
3
  namespace :cms_admin, :path => ComfortableMexicanSofa.config.admin_route_prefix, :except => :show do
4
- get '/' => redirect(
5
- "/#{ComfortableMexicanSofa.config.admin_route_prefix}/#{ComfortableMexicanSofa.config.admin_route_redirect}"
6
- )
7
- resources :pages do
8
- member do
9
- match :form_blocks
10
- match :toggle_branch
4
+ get '/', :to => 'base#jump'
5
+ resources :sites do
6
+ resources :pages do
7
+ member do
8
+ match :form_blocks
9
+ match :toggle_branch
10
+ end
11
+ collection do
12
+ match :reorder
13
+ end
14
+ resources :revisions, :only => [:index, :show, :revert] do
15
+ put :revert, :on => :member
16
+ end
11
17
  end
12
- collection do
13
- match :reorder
18
+ resources :uploads, :only => [:create, :destroy]
19
+ resources :layouts do
20
+ resources :revisions, :only => [:index, :show, :revert] do
21
+ put :revert, :on => :member
22
+ end
14
23
  end
15
- resources :revisions, :only => [:index, :show, :revert] do
16
- put :revert, :on => :member
17
- end
18
- end
19
- resources :sites
20
- resources :uploads, :only => [:create, :destroy]
21
- resources :layouts do
22
- resources :revisions, :only => [:index, :show, :revert] do
23
- put :revert, :on => :member
24
- end
25
- end
26
- resources :snippets do
27
- resources :revisions, :only => [:index, :show, :revert] do
28
- put :revert, :on => :member
24
+ resources :snippets do
25
+ resources :revisions, :only => [:index, :show, :revert] do
26
+ put :revert, :on => :member
27
+ end
29
28
  end
30
29
  end
31
30
  end unless ComfortableMexicanSofa.config.admin_route_prefix.blank?
32
31
 
33
32
  scope :controller => :cms_content do
34
- prefix = ComfortableMexicanSofa.config.content_route_prefix
35
- get "#{prefix}/cms-css/:id" => :render_css, :as => 'cms_css'
36
- get "#{prefix}/cms-js/:id" => :render_js, :as => 'cms_js'
37
- get "#{prefix}/" => :render_html, :as => 'cms_html', :path => "#{prefix}/(*cms_path)"
33
+ get 'cms-css/:id' => :render_css, :as => 'cms_css'
34
+ get 'cms-js/:id' => :render_js, :as => 'cms_js'
35
+ get '/' => :render_html, :as => 'cms_html', :path => "(*cms_path)"
38
36
  end
39
37
 
40
38
  end
@@ -5,8 +5,12 @@ class CreateCms < ActiveRecord::Migration
5
5
  create_table :cms_sites do |t|
6
6
  t.string :label
7
7
  t.string :hostname
8
+ t.string :path
9
+ t.string :locale, :null => false, :default => 'en'
10
+ t.boolean :is_mirrored, :null => false, :default => false
8
11
  end
9
12
  add_index :cms_sites, :hostname
13
+ add_index :cms_sites, :is_mirrored
10
14
 
11
15
  # -- Layouts ------------------------------------------------------------
12
16
  create_table :cms_layouts do |t|
@@ -18,7 +22,8 @@ class CreateCms < ActiveRecord::Migration
18
22
  t.text :content
19
23
  t.text :css
20
24
  t.text :js
21
- t.integer :position, :null => false, :default => 0
25
+ t.integer :position, :null => false, :default => 0
26
+ t.boolean :is_shared, :null => false, :default => false
22
27
  t.timestamps
23
28
  end
24
29
  add_index :cms_layouts, [:parent_id, :position]
@@ -37,6 +42,7 @@ class CreateCms < ActiveRecord::Migration
37
42
  t.integer :position, :null => false, :default => 0
38
43
  t.integer :children_count, :null => false, :default => 0
39
44
  t.boolean :is_published, :null => false, :default => true
45
+ t.boolean :is_shared, :null => false, :default => false
40
46
  t.timestamps
41
47
  end
42
48
  add_index :cms_pages, [:site_id, :full_path]
@@ -57,6 +63,7 @@ class CreateCms < ActiveRecord::Migration
57
63
  t.string :label
58
64
  t.string :slug
59
65
  t.text :content
66
+ t.boolean :is_shared, :null => false, :default => false
60
67
  t.timestamps
61
68
  end
62
69
  add_index :cms_snippets, [:site_id, :slug], :unique => true
@@ -0,0 +1,23 @@
1
+ class UpgradeTo130 < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :cms_sites, :is_mirrored, :boolean, :null => false, :default => false
4
+ add_column :cms_sites, :path, :string
5
+ add_column :cms_sites, :locale, :string, :null_false, :default => 'en'
6
+ add_index :cms_sites, :is_mirrored
7
+
8
+ add_column :cms_layouts, :is_shared, :null => false, :default => false
9
+ add_column :cms_pages, :is_shared, :null => false, :default => false
10
+ add_column :cms_snippets, :is_shared, :null => false, :default => false
11
+ end
12
+
13
+ def self.down
14
+ remove_index :cms_sites, :is_mirrored
15
+ remove_column :cms_sites, :path
16
+ remove_column :cms_sites, :is_mirrored
17
+ remove_column :cms_sites, :locale
18
+
19
+ remove_column :cms_layouts, :is_shared
20
+ remove_column :cms_pages, :is_shared
21
+ remove_column :cms_snippets, :is_shared
22
+ end
23
+ end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  class ComfortableMexicanSofa::Configuration
2
4
 
3
5
  # Don't like Comfortable Mexican Sofa? Set it to whatever you like. :(
@@ -10,26 +12,13 @@ class ComfortableMexicanSofa::Configuration
10
12
  # You can change 'cms-admin' to 'admin', for example.
11
13
  attr_accessor :admin_route_prefix
12
14
 
13
- # Default url to content directly is http://yourhost/
14
- # You can change '' to 'preview', for example.
15
- attr_accessor :content_route_prefix
16
-
17
- # /cms-admin redirects to /cms-admin/pages but you can change it
18
- # to something else
15
+ # When arriving at /cms-admin you may chose to redirect to arbirtary path,
16
+ # for example '/cms-admin/users'
19
17
  attr_accessor :admin_route_redirect
20
18
 
21
- # Are you running multiple sites from single install? Default assumption is 'No'
22
- attr_accessor :enable_multiple_sites
23
-
24
- # All resources across sites are kept in sync
25
- attr_accessor :enable_mirror_sites
26
-
27
19
  # Not allowing irb code to be run inside page content. False by default.
28
20
  attr_accessor :allow_irb
29
21
 
30
- # Caching for css/js. For admin layout and ones for cms content. Enabled by default.
31
- attr_accessor :enable_caching
32
-
33
22
  # Upload settings
34
23
  attr_accessor :upload_file_options
35
24
 
@@ -43,22 +32,29 @@ class ComfortableMexicanSofa::Configuration
43
32
  # Number of revisions kept. Default is 25. If you wish to disable: set this to 0.
44
33
  attr_accessor :revisions_limit
45
34
 
35
+ # Locale definitions. If you want to define your own locale merge
36
+ # {:locale => 'Locale Title'} with this.
37
+ attr_accessor :locales
38
+
39
+ # Admin interface will respect the locale of the site being managed. However you can
40
+ # force it to English by setting this to `:en`
41
+ attr_accessor :admin_locale
42
+
46
43
  # Configuration defaults
47
44
  def initialize
48
45
  @cms_title = 'ComfortableMexicanSofa MicroCMS'
49
46
  @authentication = 'ComfortableMexicanSofa::HttpAuth'
50
47
  @seed_data_path = nil
51
48
  @admin_route_prefix = 'cms-admin'
52
- @admin_route_redirect = 'pages'
53
- @content_route_prefix = ''
49
+ @admin_route_redirect = ''
54
50
  @enable_multiple_sites = false
55
- @enable_mirror_sites = false
56
51
  @allow_irb = false
57
- @enable_caching = true
58
52
  @upload_file_options = {}
59
53
  @enable_fixtures = false
60
54
  @fixtures_path = File.expand_path('db/cms_fixtures', Rails.root)
61
55
  @revisions_limit = 25
56
+ @locales = { :en => 'English', :es => 'Español' }
57
+ @admin_locale = nil
62
58
  end
63
59
 
64
60
  end
@@ -51,7 +51,10 @@ module ComfortableMexicanSofa::Fixtures
51
51
 
52
52
  # saving
53
53
  layout.parent = parent
54
- layout.save! if layout.changed?
54
+ if layout.changed?
55
+ layout.save!
56
+ Rails.logger.debug "[Fixtures] Saved Layout {#{layout.slug}}"
57
+ end
55
58
  layout_ids << layout.id
56
59
 
57
60
  # checking for nested fixtures
@@ -105,7 +108,10 @@ module ComfortableMexicanSofa::Fixtures
105
108
 
106
109
  # saving
107
110
  page.blocks_attributes = blocks_attributes if blocks_attributes.present?
108
- page.save! if page.changed? || blocks_attributes.present?
111
+ if page.changed? || blocks_attributes.present?
112
+ page.save!
113
+ Rails.logger.debug "[Fixtures] Saved Page {#{page.full_path}}"
114
+ end
109
115
  page_ids << page.id
110
116
 
111
117
  # checking for nested fixtures
@@ -146,7 +152,10 @@ module ComfortableMexicanSofa::Fixtures
146
152
  end
147
153
 
148
154
  # saving
149
- snippet.save! if snippet.changed?
155
+ if snippet.changed?
156
+ snippet.save!
157
+ Rails.logger.debug "[Fixtures] Saved Snippet {#{snippet.slug}}"
158
+ end
150
159
  snippet_ids << snippet.id
151
160
  end
152
161
 
@@ -42,9 +42,10 @@ class ComfortableMexicanSofa::FormBuilder < ActionView::Helpers::FormBuilder
42
42
  ).html_safe
43
43
  end
44
44
 
45
- def label_for(field, options)
46
- label = options.delete(:label) || field.to_s.titleize.capitalize_all
47
- "<label for=\"#{object_name}_#{field}\">#{label}</label>".html_safe
45
+ def label_for(field, options={})
46
+ label = options.delete(:label) || object.class.human_attribute_name(field).titleize
47
+ for_value = options[:id] || "#{object_name}_#{field}"
48
+ %Q{<label for="#{for_value}">#{label}</label>}.html_safe
48
49
  end
49
50
 
50
51
  def submit(value, options = {}, &block)
@@ -68,14 +69,14 @@ class ComfortableMexicanSofa::FormBuilder < ActionView::Helpers::FormBuilder
68
69
  options[:content_field_method] ||= :text_field_tag
69
70
  field =
70
71
  options[:field] ||
71
- @template.send(options[:content_field_method], 'cms_page[blocks_attributes][][content]', tag.content, :id => nil, :class => field_css_class)
72
+ @template.send(options[:content_field_method], 'page[blocks_attributes][][content]', tag.content, :id => nil, :class => field_css_class)
72
73
 
73
74
  %(
74
75
  <div class='form_element #{css_class}'>
75
76
  <div class='label'>#{label}</div>
76
77
  <div class='value'>
77
78
  #{field}
78
- #{@template.hidden_field_tag('cms_page[blocks_attributes][][label]', tag.label, :id => nil)}
79
+ #{@template.hidden_field_tag('page[blocks_attributes][][label]', tag.label, :id => nil)}
79
80
  </div>
80
81
  </div>
81
82
  ).html_safe
@@ -117,4 +118,4 @@ class ComfortableMexicanSofa::FormBuilder < ActionView::Helpers::FormBuilder
117
118
  default_tag_field(tag, :content_field_method => :text_area_tag)
118
119
  end
119
120
 
120
- end
121
+ end