lucy_cms 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +19 -0
- data/Gemfile.lock +88 -0
- data/LICENSE +24 -0
- data/README.md +161 -0
- data/Rakefile +26 -0
- data/VERSION +1 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/cms_admin/base_controller.rb +43 -0
- data/app/controllers/cms_admin/layouts_controller.rb +66 -0
- data/app/controllers/cms_admin/pages_controller.rb +111 -0
- data/app/controllers/cms_admin/sessions_controller.rb +25 -0
- data/app/controllers/cms_admin/sites_controller.rb +69 -0
- data/app/controllers/cms_admin/snippets_controller.rb +62 -0
- data/app/controllers/cms_admin/upload_dirs_controller.rb +79 -0
- data/app/controllers/cms_admin/users_controller.rb +129 -0
- data/app/controllers/cms_content_controller.rb +51 -0
- data/app/models/cms_block.rb +28 -0
- data/app/models/cms_layout.rb +118 -0
- data/app/models/cms_page.rb +163 -0
- data/app/models/cms_site.rb +38 -0
- data/app/models/cms_snippet.rb +70 -0
- data/app/models/cms_upload.rb +19 -0
- data/app/models/cms_upload_dir.rb +11 -0
- data/app/models/cms_user.rb +93 -0
- data/app/views/cms_admin/layouts/_form.html.erb +10 -0
- data/app/views/cms_admin/layouts/_index_branch.html.erb +24 -0
- data/app/views/cms_admin/layouts/edit.html.erb +6 -0
- data/app/views/cms_admin/layouts/index.html.erb +6 -0
- data/app/views/cms_admin/layouts/new.html.erb +6 -0
- data/app/views/cms_admin/pages/_form.html.erb +37 -0
- data/app/views/cms_admin/pages/_form_blocks.html.erb +7 -0
- data/app/views/cms_admin/pages/_index_branch.html.erb +40 -0
- data/app/views/cms_admin/pages/edit.html.erb +5 -0
- data/app/views/cms_admin/pages/form_blocks.js.erb +2 -0
- data/app/views/cms_admin/pages/index.html.erb +6 -0
- data/app/views/cms_admin/pages/new.html.erb +5 -0
- data/app/views/cms_admin/pages/toggle_branch.js.erb +11 -0
- data/app/views/cms_admin/sessions/new.html.erb +12 -0
- data/app/views/cms_admin/sites/_form.html.erb +16 -0
- data/app/views/cms_admin/sites/edit.html.erb +6 -0
- data/app/views/cms_admin/sites/new.html.erb +6 -0
- data/app/views/cms_admin/sites/setup.html.erb +16 -0
- data/app/views/cms_admin/snippets/_form.html.erb +4 -0
- data/app/views/cms_admin/snippets/edit.html.erb +6 -0
- data/app/views/cms_admin/snippets/index.html.erb +23 -0
- data/app/views/cms_admin/snippets/new.html.erb +6 -0
- data/app/views/cms_admin/upload_dirs/_file.html.erb +15 -0
- data/app/views/cms_admin/upload_dirs/_form.html.erb +2 -0
- data/app/views/cms_admin/upload_dirs/conflict.html.erb +12 -0
- data/app/views/cms_admin/upload_dirs/index.html.erb +23 -0
- data/app/views/cms_admin/upload_dirs/new.html.erb +6 -0
- data/app/views/cms_admin/upload_dirs/show.html.erb +26 -0
- data/app/views/cms_admin/upload_dirs/uploads_destroy.js.erb +3 -0
- data/app/views/cms_admin/users/_form.html.erb +9 -0
- data/app/views/cms_admin/users/_index_branch.html.erb +16 -0
- data/app/views/cms_admin/users/change_password.html.erb +14 -0
- data/app/views/cms_admin/users/edit.html.erb +17 -0
- data/app/views/cms_admin/users/index.html.erb +6 -0
- data/app/views/cms_admin/users/new.html.erb +14 -0
- data/app/views/layouts/cms_admin.html.erb +52 -0
- data/config/application.rb +48 -0
- data/config/boot.rb +13 -0
- data/config/database.yml +22 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +22 -0
- data/config/environments/production.rb +49 -0
- data/config/environments/test.rb +35 -0
- data/config/initializers/LucyCMS.rb +37 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +45 -0
- data/config.ru +4 -0
- data/db/cms_seeds/example.local/layouts/default.yml +8 -0
- data/db/cms_seeds/example.local/layouts/nested.yml +6 -0
- data/db/cms_seeds/example.local/pages/child/subchild.yml +14 -0
- data/db/cms_seeds/example.local/pages/child.yml +10 -0
- data/db/cms_seeds/example.local/pages/index.yml +11 -0
- data/db/cms_seeds/example.local/snippets/example.yml +4 -0
- data/db/migrate/01_create_cms.rb +114 -0
- data/db/seeds.rb +7 -0
- data/lib/LucyCMS/acts_as_tree.rb +102 -0
- data/lib/LucyCMS/cms_tag/field_datetime.rb +26 -0
- data/lib/LucyCMS/cms_tag/field_integer.rb +26 -0
- data/lib/LucyCMS/cms_tag/field_string.rb +26 -0
- data/lib/LucyCMS/cms_tag/field_text.rb +26 -0
- data/lib/LucyCMS/cms_tag/helper.rb +20 -0
- data/lib/LucyCMS/cms_tag/page_datetime.rb +22 -0
- data/lib/LucyCMS/cms_tag/page_integer.rb +22 -0
- data/lib/LucyCMS/cms_tag/page_rich_text.rb +22 -0
- data/lib/LucyCMS/cms_tag/page_string.rb +22 -0
- data/lib/LucyCMS/cms_tag/page_text.rb +22 -0
- data/lib/LucyCMS/cms_tag/partial.rb +21 -0
- data/lib/LucyCMS/cms_tag/snippet.rb +22 -0
- data/lib/LucyCMS/cms_tag.rb +119 -0
- data/lib/LucyCMS/configuration.rb +36 -0
- data/lib/LucyCMS/controller_methods.rb +42 -0
- data/lib/LucyCMS/engine.rb +12 -0
- data/lib/LucyCMS/form_builder.rb +129 -0
- data/lib/LucyCMS/rails_extensions.rb +22 -0
- data/lib/LucyCMS/site_form_builder.rb +129 -0
- data/lib/LucyCMS/view_hooks.rb +30 -0
- data/lib/LucyCMS/view_methods.rb +68 -0
- data/lib/LucyCMS.rb +40 -0
- data/lib/generators/README +17 -0
- data/lib/generators/cms_generator.rb +44 -0
- data/lib/tasks/LucyCMS.rake +283 -0
- data/lucy_cms.gemspec +100 -0
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +26 -0
- data/public/favicon.ico +0 -0
- data/public/images/LucyCMS/arrow_bottom.gif +0 -0
- data/public/images/LucyCMS/arrow_right.gif +0 -0
- data/public/images/LucyCMS/icon_folder.png +0 -0
- data/public/images/LucyCMS/icon_layout.gif +0 -0
- data/public/images/LucyCMS/icon_move.gif +0 -0
- data/public/images/LucyCMS/icon_regular.gif +0 -0
- data/public/images/LucyCMS/icon_snippet.gif +0 -0
- data/public/images/LucyCMS/icon_upload.png +0 -0
- data/public/images/LucyCMS/icon_user.jpg +0 -0
- data/public/javascripts/LucyCMS/cms.js +204 -0
- data/public/javascripts/LucyCMS/codemirror/codemirror.css +102 -0
- data/public/javascripts/LucyCMS/codemirror/codemirror.js +23 -0
- data/public/javascripts/LucyCMS/codemirror/codemirror_base.js +88 -0
- data/public/javascripts/LucyCMS/codemirror/parse_css.js +4 -0
- data/public/javascripts/LucyCMS/codemirror/parse_html_mixed.js +3 -0
- data/public/javascripts/LucyCMS/codemirror/parse_js.js +12 -0
- data/public/javascripts/LucyCMS/codemirror/parse_xml.js +7 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_222222_256x240.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_2e83ff_256x240.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_454545_256x240.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_888888_256x240.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/jquery-ui.css +362 -0
- data/public/javascripts/LucyCMS/jquery-ui/jquery-ui.js +190 -0
- data/public/javascripts/LucyCMS/jquery.js +154 -0
- data/public/javascripts/LucyCMS/plupload/plupload.full.min.js +1 -0
- data/public/javascripts/LucyCMS/plupload/plupload.html5.min.js +1 -0
- data/public/javascripts/LucyCMS/plupload/plupload.min.js +1 -0
- data/public/javascripts/LucyCMS/rails.js +132 -0
- data/public/javascripts/LucyCMS/tiny_mce/jquery.tinymce.js +1 -0
- data/public/javascripts/LucyCMS/tiny_mce/langs/en.js +170 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/about.htm +54 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/anchor.htm +26 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/charmap.htm +52 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/color_picker.htm +73 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/editor_template.js +1 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/image.htm +80 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/img/colorpicker.jpg +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/img/icons.gif +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/about.js +72 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/anchor.js +37 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/charmap.js +335 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/color_picker.js +253 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/image.js +245 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/link.js +156 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/source_editor.js +56 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/langs/en.js +62 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/langs/en_dlg.js +51 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/link.htm +58 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/content.css +36 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/dialog.css +117 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/buttons.png +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/items.gif +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/menu_arrow.gif +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/menu_check.gif +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/progress.gif +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/tabs.gif +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/ui.css +213 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/source_editor.htm +25 -0
- data/public/javascripts/LucyCMS/tiny_mce/tiny_mce.js +1 -0
- data/public/javascripts/LucyCMS/tiny_mce/tiny_mce_popup.js +5 -0
- data/public/robots.txt +5 -0
- data/public/stylesheets/LucyCMS/content.css +196 -0
- data/public/stylesheets/LucyCMS/form.css +125 -0
- data/public/stylesheets/LucyCMS/reset.css +1 -0
- data/public/stylesheets/LucyCMS/site_form.css +82 -0
- data/public/stylesheets/LucyCMS/structure.css +125 -0
- data/public/stylesheets/LucyCMS/typography.css +25 -0
- data/script/rails +6 -0
- data/test/cms_seeds/test.host/layouts/broken.yml +1 -0
- data/test/cms_seeds/test.host/layouts/default.yml +3 -0
- data/test/cms_seeds/test.host/layouts/nested.yml +4 -0
- data/test/cms_seeds/test.host/pages/broken.yml +1 -0
- data/test/cms_seeds/test.host/pages/child/subchild.yml +10 -0
- data/test/cms_seeds/test.host/pages/child.yml +10 -0
- data/test/cms_seeds/test.host/pages/index.yml +10 -0
- data/test/cms_seeds/test.host/snippets/broken.yml +1 -0
- data/test/cms_seeds/test.host/snippets/default.yml +3 -0
- data/test/fixtures/cms_blocks.yml +12 -0
- data/test/fixtures/cms_layouts.yml +36 -0
- data/test/fixtures/cms_pages.yml +39 -0
- data/test/fixtures/cms_sites.yml +3 -0
- data/test/fixtures/cms_snippets.yml +5 -0
- data/test/fixtures/cms_upload_dirs.yml +9 -0
- data/test/fixtures/cms_uploads.yml +4 -0
- data/test/fixtures/cms_users.yml +11 -0
- data/test/fixtures/files/invalid_file.gif +9 -0
- data/test/fixtures/files/valid_image.jpg +0 -0
- data/test/fixtures/views/_nav_hook.html.erb +1 -0
- data/test/fixtures/views/_nav_hook_2.html.erb +1 -0
- data/test/functional/cms_admin/layouts_controller_test.rb +103 -0
- data/test/functional/cms_admin/pages_controller_test.rb +334 -0
- data/test/functional/cms_admin/sites_controller_test.rb +99 -0
- data/test/functional/cms_admin/snippets_controller_test.rb +102 -0
- data/test/functional/cms_admin/uploads_controller_test.rb +26 -0
- data/test/functional/cms_content_controller_test.rb +134 -0
- data/test/integration/rake_tasks_test.rb +65 -0
- data/test/integration/render_cms_seed_test.rb +34 -0
- data/test/integration/render_cms_test.rb +81 -0
- data/test/integration/sites_test.rb +63 -0
- data/test/integration/view_hooks_test.rb +33 -0
- data/test/test_helper.rb +86 -0
- data/test/unit/cms_block_test.rb +43 -0
- data/test/unit/cms_configuration_test.rb +17 -0
- data/test/unit/cms_layout_test.rb +146 -0
- data/test/unit/cms_page_test.rb +257 -0
- data/test/unit/cms_site_test.rb +41 -0
- data/test/unit/cms_snippet_test.rb +77 -0
- data/test/unit/cms_tag_test.rb +206 -0
- data/test/unit/cms_tags/field_datetime_test.rb +34 -0
- data/test/unit/cms_tags/field_integer_test.rb +33 -0
- data/test/unit/cms_tags/field_string_test.rb +34 -0
- data/test/unit/cms_tags/field_text_test.rb +32 -0
- data/test/unit/cms_tags/helper_test.rb +38 -0
- data/test/unit/cms_tags/page_datetime_test.rb +34 -0
- data/test/unit/cms_tags/page_integer_test.rb +33 -0
- data/test/unit/cms_tags/page_rich_text.rb +33 -0
- data/test/unit/cms_tags/page_string_test.rb +33 -0
- data/test/unit/cms_tags/page_text_test.rb +34 -0
- data/test/unit/cms_tags/partial_test.rb +44 -0
- data/test/unit/cms_tags/snippet_test.rb +33 -0
- data/test/unit/cms_upload_dir_test.rb +8 -0
- data/test/unit/cms_upload_test.rb +26 -0
- data/test/unit/cms_user_test.rb +8 -0
- data/test/unit/view_methods_test.rb +21 -0
- metadata +488 -0
@@ -0,0 +1,283 @@
|
|
1
|
+
# Small hack to auto-run migrations during testing
|
2
|
+
namespace :db do
|
3
|
+
task :abort_if_pending_migrations => [:migrate]
|
4
|
+
end
|
5
|
+
|
6
|
+
namespace :LucyCMS do
|
7
|
+
|
8
|
+
# Example use:
|
9
|
+
# rake LucyCMS:import:all FROM=mysite.local TO=mysite.com SEED_PATH=/path/to/seed_data
|
10
|
+
namespace :import do
|
11
|
+
|
12
|
+
task :check_for_requirements => :environment do |task, args|
|
13
|
+
@from = args[:from].present?? args[:from] : nil
|
14
|
+
@site = args[:to].present?? args[:to] : nil
|
15
|
+
@seed_path =
|
16
|
+
LucyCMS.config.seed_data_path =
|
17
|
+
(args[:seed_path].present?? args[:seed_path] : nil) || LucyCMS.config.seed_data_path
|
18
|
+
|
19
|
+
if !@seed_path
|
20
|
+
abort 'SEED_PATH is not set. Please define where cms fixtures are located.'
|
21
|
+
end
|
22
|
+
unless File.exists?((@from && @seed_path = "#{@seed_path}/#{@from}").to_s)
|
23
|
+
abort "FROM is not properly set. Cannot find fixtures in '#{@seed_path}'"
|
24
|
+
end
|
25
|
+
if !(@site = CmsSite.find_by_hostname(args[:to]))
|
26
|
+
abort "TO is not properly set. Cannot find site with hostname '#{args[:to]}'"
|
27
|
+
end
|
28
|
+
|
29
|
+
# a small hack to ensure that #load_from_file looks in the right directory
|
30
|
+
@site.hostname = args[:from]
|
31
|
+
|
32
|
+
puts "Starting import into #{@site.label} (#{@site.hostname}) from '#{@seed_path}'"
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Import layouts into database'
|
36
|
+
task :layouts => [:environment, :check_for_requirements] do |task, args|
|
37
|
+
puts 'Importing Layouts'
|
38
|
+
puts '-----------------'
|
39
|
+
layouts = Dir.glob(File.expand_path('layouts/*.yml', @seed_path)).collect do |layout_file_path|
|
40
|
+
begin
|
41
|
+
attributes = YAML.load_file(layout_file_path).symbolize_keys!
|
42
|
+
@site.cms_layouts.load_from_file(@site, attributes[:slug])
|
43
|
+
rescue
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
end.compact
|
47
|
+
CmsLayout.connection.transaction do
|
48
|
+
# Fixtures are not ordered in any particular way. Saving order matters,
|
49
|
+
# so we cycle them until there nothing left to save
|
50
|
+
while layouts.present?
|
51
|
+
layout = layouts.shift
|
52
|
+
if !layout.parent || layout.parent && parent = @site.cms_layouts.find_by_slug(layout.parent.slug)
|
53
|
+
layout.parent = (parent rescue nil)
|
54
|
+
should_write = true
|
55
|
+
existing_layout = nil
|
56
|
+
|
57
|
+
if existing_layout = @site.cms_layouts.find_by_slug(layout.slug)
|
58
|
+
print "Found layout in database with slug: #{layout.slug}. Overwrite? (y/N): "
|
59
|
+
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
60
|
+
end
|
61
|
+
if should_write
|
62
|
+
if existing_layout
|
63
|
+
existing_layout.attributes = layout.attributes.slice('label', 'content', 'css', 'js')
|
64
|
+
layout = existing_layout
|
65
|
+
end
|
66
|
+
puts "Saving layout: #{layout.label} (#{layout.slug})"
|
67
|
+
layout.save!
|
68
|
+
else
|
69
|
+
puts "Skipping layout: #{layout.label} (#{layout.slug})"
|
70
|
+
end
|
71
|
+
else
|
72
|
+
layouts.push layout
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
desc 'Import pages into database'
|
79
|
+
task :pages => [:environment, :check_for_requirements] do |task, args|
|
80
|
+
puts 'Importing Pages'
|
81
|
+
puts '---------------'
|
82
|
+
pages = Dir.glob(File.expand_path('pages/**/*.yml', @seed_path)).collect do |page_file_path|
|
83
|
+
begin
|
84
|
+
attributes = YAML.load_file(page_file_path).symbolize_keys!
|
85
|
+
@site.cms_pages.load_from_file(@site, attributes[:full_path])
|
86
|
+
rescue
|
87
|
+
nil
|
88
|
+
end
|
89
|
+
end.compact
|
90
|
+
CmsPage.connection.transaction do
|
91
|
+
# Fixtures are not ordered in any particular way. Saving order matters,
|
92
|
+
# so we cycle them until there nothing left to save
|
93
|
+
while pages.present?
|
94
|
+
page = pages.shift
|
95
|
+
if !page.parent || page.parent && parent = @site.cms_pages.find_by_full_path(page.parent.full_path)
|
96
|
+
page.parent = (parent rescue nil)
|
97
|
+
page.cms_layout = @site.cms_layouts.find_by_slug(page.cms_layout.slug)
|
98
|
+
should_write = true
|
99
|
+
existing_page = nil
|
100
|
+
|
101
|
+
if existing_page = @site.cms_pages.find_by_full_path(page.full_path)
|
102
|
+
print "Found page in database with full_path: #{page.full_path}. Overwrite? (y/N): "
|
103
|
+
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
104
|
+
end
|
105
|
+
|
106
|
+
if should_write
|
107
|
+
if existing_page
|
108
|
+
# merging cms_blocks_attributes with the existing page
|
109
|
+
attrs = page.cms_blocks_attributes.collect do |block_attrs|
|
110
|
+
existing_block = existing_page.cms_blocks_attributes.find{|b| b[:label] == block_attrs[:label]}
|
111
|
+
block_attrs[:id] = existing_block[:id] if existing_block
|
112
|
+
block_attrs.stringify_keys
|
113
|
+
end
|
114
|
+
|
115
|
+
existing_page.attributes = page.attributes.slice('label')
|
116
|
+
existing_page.cms_blocks_attributes = attrs
|
117
|
+
page = existing_page
|
118
|
+
end
|
119
|
+
puts "... Saving page: #{page.label} (#{page.full_path})"
|
120
|
+
page.save!
|
121
|
+
else
|
122
|
+
puts "... Skipping page: #{page.label} (#{page.full_path})"
|
123
|
+
end
|
124
|
+
else
|
125
|
+
pages.push page
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
desc 'Import snippets into database'
|
132
|
+
task :snippets => [:environment, :check_for_requirements] do |task, args|
|
133
|
+
puts 'Importing Snippets'
|
134
|
+
puts '------------------'
|
135
|
+
snippets = Dir.glob(File.expand_path('snippets/*.yml', @seed_path)).collect do |snippet_file_path|
|
136
|
+
begin
|
137
|
+
attributes = YAML.load_file(snippet_file_path).symbolize_keys!
|
138
|
+
@site.cms_snippets.load_from_file(@site, attributes[:slug])
|
139
|
+
rescue
|
140
|
+
nil
|
141
|
+
end
|
142
|
+
end.compact
|
143
|
+
CmsSnippet.connection.transaction do
|
144
|
+
snippets.each do |snippet|
|
145
|
+
should_write = true
|
146
|
+
existing_snippet = nil
|
147
|
+
if existing_snippet = @site.cms_snippets.find_by_slug(snippet.slug)
|
148
|
+
print "Found snippet in database with slug: #{snippet.slug}. Overwrite? (y/N): "
|
149
|
+
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
150
|
+
end
|
151
|
+
if should_write
|
152
|
+
if existing_snippet
|
153
|
+
existing_snippet.attributes = snippet.attributes.slice('label', 'content')
|
154
|
+
snippet = existing_snippet
|
155
|
+
end
|
156
|
+
puts "... Saving snippet: #{snippet.label} (#{snippet.slug})"
|
157
|
+
snippet.save!
|
158
|
+
else
|
159
|
+
puts "... Skipping snippet: #{snippet.label} (#{snippet.slug})"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
desc 'Import layouts, pages and snippets all in one go'
|
166
|
+
task :all => [:layouts, :pages, :snippets]
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
# Example use:
|
171
|
+
# rake LucyCMS:import:all FROM=mysite.com TO=mysite.local SEED_PATH=/path/to/seed_data
|
172
|
+
namespace :export do
|
173
|
+
|
174
|
+
task :check_for_requirements => :environment do |task, args|
|
175
|
+
@site = args[:from].present?? args[:from] : nil
|
176
|
+
@to = args[:to].present?? args[:to] : nil
|
177
|
+
@seed_path =
|
178
|
+
LucyCMS.config.seed_data_path =
|
179
|
+
(args[:seed_path].present?? args[:seed_path] : nil) || LucyCMS.config.seed_data_path
|
180
|
+
|
181
|
+
if !@seed_path
|
182
|
+
abort 'SEED_PATH is not set. Please define where cms fixtures are located.'
|
183
|
+
end
|
184
|
+
if !(@site = CmsSite.find_by_hostname(args[:from]))
|
185
|
+
abort "FROM is not properly set. Cannot find site with hostname '#{args[:from]}'"
|
186
|
+
end
|
187
|
+
unless @to && @seed_path = "#{@seed_path}/#{@to}"
|
188
|
+
abort "TO is not properly set. What's the target hostname?"
|
189
|
+
end
|
190
|
+
|
191
|
+
FileUtils.mkdir_p @seed_path
|
192
|
+
FileUtils.mkdir_p "#{@seed_path}/layouts"
|
193
|
+
FileUtils.mkdir_p "#{@seed_path}/pages"
|
194
|
+
FileUtils.mkdir_p "#{@seed_path}/snippets"
|
195
|
+
|
196
|
+
puts "Starting export from #{@site.label} (#{@site.hostname}) to '#{@seed_path}'"
|
197
|
+
end
|
198
|
+
|
199
|
+
desc 'Export layouts to yaml files'
|
200
|
+
task :layouts => [:environment, :check_for_requirements] do |task, args|
|
201
|
+
puts 'Exporting Layouts'
|
202
|
+
puts '-----------------'
|
203
|
+
CmsLayout.all.each do |layout|
|
204
|
+
should_write = true
|
205
|
+
file_path = File.join(@seed_path, 'layouts', "#{layout.slug}.yml")
|
206
|
+
if File.exists?(file_path)
|
207
|
+
print "Found layout fixture: #{file_path} Overwrite? (y/N): "
|
208
|
+
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
209
|
+
end
|
210
|
+
if should_write
|
211
|
+
attributes = layout.attributes.slice('label', 'slug', 'content', 'css', 'js')
|
212
|
+
attributes['parent'] = layout.parent.slug if layout.parent
|
213
|
+
open(file_path, 'w') do |f|
|
214
|
+
f.write(attributes.to_yaml)
|
215
|
+
end
|
216
|
+
puts "... Saving layout: #{layout.label} (#{layout.slug})"
|
217
|
+
else
|
218
|
+
puts "... Skipping layout: #{layout.label} (#{layout.slug})"
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
desc 'Export pages to yaml files'
|
224
|
+
task :pages => [:environment, :check_for_requirements] do |task, args|
|
225
|
+
puts 'Exporting Pages'
|
226
|
+
puts '---------------'
|
227
|
+
CmsPage.all.each do |page|
|
228
|
+
should_write = true
|
229
|
+
page_name = page.full_path.split('/').last || 'index'
|
230
|
+
page_path = (p = page.full_path.split('/')) && p.pop && p.join('/')
|
231
|
+
|
232
|
+
FileUtils.mkdir_p "#{@seed_path}/pages/#{page_path}"
|
233
|
+
file_path = File.join(@seed_path, 'pages', "#{page_path}/#{page_name}.yml")
|
234
|
+
|
235
|
+
if File.exists?(file_path)
|
236
|
+
print "Found page fixture: #{file_path} Overwrite? (y/N): "
|
237
|
+
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
238
|
+
end
|
239
|
+
if should_write
|
240
|
+
|
241
|
+
attributes = page.attributes.slice('label', 'slug', 'full_path')
|
242
|
+
attributes['parent'] = page.parent.full_path if page.parent
|
243
|
+
attributes['cms_layout'] = page.cms_layout.slug
|
244
|
+
attributes['cms_blocks_attributes'] = page.cms_blocks_attributes.collect{|b| b.delete(:id) && b.stringify_keys}
|
245
|
+
|
246
|
+
open(file_path, 'w') do |f|
|
247
|
+
f.write(attributes.to_yaml)
|
248
|
+
end
|
249
|
+
puts "... Saving page: #{page.label} (#{page.full_path})"
|
250
|
+
else
|
251
|
+
puts "... Skipping page: #{page.label} (#{page.full_path})"
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
desc 'Export snippets to yaml files'
|
257
|
+
task :snippets => [:environment, :check_for_requirements] do |task, args|
|
258
|
+
puts 'Exporting Snippets'
|
259
|
+
puts '------------------'
|
260
|
+
CmsSnippet.all.each do |snippet|
|
261
|
+
should_write = true
|
262
|
+
file_path = File.join(@seed_path, 'snippets', "#{snippet.slug}.yml")
|
263
|
+
if File.exists?(file_path)
|
264
|
+
print "Found snippet fixture: #{file_path} Overwrite? (y/N): "
|
265
|
+
should_write = ($stdin.gets.to_s.strip.downcase == 'y')
|
266
|
+
end
|
267
|
+
if should_write
|
268
|
+
attributes = snippet.attributes.slice('label', 'slug', 'content')
|
269
|
+
open(file_path, 'w') do |f|
|
270
|
+
f.write(attributes.to_yaml)
|
271
|
+
end
|
272
|
+
puts "... Saving snippet: #{snippet.label} (#{snippet.slug})"
|
273
|
+
else
|
274
|
+
puts "... Skipping snippet: #{snippet.label} (#{snippet.slug})"
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
desc 'Export layouts, pages and snippets all in one go'
|
280
|
+
task :all => [:layouts, :pages, :snippets]
|
281
|
+
|
282
|
+
end
|
283
|
+
end
|
data/lucy_cms.gemspec
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{lucy_cms}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Lucysoft"]
|
12
|
+
s.date = %q{2011-03-09}
|
13
|
+
s.description = %q{}
|
14
|
+
s.email = %q{lucy@lucysoft.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.rubygems_version = %q{1.3.7}
|
21
|
+
s.summary = %q{LucyCMS is a Rails 3 CMS that lives inside your Rails App, but does not interfere with it}
|
22
|
+
s.test_files = [
|
23
|
+
"test/functional/cms_admin/layouts_controller_test.rb",
|
24
|
+
"test/functional/cms_admin/pages_controller_test.rb",
|
25
|
+
"test/functional/cms_admin/sites_controller_test.rb",
|
26
|
+
"test/functional/cms_admin/snippets_controller_test.rb",
|
27
|
+
"test/functional/cms_admin/uploads_controller_test.rb",
|
28
|
+
"test/functional/cms_content_controller_test.rb",
|
29
|
+
"test/integration/rake_tasks_test.rb",
|
30
|
+
"test/integration/render_cms_seed_test.rb",
|
31
|
+
"test/integration/render_cms_test.rb",
|
32
|
+
"test/integration/sites_test.rb",
|
33
|
+
"test/integration/view_hooks_test.rb",
|
34
|
+
"test/test_helper.rb",
|
35
|
+
"test/unit/cms_block_test.rb",
|
36
|
+
"test/unit/cms_configuration_test.rb",
|
37
|
+
"test/unit/cms_layout_test.rb",
|
38
|
+
"test/unit/cms_page_test.rb",
|
39
|
+
"test/unit/cms_site_test.rb",
|
40
|
+
"test/unit/cms_snippet_test.rb",
|
41
|
+
"test/unit/cms_tag_test.rb",
|
42
|
+
"test/unit/cms_tags/field_datetime_test.rb",
|
43
|
+
"test/unit/cms_tags/field_integer_test.rb",
|
44
|
+
"test/unit/cms_tags/field_string_test.rb",
|
45
|
+
"test/unit/cms_tags/field_text_test.rb",
|
46
|
+
"test/unit/cms_tags/helper_test.rb",
|
47
|
+
"test/unit/cms_tags/page_datetime_test.rb",
|
48
|
+
"test/unit/cms_tags/page_integer_test.rb",
|
49
|
+
"test/unit/cms_tags/page_rich_text.rb",
|
50
|
+
"test/unit/cms_tags/page_string_test.rb",
|
51
|
+
"test/unit/cms_tags/page_text_test.rb",
|
52
|
+
"test/unit/cms_tags/partial_test.rb",
|
53
|
+
"test/unit/cms_tags/snippet_test.rb",
|
54
|
+
"test/unit/cms_upload_dir_test.rb",
|
55
|
+
"test/unit/cms_upload_test.rb",
|
56
|
+
"test/unit/cms_user_test.rb",
|
57
|
+
"test/unit/view_methods_test.rb"
|
58
|
+
]
|
59
|
+
|
60
|
+
if s.respond_to? :specification_version then
|
61
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
62
|
+
s.specification_version = 3
|
63
|
+
|
64
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
65
|
+
s.add_runtime_dependency(%q<rails>, [">= 3.0.3"])
|
66
|
+
s.add_runtime_dependency(%q<active_link_to>, [">= 0.0.6"])
|
67
|
+
s.add_runtime_dependency(%q<paperclip>, [">= 2.3.8"])
|
68
|
+
s.add_runtime_dependency(%q<mime-types>, [">= 0"])
|
69
|
+
s.add_runtime_dependency(%q<net-ldap>, [">= 0.1.1"])
|
70
|
+
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
71
|
+
s.add_runtime_dependency(%q<rails>, [">= 3.0.3"])
|
72
|
+
s.add_runtime_dependency(%q<active_link_to>, [">= 0.0.6"])
|
73
|
+
s.add_runtime_dependency(%q<paperclip>, [">= 2.3.8"])
|
74
|
+
s.add_runtime_dependency(%q<net-ldap>, [">= 0.1.1"])
|
75
|
+
else
|
76
|
+
s.add_dependency(%q<rails>, [">= 3.0.3"])
|
77
|
+
s.add_dependency(%q<active_link_to>, [">= 0.0.6"])
|
78
|
+
s.add_dependency(%q<paperclip>, [">= 2.3.8"])
|
79
|
+
s.add_dependency(%q<mime-types>, [">= 0"])
|
80
|
+
s.add_dependency(%q<net-ldap>, [">= 0.1.1"])
|
81
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
82
|
+
s.add_dependency(%q<rails>, [">= 3.0.3"])
|
83
|
+
s.add_dependency(%q<active_link_to>, [">= 0.0.6"])
|
84
|
+
s.add_dependency(%q<paperclip>, [">= 2.3.8"])
|
85
|
+
s.add_dependency(%q<net-ldap>, [">= 0.1.1"])
|
86
|
+
end
|
87
|
+
else
|
88
|
+
s.add_dependency(%q<rails>, [">= 3.0.3"])
|
89
|
+
s.add_dependency(%q<active_link_to>, [">= 0.0.6"])
|
90
|
+
s.add_dependency(%q<paperclip>, [">= 2.3.8"])
|
91
|
+
s.add_dependency(%q<mime-types>, [">= 0"])
|
92
|
+
s.add_dependency(%q<net-ldap>, [">= 0.1.1"])
|
93
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
94
|
+
s.add_dependency(%q<rails>, [">= 3.0.3"])
|
95
|
+
s.add_dependency(%q<active_link_to>, [">= 0.0.6"])
|
96
|
+
s.add_dependency(%q<paperclip>, [">= 2.3.8"])
|
97
|
+
s.add_dependency(%q<net-ldap>, [">= 0.1.1"])
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
data/public/404.html
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
data/public/422.html
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
data/public/500.html
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
data/public/favicon.ico
ADDED
File without changes
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|