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,108 @@
|
|
1
|
+
class CmsAdmin::FilesController < CmsAdmin::BaseController
|
2
|
+
|
3
|
+
skip_before_filter :load_fixtures
|
4
|
+
|
5
|
+
before_filter :build_file, :only => [:new, :create]
|
6
|
+
before_filter :load_file, :only => [:edit, :update, :destroy]
|
7
|
+
|
8
|
+
def index
|
9
|
+
@files = @site.files.includes(:categories).for_category(params[:category]).order('cms_files.position')
|
10
|
+
|
11
|
+
if params[:ajax]
|
12
|
+
files = @files.images.collect do |file|
|
13
|
+
{ :thumb => file.file.url(:cms_thumb),
|
14
|
+
:image => file.file.url }
|
15
|
+
end
|
16
|
+
render :json => files
|
17
|
+
else
|
18
|
+
return redirect_to :action => :new if @site.files.count == 0
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def new
|
23
|
+
render
|
24
|
+
end
|
25
|
+
|
26
|
+
def create
|
27
|
+
@files = []
|
28
|
+
|
29
|
+
# Sometimes params[:file] comes in as a single file object
|
30
|
+
unless params[:file].is_a?(Hash)
|
31
|
+
uploaded_file = params[:file]
|
32
|
+
params[:file] = { }
|
33
|
+
params[:file][:file] = [uploaded_file]
|
34
|
+
end
|
35
|
+
|
36
|
+
file_array = params[:file][:file] || [nil]
|
37
|
+
label = params[:file][:label]
|
38
|
+
|
39
|
+
file_array.each_with_index do |file, i|
|
40
|
+
file_params = params[:file].merge(:file => file)
|
41
|
+
if file_array.size > 1 && file_params[:label].present?
|
42
|
+
label = file_params[:label] + " #{i + 1}"
|
43
|
+
end
|
44
|
+
@file = @site.files.create!(file_params.merge(:label => label))
|
45
|
+
@files << @file
|
46
|
+
end
|
47
|
+
|
48
|
+
if params[:ajax]
|
49
|
+
view = render_to_string(:partial => 'cms_admin/files/file', :collection => @files, :layout => false)
|
50
|
+
render :json => {:filelink => @file.file.url, :view => view.gsub("\n", '')}
|
51
|
+
else
|
52
|
+
flash[:success] = I18n.t('cms.files.created')
|
53
|
+
redirect_to :action => :edit, :id => @file
|
54
|
+
end
|
55
|
+
|
56
|
+
rescue ActiveRecord::RecordInvalid
|
57
|
+
logger.detailed_error($!)
|
58
|
+
if params[:ajax]
|
59
|
+
render :nothing => true, :status => :unprocessable_entity
|
60
|
+
else
|
61
|
+
flash.now[:error] = I18n.t('cms.files.creation_failure')
|
62
|
+
render :action => :new
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def update
|
67
|
+
@file.update_attributes!(params[:file])
|
68
|
+
flash[:success] = I18n.t('cms.files.updated')
|
69
|
+
redirect_to :action => :edit, :id => @file
|
70
|
+
rescue ActiveRecord::RecordInvalid
|
71
|
+
logger.detailed_error($!)
|
72
|
+
flash.now[:error] = I18n.t('cms.files.update_failure')
|
73
|
+
render :action => :edit
|
74
|
+
end
|
75
|
+
|
76
|
+
def destroy
|
77
|
+
@file.destroy
|
78
|
+
respond_to do |format|
|
79
|
+
format.js
|
80
|
+
format.html do
|
81
|
+
flash[:success] = I18n.t('cms.files.deleted')
|
82
|
+
redirect_to :action => :index
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def reorder
|
88
|
+
(params[:cms_file] || []).each_with_index do |id, index|
|
89
|
+
if (cms_file = Cms::File.find_by_id(id))
|
90
|
+
cms_file.update_attributes(:position => index)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
render :nothing => true
|
94
|
+
end
|
95
|
+
|
96
|
+
protected
|
97
|
+
|
98
|
+
def build_file
|
99
|
+
@file = @site.files.new
|
100
|
+
end
|
101
|
+
|
102
|
+
def load_file
|
103
|
+
@file = @site.files.find(params[:id])
|
104
|
+
rescue ActiveRecord::RecordNotFound
|
105
|
+
flash[:error] = I18n.t('cms.files.not_found')
|
106
|
+
redirect_to :action => :index
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class CmsAdmin::LayoutsController < CmsAdmin::BaseController
|
2
|
+
|
3
|
+
before_filter :build_layout, :only => [:new, :create]
|
4
|
+
before_filter :load_layout, :only => [:edit, :update, :destroy]
|
5
|
+
|
6
|
+
def index
|
7
|
+
return redirect_to :action => :new if @site.layouts.count == 0
|
8
|
+
@layouts = @site.layouts.roots
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
render
|
13
|
+
end
|
14
|
+
|
15
|
+
def edit
|
16
|
+
render
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
@layout.save!
|
21
|
+
flash[:success] = I18n.t('cms.layouts.created')
|
22
|
+
redirect_to :action => :edit, :id => @layout
|
23
|
+
rescue ActiveRecord::RecordInvalid
|
24
|
+
logger.detailed_error($!)
|
25
|
+
flash.now[:error] = I18n.t('cms.layouts.creation_failure')
|
26
|
+
render :action => :new
|
27
|
+
end
|
28
|
+
|
29
|
+
def update
|
30
|
+
@layout.update_attributes!(params[:layout])
|
31
|
+
flash[:success] = I18n.t('cms.layouts.updated')
|
32
|
+
redirect_to :action => :edit, :id => @layout
|
33
|
+
rescue ActiveRecord::RecordInvalid
|
34
|
+
logger.detailed_error($!)
|
35
|
+
flash.now[:error] = I18n.t('cms.layouts.update_failure')
|
36
|
+
render :action => :edit
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
@layout.destroy
|
41
|
+
flash[:success] = I18n.t('cms.layouts.deleted')
|
42
|
+
redirect_to :action => :index
|
43
|
+
end
|
44
|
+
|
45
|
+
def reorder
|
46
|
+
(params[:cms_layout] || []).each_with_index do |id, index|
|
47
|
+
Cms::Layout.where(:id => id).update_all(:position => index)
|
48
|
+
end
|
49
|
+
render :nothing => true
|
50
|
+
end
|
51
|
+
|
52
|
+
protected
|
53
|
+
|
54
|
+
def build_layout
|
55
|
+
@layout = @site.layouts.new(params[:layout])
|
56
|
+
@layout.parent ||= Cms::Layout.find_by_id(params[:parent_id])
|
57
|
+
@layout.content ||= '{{ cms:page:content:text }}'
|
58
|
+
end
|
59
|
+
|
60
|
+
def load_layout
|
61
|
+
@layout = @site.layouts.find(params[:id])
|
62
|
+
rescue ActiveRecord::RecordNotFound
|
63
|
+
flash[:error] = I18n.t('cms.layouts.not_found')
|
64
|
+
redirect_to :action => :index
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
class CmsAdmin::MenuItemsController < CmsAdmin::BaseController
|
2
|
+
before_filter :load_menu
|
3
|
+
before_filter :build_menu_item, :only => [:new, :create]
|
4
|
+
before_filter :load_menu_item, :only => [:edit, :update, :destroy]
|
5
|
+
|
6
|
+
def index
|
7
|
+
return redirect_to :action => :new if @menu.menu_items.count == 0
|
8
|
+
@menu_items = @menu.menu_items
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
render
|
13
|
+
end
|
14
|
+
|
15
|
+
def edit
|
16
|
+
render
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
@menu_item.save!
|
21
|
+
flash[:success] = I18n.t('cms.menu_items.created')
|
22
|
+
redirect_to :action => :index
|
23
|
+
rescue ActiveRecord::RecordInvalid
|
24
|
+
logger.detailed_error($!)
|
25
|
+
flash.now[:error] = I18n.t('cms.menu_items.creation_failure')
|
26
|
+
render :action => :new
|
27
|
+
end
|
28
|
+
|
29
|
+
def update
|
30
|
+
@menu_item.update_attributes!(params[:menu_item])
|
31
|
+
flash[:success] = I18n.t('cms.menu_items.updated')
|
32
|
+
redirect_to :action => :index, :id => @menu_item
|
33
|
+
rescue ActiveRecord::RecordInvalid
|
34
|
+
logger.detailed_error($!)
|
35
|
+
flash.now[:error] = I18n.t('cms.menu_items.update_failure')
|
36
|
+
render :action => :edit
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
@menu_item.destroy
|
41
|
+
flash[:success] = I18n.t('cms.menu_items.deleted')
|
42
|
+
redirect_to :action => :index
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
protected
|
47
|
+
|
48
|
+
def load_menu
|
49
|
+
@menu = @site.menus.find(params[:menu_id]) || session[:menu_id]
|
50
|
+
end
|
51
|
+
|
52
|
+
def build_menu_item
|
53
|
+
@menu_item= @menu.menu_items.new(params[:menu_item])
|
54
|
+
end
|
55
|
+
|
56
|
+
def load_menu_item
|
57
|
+
@menu_item = @menu.menu_items.find(params[:id])
|
58
|
+
rescue ActiveRecord::RecordNotFound
|
59
|
+
flash[:error] = I18n.t('cms.menu_items.not_found')
|
60
|
+
redirect_to :action => :index
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class CmsAdmin::MenusController < CmsAdmin::BaseController
|
2
|
+
before_filter :build_menu, :only => [:new, :create]
|
3
|
+
before_filter :load_menu, :only => [:edit, :update, :destroy]
|
4
|
+
|
5
|
+
def index
|
6
|
+
return redirect_to :action => :new if @site.menus.count == 0
|
7
|
+
@menus = @site.menus
|
8
|
+
end
|
9
|
+
|
10
|
+
def new
|
11
|
+
render
|
12
|
+
end
|
13
|
+
|
14
|
+
def edit
|
15
|
+
render
|
16
|
+
end
|
17
|
+
|
18
|
+
def create
|
19
|
+
@menu.save!
|
20
|
+
flash[:success] = I18n.t('cms.menus.created')
|
21
|
+
redirect_to :action => :index
|
22
|
+
rescue ActiveRecord::RecordInvalid
|
23
|
+
logger.detailed_error($!)
|
24
|
+
flash.now[:error] = I18n.t('cms.menus.creation_failure')
|
25
|
+
render :action => :new
|
26
|
+
end
|
27
|
+
|
28
|
+
def update
|
29
|
+
@menu.update_attributes!(params[:menu])
|
30
|
+
flash[:success] = I18n.t('cms.menus.updated')
|
31
|
+
redirect_to :action => :index, :id => @menu
|
32
|
+
rescue ActiveRecord::RecordInvalid
|
33
|
+
logger.detailed_error($!)
|
34
|
+
flash.now[:error] = I18n.t('cms.menus.update_failure')
|
35
|
+
render :action => :index
|
36
|
+
end
|
37
|
+
|
38
|
+
def destroy
|
39
|
+
@menu.destroy
|
40
|
+
flash[:success] = I18n.t('cms.menus.deleted')
|
41
|
+
redirect_to :action => :index
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def build_menu
|
48
|
+
@menu= @site.menus.new(params[:menu])
|
49
|
+
end
|
50
|
+
|
51
|
+
def load_menu
|
52
|
+
@menu = @site.menus.find(params[:id])
|
53
|
+
rescue ActiveRecord::RecordNotFound
|
54
|
+
flash[:error] = I18n.t('cms.menus.not_found')
|
55
|
+
redirect_to :action => :index
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
class CmsAdmin::PagesController < CmsAdmin::BaseController
|
2
|
+
|
3
|
+
before_filter :check_for_layouts, :only => [:new, :edit]
|
4
|
+
before_filter :build_cms_page, :only => [:new, :create]
|
5
|
+
before_filter :load_cms_page, :only => [:edit, :update, :destroy]
|
6
|
+
before_filter :preview_cms_page, :only => [:create, :update]
|
7
|
+
before_filter :build_file, :only => [:new, :edit]
|
8
|
+
|
9
|
+
def index
|
10
|
+
return redirect_to :action => :new if @site.pages.count == 0
|
11
|
+
@pages_by_parent = @site.pages.includes(:categories).all.group_by(&:parent_id)
|
12
|
+
if params[:category].present?
|
13
|
+
@pages = @site.pages.includes(:categories).for_category(params[:category]).all(:order => 'label')
|
14
|
+
else
|
15
|
+
@pages = [@site.pages.root].compact
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def new
|
20
|
+
render
|
21
|
+
end
|
22
|
+
|
23
|
+
def edit
|
24
|
+
render
|
25
|
+
end
|
26
|
+
|
27
|
+
def create
|
28
|
+
@page.save!
|
29
|
+
flash[:success] = I18n.t('cms.pages.created')
|
30
|
+
redirect_to :action => :edit, :id => @page
|
31
|
+
rescue ActiveRecord::RecordInvalid
|
32
|
+
logger.detailed_error($!)
|
33
|
+
flash.now[:error] = I18n.t('cms.pages.creation_failure')
|
34
|
+
render :action => :new
|
35
|
+
end
|
36
|
+
|
37
|
+
def update
|
38
|
+
@page.save!
|
39
|
+
flash[:success] = I18n.t('cms.pages.updated')
|
40
|
+
redirect_to :action => :edit, :id => @page
|
41
|
+
rescue ActiveRecord::RecordInvalid
|
42
|
+
logger.detailed_error($!)
|
43
|
+
flash.now[:error] = I18n.t('cms.pages.update_failure')
|
44
|
+
render :action => :edit
|
45
|
+
end
|
46
|
+
|
47
|
+
def destroy
|
48
|
+
@page.destroy
|
49
|
+
flash[:success] = I18n.t('cms.pages.deleted')
|
50
|
+
redirect_to :action => :index
|
51
|
+
end
|
52
|
+
|
53
|
+
def form_blocks
|
54
|
+
@page = @site.pages.find_by_id(params[:id]) || @site.pages.new
|
55
|
+
@page.layout = @site.layouts.find_by_id(params[:layout_id])
|
56
|
+
end
|
57
|
+
|
58
|
+
def toggle_branch
|
59
|
+
@pages_by_parent = @site.pages.includes(:categories).all.group_by(&:parent_id)
|
60
|
+
@page = @site.pages.find(params[:id])
|
61
|
+
s = (session[:cms_page_tree] ||= [])
|
62
|
+
id = @page.id.to_s
|
63
|
+
s.member?(id) ? s.delete(id) : s << id
|
64
|
+
rescue ActiveRecord::RecordNotFound
|
65
|
+
# do nothing
|
66
|
+
end
|
67
|
+
|
68
|
+
def reorder
|
69
|
+
(params[:cms_page] || []).each_with_index do |id, index|
|
70
|
+
Cms::Page.where(:id => id).update_all(:position => index)
|
71
|
+
end
|
72
|
+
render :nothing => true
|
73
|
+
end
|
74
|
+
|
75
|
+
protected
|
76
|
+
|
77
|
+
def check_for_layouts
|
78
|
+
if @site.layouts.count == 0
|
79
|
+
flash[:error] = I18n.t('cms.pages.layout_not_found')
|
80
|
+
redirect_to new_cms_admin_site_layout_path(@site)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def build_cms_page
|
85
|
+
@page = @site.pages.new(params[:page])
|
86
|
+
@page.parent ||= (@site.pages.find_by_id(params[:parent_id]) || @site.pages.root)
|
87
|
+
@page.layout ||= (@page.parent && @page.parent.layout || @site.layouts.first)
|
88
|
+
end
|
89
|
+
|
90
|
+
def build_file
|
91
|
+
@file = Cms::File.new
|
92
|
+
end
|
93
|
+
|
94
|
+
def load_cms_page
|
95
|
+
@page = @site.pages.find(params[:id])
|
96
|
+
@page.attributes = params[:page]
|
97
|
+
@page.layout ||= (@page.parent && @page.parent.layout || @site.layouts.first)
|
98
|
+
rescue ActiveRecord::RecordNotFound
|
99
|
+
flash[:error] = I18n.t('cms.pages.not_found')
|
100
|
+
redirect_to :action => :index
|
101
|
+
end
|
102
|
+
|
103
|
+
def preview_cms_page
|
104
|
+
if params[:preview]
|
105
|
+
layout = @page.layout.app_layout.blank?? false : @page.layout.app_layout
|
106
|
+
@cms_site = @page.site
|
107
|
+
@cms_layout = @page.layout
|
108
|
+
@cms_page = @page
|
109
|
+
render :inline => @page.content(true), :layout => layout
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class CmsAdmin::RevisionsController < CmsAdmin::BaseController
|
2
|
+
|
3
|
+
before_filter :load_record
|
4
|
+
before_filter :load_revision, :except => :index
|
5
|
+
|
6
|
+
def index
|
7
|
+
redirect_to :action => :show, :id => @record.revisions.first.try(:id) || 0
|
8
|
+
end
|
9
|
+
|
10
|
+
def show
|
11
|
+
case @record
|
12
|
+
when Cms::Page
|
13
|
+
@current_content = @record.blocks.inject({}){|c, b| c[b.identifier] = b.content; c }
|
14
|
+
@versioned_content = @record.blocks.inject({}){|c, b| c[b.identifier] = @revision.data['blocks_attributes'].detect{|r| r[:identifier] == b.identifier}.try(:[], :content); c }
|
15
|
+
else
|
16
|
+
@current_content = @record.revision_fields.inject({}){|c, f| c[f] = @record.send(f); c }
|
17
|
+
@versioned_content = @record.revision_fields.inject({}){|c, f| c[f] = @revision.data[f]; c }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def revert
|
22
|
+
@record.restore_from_revision(@revision)
|
23
|
+
flash[:success] = I18n.t('cms.revisions.reverted')
|
24
|
+
redirect_to_record
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def load_record
|
30
|
+
@record = if params[:layout_id]
|
31
|
+
Cms::Layout.find(params[:layout_id])
|
32
|
+
elsif params[:page_id]
|
33
|
+
Cms::Page.find(params[:page_id])
|
34
|
+
elsif params[:snippet_id]
|
35
|
+
Cms::Snippet.find(params[:snippet_id])
|
36
|
+
end
|
37
|
+
rescue ActiveRecord::RecordNotFound
|
38
|
+
flash[:error] = I18n.t('cms.revisions.record_not_found')
|
39
|
+
redirect_to cms_admin_path
|
40
|
+
end
|
41
|
+
|
42
|
+
def load_revision
|
43
|
+
@revision = @record.revisions.find(params[:id])
|
44
|
+
rescue ActiveRecord::RecordNotFound
|
45
|
+
flash[:error] = I18n.t('cms.revisions.not_found')
|
46
|
+
redirect_to_record
|
47
|
+
end
|
48
|
+
|
49
|
+
def redirect_to_record
|
50
|
+
redirect_to case @record
|
51
|
+
when Cms::Layout then edit_cms_admin_site_layout_path(@site, @record)
|
52
|
+
when Cms::Page then edit_cms_admin_site_page_path(@site, @record)
|
53
|
+
when Cms::Snippet then edit_cms_admin_site_snippet_path(@site, @record)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class CmsAdmin::SitesController < CmsAdmin::BaseController
|
2
|
+
|
3
|
+
skip_before_filter :load_admin_site,
|
4
|
+
:load_fixtures
|
5
|
+
|
6
|
+
before_filter :build_site, :only => [:new, :create]
|
7
|
+
before_filter :load_site, :only => [:edit, :update, :destroy]
|
8
|
+
|
9
|
+
def index
|
10
|
+
return redirect_to :action => :new if Cms::Site.count == 0
|
11
|
+
@site = Cms::Site.find_by_id(session[:site_id])
|
12
|
+
@sites ||= Cms::Site.all
|
13
|
+
end
|
14
|
+
|
15
|
+
def new
|
16
|
+
render
|
17
|
+
end
|
18
|
+
|
19
|
+
def edit
|
20
|
+
render
|
21
|
+
end
|
22
|
+
|
23
|
+
def create
|
24
|
+
@site.save!
|
25
|
+
flash[:success] = I18n.t('cms.sites.created')
|
26
|
+
redirect_to cms_admin_site_layouts_path(@site)
|
27
|
+
rescue ActiveRecord::RecordInvalid
|
28
|
+
logger.detailed_error($!)
|
29
|
+
flash.now[:error] = I18n.t('cms.sites.creation_failure')
|
30
|
+
render :action => :new
|
31
|
+
end
|
32
|
+
|
33
|
+
def update
|
34
|
+
@site.update_attributes!(params[:site])
|
35
|
+
flash[:success] = I18n.t('cms.sites.updated')
|
36
|
+
redirect_to :action => :edit, :id => @site
|
37
|
+
rescue ActiveRecord::RecordInvalid
|
38
|
+
logger.detailed_error($!)
|
39
|
+
flash.now[:error] = I18n.t('cms.sites.update_failure')
|
40
|
+
render :action => :edit
|
41
|
+
end
|
42
|
+
|
43
|
+
def destroy
|
44
|
+
@site.destroy
|
45
|
+
flash[:success] = I18n.t('cms.sites.deleted')
|
46
|
+
redirect_to :action => :index
|
47
|
+
end
|
48
|
+
|
49
|
+
protected
|
50
|
+
|
51
|
+
def build_site
|
52
|
+
@site = Cms::Site.new(params[:site])
|
53
|
+
@site.hostname ||= request.host.downcase
|
54
|
+
end
|
55
|
+
|
56
|
+
def load_site
|
57
|
+
@site = Cms::Site.find(params[:id])
|
58
|
+
I18n.locale = ComfyPress.config.admin_locale || @site.locale
|
59
|
+
rescue ActiveRecord::RecordNotFound
|
60
|
+
flash[:error] = I18n.t('cms.sites.not_found')
|
61
|
+
redirect_to :action => :index
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class CmsAdmin::SnippetsController < CmsAdmin::BaseController
|
2
|
+
|
3
|
+
before_filter :build_snippet, :only => [:new, :create]
|
4
|
+
before_filter :load_snippet, :only => [:edit, :update, :destroy]
|
5
|
+
|
6
|
+
def index
|
7
|
+
return redirect_to :action => :new if @site.snippets.count == 0
|
8
|
+
@snippets = @site.snippets.includes(:categories).for_category(params[:category])
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
render
|
13
|
+
end
|
14
|
+
|
15
|
+
def edit
|
16
|
+
render
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
@snippet.save!
|
21
|
+
flash[:success] = I18n.t('cms.snippets.created')
|
22
|
+
redirect_to :action => :edit, :id => @snippet
|
23
|
+
rescue ActiveRecord::RecordInvalid
|
24
|
+
logger.detailed_error($!)
|
25
|
+
flash.now[:error] = I18n.t('cms.snippets.creation_failure')
|
26
|
+
render :action => :new
|
27
|
+
end
|
28
|
+
|
29
|
+
def update
|
30
|
+
@snippet.update_attributes!(params[:snippet])
|
31
|
+
flash[:success] = I18n.t('cms.snippets.updated')
|
32
|
+
redirect_to :action => :edit, :id => @snippet
|
33
|
+
rescue ActiveRecord::RecordInvalid
|
34
|
+
logger.detailed_error($!)
|
35
|
+
flash.now[:error] = I18n.t('cms.snippets.update_failure')
|
36
|
+
render :action => :edit
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
@snippet.destroy
|
41
|
+
flash[:success] = I18n.t('cms.snippets.deleted')
|
42
|
+
redirect_to :action => :index
|
43
|
+
end
|
44
|
+
|
45
|
+
def reorder
|
46
|
+
(params[:cms_snippet] || []).each_with_index do |id, index|
|
47
|
+
Cms::Snippet.where(:id => id).update_all(:position => index)
|
48
|
+
end
|
49
|
+
render :nothing => true
|
50
|
+
end
|
51
|
+
|
52
|
+
protected
|
53
|
+
|
54
|
+
def build_snippet
|
55
|
+
@snippet = @site.snippets.new(params[:snippet])
|
56
|
+
end
|
57
|
+
|
58
|
+
def load_snippet
|
59
|
+
@snippet = @site.snippets.find(params[:id])
|
60
|
+
rescue ActiveRecord::RecordNotFound
|
61
|
+
flash[:error] = I18n.t('cms.snippets.not_found')
|
62
|
+
redirect_to :action => :index
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
class CmsContentController < ApplicationController
|
2
|
+
|
3
|
+
# Authentication module must have #authenticate method
|
4
|
+
include ComfyPress.config.public_auth.to_s.constantize
|
5
|
+
|
6
|
+
before_filter :load_cms_site,
|
7
|
+
:load_fixtures
|
8
|
+
before_filter :load_cms_page,
|
9
|
+
:authenticate,
|
10
|
+
:only => :render_html
|
11
|
+
before_filter :load_cms_layout,
|
12
|
+
:only => [:render_css, :render_js]
|
13
|
+
|
14
|
+
def render_html(status = 200)
|
15
|
+
if @cms_layout = @cms_page.layout
|
16
|
+
app_layout = (@cms_layout.app_layout.blank? || request.xhr?) ? false : @cms_layout.app_layout
|
17
|
+
render :inline => @cms_page.content, :layout => app_layout, :status => status, :content_type => 'text/html'
|
18
|
+
else
|
19
|
+
render :text => I18n.t('cms.content.layout_not_found'), :status => 404
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def render_sitemap
|
24
|
+
render
|
25
|
+
end
|
26
|
+
|
27
|
+
def render_css
|
28
|
+
render :text => @cms_layout.css, :content_type => 'text/css'
|
29
|
+
end
|
30
|
+
|
31
|
+
def render_js
|
32
|
+
render :text => @cms_layout.js, :content_type => 'text/javascript'
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
def load_fixtures
|
38
|
+
return unless ComfyPress.config.enable_fixtures
|
39
|
+
ComfyPress::Fixtures.import_all(@cms_site.identifier)
|
40
|
+
end
|
41
|
+
|
42
|
+
def load_cms_site
|
43
|
+
@cms_site ||= if params[:site_id]
|
44
|
+
Cms::Site.find_by_id(params[:site_id])
|
45
|
+
else
|
46
|
+
Cms::Site.find_site(request.host_with_port.downcase, request.fullpath)
|
47
|
+
end
|
48
|
+
|
49
|
+
if @cms_site
|
50
|
+
if params[:cms_path].present?
|
51
|
+
params[:cms_path].gsub!(/^#{@cms_site.path}/, '')
|
52
|
+
params[:cms_path].to_s.gsub!(/^\//, '')
|
53
|
+
end
|
54
|
+
I18n.locale = @cms_site.locale
|
55
|
+
else
|
56
|
+
I18n.locale = I18n.default_locale
|
57
|
+
raise ActionController::RoutingError.new('Site Not Found')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def load_cms_page
|
62
|
+
@cms_page = @cms_site.pages.published.find_by_full_path!("/#{params[:cms_path]}")
|
63
|
+
return redirect_to(@cms_page.target_page.url) if @cms_page.target_page
|
64
|
+
|
65
|
+
rescue ActiveRecord::RecordNotFound
|
66
|
+
if @cms_page = @cms_site.pages.published.find_by_full_path('/404')
|
67
|
+
render_html(404)
|
68
|
+
else
|
69
|
+
raise ActionController::RoutingError.new('Page Not Found')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def load_cms_layout
|
74
|
+
@cms_layout = @cms_site.layouts.find_by_identifier!(params[:identifier])
|
75
|
+
rescue ActiveRecord::RecordNotFound
|
76
|
+
render :nothing => true, :status => 404
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ApplicationHelper
|
2
|
+
def link_to_menu_item(menu_item)
|
3
|
+
if 'link' == menu_item.menu_item_type
|
4
|
+
link = link_to(menu_item.label, menu_item.link)
|
5
|
+
else
|
6
|
+
if menu_item.page_id
|
7
|
+
page = Cms::Page.find(menu_item.page_id)
|
8
|
+
link = link_to(menu_item.label, page.url)
|
9
|
+
else
|
10
|
+
ComfyPress.logger.warn('Page is not selected for menu item.')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
link
|
15
|
+
end
|
16
|
+
end
|