alchemy_cms 2.3.2 → 2.4.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. data/.gitignore +1 -2
  2. data/.travis.yml +1 -5
  3. data/Gemfile +4 -4
  4. data/README.md +22 -15
  5. data/alchemy_cms.gemspec +38 -38
  6. data/app/assets/javascripts/alchemy/alchemy.base.js +2 -2
  7. data/app/assets/javascripts/alchemy/alchemy.buttons.js.coffee +31 -0
  8. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +1 -1
  9. data/app/assets/javascripts/alchemy/alchemy.elements_window.js +24 -15
  10. data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +9 -3
  11. data/app/assets/javascripts/alchemy/alchemy.jquery_loader.js +2 -2
  12. data/app/assets/javascripts/alchemy/alchemy.js +1 -0
  13. data/app/assets/javascripts/alchemy/alchemy.menubar.js +4 -12
  14. data/app/assets/javascripts/alchemy/alchemy.onload.js.coffee +32 -0
  15. data/app/assets/javascripts/alchemy/alchemy.windows.js +4 -4
  16. data/app/assets/stylesheets/alchemy/_defaults.scss +0 -1
  17. data/app/assets/stylesheets/alchemy/alchemy.css +2 -1
  18. data/app/assets/stylesheets/alchemy/base.css.scss +2 -54
  19. data/app/assets/stylesheets/alchemy/elements.css.scss +8 -5
  20. data/app/assets/stylesheets/alchemy/errors.css.scss +51 -0
  21. data/app/assets/stylesheets/alchemy/flash.css.scss +0 -2
  22. data/app/assets/stylesheets/alchemy/form_elements.css.scss +31 -75
  23. data/app/assets/stylesheets/alchemy/icons.css.scss +5 -5
  24. data/app/assets/stylesheets/alchemy/menubar.css.scss +0 -2
  25. data/app/assets/stylesheets/alchemy/sitemap.css.scss +0 -1
  26. data/app/assets/stylesheets/alchemy/tables.css.scss +3 -1
  27. data/app/controllers/alchemy/admin/base_controller.rb +19 -12
  28. data/app/controllers/alchemy/admin/elements_controller.rb +52 -24
  29. data/app/controllers/alchemy/admin/pages_controller.rb +11 -5
  30. data/app/controllers/alchemy/admin/resources_controller.rb +3 -4
  31. data/app/controllers/alchemy/admin/users_controller.rb +1 -0
  32. data/app/controllers/alchemy/base_controller.rb +34 -8
  33. data/app/controllers/alchemy/pictures_controller.rb +16 -1
  34. data/app/controllers/alchemy/user_sessions_controller.rb +6 -1
  35. data/app/helpers/alchemy/base_helper.rb +14 -0
  36. data/app/helpers/alchemy/elements_helper.rb +10 -5
  37. data/app/helpers/alchemy/pages_helper.rb +1 -2
  38. data/app/helpers/alchemy/url_helper.rb +43 -24
  39. data/app/models/alchemy/element.rb +23 -16
  40. data/app/models/alchemy/page.rb +25 -14
  41. data/app/models/alchemy/picture.rb +24 -0
  42. data/app/views/alchemy/admin/contents/create.js.erb +1 -1
  43. data/app/views/alchemy/admin/elements/_new_element_form.html.erb +1 -1
  44. data/app/views/alchemy/admin/elements/create.js.erb +11 -3
  45. data/app/views/alchemy/admin/elements/fold.js.erb +1 -1
  46. data/app/views/alchemy/admin/elements/new.html.erb +1 -1
  47. data/app/views/alchemy/admin/elements/update.js.erb +1 -1
  48. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +1 -1
  49. data/app/views/alchemy/admin/languages/_form.html.erb +1 -1
  50. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
  51. data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
  52. data/app/views/alchemy/admin/pages/configure.html.erb +10 -6
  53. data/app/views/alchemy/admin/pages/configure_external.html.erb +1 -1
  54. data/app/views/alchemy/admin/pages/edit.html.erb +1 -2
  55. data/app/views/alchemy/admin/pages/new.html.erb +2 -2
  56. data/app/views/alchemy/admin/pages/update.js.erb +10 -2
  57. data/app/views/alchemy/admin/partials/_sub_navigation_tab.html.erb +5 -5
  58. data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +2 -1
  59. data/app/views/alchemy/admin/pictures/_picture.html.erb +2 -2
  60. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +2 -1
  61. data/app/views/alchemy/admin/pictures/show_in_window.html.erb +3 -2
  62. data/app/views/alchemy/admin/resources/_form.html.erb +1 -1
  63. data/app/views/alchemy/admin/users/_table.html.erb +4 -4
  64. data/app/views/alchemy/admin/users/edit.html.erb +1 -1
  65. data/app/views/alchemy/admin/users/new.html.erb +1 -1
  66. data/app/views/alchemy/base/error_notice.js.erb +1 -1
  67. data/app/views/alchemy/base/remote_errors.js.erb +2 -3
  68. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +10 -7
  69. data/app/views/alchemy/essences/_essence_picture_view.html.erb +24 -21
  70. data/app/views/layouts/alchemy/admin.html.erb +9 -31
  71. data/bin/alchemy +20 -24
  72. data/config/alchemy/config.yml +6 -0
  73. data/config/alchemy/page_layouts.yml +2 -0
  74. data/config/authorization_rules.rb +1 -1
  75. data/config/locales/alchemy.de.yml +3 -0
  76. data/config/locales/alchemy.en.yml +4 -1
  77. data/db/migrate/20121026100815_alchemy_two_point_three.rb +312 -0
  78. data/lib/alchemy/mount_point.rb +9 -3
  79. data/lib/alchemy/page_layout.rb +89 -73
  80. data/lib/alchemy/version.rb +1 -1
  81. data/lib/rails/generators/alchemy/deploy_script/deploy_script_generator.rb +45 -12
  82. data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +3 -1
  83. data/lib/rails/generators/alchemy/essence/essence_generator.rb +51 -0
  84. data/lib/rails/generators/alchemy/essence/templates/editor.html.erb +18 -0
  85. data/lib/rails/generators/alchemy/essence/templates/view.html.erb +2 -0
  86. data/lib/rails/templates/alchemy.rb +1 -1
  87. data/lib/tasks/install.rake +57 -2
  88. data/spec/controllers/admin/elements_controller_spec.rb +170 -22
  89. data/spec/controllers/admin/trash_controller_spec.rb +1 -1
  90. data/spec/controllers/admin/users_controller_spec.rb +36 -0
  91. data/spec/controllers/base_controller_spec.rb +12 -1
  92. data/spec/controllers/elements_controller_spec.rb +17 -13
  93. data/spec/controllers/pictures_controller_spec.rb +4 -4
  94. data/spec/dummy/config/application.rb +1 -1
  95. data/spec/dummy/db/migrate/20121026100815_alchemy_two_point_three.rb +312 -0
  96. data/spec/dummy/db/migrate/20121026104128_create_events.rb +19 -0
  97. data/spec/dummy/db/schema.rb +1 -1
  98. data/spec/factories.rb +0 -1
  99. data/spec/helpers/base_helper_spec.rb +48 -0
  100. data/spec/helpers/elements_helper_spec.rb +14 -3
  101. data/spec/helpers/url_helper_spec.rb +8 -3
  102. data/spec/integration/picture_security_spec.rb +35 -0
  103. data/spec/integration/translation_integration_spec.rb +6 -5
  104. data/spec/models/element_spec.rb +5 -5
  105. data/spec/models/page_layout_spec.rb +10 -16
  106. data/spec/models/page_spec.rb +25 -2
  107. data/spec/models/picture_spec.rb +24 -2
  108. data/spec/routing_spec.rb +115 -115
  109. data/spec/support/alchemy/specs_helpers.rb +4 -4
  110. data/{app/assets/images/alchemy → vendor/assets/images}/Jcrop.gif +0 -0
  111. data/vendor/assets/javascripts/jquery_plugins/jquery.Jcrop.min.js +19 -243
  112. data/vendor/assets/javascripts/jquery_plugins/jquery.selectboxit.min.js +1 -0
  113. data/vendor/assets/javascripts/jquery_plugins/jquery.ui.tabspaging.js +6 -6
  114. data/vendor/assets/stylesheets/jquery.Jcrop.min.css +28 -0
  115. metadata +48 -82
  116. data/app/assets/javascripts/alchemy/alchemy.buttons.js +0 -50
  117. data/app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss +0 -54
  118. data/app/helpers/alchemy/pictures_helper.rb +0 -19
  119. data/db/migrate/20100607143125_create_pages.rb +0 -34
  120. data/db/migrate/20100607144254_create_elements.rb +0 -20
  121. data/db/migrate/20100607145256_create_contents.rb +0 -18
  122. data/db/migrate/20100607145719_create_users.rb +0 -32
  123. data/db/migrate/20100607150611_create_pictures.rb +0 -16
  124. data/db/migrate/20100607150812_create_attachments.rb +0 -16
  125. data/db/migrate/20100607153647_create_folded_pages.rb +0 -13
  126. data/db/migrate/20100607161345_create_essence_texts.rb +0 -19
  127. data/db/migrate/20100607162339_create_elements_pages.rb +0 -12
  128. data/db/migrate/20100607193638_create_essence_pictures.rb +0 -23
  129. data/db/migrate/20100607193646_create_essence_richtexts.rb +0 -16
  130. data/db/migrate/20100607193653_create_essence_htmls.rb +0 -13
  131. data/db/migrate/20100609111653_create_essence_dates.rb +0 -13
  132. data/db/migrate/20100609111809_create_essence_files.rb +0 -15
  133. data/db/migrate/20100609111821_create_essence_flashes.rb +0 -16
  134. data/db/migrate/20100609111837_create_essence_videos.rb +0 -18
  135. data/db/migrate/20100616150753_create_essence_audios.rb +0 -17
  136. data/db/migrate/20100812085225_add_crop_from_and_crop_size_to_essence_pictures.rb +0 -11
  137. data/db/migrate/20100909140701_change_essence_htmls_source_column_type.rb +0 -9
  138. data/db/migrate/20101109150312_alter_pages_visible_column_default.rb +0 -9
  139. data/db/migrate/20101109151812_create_languages.rb +0 -19
  140. data/db/migrate/20101216151419_add_language_id_to_pages.rb +0 -27
  141. data/db/migrate/20101216155216_add_index_to_languages.rb +0 -9
  142. data/db/migrate/20101216173323_add_default_to_languages.rb +0 -9
  143. data/db/migrate/20101218130049_add_urlname_index_to_pages.rb +0 -9
  144. data/db/migrate/20110115123343_remove_css_class_default_from_essence_pictures.rb +0 -11
  145. data/db/migrate/20110224105120_change_pages_visible_default.rb +0 -11
  146. data/db/migrate/20110228182659_remove_default_page_layout_from_pages.rb +0 -11
  147. data/db/migrate/20110414163140_remove_display_name_from_elements.rb +0 -11
  148. data/db/migrate/20110511100516_rename_essence_texts_title_to_link_title.rb +0 -9
  149. data/db/migrate/20110529130429_create_cells.rb +0 -14
  150. data/db/migrate/20110529130500_add_cell_id_to_elements.rb +0 -11
  151. data/db/migrate/20110530102804_change_pages_page_layout_column.rb +0 -11
  152. data/db/migrate/20110707190728_add_render_size_to_essence_pictures.rb +0 -9
  153. data/db/migrate/20110711142057_change_open_link_in_new_window_to_link_target.rb +0 -19
  154. data/db/migrate/20110919110451_add_default_role_to_users.rb +0 -9
  155. data/db/migrate/20111116125112_namespace_alchemy_models.rb +0 -23
  156. data/db/migrate/20120216135355_add_country_code_to_languages.rb +0 -9
  157. data/db/migrate/20120608085509_create_alchemy_essence_selects.rb +0 -11
  158. data/db/migrate/20120611221734_create_alchemy_essence_booleans.rb +0 -11
  159. data/db/migrate/20120704181529_add_upload_hash_to_alchemy_picture.rb +0 -5
  160. data/db/migrate/20120705214247_acts_as_taggable_on_migration.rb +0 -28
  161. data/db/migrate/20120728185830_add_cached_tag_list_to_alchemy_pictures.rb +0 -5
  162. data/db/migrate/20120831135441_set_alchemy_languages_country_code_default_to_empty_string.rb +0 -9
  163. data/spec/helpers/pictures_helper_spec.rb +0 -14
  164. data/vendor/assets/javascripts/jquery_plugins/jquery.selectBoxIt.js +0 -1909
