deluxe_publisher 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +29 -0
- data/LICENSE +20 -0
- data/README.rdoc +127 -0
- data/Rakefile +61 -0
- data/VERSION +1 -0
- data/app/controllers/deluxe_publisher/comments_controller.rb +93 -0
- data/app/controllers/deluxe_publisher/page_types_controller.rb +115 -0
- data/app/controllers/deluxe_publisher/pages_controller.rb +191 -0
- data/app/controllers/deluxe_publisher/presenter_controller.rb +185 -0
- data/app/controllers/deluxe_publisher/redirects_controller.rb +90 -0
- data/app/controllers/deluxe_publisher/sitemap_controller.rb +10 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/helpers/deluxe_publisher/comments_helper.rb +2 -0
- data/app/helpers/deluxe_publisher/page_types_helper.rb +13 -0
- data/app/helpers/deluxe_publisher/pages_helper.rb +41 -0
- data/app/helpers/deluxe_publisher/presenter_helper.rb +111 -0
- data/app/helpers/deluxe_publisher/redirects_helper.rb +2 -0
- data/app/helpers/deluxe_publisher/sitemap_helper.rb +2 -0
- data/app/models/ckeditor/asset.rb +88 -0
- data/app/models/ckeditor/attachment_file.rb +40 -0
- data/app/models/ckeditor/picture.rb +23 -0
- data/app/models/deluxe_publisher/comment.rb +6 -0
- data/app/models/deluxe_publisher/content.rb +6 -0
- data/app/models/deluxe_publisher/content_descriptor.rb +4 -0
- data/app/models/deluxe_publisher/page.rb +206 -0
- data/app/models/deluxe_publisher/page_type.rb +55 -0
- data/app/models/deluxe_publisher/redirect.rb +6 -0
- data/app/models/deluxe_publisher.rb +5 -0
- data/app/views/deluxe_publisher/comments/_form.html.erb +31 -0
- data/app/views/deluxe_publisher/comments/edit.html.erb +6 -0
- data/app/views/deluxe_publisher/comments/index.html.erb +31 -0
- data/app/views/deluxe_publisher/comments/new.html.erb +6 -0
- data/app/views/deluxe_publisher/comments/show.html.erb +30 -0
- data/app/views/deluxe_publisher/page_types/_content_descriptors.html.erb +15 -0
- data/app/views/deluxe_publisher/page_types/_form.html.erb +59 -0
- data/app/views/deluxe_publisher/page_types/content_areas_change.js.erb +3 -0
- data/app/views/deluxe_publisher/page_types/edit.html.erb +8 -0
- data/app/views/deluxe_publisher/page_types/index.html.erb +29 -0
- data/app/views/deluxe_publisher/page_types/new.html.erb +7 -0
- data/app/views/deluxe_publisher/page_types/show.html.erb +45 -0
- data/app/views/deluxe_publisher/pages/_form.html.erb +39 -0
- data/app/views/deluxe_publisher/pages/_general.html.erb +108 -0
- data/app/views/deluxe_publisher/pages/_page.html.erb +23 -0
- data/app/views/deluxe_publisher/pages/_page_content.html.erb +16 -0
- data/app/views/deluxe_publisher/pages/_page_links.html.erb +9 -0
- data/app/views/deluxe_publisher/pages/_seo.html.erb +27 -0
- data/app/views/deluxe_publisher/pages/edit.html.erb +5 -0
- data/app/views/deluxe_publisher/pages/index.html.erb +11 -0
- data/app/views/deluxe_publisher/pages/new.html.erb +6 -0
- data/app/views/deluxe_publisher/pages/page_type_change.js.erb +3 -0
- data/app/views/deluxe_publisher/pages/show.html.erb +115 -0
- data/app/views/deluxe_publisher/presenter/create_comment.js.erb +3 -0
- data/app/views/deluxe_publisher/presenter/create_comment_failed.js.erb +1 -0
- data/app/views/deluxe_publisher/presenter/new_comment.js.erb +7 -0
- data/app/views/deluxe_publisher/presenter/preview.html.erb +2 -0
- data/app/views/deluxe_publisher/redirects/_form.html.erb +29 -0
- data/app/views/deluxe_publisher/redirects/edit.html.erb +6 -0
- data/app/views/deluxe_publisher/redirects/index.html.erb +27 -0
- data/app/views/deluxe_publisher/redirects/new.html.erb +5 -0
- data/app/views/deluxe_publisher/redirects/show.html.erb +20 -0
- data/app/views/deluxe_publisher/sitemap/index.xml.builder +12 -0
- data/app/views/deluxe_publisher/templates/simple_blog.html.erb +19 -0
- data/app/views/deluxe_publisher/templates/simple_blog.rss.builder +23 -0
- data/app/views/deluxe_publisher/templates/simple_blog_story.html.erb +9 -0
- data/app/views/deluxe_publisher/templates/simple_page.html.erb +4 -0
- data/app/views/layouts/_deluxe_publisher_comment_form.html.erb +29 -0
- data/app/views/layouts/_deluxe_publisher_comments_list.html.erb +8 -0
- data/app/views/layouts/application.html.erb +14 -0
- data/app/views/layouts/deluxe_publisher.html.erb +36 -0
- data/app/views/layouts/deluxe_publisher_blog.html.erb +63 -0
- data/app/views/layouts/deluxe_publisher_simple.html.erb +30 -0
- data/config/routes.rb +49 -0
- data/deluxe_publisher.gemspec +466 -0
- data/lib/deluxe_publisher/deluxe_publisher_authentication.rb +37 -0
- data/lib/deluxe_publisher/engine.rb +5 -0
- data/lib/deluxe_publisher.rb +40 -0
- data/lib/generators/deluxe_publisher/base/USAGE +8 -0
- data/lib/generators/deluxe_publisher/base/base_generator.rb +45 -0
- data/lib/generators/deluxe_publisher/base/templates/images/add.png +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/btn_addNewPage.gif +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/btn_cancel.gif +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/btn_preview.gif +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/btn_save.gif +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/bullet.gif +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/content_bg.jpg +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/delete.png +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/edit.png +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/header_background.jpg +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/icon_published.gif +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/icon_unpublished.gif +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/logo.gif +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/minus.gif +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/plus.gif +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/show.png +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/tab_bg.gif +0 -0
- data/lib/generators/deluxe_publisher/base/templates/images/tabs_bg.jpg +0 -0
- data/lib/generators/deluxe_publisher/base/templates/initializer.rb +23 -0
- data/lib/generators/deluxe_publisher/base/templates/javascripts/deluxe_presenter.js +25 -0
- data/lib/generators/deluxe_publisher/base/templates/javascripts/deluxe_publisher.js +86 -0
- data/lib/generators/deluxe_publisher/base/templates/javascripts/jquery-rails.js +158 -0
- data/lib/generators/deluxe_publisher/base/templates/layouts/_deluxe_publisher_comment_form.html.erb +29 -0
- data/lib/generators/deluxe_publisher/base/templates/layouts/_deluxe_publisher_comments_list.html.erb +8 -0
- data/lib/generators/deluxe_publisher/base/templates/layouts/deluxe_publisher_blog.html.erb +74 -0
- data/lib/generators/deluxe_publisher/base/templates/layouts/deluxe_publisher_simple.html.erb +47 -0
- data/lib/generators/deluxe_publisher/base/templates/stylesheets/deluxe_presenter.css +458 -0
- data/lib/generators/deluxe_publisher/base/templates/stylesheets/deluxe_publisher.css +202 -0
- data/lib/generators/deluxe_publisher/base/templates/templates/simple_blog.html.erb +19 -0
- data/lib/generators/deluxe_publisher/base/templates/templates/simple_blog.rss.builder +23 -0
- data/lib/generators/deluxe_publisher/base/templates/templates/simple_blog_story.html.erb +12 -0
- data/lib/generators/deluxe_publisher/base/templates/templates/simple_page.html.erb +4 -0
- data/lib/generators/deluxe_publisher/migration/USAGE +0 -0
- data/lib/generators/deluxe_publisher/migration/migration_generator.rb +18 -0
- data/lib/generators/deluxe_publisher/migration/templates/migration.rb +98 -0
- data/lib/generators/deluxe_publisher/sample_site/sample_site_generator.rb +316 -0
- data/spec/controllers/deluxe_publisher/comments_controller_spec.rb +129 -0
- data/spec/controllers/deluxe_publisher/page_types_controller_spec.rb +125 -0
- data/spec/controllers/deluxe_publisher/pages_controller_spec.rb +129 -0
- data/spec/controllers/deluxe_publisher/presenter_controller_spec.rb +19 -0
- data/spec/controllers/deluxe_publisher/redirects_controller_spec.rb +118 -0
- data/spec/deluxe_publisher_spec.rb +7 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/deluxe_publisher/comments/_form.html.erb +31 -0
- data/spec/dummy/app/views/deluxe_publisher/comments/edit.html.erb +6 -0
- data/spec/dummy/app/views/deluxe_publisher/comments/index.html.erb +31 -0
- data/spec/dummy/app/views/deluxe_publisher/comments/new.html.erb +6 -0
- data/spec/dummy/app/views/deluxe_publisher/comments/show.html.erb +30 -0
- data/spec/dummy/app/views/deluxe_publisher/page_types/_content_descriptors.html.erb +15 -0
- data/spec/dummy/app/views/deluxe_publisher/page_types/_form.html.erb +59 -0
- data/spec/dummy/app/views/deluxe_publisher/page_types/content_areas_change.js.erb +3 -0
- data/spec/dummy/app/views/deluxe_publisher/page_types/edit.html.erb +8 -0
- data/spec/dummy/app/views/deluxe_publisher/page_types/index.html.erb +29 -0
- data/spec/dummy/app/views/deluxe_publisher/page_types/new.html.erb +7 -0
- data/spec/dummy/app/views/deluxe_publisher/page_types/show.html.erb +45 -0
- data/spec/dummy/app/views/deluxe_publisher/pages/_form.html.erb +36 -0
- data/spec/dummy/app/views/deluxe_publisher/pages/_general.html.erb +108 -0
- data/spec/dummy/app/views/deluxe_publisher/pages/_page.html.erb +23 -0
- data/spec/dummy/app/views/deluxe_publisher/pages/_page_content.html.erb +16 -0
- data/spec/dummy/app/views/deluxe_publisher/pages/_page_links.html.erb +9 -0
- data/spec/dummy/app/views/deluxe_publisher/pages/_seo.html.erb +27 -0
- data/spec/dummy/app/views/deluxe_publisher/pages/edit.html.erb +7 -0
- data/spec/dummy/app/views/deluxe_publisher/pages/index.html.erb +10 -0
- data/spec/dummy/app/views/deluxe_publisher/pages/new.html.erb +7 -0
- data/spec/dummy/app/views/deluxe_publisher/pages/page_type_change.js.erb +3 -0
- data/spec/dummy/app/views/deluxe_publisher/pages/show.html.erb +115 -0
- data/spec/dummy/app/views/deluxe_publisher/presenter/create_comment.js.erb +3 -0
- data/spec/dummy/app/views/deluxe_publisher/presenter/create_comment_failed.js.erb +1 -0
- data/spec/dummy/app/views/deluxe_publisher/presenter/new_comment.js.erb +7 -0
- data/spec/dummy/app/views/deluxe_publisher/presenter/preview.html.erb +2 -0
- data/spec/dummy/app/views/deluxe_publisher/templates/simple_blog.html.erb +19 -0
- data/spec/dummy/app/views/deluxe_publisher/templates/simple_blog.rss.builder +23 -0
- data/spec/dummy/app/views/deluxe_publisher/templates/simple_blog_story.html.erb +9 -0
- data/spec/dummy/app/views/deluxe_publisher/templates/simple_page.html.erb +4 -0
- data/spec/dummy/app/views/layouts/_deluxe_publisher_comment_form.html.erb +29 -0
- data/spec/dummy/app/views/layouts/_deluxe_publisher_comments_list.html.erb +8 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/deluxe_publisher.html.erb +31 -0
- data/spec/dummy/app/views/layouts/deluxe_publisher_blog.html.erb +63 -0
- data/spec/dummy/app/views/layouts/deluxe_publisher_simple.html.erb +30 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/deluxe_publisher.rb +23 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +104 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20110405190943_create_deluxe_publisher.rb +135 -0
- data/spec/dummy/db/schema.rb +130 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +191 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/comment_factory.rb +4 -0
- data/spec/factories/content_descriptor_factory.rb +5 -0
- data/spec/factories/content_factory.rb +24 -0
- data/spec/factories/page_factory.rb +26 -0
- data/spec/factories/page_type_factory.rb +10 -0
- data/spec/factories/redirect_factory.rb +4 -0
- data/spec/helpers/deluxe_publisher/comments_helper_spec.rb +15 -0
- data/spec/helpers/deluxe_publisher/page_types_helper_spec.rb +26 -0
- data/spec/helpers/deluxe_publisher/pages_helper_spec.rb +65 -0
- data/spec/helpers/deluxe_publisher/presenter_helper_spec.rb +19 -0
- data/spec/helpers/deluxe_publisher/redirects_helper_spec.rb +15 -0
- data/spec/integration/navigation_spec.rb +9 -0
- data/spec/models/deluxe_publisher/comment_spec.rb +5 -0
- data/spec/models/deluxe_publisher/content_descriptor_spec.rb +5 -0
- data/spec/models/deluxe_publisher/content_spec.rb +5 -0
- data/spec/models/deluxe_publisher/page_spec.rb +358 -0
- data/spec/models/deluxe_publisher/page_type_spec.rb +62 -0
- data/spec/models/deluxe_publisher/redirect_spec.rb +17 -0
- data/spec/requests/deluxe_publisher/deluxe_publisher_comments_spec.rb +11 -0
- data/spec/requests/deluxe_publisher/deluxe_publisher_page_types_spec.rb +11 -0
- data/spec/requests/deluxe_publisher/deluxe_publisher_redirects_spec.rb +11 -0
- data/spec/requests/deluxe_publisher/pages_spec.rb +11 -0
- data/spec/routing/deluxe_publisher/comments_routing_spec.rb +35 -0
- data/spec/routing/deluxe_publisher/page_types_routing_spec.rb +47 -0
- data/spec/routing/deluxe_publisher/pages_routing_spec.rb +47 -0
- data/spec/routing/deluxe_publisher/presenter_routing_spec.rb +66 -0
- data/spec/routing/deluxe_publisher/redirects_routing_spec.rb +35 -0
- data/spec/spec_helper.rb +234 -0
- data/spec/views/deluxe_publisher/comments/edit.html.erb_spec.rb +24 -0
- data/spec/views/deluxe_publisher/comments/index.html.erb_spec.rb +32 -0
- data/spec/views/deluxe_publisher/comments/new.html.erb_spec.rb +24 -0
- data/spec/views/deluxe_publisher/comments/show.html.erb_spec.rb +24 -0
- data/spec/views/deluxe_publisher/page_types/edit.html.erb_spec.rb +32 -0
- data/spec/views/deluxe_publisher/page_types/index.html.erb_spec.rb +48 -0
- data/spec/views/deluxe_publisher/page_types/new.html.erb_spec.rb +32 -0
- data/spec/views/deluxe_publisher/page_types/show.html.erb_spec.rb +36 -0
- data/spec/views/deluxe_publisher/pages/edit.html.erb_spec.rb +58 -0
- data/spec/views/deluxe_publisher/pages/index.html.erb_spec.rb +100 -0
- data/spec/views/deluxe_publisher/pages/new.html.erb_spec.rb +81 -0
- data/spec/views/deluxe_publisher/pages/show.html.erb_spec.rb +75 -0
- data/spec/views/deluxe_publisher/presenter/present.html.erb_spec.rb +5 -0
- data/spec/views/deluxe_publisher/presenter/preview.html.erb_spec.rb +5 -0
- data/spec/views/deluxe_publisher/redirects/edit.html.erb_spec.rb +22 -0
- data/spec/views/deluxe_publisher/redirects/index.html.erb_spec.rb +28 -0
- data/spec/views/deluxe_publisher/redirects/new.html.erb_spec.rb +22 -0
- data/spec/views/deluxe_publisher/redirects/show.html.erb_spec.rb +21 -0
- metadata +1006 -0
@@ -0,0 +1,206 @@
|
|
1
|
+
|
2
|
+
class DeluxePublisher::Page < ActiveRecord::Base
|
3
|
+
|
4
|
+
set_table_name 'deluxe_publisher_pages'
|
5
|
+
|
6
|
+
acts_as_taggable
|
7
|
+
|
8
|
+
scope :published, where(["is_published = ? and publish_at < ?", true, DateTime.now])
|
9
|
+
scope :main_nav, where(["is_shown_in_main_navigation = ?", true])
|
10
|
+
scope :secondary_nav, where(["is_shown_in_secondary_navigation = ?", true])
|
11
|
+
|
12
|
+
after_initialize :init_stash
|
13
|
+
before_save :set_path
|
14
|
+
after_save :save_the_children
|
15
|
+
|
16
|
+
belongs_to :page_type, :class_name => 'DeluxePublisher::PageType'
|
17
|
+
has_many :contents, :class_name => 'DeluxePublisher::Content', :dependent => :destroy, :order => "position"
|
18
|
+
has_many :comments, :class_name => 'DeluxePublisher::Comment', :dependent => :destroy
|
19
|
+
|
20
|
+
accepts_nested_attributes_for :contents
|
21
|
+
|
22
|
+
validates_presence_of [:site_id, :parent_id, :footer_position, :page_type_id, :position,
|
23
|
+
:browser_title, :page_title, :menu_title, :file_name], :unless => Proc.new {|page| page.menu_title == "ROOT"}
|
24
|
+
|
25
|
+
# validates_format_of :file_name, :with => /\A[\w\-_\.]+\Z/
|
26
|
+
|
27
|
+
acts_as_nested_set
|
28
|
+
|
29
|
+
def init_stash
|
30
|
+
@content_stash = {}
|
31
|
+
end
|
32
|
+
|
33
|
+
def set_path
|
34
|
+
if self.parent.nil?
|
35
|
+
self.path = ""
|
36
|
+
else
|
37
|
+
unless self.parent.path[-1,1] == "/"
|
38
|
+
self.path = "#{self.parent.path}/#{self.file_name}"
|
39
|
+
else
|
40
|
+
self.path = "#{self.parent.path}#{self.file_name}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# self.path = "#{self.ancestors.map {|p| p.file_name}.join("/")}/#{self.file_name}"
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def path_wo_leading_slash
|
50
|
+
self.path[1..-1]
|
51
|
+
end
|
52
|
+
def save_the_children # to update their paths
|
53
|
+
# I believe the children are the future
|
54
|
+
self.children.each do |child|
|
55
|
+
child.save #they will save their children in turn
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
def is_a_blog?
|
61
|
+
if self.page_type.nil?
|
62
|
+
false
|
63
|
+
else
|
64
|
+
self.page_type.function_as == "blog_page"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def is_a_blog_story?
|
69
|
+
if self.page_type.nil?
|
70
|
+
false
|
71
|
+
else
|
72
|
+
self.page_type.function_as == "blog_story"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def child_of_a_blog?
|
77
|
+
if self.parent.page_type.nil?
|
78
|
+
false #when parent is Root
|
79
|
+
else
|
80
|
+
self.parent.page_type.function_as == "blog_page"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def alias?
|
85
|
+
false #TODO
|
86
|
+
end
|
87
|
+
|
88
|
+
def blog_stories(options = {})
|
89
|
+
|
90
|
+
options = {:limit => 10}.merge(options)
|
91
|
+
if options[:year].nil? && options[:tag].nil? # if there is no year and no tag just return the last 10 stories
|
92
|
+
self.children.published.find(:all, :order => "publish_at desc", :limit => options[:limit])
|
93
|
+
elsif !options[:tag].nil? # find tagged stories
|
94
|
+
|
95
|
+
self.children.published.tagged_with(options[:tag], :order => "publish_at desc")
|
96
|
+
else
|
97
|
+
if !options[:day].nil?
|
98
|
+
start_date = Date.new(options[:year].to_i, options[:month].to_i, options[:day].to_i)
|
99
|
+
end_date = start_date + 1.day
|
100
|
+
elsif !options[:month].nil?
|
101
|
+
start_date = Date.new(options[:year].to_i, options[:month].to_i, 1)
|
102
|
+
end_date = start_date + 1.month
|
103
|
+
else
|
104
|
+
start_date = Date.new(options[:year].to_i, 1, 1)
|
105
|
+
end_date = start_date + 1.year
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
self.children.published.find(:all,
|
110
|
+
:conditions => ["publish_at >= ? and publish_at < ?", start_date, end_date],
|
111
|
+
:order => "publish_at desc")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
def dom_id
|
117
|
+
self.path[1..-1].gsub("/", "_")
|
118
|
+
end
|
119
|
+
|
120
|
+
def number_of_contents
|
121
|
+
unless self.page_type.nil?
|
122
|
+
self.page_type.number_of_content_areas
|
123
|
+
else
|
124
|
+
1
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
def descriptor_for_position(position)
|
130
|
+
unless self.page_type.nil?
|
131
|
+
descriptor = self.page_type.content_descriptors.first(:conditions => {:position => position})
|
132
|
+
else
|
133
|
+
descriptor = DeluxePublisher::ContentDescriptor.new({:title => "Content", :content_type => "text"})
|
134
|
+
end
|
135
|
+
descriptor
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
def stash_content(position, content)
|
140
|
+
@content_stash[position] = content
|
141
|
+
end
|
142
|
+
|
143
|
+
def get_content(position)
|
144
|
+
|
145
|
+
content = @content_stash.fetch(position, nil)
|
146
|
+
|
147
|
+
content ||= self.contents.first(:conditions => {:position => position})
|
148
|
+
content || DeluxePublisher::Content.new({:position => position})
|
149
|
+
end
|
150
|
+
|
151
|
+
def all_contents
|
152
|
+
contents = []
|
153
|
+
(0..(self.number_of_contents-1)).each do |position|
|
154
|
+
contents << get_content(position)
|
155
|
+
end
|
156
|
+
contents
|
157
|
+
end
|
158
|
+
|
159
|
+
def stash_content_attributes(attributes)
|
160
|
+
attributes.each do |key, value|
|
161
|
+
content = self.contents.first(:conditions => {:position => value[:position]})
|
162
|
+
if content.nil?
|
163
|
+
content = DeluxePublisher::Content.new(value)
|
164
|
+
else
|
165
|
+
value.delete(:id)
|
166
|
+
content.attributes = value
|
167
|
+
|
168
|
+
end
|
169
|
+
self.stash_content(value[:position].to_i, content)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def new_contents
|
174
|
+
contents = []
|
175
|
+
(0..(self.number_of_contents-1)).each do |position|
|
176
|
+
contents << DeluxePublisher::Content.new({:position => position})
|
177
|
+
end
|
178
|
+
contents
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
def self.get_site_root(site_id)
|
183
|
+
site_root = DeluxePublisher::Page.find(:first, :conditions => ["site_id = ? and parent_id is null", site_id])
|
184
|
+
if site_root.nil?
|
185
|
+
site_root = DeluxePublisher::Page.create({:site_id => site_id, :menu_title => "ROOT"})
|
186
|
+
end
|
187
|
+
site_root
|
188
|
+
end
|
189
|
+
|
190
|
+
def self.find_with_content(*args)
|
191
|
+
page = find(*args)
|
192
|
+
|
193
|
+
|
194
|
+
(0..(page.number_of_contents-1)).each do |position|
|
195
|
+
unless page.contents.exists?(:position => position)
|
196
|
+
page.contents.create(:position => position)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
page
|
201
|
+
end
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
end
|
206
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class DeluxePublisher::PageType < ActiveRecord::Base
|
2
|
+
|
3
|
+
set_table_name 'deluxe_publisher_page_types'
|
4
|
+
scope :published, where(:is_published => true)
|
5
|
+
|
6
|
+
has_many :content_descriptors, :dependent => :destroy
|
7
|
+
has_many :pages
|
8
|
+
accepts_nested_attributes_for :content_descriptors
|
9
|
+
|
10
|
+
validates_presence_of :name, :position, :function_as, :template
|
11
|
+
|
12
|
+
after_initialize :init_stash
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
# Stashed descriptors are used by the controller to store descriptor data so that when
|
17
|
+
# ajax is used to change the number of descriptors the data entered is not lost.
|
18
|
+
def init_stash
|
19
|
+
@stashed_descriptors = {}
|
20
|
+
end
|
21
|
+
|
22
|
+
def stash_descriptor(position, descriptor)
|
23
|
+
@stashed_descriptors[position.to_i] = descriptor
|
24
|
+
end
|
25
|
+
|
26
|
+
def stash_descriptor_attributes(attributes)
|
27
|
+
attributes.each do |key, value|
|
28
|
+
descriptor = self.content_descriptors.find(:first, :conditions => {:position => value[:position]})
|
29
|
+
if descriptor.nil?
|
30
|
+
descriptor = DeluxePublisher::ContentDescriptor.new(value)
|
31
|
+
else
|
32
|
+
descriptor.attributes = value
|
33
|
+
end
|
34
|
+
@stashed_descriptors[value[:position].to_i] = descriptor
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_content_descriptor(position)
|
40
|
+
descriptor = @stashed_descriptors.fetch(position, nil)
|
41
|
+
descriptor ||= self.content_descriptors.find(:first, :conditions => {:position => position})
|
42
|
+
descriptor ||= DeluxePublisher::ContentDescriptor.new({:position => position})
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def all_content_descriptors
|
47
|
+
descriptors = []
|
48
|
+
(0..((self.number_of_content_areas||1)-1)).each do |position|
|
49
|
+
descriptors << self.get_content_descriptor(position)
|
50
|
+
end
|
51
|
+
descriptors
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
<% if f.object.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@deluxe_publisher_comment.errors.count, "error") %> prohibited this Comment from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @deluxe_publisher_comment.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
|
15
|
+
<div class="field">
|
16
|
+
<%= f.label :body %><br />
|
17
|
+
<%= f.text_area :body %>
|
18
|
+
</div>
|
19
|
+
<div class="field">
|
20
|
+
<%= f.label :author %><br />
|
21
|
+
<%= f.text_field :author %>
|
22
|
+
</div>
|
23
|
+
<div class="field">
|
24
|
+
<%= f.label :status %><br />
|
25
|
+
<%= f.select :status, ["pending", "approved", "declined"] %>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="actions">
|
29
|
+
<%= f.submit %>
|
30
|
+
</div>
|
31
|
+
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<h1>Editing deluxe_publisher_comment</h1>
|
2
|
+
<%= form_for(@deluxe_publisher_comment, :url => deluxe_publisher_page_comment_path(@page.id, @deluxe_publisher_comment)) do |f| %>
|
3
|
+
<%= render :partial => 'form', :locals => {:f => f} %>
|
4
|
+
<% end %>
|
5
|
+
<%= link_to 'Show', deluxe_publisher_page_comment_path(@page,@deluxe_publisher_comment) %> |
|
6
|
+
<%= link_to 'Back', deluxe_publisher_page_comments_path(@page) %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<h1>Listing deluxe_publisher_comments</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<th>Page</th>
|
6
|
+
<th>Author</th>
|
7
|
+
<th>Body</th>
|
8
|
+
<th>Status</th>
|
9
|
+
<th>Posted at</th>
|
10
|
+
<th></th>
|
11
|
+
<th></th>
|
12
|
+
<th></th>
|
13
|
+
</tr>
|
14
|
+
|
15
|
+
<% @deluxe_publisher_comments.each do |deluxe_publisher_comment| %>
|
16
|
+
<tr>
|
17
|
+
<td><%= deluxe_publisher_comment.page_id %></td>
|
18
|
+
<td><%= deluxe_publisher_comment.author %></td>
|
19
|
+
<td><%= deluxe_publisher_comment.body %></td>
|
20
|
+
<td><%= deluxe_publisher_comment.status %></td>
|
21
|
+
<td><%= deluxe_publisher_comment.posted_at %></td>
|
22
|
+
<td><%= link_to 'Show', deluxe_publisher_page_comment_path(@page, deluxe_publisher_comment) %></td>
|
23
|
+
<td><%= link_to 'Edit', edit_deluxe_publisher_page_comment_path(@page,deluxe_publisher_comment) %></td>
|
24
|
+
<td><%= link_to 'Destroy', deluxe_publisher_page_comment_path(@page, deluxe_publisher_comment), :confirm => 'Are you sure?', :method => :delete %></td>
|
25
|
+
</tr>
|
26
|
+
<% end %>
|
27
|
+
</table>
|
28
|
+
|
29
|
+
<br />
|
30
|
+
|
31
|
+
<%= link_to 'New Comment', new_deluxe_publisher_page_comment_path(@page) %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<b>Page:</b>
|
5
|
+
<%= @deluxe_publisher_comment.page_id %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<b>Author:</b>
|
10
|
+
<%= @deluxe_publisher_comment.author %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
<b>Body:</b>
|
15
|
+
<%= @deluxe_publisher_comment.body %>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<p>
|
19
|
+
<b>Status:</b>
|
20
|
+
<%= @deluxe_publisher_comment.status %>
|
21
|
+
</p>
|
22
|
+
|
23
|
+
<p>
|
24
|
+
<b>Posted at:</b>
|
25
|
+
<%= @deluxe_publisher_comment.posted_at %>
|
26
|
+
</p>
|
27
|
+
|
28
|
+
|
29
|
+
<%= link_to 'Edit', edit_deluxe_publisher_page_comment_path(@page, @deluxe_publisher_comment) %> |
|
30
|
+
<%= link_to 'Back', deluxe_publisher_page_comments_path(@page) %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= f.fields_for :content_descriptors, @deluxe_publisher_page_type.all_content_descriptors do |cd| %>
|
2
|
+
<div class="content_descriptor">
|
3
|
+
<h3>Content Area #<%= cd.object.position %></h3>
|
4
|
+
<div class="field">
|
5
|
+
<%= cd.label :title %>
|
6
|
+
<%= cd.text_field :title %>
|
7
|
+
</div>
|
8
|
+
<div class="field">
|
9
|
+
<%= cd.label :content_type, "Type" %>
|
10
|
+
|
11
|
+
<%= cd.select :content_type, [["Text Area", "text"],["Text Input", "string"]] %>
|
12
|
+
<%= cd.hidden_field :position %>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
@@ -0,0 +1,59 @@
|
|
1
|
+
|
2
|
+
<%= form_for(@deluxe_publisher_page_type) do |f| %>
|
3
|
+
<article>
|
4
|
+
<% if @deluxe_publisher_page_type.errors.any? %>
|
5
|
+
<div id="error_explanation">
|
6
|
+
<h2><%= pluralize(@deluxe_publisher_page_type.errors.count, "error") %> prohibited this deluxe_publisher_page_type from being saved:</h2>
|
7
|
+
|
8
|
+
<ul>
|
9
|
+
<% @deluxe_publisher_page_type.errors.full_messages.each do |msg| %>
|
10
|
+
<li><%= msg %></li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<div class="field">
|
17
|
+
<%= f.label :name %><br />
|
18
|
+
<%= f.text_field :name %>
|
19
|
+
</div>
|
20
|
+
<div class="field">
|
21
|
+
<%= f.label :description %><br />
|
22
|
+
<%= f.text_area :description %>
|
23
|
+
</div>
|
24
|
+
<div class="field">
|
25
|
+
<%= f.check_box :is_published %> <%= f.label :is_published, "Publish" %>
|
26
|
+
</div>
|
27
|
+
<div class="field">
|
28
|
+
<%= f.label :position %><br />
|
29
|
+
<%= f.select :position, (1..100) %>
|
30
|
+
</div>
|
31
|
+
<div class="field">
|
32
|
+
<%= f.label :function_as %><br />
|
33
|
+
<%= f.radio_button :function_as, "web_page" %> <%= f.label :function_as_web_page, "Web Page"%>
|
34
|
+
<%= f.radio_button :function_as, "blog_page" %> <%= f.label :function_as_blog_page, "Blog Page"%>
|
35
|
+
<%= f.radio_button :function_as, "blog_story" %> <%= f.label :function_as_blog_story, "Blog Story"%>
|
36
|
+
</div>
|
37
|
+
<div class="field">
|
38
|
+
<%= f.label :number_of_content_areas %><br />
|
39
|
+
<%= f.select :number_of_content_areas, (1..25) %>
|
40
|
+
</div>
|
41
|
+
<div class="field">
|
42
|
+
<%= f.label :template %><br />
|
43
|
+
<%= f.select :template, template_options %>
|
44
|
+
</div>
|
45
|
+
<div class="field">
|
46
|
+
<%= f.label :layout %><br />
|
47
|
+
<%= f.select :layout, layout_options %>
|
48
|
+
</div>
|
49
|
+
|
50
|
+
|
51
|
+
<div id="content_descriptors">
|
52
|
+
<%= render :partial => 'content_descriptors', :locals => {:f => f} %>
|
53
|
+
</div>
|
54
|
+
|
55
|
+
<div class="actions">
|
56
|
+
<%= f.submit %>
|
57
|
+
</div>
|
58
|
+
</article>
|
59
|
+
<% end %>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<header></header><h1>Page Types</h1></header>
|
2
|
+
<article>
|
3
|
+
|
4
|
+
<table>
|
5
|
+
<tr>
|
6
|
+
<th>Name</th>
|
7
|
+
|
8
|
+
<th>Published</th>
|
9
|
+
<th></th>
|
10
|
+
<th></th>
|
11
|
+
<th></th>
|
12
|
+
</tr>
|
13
|
+
|
14
|
+
<% @deluxe_publisher_page_types.each do |deluxe_publisher_page_type| %>
|
15
|
+
<tr>
|
16
|
+
<td><%= deluxe_publisher_page_type.name %></td>
|
17
|
+
|
18
|
+
<td><%= "Yes" if deluxe_publisher_page_type.is_published? %></td>
|
19
|
+
<td><%= link_to 'Show', deluxe_publisher_page_type %></td>
|
20
|
+
<td><%= link_to 'Edit', edit_deluxe_publisher_page_type_path(deluxe_publisher_page_type) %></td>
|
21
|
+
<td><%= link_to 'Destroy', deluxe_publisher_page_type, :confirm => 'Are you sure?', :method => :delete %></td>
|
22
|
+
</tr>
|
23
|
+
<% end %>
|
24
|
+
</table>
|
25
|
+
|
26
|
+
<br />
|
27
|
+
|
28
|
+
<%= link_to 'New Page type', new_deluxe_publisher_page_type_path %>
|
29
|
+
</article>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<b>Name:</b>
|
5
|
+
<%= @deluxe_publisher_page_type.name %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<b>Description:</b>
|
10
|
+
<%= @deluxe_publisher_page_type.description %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
<b>Is published:</b>
|
15
|
+
<%= @deluxe_publisher_page_type.is_published %>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<p>
|
19
|
+
<b>Position:</b>
|
20
|
+
<%= @deluxe_publisher_page_type.position %>
|
21
|
+
</p>
|
22
|
+
|
23
|
+
<p>
|
24
|
+
<b>Function as:</b>
|
25
|
+
<%= @deluxe_publisher_page_type.function_as %>
|
26
|
+
</p>
|
27
|
+
|
28
|
+
<p>
|
29
|
+
<b>Number of content areas:</b>
|
30
|
+
<%= @deluxe_publisher_page_type.number_of_content_areas %>
|
31
|
+
</p>
|
32
|
+
|
33
|
+
<p>
|
34
|
+
<b>Template:</b>
|
35
|
+
<%= @deluxe_publisher_page_type.template %>
|
36
|
+
</p>
|
37
|
+
|
38
|
+
<p>
|
39
|
+
<b>Layout:</b>
|
40
|
+
<%= @deluxe_publisher_page_type.layout %>
|
41
|
+
</p>
|
42
|
+
|
43
|
+
|
44
|
+
<%= link_to 'Edit', edit_deluxe_publisher_page_type_path(@deluxe_publisher_page_type) %> |
|
45
|
+
<%= link_to 'Back', deluxe_publisher_page_types_path %>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
<% form_for(@page, :html => {:class => "deluxe_publisher_page"}) do |f| %>
|
3
|
+
<% if @page.errors.any? %>
|
4
|
+
<div id="error_explanation">
|
5
|
+
<h2> <%= pluralize(@page.errors.count, "error") %> prohibited this page from being saved </h2>
|
6
|
+
|
7
|
+
<ul>
|
8
|
+
<% @page.errors.full_messages.each do |msg| %>
|
9
|
+
<li> <%= msg %> </li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
<ul id="tabs">
|
15
|
+
<li id="tab_general" class="on"><a href="#general" class="on">General</a></li>
|
16
|
+
<li id="tab_content" class=""><a href="#content_area">Content</a></li>
|
17
|
+
<li id="tab_seo" class=""><a href="#seo">SEO</a></li>
|
18
|
+
</ul>
|
19
|
+
|
20
|
+
|
21
|
+
<article id="general">
|
22
|
+
<%= render :partial => 'general', :locals => {:f => f} %>
|
23
|
+
</article>
|
24
|
+
|
25
|
+
<article id="page_content">
|
26
|
+
<%= render :partial => 'page_content', :locals => {:f => f} %>
|
27
|
+
</article>
|
28
|
+
|
29
|
+
<article id="seo">
|
30
|
+
<%= render :partial => 'seo', :locals => {:f => f} %>
|
31
|
+
</article>
|
32
|
+
|
33
|
+
<div class="actions">
|
34
|
+
<%= link_to 'Preview', "#", :class => "btn_preview" %>
|
35
|
+
<%= f.submit :class => "btn_save"%>
|
36
|
+
<%= link_to 'Back', deluxe_publisher_pages_path, :class => "btn_cancel" %>
|
37
|
+
|
38
|
+
</div>
|
39
|
+
<% end %>
|