knitkit 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +22 -0
- data/app/controllers/knitkit/base_controller.rb +15 -2
- data/app/controllers/knitkit/blogs_controller.rb +4 -4
- data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +16 -2
- data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +198 -57
- data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +25 -11
- data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +123 -44
- data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +83 -9
- data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +38 -0
- data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +15 -6
- data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +185 -98
- data/app/controllers/knitkit/erp_app/desktop/versions_controller.rb +38 -16
- data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +126 -68
- data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +154 -107
- data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +113 -54
- data/app/controllers/knitkit/online_document_sections_controller.rb +45 -0
- data/app/controllers/knitkit/unauthorized_controller.rb +5 -0
- data/app/controllers/knitkit/website_sections_controller.rb +8 -9
- data/app/mailers/document_mailer.rb +10 -0
- data/app/models/article.rb +1 -1
- data/app/models/content.rb +35 -3
- data/app/models/document.rb +8 -0
- data/app/models/document_type.rb +3 -0
- data/app/models/documented_content.rb +29 -0
- data/app/models/documented_item.rb +31 -0
- data/app/models/extensions/configuration.rb +5 -0
- data/app/models/extensions/party.rb +13 -0
- data/app/models/online_document_section.rb +40 -0
- data/app/models/theme.rb +22 -26
- data/app/models/valid_document.rb +4 -0
- data/app/models/website.rb +158 -119
- data/app/models/website_inquiry.rb +7 -2
- data/app/models/website_inquiry_mailer.rb +4 -3
- data/app/models/website_party_role.rb +5 -0
- data/app/models/website_section.rb +76 -38
- data/app/views/document_mailer/email_document.html.erb +12 -0
- data/app/views/knitkit/blogs/_add_comment.html.erb +2 -2
- data/app/views/knitkit/online_document_sections/index.html.erb +149 -0
- data/app/views/knitkit/website_sections/index.html.erb +0 -1
- data/app/views/layouts/knitkit/base.html.erb +4 -2
- data/app/views/layouts/knitkit/online_document_sections.html.erb +59 -0
- data/app/views/menus/knitkit/_default_menu.html.erb +1 -1
- data/app/views/menus/knitkit/_default_section_menu.html.erb +1 -1
- data/app/views/menus/knitkit/_default_sub_menu.html.erb +2 -2
- data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +1 -1
- data/app/widgets/contact_us/base.rb +5 -5
- data/app/widgets/contact_us/javascript/contact_us.js +2 -1
- data/app/widgets/google_map/base.rb +0 -4
- data/app/widgets/google_map/javascript/google_map.js +4 -3
- data/app/widgets/login/base.rb +0 -5
- data/app/widgets/login/javascript/login.js +155 -153
- data/app/widgets/login/views/index.html.erb +3 -3
- data/app/widgets/login/views/reset_password.html.erb +2 -2
- data/app/widgets/manage_profile/base.rb +46 -67
- data/app/widgets/manage_profile/javascript/manage_profile.js +2 -1
- data/app/widgets/manage_profile/views/_user_information_form.html.erb +5 -1
- data/app/widgets/reset_password/base.rb +4 -6
- data/app/widgets/reset_password/javascript/reset_password.js +2 -1
- data/app/widgets/reset_password/views/index.html.erb +4 -3
- data/app/widgets/search/base.rb +1 -5
- data/app/widgets/search/javascript/search.js +2 -1
- data/app/widgets/search/views/show.html.erb +2 -2
- data/app/widgets/signup/base.rb +7 -6
- data/app/widgets/signup/javascript/signup.js +2 -1
- data/app/widgets/signup/views/error.html.erb +1 -1
- data/config/routes.rb +6 -2
- data/db/data_migrations/20110509223702_add_publisher_role.rb +10 -0
- data/db/data_migrations/20111118182910_setup_knitkit_capabilities.rb +84 -0
- data/db/data_migrations/20120127144444_create_website_role_types.rb +13 -0
- data/db/data_migrations/20120127150505_create_website_default_configuration.rb +72 -0
- data/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.rb +33 -0
- data/db/data_migrations/20120316150424_add_is_template_to_default_website_config.rb +16 -0
- data/db/data_migrations/upgrade/20120210195616_add_website_configs.rb +19 -0
- data/db/data_migrations/upgrade/20120213205519_populate_website_iids.rb +17 -0
- data/db/migrate/20110211002317_setup_knitkit.rb +22 -5
- data/db/migrate/20111207161928_create_documented_items_table.rb +13 -0
- data/db/migrate/20111208180539_add_document_id_to_documented_item.rb +9 -0
- data/db/migrate/20120315163736_add_document.rb +32 -0
- data/db/migrate/20120503183431_create_valid_documents.rb +16 -0
- data/db/migrate/upgrade/20120116201510_add_render_base_layout_flag.rb +13 -0
- data/db/migrate/upgrade/20120127143745_create_website_party_roles.rb +24 -0
- data/db/migrate/upgrade/20120213184509_add_iid_to_websites.rb +14 -0
- data/lib/knitkit.rb +2 -0
- data/lib/knitkit/config.rb +31 -0
- data/lib/knitkit/engine.rb +12 -3
- data/lib/knitkit/extensions.rb +1 -3
- data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +2 -3
- data/lib/knitkit/extensions/active_record/acts_as_document.rb +63 -0
- data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +5 -4
- data/lib/knitkit/extensions/compass_ae/widgets/base.rb +70 -0
- data/lib/knitkit/extensions/railties/action_view.rb +22 -10
- data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +3 -3
- data/lib/knitkit/extensions/railties/theme_support/theme_file_resolver.rb +8 -3
- data/lib/knitkit/routing_filter/section_router.rb +16 -6
- data/lib/knitkit/version.rb +7 -1
- data/public/images/check.png +0 -0
- data/public/images/credit_card.png +0 -0
- data/public/images/knitkit/tooltip.gif +0 -0
- data/public/javascripts/ajax_pagination.js +33 -0
- data/public/javascripts/datepicker.js +6 -1
- data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +731 -258
- data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +289 -238
- data/public/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +2 -4
- data/public/javascripts/erp_app/desktop/applications/knitkit/east_region.js +29 -3
- data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +193 -21
- data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +27 -26
- data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +167 -20
- data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +1 -2
- data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +5 -1
- data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +2 -2
- data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +20 -11
- data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +279 -228
- data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +40 -40
- data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +83 -76
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region.js +1961 -1397
- data/public/javascripts/erp_app/desktop/applications/knitkit/widgets_panel.js +47 -43
- data/public/javascripts/knitkit/helpers.js +26 -0
- data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +1 -2
- data/public/stylesheets/knitkit/documentation.css +50 -0
- data/public/stylesheets/knitkit/style.css +23 -1
- data/spec/controllers/knitkit/erp_app/desktop/articles_controller_spec.rb +8 -0
- data/spec/controllers/knitkit/erp_app/desktop/website_controller_spec.rb +396 -0
- data/spec/controllers/knitkit/erp_app/desktop/website_nav_controller_spec.rb +260 -0
- data/spec/controllers/knitkit/erp_app/desktop/website_section_controller_spec.rb +222 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +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/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +43 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +8 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/spec.rb +27 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -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/initializers/wrap_parameters.rb +12 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/workflow.yml +1 -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/script/rails +6 -0
- data/spec/factories/article.rb +4 -0
- data/spec/factories/basic.rb +3 -0
- data/spec/factories/blog.rb +5 -0
- data/spec/factories/documented_content.rb +4 -0
- data/spec/factories/documented_item.rb +4 -0
- data/spec/factories/online_document_section.rb +6 -0
- data/spec/factories/published_website.rb +4 -0
- data/spec/factories/theme.rb +6 -0
- data/spec/factories/website.rb +5 -0
- data/spec/factories/website_host.rb +4 -0
- data/spec/factories/website_nav.rb +5 -0
- data/spec/factories/website_nav_item.rb +4 -0
- data/spec/factories/website_section.rb +5 -0
- data/spec/models/article_spec.rb +35 -0
- data/spec/models/attribute_type_spec.rb +55 -0
- data/spec/models/attribute_value_spec.rb +114 -0
- data/spec/models/blog_spec.rb +16 -0
- data/spec/models/comment_spec.rb +11 -0
- data/spec/models/content_spec.rb +187 -0
- data/spec/models/documented_item_spec.rb +29 -0
- data/spec/models/online_document_section_spec.rb +34 -0
- data/spec/models/published_element_spec.rb +11 -0
- data/spec/models/published_website_spec.rb +11 -0
- data/spec/models/theme_spec.rb +12 -0
- data/spec/models/website_host_spec.rb +11 -0
- data/spec/models/website_inquiry_spec.rb +24 -0
- data/spec/models/website_nav_item_spec.rb +11 -0
- data/spec/models/website_nav_spec.rb +11 -0
- data/spec/models/website_section_content_spec.rb +11 -0
- data/spec/models/website_section_spec.rb +49 -0
- data/spec/models/website_spec.rb +146 -0
- data/spec/spec_helper.rb +61 -0
- metadata +391 -154
- data/app/controllers/knitkit/articles_controller.rb +0 -7
- data/lib/knitkit/extensions/compass/widgets/base.rb +0 -53
@@ -2,94 +2,153 @@ module Knitkit
|
|
2
2
|
module ErpApp
|
3
3
|
module Desktop
|
4
4
|
class WebsiteSectionController < Knitkit::ErpApp::Desktop::AppController
|
5
|
-
before_filter :set_website_section, :only => [:update, :update_security, :add_layout, :get_layout, :save_layout]
|
5
|
+
before_filter :set_website_section, :only => [:detach_article, :update, :update_security, :add_layout, :get_layout, :save_layout]
|
6
6
|
|
7
7
|
def new
|
8
|
-
|
9
|
-
|
8
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
9
|
+
begin
|
10
|
+
current_user.with_capability(model, 'create', 'Section') do
|
11
|
+
website = Website.find(params[:website_id])
|
12
|
+
website_section = nil
|
13
|
+
|
14
|
+
if params[:title].to_s.downcase == 'blog' && params[:type] == 'Blog'
|
15
|
+
result = {:success => false, :message => 'Blog can not be the title of a Blog'}
|
16
|
+
else
|
17
|
+
website_section = WebsiteSection.new
|
18
|
+
website_section.website_id = website.id
|
19
|
+
website_section.in_menu = params[:in_menu] == 'yes'
|
20
|
+
website_section.title = params[:title]
|
21
|
+
website_section.render_base_layout = params[:render_with_base_layout] == 'yes'
|
22
|
+
website_section.type = params[:type] unless params[:type] == 'Page'
|
23
|
+
website_section.internal_identifier = params[:internal_identifier]
|
24
|
+
|
25
|
+
if website_section.save
|
26
|
+
if params[:website_section_id]
|
27
|
+
parent_website_section = WebsiteSection.find(params[:website_section_id])
|
28
|
+
website_section.move_to_child_of(parent_website_section)
|
29
|
+
end
|
30
|
+
|
31
|
+
if params[:type] == "OnlineDocumentSection"
|
32
|
+
documented_content = DocumentedContent.create(:title => website_section.title, :created_by => current_user, :body_html => website_section.title)
|
33
|
+
DocumentedItem.create(:documented_content_id => documented_content.id, :online_document_section_id => website_section.id)
|
34
|
+
end
|
35
|
+
|
36
|
+
website_section.update_path!
|
37
|
+
result = {:success => true, :node => build_section_hash(website_section, website_section.website)}
|
38
|
+
else
|
39
|
+
message = "<ul>"
|
40
|
+
website_section.errors.collect do |e, m|
|
41
|
+
message << "<li>#{e} #{m}</li>"
|
42
|
+
end
|
43
|
+
message << "</ul>"
|
44
|
+
result = {:success => false, :message => message}
|
45
|
+
end
|
10
46
|
|
11
|
-
if params[:title].to_s.downcase == 'blog' && params[:type] == 'Blog'
|
12
|
-
result = {:success => false, :message => 'Blog can not be the title of a Blog'}
|
13
|
-
else
|
14
|
-
website_section = WebsiteSection.new
|
15
|
-
website_section.website_id = website.id
|
16
|
-
website_section.in_menu = params[:in_menu] == 'yes'
|
17
|
-
website_section.title = params[:title]
|
18
|
-
website_section.type = params[:type] unless params[:type] == 'Page'
|
19
|
-
website_section.internal_identifier = params[:internal_identifier]
|
20
|
-
|
21
|
-
if website_section.save
|
22
|
-
if params[:website_section_id]
|
23
|
-
parent_website_section = WebsiteSection.find(params[:website_section_id])
|
24
|
-
website_section.move_to_child_of(parent_website_section)
|
25
|
-
end
|
26
|
-
|
27
|
-
website_section.update_path!
|
28
|
-
result = {:success => true, :node => build_section_hash(website_section, website_section.website)}
|
29
|
-
else
|
30
|
-
message = "<ul>"
|
31
|
-
website_section.errors.collect do |e, m|
|
32
|
-
message << "<li>#{e} #{m}</li>"
|
33
47
|
end
|
34
|
-
message << "</ul>"
|
35
|
-
result = {:success => false, :message => message}
|
36
|
-
end
|
37
48
|
|
49
|
+
render :json => result
|
50
|
+
end
|
51
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
52
|
+
render :json => {:success => false, :message => ex.message}
|
38
53
|
end
|
39
|
-
|
40
|
-
render :json => result
|
41
54
|
end
|
42
55
|
|
43
56
|
def delete
|
44
|
-
|
57
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
58
|
+
begin
|
59
|
+
current_user.with_capability(model, 'delete', 'Section') do
|
60
|
+
render :json => WebsiteSection.destroy(params[:id]) ? {:success => true} : {:success => false}
|
61
|
+
end
|
62
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
63
|
+
render :json => {:success => false, :message => ex.message}
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def detach_article
|
68
|
+
success = WebsiteSectionContent.where(:website_section_id => @website_section.id, :content_id => params[:article_id]).first.destroy
|
69
|
+
render :json => success ? {:success => true} : {:success => false}
|
45
70
|
end
|
46
71
|
|
47
72
|
def update_security
|
48
|
-
|
49
|
-
if(
|
50
|
-
|
73
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
74
|
+
if current_user.has_capability?(model, 'secure', 'Section') or current_user.has_capability?(model, 'unsecure', 'Section')
|
75
|
+
website = Website.find(params[:site_id])
|
76
|
+
if(params[:secure] == "true")
|
77
|
+
@website_section.add_role(website.role)
|
78
|
+
else
|
79
|
+
@website_section.remove_role(website.role)
|
80
|
+
end
|
81
|
+
|
82
|
+
render :json => {:success => true}
|
51
83
|
else
|
52
|
-
|
84
|
+
render :json => {:success => false, :message => "User does not have capability."}
|
53
85
|
end
|
54
|
-
|
55
|
-
render :json => {:success => true}
|
56
86
|
end
|
57
87
|
|
58
88
|
def update
|
59
|
-
|
60
|
-
|
61
|
-
|
89
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
90
|
+
begin
|
91
|
+
current_user.with_capability(model, 'edit', 'Section') do
|
92
|
+
@website_section.in_menu = params[:in_menu] == 'yes'
|
93
|
+
@website_section.title = params[:title]
|
94
|
+
@website_section.render_base_layout = params[:render_with_base_layout] == 'yes'
|
95
|
+
@website_section.internal_identifier = params[:internal_identifier]
|
62
96
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
97
|
+
if @website_section.save
|
98
|
+
render :json => {:success => true}
|
99
|
+
else
|
100
|
+
render :json => {:success => false}
|
101
|
+
end
|
102
|
+
end
|
103
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
104
|
+
render :json => {:success => false, :message => ex.message}
|
67
105
|
end
|
68
106
|
end
|
69
107
|
|
70
108
|
def add_layout
|
71
|
-
|
72
|
-
|
109
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
110
|
+
begin
|
111
|
+
current_user.with_capability(model, 'create', 'Layout') do
|
112
|
+
@website_section.create_layout
|
113
|
+
render :json => {:success => true}
|
114
|
+
end
|
115
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
116
|
+
render :json => {:success => false, :message => ex.message}
|
117
|
+
end
|
73
118
|
end
|
74
119
|
|
75
120
|
def get_layout
|
76
|
-
|
121
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
122
|
+
begin
|
123
|
+
current_user.with_capability(model, 'edit', 'Layout') do
|
124
|
+
render :text => @website_section.layout
|
125
|
+
end
|
126
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
127
|
+
render :json => {:success => false, :message => ex.message}
|
128
|
+
end
|
77
129
|
end
|
78
130
|
|
79
131
|
def save_layout
|
80
|
-
|
132
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
133
|
+
begin
|
134
|
+
current_user.with_capability(model, 'edit', 'Layout') do
|
135
|
+
result = Knitkit::SyntaxValidator.validate_content(:erb, params[:content])
|
81
136
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
137
|
+
unless result
|
138
|
+
@website_section.layout = params[:content]
|
139
|
+
render :json => @website_section.save ? {:success => true} : {:success => false}
|
140
|
+
else
|
141
|
+
render :json => {:success => false, :message => result}
|
142
|
+
end
|
143
|
+
end
|
144
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
145
|
+
render :json => {:success => false, :message => ex.message}
|
87
146
|
end
|
88
147
|
end
|
89
148
|
|
90
149
|
def available_articles
|
91
150
|
current_articles = Article.joins("INNER JOIN website_section_contents ON website_section_contents.content_id = contents.id").where("website_section_id = #{params[:section_id]}").all
|
92
|
-
available_articles = Article.all - current_articles
|
151
|
+
available_articles = Article.order('LOWER(internal_identifier) ASC').all - current_articles
|
93
152
|
|
94
153
|
render :inline => "{\"articles\":#{available_articles.to_json(:only => [:internal_identifier, :id])}}"
|
95
154
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Knitkit
|
2
|
+
class OnlineDocumentSectionsController < BaseController
|
3
|
+
layout 'knitkit/online_document_sections'
|
4
|
+
|
5
|
+
before_filter :find_root
|
6
|
+
before_filter :find_document_sections, :only => :build_tree
|
7
|
+
|
8
|
+
def index
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
def build_tree
|
13
|
+
render :inline => build_document_hash.to_json
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def id_or_node
|
19
|
+
(params[:node].to_i == 0) ? params[:section_id] : params[:node]
|
20
|
+
end
|
21
|
+
|
22
|
+
def find_root
|
23
|
+
@root = OnlineDocumentSection.find(params[:section_id])
|
24
|
+
if @root.documented_item_published_content(@active_publication)
|
25
|
+
@root_content = @root.documented_item_published_content(@active_publication).body_html
|
26
|
+
else
|
27
|
+
@root_content = ""
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def find_document_sections
|
32
|
+
@document_sections = OnlineDocumentSection.find(id_or_node).positioned_children
|
33
|
+
end
|
34
|
+
|
35
|
+
def build_document_hash
|
36
|
+
[].tap do |documents|
|
37
|
+
@document_sections.each do |section|
|
38
|
+
documents << {:id => section.id, :title => section.title,
|
39
|
+
:leaf => section.leaf, :documented_item_published_content_html => section.documented_item_published_content_html(@active_publication)}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -1,17 +1,16 @@
|
|
1
1
|
module Knitkit
|
2
2
|
class WebsiteSectionsController < BaseController
|
3
|
-
|
3
|
+
|
4
4
|
def index
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
5
|
+
@current_user = current_user
|
6
|
+
@contents = Article.find_published_by_section(@active_publication, @website_section)
|
7
|
+
layout = @website_section.get_published_layout(@active_publication)
|
8
|
+
unless layout.nil?
|
9
|
+
@website_section.render_base_layout? ? (render :inline => layout, :layout => 'knitkit/base') : (render :inline => layout)
|
11
10
|
else
|
12
|
-
|
11
|
+
@website_section.render_base_layout? ? (render) : (render :layout => false)
|
13
12
|
end
|
14
13
|
end
|
15
|
-
|
14
|
+
|
16
15
|
end
|
17
16
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class DocumentMailer < ActionMailer::Base
|
2
|
+
default :from => ErpTechSvcs::Config.email_notifications_from
|
3
|
+
|
4
|
+
def email_document(to_email, document)
|
5
|
+
file = document.files.first
|
6
|
+
attachments[file.data_file_name] = document.files.first.get_contents
|
7
|
+
|
8
|
+
mail(:to => to_email, :subject => 'The Document You Requested')
|
9
|
+
end
|
10
|
+
end
|
data/app/models/article.rb
CHANGED
data/app/models/content.rb
CHANGED
@@ -5,6 +5,7 @@ class Content < ActiveRecord::Base
|
|
5
5
|
acts_as_commentable
|
6
6
|
acts_as_versioned :table_name => :content_versions
|
7
7
|
can_be_published
|
8
|
+
has_relational_dynamic_attributes
|
8
9
|
|
9
10
|
has_many :website_section_contents, :dependent => :destroy
|
10
11
|
has_many :website_sections, :through => :website_section_contents
|
@@ -91,7 +92,7 @@ class Content < ActiveRecord::Base
|
|
91
92
|
end
|
92
93
|
|
93
94
|
def get_comments(limit)
|
94
|
-
self.
|
95
|
+
self.comments.recent.limit(limit).all
|
95
96
|
end
|
96
97
|
|
97
98
|
def update_content_area_and_position_by_section(section, content_area, position)
|
@@ -119,6 +120,37 @@ class Content < ActiveRecord::Base
|
|
119
120
|
position
|
120
121
|
end
|
121
122
|
|
123
|
+
def assign_attribute_on_save
|
124
|
+
super
|
125
|
+
|
126
|
+
Article.find_by_internal_identifier(self.internal_identifier) ? attribute_type_description = "updated_by_role" : attribute_type_description = "created_by_role"
|
127
|
+
|
128
|
+
if attribute_type_description == "created_by_role"
|
129
|
+
user = self.created_by
|
130
|
+
else
|
131
|
+
user = User.find(self.versions.sort_by {|version| version.version}.reverse[0].created_by_id)
|
132
|
+
end
|
133
|
+
|
134
|
+
if user
|
135
|
+
#keep only the attributes related to the most recent change for each attribute_type
|
136
|
+
self.destroy_values_of_type attribute_type_description
|
137
|
+
|
138
|
+
attribute_type = AttributeType.find_by_internal_identifier(attribute_type_description)
|
139
|
+
attribute_type = AttributeType.create(:description => attribute_type_description, :data_type => "Text") unless attribute_type
|
140
|
+
|
141
|
+
user.roles.each do |role|
|
142
|
+
new_value = AttributeValue.new(:value => role.internal_identifier)
|
143
|
+
attribute_type.attribute_values << new_value
|
144
|
+
self.attribute_values << new_value
|
145
|
+
new_value.save
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def is_published?
|
151
|
+
!PublishedElement.where('published_element_record_id = ? and published_element_record_type = ? and published_elements.version = ?', self.id, 'Content', self.version).first.nil?
|
152
|
+
end
|
153
|
+
|
122
154
|
protected
|
123
155
|
|
124
156
|
def self.build_search_results(results)
|
@@ -129,10 +161,10 @@ class Content < ActiveRecord::Base
|
|
129
161
|
|
130
162
|
results_hash = {}
|
131
163
|
if section.attributes['type'] == 'Blog'
|
132
|
-
results_hash[:link] = section.
|
164
|
+
results_hash[:link] = section.path + '/' + content.permalink
|
133
165
|
results_hash[:title] = content.title
|
134
166
|
else
|
135
|
-
results_hash[:link] = section.
|
167
|
+
results_hash[:link] = section.path
|
136
168
|
results_hash[:title] = section.title
|
137
169
|
end
|
138
170
|
results_hash[:section] = section
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class DocumentedContent < Content
|
2
|
+
has_permalink :title
|
3
|
+
before_save :check_internal_indentifier
|
4
|
+
|
5
|
+
def to_param
|
6
|
+
permalink
|
7
|
+
end
|
8
|
+
|
9
|
+
def check_internal_indentifier
|
10
|
+
self.internal_identifier = self.permalink if self.internal_identifier.blank?
|
11
|
+
end
|
12
|
+
|
13
|
+
def content_hash
|
14
|
+
{:id => self.id, :title => self.title, :body_html => self.body_html}
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.find_published_by_section(active_publication, website_section)
|
18
|
+
published_content = []
|
19
|
+
documented_item = DocumentedItem.where(["online_document_section_id = ?", website_section.id]).first
|
20
|
+
if documented_item
|
21
|
+
documented_content = DocumentedContent.find(documented_item.documented_content_id)
|
22
|
+
content = get_published_version(active_publication, documented_content)
|
23
|
+
published_content << content unless content.nil?
|
24
|
+
end
|
25
|
+
|
26
|
+
published_content.first
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class DocumentedItem < ActiveRecord::Base
|
2
|
+
belongs_to :online_document_section
|
3
|
+
|
4
|
+
def content
|
5
|
+
if content?
|
6
|
+
Content.find(documented_content_id)
|
7
|
+
elsif klass?
|
8
|
+
self.documented_klass
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def published_content(active_publication)
|
13
|
+
if content?
|
14
|
+
DocumentedContent.find_published_by_section(active_publication, online_document_section)
|
15
|
+
elsif klass?
|
16
|
+
self.documented_klass
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def klass?
|
21
|
+
!!self.documented_klass
|
22
|
+
end
|
23
|
+
|
24
|
+
def content?
|
25
|
+
!!self.documented_content_id
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.find_by_section_id( website_section_id )
|
29
|
+
DocumentedItem.where(["online_document_section_id = ?", website_section_id]).first
|
30
|
+
end
|
31
|
+
end
|