@@ -9,6 +9,12 @@
9
9
  #
10
10
  # rake alchemy:app_structure:create:config
11
11
 
12
+ # === Require SSL for login form and all admin modules
13
+ #
14
+ # NOTE: You have to create a SSL certificate on your server to make this work
15
+ #
16
+ require_ssl: false
17
+
12
18
  # === Auto Log Out Time
13
19
  #
14
20
  # The amount of time of inactivity in minutes after which the user is kicked out of his current session.
@@ -7,6 +7,7 @@
7
7
  # unique: Bool # Pass true and the user can only choose this layout once inside a language tree.
8
8
  # hide: Bool # Pass true to hide this layout from the user.
9
9
  # elements: Array # A list of element names that can be placed on this layout i.e. [text, picture]. Elements are defined inside the elements.yml file.
10
+ # insert_elements_at: String # Pass top to insert elements at top of the list. Default: bottom
10
11
  # autogenerate: Array # A list of element names that are autogenerated after creating the Page.
11
12
  # searchresults: Bool # Pass true to enable rendering the searchresults of the fulltext-search.
12
13
  # layoutpage: Bool # Layoutpages are outside the normal pagetree and can be used to place "global" language independent Elements.
@@ -46,6 +47,7 @@
46
47
  - name: news
47
48
  feed: true
