comfypress 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.travis.yml +22 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +175 -0
- data/LICENSE +20 -0
- data/README.md +79 -0
- data/Rakefile +5 -0
- data/app/assets/images/comfypress/arrow_bottom.gif +0 -0
- data/app/assets/images/comfypress/arrow_right.gif +0 -0
- data/app/assets/images/comfypress/bootstrap/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/comfypress/bootstrap/glyphicons-halflings.png +0 -0
- data/app/assets/images/comfypress/checkerboard.gif +0 -0
- data/app/assets/images/comfypress/icon_draft.gif +0 -0
- data/app/assets/images/comfypress/icon_file.gif +0 -0
- data/app/assets/images/comfypress/icon_layout.gif +0 -0
- data/app/assets/images/comfypress/icon_move.gif +0 -0
- data/app/assets/images/comfypress/icon_page.gif +0 -0
- data/app/assets/images/comfypress/icon_site.gif +0 -0
- data/app/assets/images/comfypress/icon_snippet.gif +0 -0
- data/app/assets/images/comfypress/nav_arrow.png +0 -0
- data/app/assets/javascripts/comfypress/admin/application.js +1 -0
- data/app/assets/javascripts/comfypress/application.js.coffee +175 -0
- data/app/assets/javascripts/comfypress/lib/bootstrap-datetimepicker.js +21 -0
- data/app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js +492 -0
- data/app/assets/javascripts/comfypress/lib/bootstrap.js +6 -0
- data/app/assets/javascripts/comfypress/lib/codemirror.js +10 -0
- data/app/assets/javascripts/comfypress/lib/wysihtml5.js +261 -0
- data/app/assets/stylesheets/comfypress/admin/application.css +1 -0
- data/app/assets/stylesheets/comfypress/application.css.sass +8 -0
- data/app/assets/stylesheets/comfypress/base.css.sass +333 -0
- data/app/assets/stylesheets/comfypress/bootstrap_overrides.css.sass +45 -0
- data/app/assets/stylesheets/comfypress/codemirror_overrides.css.sass +27 -0
- data/app/assets/stylesheets/comfypress/lib/bootstrap-datetimepicker.css +9 -0
- data/app/assets/stylesheets/comfypress/lib/bootstrap-wysihtml5.css +102 -0
- data/app/assets/stylesheets/comfypress/lib/bootstrap.css +9 -0
- data/app/assets/stylesheets/comfypress/lib/codemirror.css +240 -0
- data/app/assets/stylesheets/comfypress/wysihtml5_overrides.css.sass +5 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/cms_admin/base_controller.rb +51 -0
- data/app/controllers/cms_admin/categories_controller.rb +35 -0
- data/app/controllers/cms_admin/files_controller.rb +108 -0
- data/app/controllers/cms_admin/layouts_controller.rb +67 -0
- data/app/controllers/cms_admin/menu_items_controller.rb +65 -0
- data/app/controllers/cms_admin/menus_controller.rb +60 -0
- data/app/controllers/cms_admin/pages_controller.rb +112 -0
- data/app/controllers/cms_admin/revisions_controller.rb +57 -0
- data/app/controllers/cms_admin/sites_controller.rb +64 -0
- data/app/controllers/cms_admin/snippets_controller.rb +64 -0
- data/app/controllers/cms_content_controller.rb +79 -0
- data/app/helpers/application_helper.rb +16 -0
- data/app/models/cms/block.rb +48 -0
- data/app/models/cms/categorization.rb +21 -0
- data/app/models/cms/category.rb +30 -0
- data/app/models/cms/file.rb +75 -0
- data/app/models/cms/layout.rb +99 -0
- data/app/models/cms/menu.rb +26 -0
- data/app/models/cms/menu_item.rb +14 -0
- data/app/models/cms/page.rb +202 -0
- data/app/models/cms/revision.rb +17 -0
- data/app/models/cms/site.rb +113 -0
- data/app/models/cms/snippet.rb +58 -0
- data/app/models/cms.rb +5 -0
- data/app/views/cms_admin/categories/_categories.html.haml +3 -0
- data/app/views/cms_admin/categories/_edit.html.haml +6 -0
- data/app/views/cms_admin/categories/_form.html.haml +8 -0
- data/app/views/cms_admin/categories/_index.html.haml +24 -0
- data/app/views/cms_admin/categories/_show.html.haml +13 -0
- data/app/views/cms_admin/categories/create.js.erb +7 -0
- data/app/views/cms_admin/categories/destroy.js.erb +3 -0
- data/app/views/cms_admin/categories/edit.js.erb +3 -0
- data/app/views/cms_admin/categories/update.js.erb +6 -0
- data/app/views/cms_admin/files/_file.html.haml +13 -0
- data/app/views/cms_admin/files/_form.html.haml +14 -0
- data/app/views/cms_admin/files/_index.html.haml +14 -0
- data/app/views/cms_admin/files/_page_form.html.haml +9 -0
- data/app/views/cms_admin/files/destroy.js.coffee +2 -0
- data/app/views/cms_admin/files/edit.html.haml +5 -0
- data/app/views/cms_admin/files/index.html.haml +28 -0
- data/app/views/cms_admin/files/new.html.haml +5 -0
- data/app/views/cms_admin/layouts/_form.html.haml +17 -0
- data/app/views/cms_admin/layouts/_index_branch.html.haml +23 -0
- data/app/views/cms_admin/layouts/edit.html.haml +9 -0
- data/app/views/cms_admin/layouts/index.html.haml +9 -0
- data/app/views/cms_admin/layouts/new.html.haml +5 -0
- data/app/views/cms_admin/menu_items/_form.html.haml +22 -0
- data/app/views/cms_admin/menu_items/edit.html.haml +8 -0
- data/app/views/cms_admin/menu_items/index.html.haml +24 -0
- data/app/views/cms_admin/menu_items/new.html.haml +5 -0
- data/app/views/cms_admin/menus/_form.html.haml +8 -0
- data/app/views/cms_admin/menus/edit.html.haml +8 -0
- data/app/views/cms_admin/menus/index.html.haml +24 -0
- data/app/views/cms_admin/menus/new.html.haml +5 -0
- data/app/views/cms_admin/pages/_form.html.haml +38 -0
- data/app/views/cms_admin/pages/_form_blocks.html.haml +28 -0
- data/app/views/cms_admin/pages/_index_branch.html.haml +35 -0
- data/app/views/cms_admin/pages/edit.html.haml +9 -0
- data/app/views/cms_admin/pages/form_blocks.js.erb +2 -0
- data/app/views/cms_admin/pages/index.html.haml +11 -0
- data/app/views/cms_admin/pages/new.html.haml +5 -0
- data/app/views/cms_admin/pages/toggle_branch.js.erb +11 -0
- data/app/views/cms_admin/revisions/show.html.haml +28 -0
- data/app/views/cms_admin/sites/_form.html.haml +14 -0
- data/app/views/cms_admin/sites/_mirrors.html.haml +17 -0
- data/app/views/cms_admin/sites/edit.html.haml +5 -0
- data/app/views/cms_admin/sites/index.html.haml +24 -0
- data/app/views/cms_admin/sites/new.html.haml +5 -0
- data/app/views/cms_admin/snippets/_form.html.haml +11 -0
- data/app/views/cms_admin/snippets/edit.html.haml +9 -0
- data/app/views/cms_admin/snippets/index.html.haml +28 -0
- data/app/views/cms_admin/snippets/new.html.haml +5 -0
- data/app/views/cms_content/_menu.html.haml +5 -0
- data/app/views/cms_content/render_sitemap.xml.builder +15 -0
- data/app/views/layouts/cms_admin/_body.html.haml +16 -0
- data/app/views/layouts/cms_admin/_center.html.haml +7 -0
- data/app/views/layouts/cms_admin/_footer.html.haml +3 -0
- data/app/views/layouts/cms_admin/_footer_js.html.haml +7 -0
- data/app/views/layouts/cms_admin/_head.html.haml +12 -0
- data/app/views/layouts/cms_admin/_left.html.haml +11 -0
- data/app/views/layouts/cms_admin/_right.html.haml +1 -0
- data/app/views/layouts/cms_admin.html.haml +4 -0
- data/comfypress.gemspec +28 -0
- data/config/application.rb +69 -0
- data/config/boot.rb +6 -0
- data/config/database.sqlite.yml +47 -0
- data/config/database.yml +47 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +39 -0
- data/config/environments/production.rb +67 -0
- data/config/environments/test.rb +39 -0
- data/config/initializers/comfypress.rb +100 -0
- data/config/initializers/paperclip.rb +3 -0
- data/config/locales/de.yml +236 -0
- data/config/locales/en.yml +285 -0
- data/config/locales/es.yml +236 -0
- data/config/locales/fr.yml +236 -0
- data/config/locales/ja.yml +237 -0
- data/config/locales/pl.yml +236 -0
- data/config/locales/pt-BR.yml +236 -0
- data/config/locales/ru.yml +236 -0
- data/config/locales/sv.yml +236 -0
- data/config/locales/zh-CN.yml +236 -0
- data/config/routes.rb +10 -0
- data/config.ru +4 -0
- data/db/cms_fixtures/sample-site/layouts/default/_default.yml +1 -0
- data/db/cms_fixtures/sample-site/layouts/default/content.html +5 -0
- data/db/cms_fixtures/sample-site/layouts/default/css.css +1 -0
- data/db/cms_fixtures/sample-site/layouts/default/js.js +1 -0
- data/db/cms_fixtures/sample-site/layouts/default/nested/_nested.yml +2 -0
- data/db/cms_fixtures/sample-site/layouts/default/nested/content.html +2 -0
- data/db/cms_fixtures/sample-site/layouts/default/nested/css.css +1 -0
- data/db/cms_fixtures/sample-site/layouts/default/nested/js.js +1 -0
- data/db/cms_fixtures/sample-site/pages/index/_index.yml +2 -0
- data/db/cms_fixtures/sample-site/pages/index/child/_child.yml +3 -0
- data/db/cms_fixtures/sample-site/pages/index/child/left.html +1 -0
- data/db/cms_fixtures/sample-site/pages/index/child/right.html +1 -0
- data/db/cms_fixtures/sample-site/pages/index/content.html +2 -0
- data/db/cms_fixtures/sample-site/snippets/default/_default.yml +1 -0
- data/db/cms_fixtures/sample-site/snippets/default/content.html +1 -0
- data/db/migrate/01_create_cms.rb +163 -0
- data/db/seeds.rb +9 -0
- data/db/upgrade_migrations/02_upgrade_to_1_1_0.rb +19 -0
- data/db/upgrade_migrations/03_upgrade_to_1_2_0.rb +15 -0
- data/db/upgrade_migrations/04_upgrade_to_1_3_0.rb +23 -0
- data/db/upgrade_migrations/05_upgrade_to_1_4_0.rb +33 -0
- data/db/upgrade_migrations/06_upgrade_to_1_5_0.rb +21 -0
- data/db/upgrade_migrations/07_upgrade_to_1_6_0.rb +25 -0
- data/doc/preview.png +0 -0
- data/doc/sofa.png +0 -0
- data/lib/comfypress/authentication/dummy_auth.rb +8 -0
- data/lib/comfypress/authentication/http_auth.rb +18 -0
- data/lib/comfypress/configuration.rb +99 -0
- data/lib/comfypress/engine.rb +18 -0
- data/lib/comfypress/error.rb +24 -0
- data/lib/comfypress/extensions/acts_as_tree.rb +102 -0
- data/lib/comfypress/extensions/has_revisions.rb +64 -0
- data/lib/comfypress/extensions/is_categorized.rb +49 -0
- data/lib/comfypress/extensions/is_mirrored.rb +85 -0
- data/lib/comfypress/extensions/rails.rb +24 -0
- data/lib/comfypress/fixtures.rb +289 -0
- data/lib/comfypress/form_builder.rb +97 -0
- data/lib/comfypress/render_methods.rb +85 -0
- data/lib/comfypress/routing.rb +62 -0
- data/lib/comfypress/sitemap.rb +27 -0
- data/lib/comfypress/tag.rb +154 -0
- data/lib/comfypress/tags/asset.rb +25 -0
- data/lib/comfypress/tags/collection.rb +64 -0
- data/lib/comfypress/tags/field_datetime.rb +17 -0
- data/lib/comfypress/tags/field_integer.rb +17 -0
- data/lib/comfypress/tags/field_rich_text.rb +17 -0
- data/lib/comfypress/tags/field_string.rb +17 -0
- data/lib/comfypress/tags/field_text.rb +17 -0
- data/lib/comfypress/tags/file.rb +29 -0
- data/lib/comfypress/tags/helper.rb +24 -0
- data/lib/comfypress/tags/menu.rb +27 -0
- data/lib/comfypress/tags/page_datetime.rb +13 -0
- data/lib/comfypress/tags/page_file.rb +51 -0
- data/lib/comfypress/tags/page_files.rb +52 -0
- data/lib/comfypress/tags/page_integer.rb +13 -0
- data/lib/comfypress/tags/page_markdown.rb +22 -0
- data/lib/comfypress/tags/page_rich_text.rb +13 -0
- data/lib/comfypress/tags/page_string.rb +13 -0
- data/lib/comfypress/tags/page_text.rb +13 -0
- data/lib/comfypress/tags/partial.rb +23 -0
- data/lib/comfypress/tags/snippet.rb +19 -0
- data/lib/comfypress/version.rb +3 -0
- data/lib/comfypress/view_hooks.rb +32 -0
- data/lib/comfypress/view_methods.rb +52 -0
- data/lib/comfypress.rb +66 -0
- data/lib/generators/comfy/cms/README +10 -0
- data/lib/generators/comfy/cms/cms_generator.rb +57 -0
- data/lib/tasks/comfypress.rake +45 -0
- data/script/rails +6 -0
- data/test/fixtures/cms/blocks.yml +12 -0
- data/test/fixtures/cms/categories.yml +4 -0
- data/test/fixtures/cms/categorizations.yml +3 -0
- data/test/fixtures/cms/files.yml +9 -0
- data/test/fixtures/cms/layouts.yml +40 -0
- data/test/fixtures/cms/menu_items.yml +15 -0
- data/test/fixtures/cms/menus.yml +9 -0
- data/test/fixtures/cms/pages.yml +39 -0
- data/test/fixtures/cms/revisions.yml +21 -0
- data/test/fixtures/cms/sites.yml +6 -0
- data/test/fixtures/cms/snippets.yml +6 -0
- data/test/fixtures/files/data.zip +0 -0
- data/test/fixtures/files/document.pdf +0 -0
- data/test/fixtures/files/image.gif +0 -0
- data/test/fixtures/files/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/fixtures/views/render_test/_test.html.erb +1 -0
- data/test/fixtures/views/render_test/new.html.erb +1 -0
- data/test/fixtures/views/render_test/render_layout.html.erb +1 -0
- data/test/functional/cms_admin/base_controller_test.rb +18 -0
- data/test/functional/cms_admin/categories_controller_test.rb +70 -0
- data/test/functional/cms_admin/files_controller_test.rb +216 -0
- data/test/functional/cms_admin/layouts_controller_test.rb +123 -0
- data/test/functional/cms_admin/pages_controller_test.rb +450 -0
- data/test/functional/cms_admin/revisions_controller_test.rb +138 -0
- data/test/functional/cms_admin/sites_controller_test.rb +105 -0
- data/test/functional/cms_admin/snippets_controller_test.rb +140 -0
- data/test/functional/cms_content_controller_test.rb +205 -0
- data/test/gemfiles/Gemfile.rails.3.1 +16 -0
- data/test/gemfiles/Gemfile.rails.3.2 +16 -0
- data/test/gemfiles/Gemfile.rails.4.0 +16 -0
- data/test/integration/authentication_test.rb +48 -0
- data/test/integration/fixtures_test.rb +61 -0
- data/test/integration/mirrors_test.rb +72 -0
- data/test/integration/render_cms_test.rb +233 -0
- data/test/integration/sites_test.rb +120 -0
- data/test/integration/view_hooks_test.rb +43 -0
- data/test/test_helper.rb +124 -0
- data/test/unit/cms/menu_item_test.rb +7 -0
- data/test/unit/cms/menu_test.rb +7 -0
- data/test/unit/configuration_test.rb +42 -0
- data/test/unit/fixtures_test.rb +357 -0
- data/test/unit/mirrors_test.rb +242 -0
- data/test/unit/models/block_test.rb +199 -0
- data/test/unit/models/categorization_test.rb +76 -0
- data/test/unit/models/category_test.rb +39 -0
- data/test/unit/models/file_test.rb +89 -0
- data/test/unit/models/layout_test.rb +125 -0
- data/test/unit/models/page_test.rb +255 -0
- data/test/unit/models/site_test.rb +152 -0
- data/test/unit/models/snippet_test.rb +49 -0
- data/test/unit/revisions_test.rb +185 -0
- data/test/unit/sitemap_test.rb +20 -0
- data/test/unit/tag_test.rb +308 -0
- data/test/unit/tags/asset_test.rb +56 -0
- data/test/unit/tags/collection_test.rb +116 -0
- data/test/unit/tags/field_datetime_test.rb +50 -0
- data/test/unit/tags/field_integer_test.rb +49 -0
- data/test/unit/tags/field_rich_text_test.rb +49 -0
- data/test/unit/tags/field_string_test.rb +52 -0
- data/test/unit/tags/field_text_test.rb +48 -0
- data/test/unit/tags/file_test.rb +67 -0
- data/test/unit/tags/helper_test.rb +86 -0
- data/test/unit/tags/page_datetime_test.rb +50 -0
- data/test/unit/tags/page_file_test.rb +119 -0
- data/test/unit/tags/page_files_test.rb +113 -0
- data/test/unit/tags/page_integer_test.rb +49 -0
- data/test/unit/tags/page_markdown_test.rb +48 -0
- data/test/unit/tags/page_rich_text_test.rb +49 -0
- data/test/unit/tags/page_string_test.rb +49 -0
- data/test/unit/tags/page_text_test.rb +52 -0
- data/test/unit/tags/partial_test.rb +76 -0
- data/test/unit/tags/snippet_test.rb +45 -0
- data/test/unit/view_methods_test.rb +80 -0
- metadata +457 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
module ComfyPress::ViewHooks
|
2
|
+
|
3
|
+
# Array of declared hooks
|
4
|
+
def self.hooks
|
5
|
+
@@hooks ||= { }
|
6
|
+
end
|
7
|
+
|
8
|
+
# Renders hook content
|
9
|
+
def self.render(name, template, options = {})
|
10
|
+
out = ''
|
11
|
+
(self.hooks[name.to_sym] || []).each do |path|
|
12
|
+
out += template.render({:partial => path.first}.merge(options))
|
13
|
+
end
|
14
|
+
return out.html_safe
|
15
|
+
end
|
16
|
+
|
17
|
+
# Will declare a partial that will be rendered for this hook
|
18
|
+
# Example:
|
19
|
+
# ComfyPress::ViewHooks.add(:navigation, 'shared/navigation')
|
20
|
+
def self.add(name, partial_path, position = 0)
|
21
|
+
self.hooks[name.to_sym] ||= []
|
22
|
+
self.hooks[name.to_sym] << [partial_path, position]
|
23
|
+
self.hooks[name.to_sym].sort_by! { |hook| hook.last }
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
# Removing previously declared hook
|
28
|
+
def self.remove(name)
|
29
|
+
self.hooks.delete(name)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module ComfyPress::ViewMethods
|
2
|
+
|
3
|
+
# Wrapper around ComfyPress::FormBuilder
|
4
|
+
def comfy_form_for(record, options = {}, &proc)
|
5
|
+
options[:builder] = ComfyPress::FormBuilder
|
6
|
+
options[:type] ||= :horizontal
|
7
|
+
formatted_form_for(record, options, &proc)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Injects some content somewhere inside cms admin area
|
11
|
+
def cms_hook(name, options = {})
|
12
|
+
ComfyPress::ViewHooks.render(name, self, options)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Content of a snippet. Example:
|
16
|
+
# cms_snippet_content(:my_snippet)
|
17
|
+
def cms_snippet_content(identifier, cms_site = nil)
|
18
|
+
unless cms_site
|
19
|
+
host, path = request.host.downcase, request.fullpath if respond_to?(:request) && request
|
20
|
+
cms_site ||= (@cms_site || Cms::Site.find_site(host, path))
|
21
|
+
end
|
22
|
+
return '' unless cms_site
|
23
|
+
case identifier
|
24
|
+
when Cms::Snippet
|
25
|
+
snippet = identifier
|
26
|
+
else
|
27
|
+
return '' unless snippet = cms_site.snippets.find_by_identifier(identifier)
|
28
|
+
end
|
29
|
+
render :inline => ComfyPress::Tag.process_content(cms_site.pages.build, snippet.content)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Content of a page block. This is how you get content from page:field
|
33
|
+
# Example:
|
34
|
+
# cms_page_content(:left_column, CmsPage.first)
|
35
|
+
# cms_page_content(:left_column) # if @cms_page is present
|
36
|
+
def cms_page_content(identifier, page = nil)
|
37
|
+
return '' unless page ||= @cms_page
|
38
|
+
return '' unless block = page.blocks.find_by_identifier(identifier)
|
39
|
+
# If block is a page_file(s) we will return objects instead of attempting
|
40
|
+
# to render them out
|
41
|
+
case block.tag
|
42
|
+
when ComfyPress::Tag::PageFile
|
43
|
+
block.files.first
|
44
|
+
when ComfyPress::Tag::PageFiles
|
45
|
+
block.files
|
46
|
+
else
|
47
|
+
render :inline => ComfyPress::Tag.process_content(page, block.content)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
ActionView::Base.send :include, ComfyPress::ViewMethods
|
data/lib/comfypress.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Loading engine only if this is not a standalone installation
|
2
|
+
unless defined? ComfyPress::Application
|
3
|
+
require File.expand_path('comfypress/engine', File.dirname(__FILE__))
|
4
|
+
end
|
5
|
+
|
6
|
+
[ 'comfypress/version',
|
7
|
+
'comfypress/error',
|
8
|
+
'comfypress/configuration',
|
9
|
+
'comfypress/routing',
|
10
|
+
'comfypress/authentication/http_auth',
|
11
|
+
'comfypress/authentication/dummy_auth',
|
12
|
+
'comfypress/render_methods',
|
13
|
+
'comfypress/view_hooks',
|
14
|
+
'comfypress/view_methods',
|
15
|
+
'comfypress/form_builder',
|
16
|
+
'comfypress/tag',
|
17
|
+
'comfypress/sitemap',
|
18
|
+
'comfypress/fixtures',
|
19
|
+
'comfypress/extensions/rails',
|
20
|
+
'comfypress/extensions/acts_as_tree',
|
21
|
+
'comfypress/extensions/has_revisions',
|
22
|
+
'comfypress/extensions/is_mirrored',
|
23
|
+
'comfypress/extensions/is_categorized'
|
24
|
+
].each do |path|
|
25
|
+
require File.expand_path(path, File.dirname(__FILE__))
|
26
|
+
end
|
27
|
+
|
28
|
+
Dir.glob(File.expand_path('comfypress/tags/*.rb', File.dirname(__FILE__))).each do |path|
|
29
|
+
require path
|
30
|
+
end
|
31
|
+
|
32
|
+
module ComfyPress
|
33
|
+
class << self
|
34
|
+
|
35
|
+
# Modify CMS configuration
|
36
|
+
# Example:
|
37
|
+
# ComfyPress.configure do |config|
|
38
|
+
# config.cms_title = 'ComfyPress'
|
39
|
+
# end
|
40
|
+
def configure
|
41
|
+
yield configuration
|
42
|
+
end
|
43
|
+
|
44
|
+
# Accessor for ComfyPress::Configuration
|
45
|
+
def configuration
|
46
|
+
@configuration ||= Configuration.new
|
47
|
+
end
|
48
|
+
alias :config :configuration
|
49
|
+
|
50
|
+
# Establishing database connection if custom one is defined
|
51
|
+
def establish_connection(klass)
|
52
|
+
if ComfyPress.config.database_config && !Rails.env.test?
|
53
|
+
klass.establish_connection "#{ComfyPress.config.database_config}_#{Rails.env}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def logger=(new_logger)
|
58
|
+
@logger = new_logger
|
59
|
+
end
|
60
|
+
|
61
|
+
def logger
|
62
|
+
@logger ||= Rails.logger
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
--------------
|
2
|
+
!!COMFYPRESS!!
|
3
|
+
--------------
|
4
|
+
|
5
|
+
Hey! Everything is almost done. Please don't forget to
|
6
|
+
|
7
|
+
* run migrations -> `rake db:migrate`
|
8
|
+
|
9
|
+
After that go to http://your-awesome-app/cms-admin to start populating content.
|
10
|
+
Default username and password are: username // password
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Comfy
|
2
|
+
module Generators
|
3
|
+
class CmsGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
require 'rails/generators/active_record'
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
source_root File.expand_path('../../../../..', __FILE__)
|
10
|
+
|
11
|
+
def generate_migration
|
12
|
+
destination = File.expand_path('db/migrate/01_create_cms.rb', self.destination_root)
|
13
|
+
migration_dir = File.dirname(destination)
|
14
|
+
destination = self.class.migration_exists?(migration_dir, 'create_cms')
|
15
|
+
|
16
|
+
if destination
|
17
|
+
puts "\e[0m\e[31mFound existing cms_create.rb migration. Remove it if you want to regenerate.\e[0m"
|
18
|
+
else
|
19
|
+
migration_template 'db/migrate/01_create_cms.rb', 'db/migrate/create_cms.rb'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate_initialization
|
24
|
+
copy_file 'config/initializers/comfypress.rb',
|
25
|
+
'config/initializers/comfypress.rb'
|
26
|
+
end
|
27
|
+
|
28
|
+
def generate_routing
|
29
|
+
route "
|
30
|
+
ComfyPress::Routing.admin(:path => '/cms-admin')
|
31
|
+
|
32
|
+
# Make sure this routeset is defined last
|
33
|
+
ComfyPress::Routing.content(:path => '/', :sitemap => false)"
|
34
|
+
end
|
35
|
+
|
36
|
+
def generate_cms_seeds
|
37
|
+
directory 'db/cms_fixtures', 'db/cms_fixtures'
|
38
|
+
end
|
39
|
+
|
40
|
+
def generate_assets
|
41
|
+
directory 'app/assets/javascripts/comfypress/admin',
|
42
|
+
'app/assets/javascripts/comfypress/admin'
|
43
|
+
directory 'app/assets/stylesheets/comfypress/admin',
|
44
|
+
'app/assets/stylesheets/comfypress/admin'
|
45
|
+
end
|
46
|
+
|
47
|
+
def show_readme
|
48
|
+
readme 'lib/generators/comfy/cms/README'
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.next_migration_number(dirname)
|
52
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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 :comfypress do
|
7
|
+
namespace :fixtures do
|
8
|
+
|
9
|
+
desc 'Import Fixture data into database (options: FROM=folder_name TO=site_identifier)'
|
10
|
+
|
11
|
+
task :import => :environment do
|
12
|
+
to = ENV['TO'] || ENV['FROM']
|
13
|
+
from = ENV['FROM']
|
14
|
+
force_reload = ENV['FORCE'].try(:downcase) != 'false'
|
15
|
+
|
16
|
+
puts "Importing CMS Fixtures from Folder [#{from}] to Site [#{to}] ..."
|
17
|
+
|
18
|
+
# changing so that logger is going straight to screen
|
19
|
+
logger_org = ComfyPress.logger
|
20
|
+
ComfyPress.logger = Logger.new(STDOUT)
|
21
|
+
|
22
|
+
ComfyPress::Fixtures.import_all(to, from, force_reload)
|
23
|
+
|
24
|
+
ComfyPress.logger = logger_org
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Export database data into Fixtures (options: FROM=site_identifier.com TO=folder_name)'
|
28
|
+
task :export => :environment do
|
29
|
+
to = ENV['TO'] || ENV['FROM']
|
30
|
+
from = ENV['FROM']
|
31
|
+
|
32
|
+
puts "Exporting CMS data from Site [#{from}] to Folder [#{to}] ..."
|
33
|
+
|
34
|
+
# changing so that logger is going straight to screen
|
35
|
+
logger_org = ComfyPress.logger
|
36
|
+
ComfyPress.logger = Logger.new(STDOUT)
|
37
|
+
|
38
|
+
ComfyPress::Fixtures.export_all(from, to)
|
39
|
+
|
40
|
+
ComfyPress.logger = logger_org
|
41
|
+
|
42
|
+
puts 'Done!'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/script/rails
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
default_field_text:
|
2
|
+
page: default
|
3
|
+
identifier: default_field_text
|
4
|
+
content: default_field_text_content
|
5
|
+
|
6
|
+
default_page_text:
|
7
|
+
page: default
|
8
|
+
identifier: default_page_text
|
9
|
+
content: |-
|
10
|
+
default_page_text_content_a
|
11
|
+
{{cms:snippet:default}}
|
12
|
+
default_page_text_content_b
|
@@ -0,0 +1,40 @@
|
|
1
|
+
default:
|
2
|
+
site: default
|
3
|
+
label: Default Layout
|
4
|
+
identifier: default
|
5
|
+
parent:
|
6
|
+
content: |-
|
7
|
+
{{cms:field:default_field_text:text}}
|
8
|
+
layout_content_a
|
9
|
+
{{cms:page:default_page_text:text}}
|
10
|
+
layout_content_b
|
11
|
+
{{cms:snippet:default}}
|
12
|
+
layout_content_c
|
13
|
+
css: default_css
|
14
|
+
js: default_js
|
15
|
+
position: 0
|
16
|
+
|
17
|
+
nested:
|
18
|
+
site: default
|
19
|
+
label: Nested Layout
|
20
|
+
identifier: nested
|
21
|
+
parent:
|
22
|
+
content: |-
|
23
|
+
{{cms:page:header}}
|
24
|
+
{{cms:page:content}}
|
25
|
+
css: nested_css
|
26
|
+
js: nested_js
|
27
|
+
position: 0
|
28
|
+
|
29
|
+
child:
|
30
|
+
site: default
|
31
|
+
label: Child Layout
|
32
|
+
identifier: child
|
33
|
+
parent: nested
|
34
|
+
content: |-
|
35
|
+
{{cms:page:left_column}}
|
36
|
+
{{cms:page:right_column}}
|
37
|
+
css: child_css
|
38
|
+
js: child_js
|
39
|
+
position: 0
|
40
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
default:
|
2
|
+
site: default
|
3
|
+
parent:
|
4
|
+
target_page:
|
5
|
+
layout: default
|
6
|
+
label: Default Page
|
7
|
+
slug:
|
8
|
+
full_path: '/'
|
9
|
+
children_count: 1
|
10
|
+
position: 0
|
11
|
+
is_published: true
|
12
|
+
content: |-
|
13
|
+
|
14
|
+
layout_content_a
|
15
|
+
default_page_text_content_a
|
16
|
+
default_snippet_content
|
17
|
+
default_page_text_content_b
|
18
|
+
layout_content_b
|
19
|
+
default_snippet_content
|
20
|
+
layout_content_c
|
21
|
+
|
22
|
+
child:
|
23
|
+
site: default
|
24
|
+
parent: default
|
25
|
+
target_page:
|
26
|
+
layout: default
|
27
|
+
label: Child Page
|
28
|
+
slug: 'child-page'
|
29
|
+
full_path: '/child-page'
|
30
|
+
children_count: 0
|
31
|
+
position: 0
|
32
|
+
is_published: true
|
33
|
+
content: |-
|
34
|
+
|
35
|
+
layout_content_a
|
36
|
+
|
37
|
+
layout_content_b
|
38
|
+
default_snippet_content
|
39
|
+
layout_content_c
|
@@ -0,0 +1,21 @@
|
|
1
|
+
layout:
|
2
|
+
record: default (Cms::Layout)
|
3
|
+
data: <%= {
|
4
|
+
'content' => 'revision {{cms:page:default_page_text}}',
|
5
|
+
'css' => 'revision css',
|
6
|
+
'js' => 'revision js' }.to_yaml.inspect %>
|
7
|
+
|
8
|
+
page:
|
9
|
+
record: default (Cms::Page)
|
10
|
+
data: <%= {
|
11
|
+
'blocks_attributes' => [
|
12
|
+
{ 'identifier' => 'default_page_text',
|
13
|
+
'content' => 'revision page content' },
|
14
|
+
{ 'identifier' => 'default_field_text',
|
15
|
+
'content' => 'revision field content'}
|
16
|
+
]}.to_yaml.inspect %>
|
17
|
+
|
18
|
+
snippet:
|
19
|
+
record: default (Cms::Snippet)
|
20
|
+
data: <%= {
|
21
|
+
'content' => 'revision content' }.to_yaml.inspect %>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
hook_content
|
@@ -0,0 +1 @@
|
|
1
|
+
<hook_content_2>
|
@@ -0,0 +1 @@
|
|
1
|
+
TestPartial <%= @test_value %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Can render CMS layout and specify action
|
@@ -0,0 +1 @@
|
|
1
|
+
TestTemplate <%= @test_value %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class CmsAdmin::BaseControllerTest < ActionController::TestCase
|
4
|
+
|
5
|
+
def test_get_jump
|
6
|
+
get :jump
|
7
|
+
assert_response :redirect
|
8
|
+
assert_redirected_to cms_admin_site_pages_path(cms_sites(:default))
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_get_jump_with_redirect_setting
|
12
|
+
ComfyPress.config.admin_route_redirect = '/cms-admin/sites'
|
13
|
+
get :jump
|
14
|
+
assert_response :redirect
|
15
|
+
assert_redirected_to '/cms-admin/sites'
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class CmsAdmin::CategoriesControllerTest < ActionController::TestCase
|
4
|
+
|
5
|
+
def test_get_edit
|
6
|
+
xhr :get, :edit, :site_id => cms_sites(:default), :id => cms_categories(:default)
|
7
|
+
assert_response :success
|
8
|
+
assert_template :edit
|
9
|
+
assert assigns(:category)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_get_edit_failure
|
13
|
+
xhr :get, :edit, :site_id => cms_sites(:default), :id => 'invalid'
|
14
|
+
assert_response :success
|
15
|
+
assert response.body.blank?
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_creation
|
19
|
+
assert_difference 'Cms::Category.count' do
|
20
|
+
xhr :post, :create, :site_id => cms_sites(:default), :category => {
|
21
|
+
:label => 'Test Label',
|
22
|
+
:categorized_type => 'Cms::Snippet'
|
23
|
+
}
|
24
|
+
assert_response :success
|
25
|
+
assert_template :create
|
26
|
+
assert assigns(:category)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_creation_failure
|
31
|
+
assert_no_difference 'Cms::Category.count' do
|
32
|
+
xhr :post, :create, :site_id => cms_sites(:default), :category => { }
|
33
|
+
assert_response :success
|
34
|
+
assert response.body.blank?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_update
|
39
|
+
category = cms_categories(:default)
|
40
|
+
xhr :put, :update, :site_id => cms_sites(:default), :id => category, :category => {
|
41
|
+
:label => 'Updated Label'
|
42
|
+
}
|
43
|
+
assert_response :success
|
44
|
+
assert_template :update
|
45
|
+
assert assigns(:category)
|
46
|
+
category.reload
|
47
|
+
assert_equal 'Updated Label', category.label
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_update_failure
|
51
|
+
category = cms_categories(:default)
|
52
|
+
xhr :put, :update, :site_id => cms_sites(:default), :id => category, :category => {
|
53
|
+
:label => ''
|
54
|
+
}
|
55
|
+
assert_response :success
|
56
|
+
assert response.body.blank?
|
57
|
+
category.reload
|
58
|
+
assert_not_equal '', category.label
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_destroy
|
62
|
+
assert_difference 'Cms::Category.count', -1 do
|
63
|
+
xhr :delete, :destroy, :site_id => cms_sites(:default), :id => cms_categories(:default)
|
64
|
+
assert assigns(:category)
|
65
|
+
assert_response :success
|
66
|
+
assert_template :destroy
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|