48
49
  unique: true
50
+ insert_elements_at: top
49
51
  elements: [headline, news]
50
52
  autogenerate: [news]
51
53
  feed_elements: [news]
@@ -56,7 +56,7 @@ authorization do
56
56
 
57
57
  role :admin do
58
58
  includes :editor
59
- has_permission_on :alchemy_admin_users, :to => [:manage]
59
+ has_permission_on :alchemy_admin_users, :to => [:manage, :update_role]
60
60
  has_permission_on :alchemy_admin_languages, :to => [:manage]
61
61
  has_permission_on :authorization_rules, :to => :read
62
62
  end
@@ -278,6 +278,7 @@ de:
278
278
  "Successfully added content": "%{content} wurde hinzugefügt"
279
279
  "Successfully deleted content": "%{content} wurde gelöscht"
280
280
  "Successfully saved content position": "Die Position wurde gespeichert."
281
+ "Successfully signup admin user": "Admin Benutzer wurde erfolgreich eingerichtet."
281
282
  "Switch to Flash® Uploader": "Auf den Flash® Uploader wechseln"
282
283
  sitemap_editor_info: "Die Sitemap wird automatisch generiert"
283
284
  searchresults_editor_info: "Dieses Element stellt die Suchergebnisse dar. Es Bedarf keinerlei Anpassung."
@@ -462,6 +463,7 @@ de:
462
463
  "Page created": "Seite '%{name}' wurde erstellt."
463
464
  page_for_links:
464
465
  choose_page: "%{name} wählen"
466
+ page_layout_changed_notice: "Der Seitentyp wurde verändert. Nicht mehr verwendbare Elemente wurden in den Papierkorb verschoben."
465
467
  page_locked: "Die Seite ist gesperrt"
466
468
  page_properties: "Seiteneigenschaften"
467
469
  page_public: "öffentlich"
@@ -517,6 +519,7 @@ de:
517
519
  show_eq: "EQ anzeigen"
518
520
  show_navigation: "Navigation anzeigen"
519
521
  show_page_in_sitemap: "Seite in der Sitemap zeigen"
522
+ signup_mail_delivery_error: "Einrichtungs-E-Mail konnte nicht verschickt werden. Bitte überprüfen Sie die Mail Einstellungen."
520
523
  small_thumbnails: "kleine Miniaturbilder"
521
524
  subject: "Betreff"
522
525
  successfully_added_element: "Element wurde hinzugefügt."
@@ -296,7 +296,9 @@ en:
296
296
  "No users found": "No users found."
297
297
  "not a valid image": "This is not an valid image."
298
298
  "Page created": "Page: '%{name}' created."
299
- page_for_links.choose_page: "Choose %{name}"
299
+ page_for_links:
300
+ choose_page: "Choose %{name}"
301
+ page_layout_changed_notice: "Page type was changed. Elements not usable anymore have been moved into the trash."
300
302
  page_locked: "This page is locked by another user."
301
303
  page_properties: "Page properties"
302
304
  page_public: "published"
@@ -346,6 +348,7 @@ en:
346
348
  show_eq: "Show EQ"
347
349
  show_navigation: "Show in navigation"
348
350
  show_page_in_sitemap: "Show page in sitemap."
351
+ signup_mail_delivery_error: 'Signup mail could not be delivered. Please check your mail settings.'
349
352
  sitemap_editor_notice: "The sitemap is autogenerated."
350
353
  searchresults_editor_info: "This element displays the search and the searchresults."
351
354
  small_thumbnails: "Small thumbnails"
@@ -0,0 +1,312 @@
1
+ # This is a compressed migration for creating all Alchemy 2.3 tables at once.
2
+ #
3
+ # === Notice
4
+ #
5
+ # In order to upgrade from an old version of Alchemy, you have to run all migrations from
6
+ # each version you missed up to the version you want to upgrade to, before running this migration.
7
+ #
8
+ class AlchemyTwoPointThree < ActiveRecord::Migration
9
+ def up
10
+ # Do not run if Alchemy tables are already present
11
+ return if table_exists?(:alchemy_pages)
12
+
13
+ create_table "alchemy_attachments", :force => true do |t|
14
+ t.string "name"
15
+ t.string "filename"
16
+ t.string "content_type"
17
+ t.integer "size"
18
+ t.integer "creator_id"
19
+ t.integer "updater_id"
20
+ t.datetime "created_at", :null => false
21
+ t.datetime "updated_at", :null => false
22
+ end
23
+
24
+ create_table "alchemy_cells", :force => true do |t|
25
+ t.integer "page_id"
26
+ t.string "name"
27
+ t.datetime "created_at", :null => false
28
+ t.datetime "updated_at", :null => false
29
+ end
30
+
31
+ create_table "alchemy_contents", :force => true do |t|
32
+ t.string "name"
33
+ t.string "essence_type"
34
+ t.integer "essence_id"
35
+ t.integer "element_id"
36
+ t.integer "position"
37
+ t.datetime "created_at", :null => false
38
+ t.datetime "updated_at", :null => false
39
+ t.integer "creator_id"
40
+ t.integer "updater_id"
41
+ end
42
+
43
+ add_index "alchemy_contents", ["element_id", "position"], :name => "index_contents_on_element_id_and_position"
44
+
45
+ create_table "alchemy_elements", :force => true do |t|
46
+ t.string "name"
47
+ t.integer "position"
48
+ t.integer "page_id"
49
+ t.boolean "public", :default => true
50
+ t.boolean "folded", :default => false
51
+ t.boolean "unique", :default => false
52
+ t.datetime "created_at", :null => false
53
+ t.datetime "updated_at", :null => false
54
+ t.integer "creator_id"
55
+ t.integer "updater_id"
56
+ t.integer "cell_id"
57
+ end
58
+
59
+ add_index "alchemy_elements", ["page_id", "position"], :name => "index_elements_on_page_id_and_position"
60
+
61
+ create_table "alchemy_elements_alchemy_pages", :id => false, :force => true do |t|
62
+ t.integer "element_id"
63
+ t.integer "page_id"
64
+ end
65
+
66
+ create_table "alchemy_essence_audios", :force => true do |t|
67
+ t.integer "attachment_id"
68
+ t.integer "width", :default => 400
69
+ t.integer "height", :default => 300
70
+ t.boolean "show_eq", :default => true
71
+ t.boolean "show_navigation", :default => true
72
+ t.integer "creator_id"
73
+ t.integer "updater_id"
74
+ t.datetime "created_at", :null => false
75
+ t.datetime "updated_at", :null => false
76
+ end
77
+
78
+ create_table "alchemy_essence_booleans", :force => true do |t|
79
+ t.boolean "value"
80
+ t.datetime "created_at", :null => false
81
+ t.datetime "updated_at", :null => false
82
+ t.integer "creator_id"
83
+ t.integer "updater_id"
84
+ end
85
+
86
+ add_index "alchemy_essence_booleans", ["value"], :name => "index_alchemy_essence_booleans_on_value"
87
+
88
+ create_table "alchemy_essence_dates", :force => true do |t|
89
+ t.datetime "date"
90
+ t.integer "creator_id"
91
+ t.integer "updater_id"
92
+ t.datetime "created_at", :null => false
93
+ t.datetime "updated_at", :null => false
94
+ end
95
+
96
+ create_table "alchemy_essence_files", :force => true do |t|
97
+ t.integer "attachment_id"
98
+ t.string "title"
99
+ t.string "css_class"
100
+ t.integer "creator_id"
101
+ t.integer "updater_id"
102
+ t.datetime "created_at", :null => false
103
+ t.datetime "updated_at", :null => false
104
+ end
105
+
106
+ create_table "alchemy_essence_flashes", :force => true do |t|
107
+ t.integer "attachment_id"
108
+ t.integer "width", :default => 400
109
+ t.integer "height", :default => 300
110
+ t.string "player_version", :default => "9.0.28"
111
+ t.integer "creator_id"
112
+ t.integer "updater_id"
113
+ t.datetime "created_at", :null => false
114
+ t.datetime "updated_at", :null => false
115
+ end
116
+
117
+ create_table "alchemy_essence_htmls", :force => true do |t|
118
+ t.text "source"
119
+ t.integer "creator_id"
120
+ t.integer "updater_id"
121
+ t.datetime "created_at", :null => false
122
+ t.datetime "updated_at", :null => false
123
+ end
124
+
125
+ create_table "alchemy_essence_pictures", :force => true do |t|
126
+ t.integer "picture_id"
127
+ t.string "caption"
128
+ t.string "title"
129
+ t.string "alt_tag"
130
+ t.string "link"
131
+ t.string "link_class_name"
132
+ t.string "link_title"
133
+ t.string "css_class"
134
+ t.string "link_target"
135
+ t.integer "creator_id"
136
+ t.integer "updater_id"
137
+ t.datetime "created_at", :null => false
138
+ t.datetime "updated_at", :null => false
139
+ t.string "crop_from"
140
+ t.string "crop_size"
141
+ t.string "render_size"
142
+ end
143
+
144
+ create_table "alchemy_essence_richtexts", :force => true do |t|
145
+ t.text "body"
146
+ t.text "stripped_body"
147
+ t.boolean "do_not_index", :default => false
148
+ t.boolean "public"
149
+ t.integer "creator_id"
150
+ t.integer "updater_id"
151
+ t.datetime "created_at", :null => false
152
+ t.datetime "updated_at", :null => false
153
+ end
154
+
155
+ create_table "alchemy_essence_selects", :force => true do |t|
156
+ t.string "value"
157
+ t.datetime "created_at", :null => false
158
+ t.datetime "updated_at", :null => false
159
+ t.integer "creator_id"
160
+ t.integer "updater_id"
161
+ end
162
+
163
+ add_index "alchemy_essence_selects", ["value"], :name => "index_alchemy_essence_selects_on_value"
164
+
165
+ create_table "alchemy_essence_texts", :force => true do |t|
166
+ t.text "body"
167
+ t.string "link"
168
+ t.string "link_title"
169
+ t.string "link_class_name"
170
+ t.boolean "public", :default => false
171
+ t.boolean "do_not_index", :default => false
172
+ t.string "link_target"
173
+ t.integer "creator_id"
174
+ t.integer "updater_id"
175
+ t.datetime "created_at", :null => false
176
+ t.datetime "updated_at", :null => false
177
+ end
178
+
179
+ create_table "alchemy_essence_videos", :force => true do |t|
180
+ t.integer "attachment_id"
181
+ t.integer "width"
182
+ t.integer "height"
183
+ t.boolean "allow_fullscreen", :default => true
184
+ t.boolean "auto_play", :default => false
185
+ t.boolean "show_navigation", :default => true
186
+ t.integer "creator_id"
187
+ t.integer "updater_id"
188
+ t.datetime "created_at", :null => false
189
+ t.datetime "updated_at", :null => false
190
+ end
191
+
192
+ create_table "alchemy_folded_pages", :force => true do |t|
193
+ t.integer "page_id"
194
+ t.integer "user_id"
195
+ t.boolean "folded", :default => false
196
+ end
197
+
198
+ create_table "alchemy_languages", :force => true do |t|
199
+ t.string "name"
200
+ t.string "language_code"
201
+ t.string "frontpage_name"
202
+ t.string "page_layout", :default => "intro"
203
+ t.boolean "public", :default => false
204
+ t.datetime "created_at", :null => false
205
+ t.datetime "updated_at", :null => false
206
+ t.integer "creator_id"
207
+ t.integer "updater_id"
208
+ t.boolean "default", :default => false
209
+ t.string "country_code", :default => "", :null => false
210
+ end
211
+
212
+ add_index "alchemy_languages", ["language_code", "country_code"], :name => "index_alchemy_languages_on_language_code_and_country_code"
213
+ add_index "alchemy_languages", ["language_code"], :name => "index_alchemy_languages_on_language_code"
214
+
215
+ create_table "alchemy_pages", :force => true do |t|
216
+ t.string "name"
217
+ t.string "urlname"
218
+ t.string "title"
219
+ t.string "language_code"
220
+ t.boolean "language_root"
221
+ t.string "page_layout"
222
+ t.text "meta_keywords"
223
+ t.text "meta_description"
224
+ t.integer "lft"
225
+ t.integer "rgt"
226
+ t.integer "parent_id"
227
+ t.integer "depth"
228
+ t.boolean "visible", :default => false
229
+ t.boolean "public", :default => false
230
+ t.boolean "locked", :default => false
231
+ t.integer "locked_by"
232
+ t.boolean "restricted", :default => false
233
+ t.boolean "robot_index", :default => true
234
+ t.boolean "robot_follow", :default => true
235
+ t.boolean "sitemap", :default => true
236
+ t.boolean "layoutpage", :default => false
237
+ t.datetime "created_at", :null => false
238
+ t.datetime "updated_at", :null => false
239
+ t.integer "creator_id"
240
+ t.integer "updater_id"
241
+ t.integer "language_id"
242
+ end
243
+
244
+ add_index "alchemy_pages", ["language_id"], :name => "index_pages_on_language_id"
245
+ add_index "alchemy_pages", ["parent_id", "lft"], :name => "index_pages_on_parent_id_and_lft"
246
+ add_index "alchemy_pages", ["urlname"], :name => "index_pages_on_urlname"
247
+
248
+ create_table "alchemy_pictures", :force => true do |t|
249
+ t.string "name"
250
+ t.string "image_filename"
251
+ t.integer "image_width"
252
+ t.integer "image_height"
253
+ t.datetime "created_at", :null => false
254
+ t.datetime "updated_at", :null => false
255
+ t.integer "creator_id"
256
+ t.integer "updater_id"
257
+ t.string "upload_hash"
258
+ t.string "cached_tag_list"
259
+ end
260
+
261
+ create_table "alchemy_users", :force => true do |t|
262
+ t.string "firstname"
263
+ t.string "lastname"
264
+ t.string "login"
265
+ t.string "email"
266
+ t.string "gender"
267
+ t.string "role", :default => "registered"
268
+ t.string "language"
269
+ t.string "crypted_password", :limit => 128, :default => "", :null => false
270
+ t.string "password_salt", :limit => 128, :default => "", :null => false
271
+ t.integer "login_count", :default => 0, :null => false
272
+ t.integer "failed_login_count", :default => 0, :null => false
273
+ t.datetime "last_request_at"
274
+ t.datetime "current_login_at"
275
+ t.datetime "last_login_at"
276
+ t.string "current_login_ip"
277
+ t.string "last_login_ip"
278
+ t.string "persistence_token", :null => false
279
+ t.string "single_access_token", :null => false
280
+ t.string "perishable_token", :null => false
281
+ t.datetime "created_at", :null => false
282
+ t.datetime "updated_at", :null => false
283
+ t.integer "creator_id"
284
+ t.integer "updater_id"
285
+ end
286
+
287
+ add_index "alchemy_users", ["perishable_token"], :name => "index_users_on_perishable_token"
288
+
289
+ # Skip migrations for acts-as-taggable-on, if the tables are already present
290
+ unless table_exists?(:taggings)
291
+ create_table "taggings", :force => true do |t|
292
+ t.integer "tag_id"
293
+ t.integer "taggable_id"
294
+ t.string "taggable_type"
295
+ t.integer "tagger_id"
296
+ t.string "tagger_type"
297
+ t.string "context"
298
+ t.datetime "created_at"
299
+ end
300
+
301
+ add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
302
+ add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"
303
+ end
304
+
305
+ unless table_exists?(:tags)
306
+ create_table "tags", :force => true do |t|
307
+ t.string "name"
308
+ end
309
+ end
310
+
311
+ end
312
+ end
@@ -1,10 +1,16 @@
1
1
  module Alchemy
2
2
 
3
3
  # Returns alchemys mount point in current rails app.
4
- def self.mount_point
4
+ # Pass false to not return a leading slash on empty mount point.
5
+ def self.mount_point(remove_leading_slash_if_blank = true)
5
6
  alchemy_routes = Rails.application.routes.named_routes[:alchemy]
6
7
  raise "Alchemy not mounted! Please mount Alchemy::Engine in your config/routes.rb file." if alchemy_routes.nil?
7
- alchemy_routes.path.spec.to_s.gsub(/^\/$/, '')
8
+ mount_point = alchemy_routes.path.spec.to_s
9
+ if remove_leading_slash_if_blank && mount_point == "/"
10
+ mount_point.gsub(/^\/$/, '')
11
+ else
12
+ mount_point
13
+ end
8
14
  end
9
15
 
10
- end
16
+ end
@@ -1,96 +1,112 @@
1
1
  module Alchemy
2
2
  class PageLayout
3
+ class << self
3
4
 
4
- def self.included(base)
5
- get_layouts
6
- end
7
-
8
- def self.element_names_for(page_layout)
9
- layout_description = get(page_layout)
10
- if layout_description.blank?
11
- puts "\n+++ Warning: No Layout Description for #{page_layout} found! in page_layouts.yml\n"
12
- return []
13
- else
14
- layout_description["elements"]
5
+ def element_names_for(page_layout)
6
+ layout_description = get(page_layout)
7
+ if layout_description.blank?
8
+ puts "\n+++ Warning: No Layout Description for #{page_layout} found! in page_layouts.yml\n"
9
+ return []
10
+ else
11
+ layout_description["elements"]
12
+ end
15
13
  end
16
- end
17
14
 
18
- # Returns the page_layout.yml file. Tries to first load from config/alchemy and if not found from vendor/plugins/alchemy/config/alchemy.
19
- def self.get_layouts
20
- @@definitions ||= read_layouts_file
21
- end
15
+ # Returns all layouts defined in +config/alchemy/page_layout.yml+.
16
+ def all
17
+ @@definitions ||= read_layouts_file
18
+ end
22
19
 
23
- # Add additional pagelayout definitions. I.E. from your module.
24
- # Call +Alchemy::PageLayout.add(your_layout_definition)+ in your engine.rb file.
25
- # You can pass a single layout definition as Hash, or a collection of pagelayouts as Array.
26
- # Example Pagelayout definitions can be found in the +page_layouts.yml+ from the standard set.
27
- def self.add(page_layout)
28
- get_layouts
29
- if page_layout.is_a?(Array)
30
- @@definitions += page_layout
31
- elsif page_layout.is_a?(Hash)
32
- @@definitions << page_layout
33
- else
34
- raise TypeError
20
+ # Add additional pagelayout definitions. I.E. from your module.
21
+ # Call +Alchemy::PageLayout.add(your_layout_definition)+ in your engine.rb file.
22
+ # You can pass a single layout definition as Hash, or a collection of pagelayouts as Array.
23
+ # Example Pagelayout definitions can be found in the +page_layouts.yml+ from the standard set.
24
+ def add(page_layout)
25
+ all
26
+ if page_layout.is_a?(Array)
27
+ @@definitions += page_layout
28
+ elsif page_layout.is_a?(Hash)
29
+ @@definitions << page_layout
30
+ else
31
+ raise TypeError
32
+ end
35
33
  end
36
- end
37
34
 
38
- # Returns the page_layout description found by name in page_layouts.yml
39
- def self.get(name)
40
- return {} if name.blank?
41
- get_layouts.detect { |a| a["name"].downcase == name.downcase }
42
- end
35
+ # Returns the page_layout description found by name in page_layouts.yml
36
+ def get(name)
37
+ return {} if name.blank?
38
+ all.detect { |a| a["name"].downcase == name.downcase }
39
+ end
43
40
 
44
- def self.get_all_by_attributes(attributes)
45
- return [] if attributes.blank?
46
- if attributes.class.name == 'Hash'
47
- layouts = []
48
- attributes.stringify_keys.each do |key, value|
49
- result = get_layouts.select { |a| a[key].to_s.downcase == value.to_s.downcase if a.has_key?(key) }
50
- layouts += result unless result.empty?
41
+ def get_all_by_attributes(attributes)
42
+ return [] if attributes.blank?
43
+ if attributes.class.name == 'Hash'
44
+ layouts = []
45
+ attributes.stringify_keys.each do |key, value|
46
+ result = all.select { |a| a[key].to_s.downcase == value.to_s.downcase if a.has_key?(key) }
47
+ layouts += result unless result.empty?
48
+ end
49
+ return layouts
50
+ else
51
+ return []
51
52
  end
52
- return layouts
53
- else
54
- return []
55
53
  end
56
- end
57
54
 
58
- # Returns page layouts ready for Rails' select form helper.
59
- def self.get_layouts_for_select(language_id, layoutpage = false)
60
- layouts_for_select = [[Alchemy::I18n.t("Please choose"), ""]]
61
- selectable_layouts(language_id, layoutpage).each do |layout|
62
- display_name = Alchemy::I18n.t("page_layout_names.#{layout['name']}", :default => layout['name'].camelize)
63
- layouts_for_select << [display_name, layout["name"]]
55
+ # Returns page layouts ready for Rails' select form helper.
56
+ def layouts_for_select(language_id, layoutpage = false)
57
+ map_layouts(selectable_layouts(language_id, layoutpage), [[I18n.t("Please choose"), ""]])
64
58
  end
65
- layouts_for_select
66
- end
67
59
 
68
- def self.selectable_layouts(language_id, layoutpage = false)
69
- get_layouts.select do |layout|
70
- next if layout["hide"]
71
- used = layout["unique"] && has_a_page_this_layout?(layout["name"], language_id)
72
- if layoutpage
73
- layout["layoutpage"] == true && !used
60
+ def layouts_with_own_for_select(own_layout, language_id, layoutpage)
61
+ layouts = selectable_layouts(language_id, layoutpage)
62
+ if layouts.detect { |l| l['name'] == own_layout } == nil
63
+ map_array = [[I18n.t(own_layout, :scope => 'page_layout_names'), own_layout]]
74
64
  else
75
- layout["layoutpage"] != true && !used
65
+ map_array = []
76
66
  end
67
+ map_layouts(layouts, map_array)
77
68
  end
78
- end
79
69
 
80
- def self.has_a_page_this_layout?(layout, language_id)
81
- Page.where({:page_layout => layout, :language_id => language_id}).any?
82
- end
70
+ # Maps given layouts for Rails select form helper.
71
+ def map_layouts(layouts, map_array = [])
72
+ layouts.each do |layout|
73
+ map_array << [
74
+ I18n.t(layout['name'], :scope => 'page_layout_names'),
75
+ layout["name"]
76
+ ]
77
+ end
78
+ map_array
79
+ end
83
80
 
84
- # Reads the layout definitions from +config/alchemy/page_layouts.yml+.
85
- def self.read_layouts_file
86
- if File.exists? "#{Rails.root}/config/alchemy/page_layouts.yml"
87
- layouts = YAML.load_file "#{Rails.root}/config/alchemy/page_layouts.yml"
88
- else
89
- raise LoadError, "Could not find page_layouts.yml file! Please run: rails generate alchemy:scaffold"
81
+ def selectable_layouts(language_id, layoutpage = false)
82
+ all.select do |layout|
83
+ next if layout["hide"]
84
+ used = layout["unique"] && has_a_page_this_layout?(layout["name"], language_id)
85
+ if layoutpage
86
+ layout["layoutpage"] == true && !used
87
+ else
88
+ layout["layoutpage"] != true && !used
89
+ end
90
+ end
90
91
  end
91
- # Since YAML returns false for an empty file, we have to normalize it here.
92
- layouts || []
93
- end
94
92
 
93
+ def has_a_page_this_layout?(layout, language_id)
94
+ Page.where({:page_layout => layout, :language_id => language_id}).any?
95
+ end
96
+
97
+ private
98
+
99
+ # Reads the layout definitions from +config/alchemy/page_layouts.yml+.
100
+ def read_layouts_file
101
+ if File.exists? "#{Rails.root}/config/alchemy/page_layouts.yml"
102
+ layouts = YAML.load_file "#{Rails.root}/config/alchemy/page_layouts.yml"
103
+ else
104
+ raise LoadError, "Could not find page_layouts.yml file! Please run: rails generate alchemy:scaffold"
105
+ end
106
+ # Since YAML returns false for an empty file, we have to normalize it here.
107
+ layouts || []
108
+ end
109
+
110
+ end
95
111
  end
96
112
  end