Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'blog-wizard' into development
- Loading branch information
Showing
16 changed files
with
256 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
<div class='admin_content'> | ||
|
||
<% @wizard_list.each do |wizard| -%> | ||
<h2><%= link_to wizard[:name], wizard[:url] -%></h2> | ||
<%= simple_format(wizard[:description]) -%> | ||
<% end -%> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
vendor/modules/blog/app/controllers/blog/wizard_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright (C) 2010 Cykod LLC. | ||
|
||
class Blog::WizardController < ModuleController | ||
|
||
permit 'blog_config' | ||
|
||
component_info 'Blog' | ||
|
||
cms_admin_paths 'website' | ||
|
||
def self.structure_wizard_handler_info | ||
{ :name => "Add a Blog to your Site", | ||
:description => 'This wizard will add an existing blog to a url on your site.', | ||
:permit => "blog_config", | ||
:url => { :controller => '/blog/wizard' } | ||
} | ||
end | ||
|
||
def index | ||
cms_page_path ["Website"],"Add a Blog to your site structure" | ||
|
||
@blog_wizard = Blog::AddBlogWizard.new(params[:wizard] || { :blog_id => params[:blog_id].to_i}) | ||
if request.post? | ||
if !params[:commit] | ||
redirect_to :controller => '/structure', :action => 'wizards' | ||
elsif @blog_wizard.valid? | ||
@blog_wizard.add_to_site! | ||
flash[:notice] = "Added blog to site" | ||
redirect_to :controller => '/structure' | ||
end | ||
end | ||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
|
||
|
||
class Blog::AddBlogWizard < HashModel | ||
|
||
attributes :blog_id => nil, | ||
:add_to_id=>nil, | ||
:add_to_subpage => nil, | ||
:add_to_existing => nil, | ||
:detail_page_url => 'view', | ||
:opts => [] | ||
|
||
|
||
validates_format_of :add_to_subpage, :with => /^[a-zA-Z0-9\-_]+$/, :message => 'is an invalid url' | ||
validates_format_of :detail_page_url, :with => /^[a-zA-Z0-9\-_]+$/, :message => 'is an invalid url' | ||
validates_presence_of :add_to_id | ||
|
||
validates_presence_of :blog_id | ||
validates_presence_of :detail_page_url | ||
|
||
def validate | ||
if self.add_to_existing.blank? && self.add_to_subpage.blank? | ||
self.errors.add(:add_to," must have a subpage selected or add\n to existing must be checked") | ||
end | ||
end | ||
|
||
def add_to_site! | ||
nd = SiteNode.find(self.add_to_id) | ||
|
||
if self.add_to_existing.blank? | ||
nd = nd.add_subpage(self.add_to_subpage) | ||
end | ||
|
||
sub = nd.add_subpage(self.detail_page_url) | ||
sub.save | ||
|
||
list_revision = nd.page_revisions[0] | ||
detail_revision = sub.page_revisions[0] | ||
|
||
list_para = list_revision.add_paragraph('/blog/page','entry_list', | ||
{ | ||
:detail_page => sub.id, | ||
:blog_id => self.blog_id | ||
} | ||
) | ||
list_para.add_page_input(:type,:page_arg_0,:list_type) | ||
list_para.add_page_input(:identifier,:page_arg_1,:list_type_identifier) | ||
list_para.save | ||
|
||
detail_para = detail_revision.add_paragraph('/blog/page','entry_detail', | ||
{ | ||
:list_page_id => nd.id, | ||
:blog_id => self.blog_id | ||
} | ||
) | ||
|
||
detail_para.add_page_input(:input,:page_arg_0,:post_permalink) | ||
detail_para.save | ||
|
||
if self.opts.include?('comments') | ||
|
||
comments_paragraph = detail_revision.add_paragraph('/feedback/comments','comments', | ||
{ | ||
:show => -1, | ||
:allowed_to_post => 'all', | ||
:linked_to_type => 'connection', | ||
:captcha => false, | ||
:order => 'newest' | ||
} | ||
) | ||
|
||
comments_paragraph.save | ||
comments_paragraph.add_paragraph_input!(:input,detail_para,:content_id,:content_identifier) | ||
end | ||
|
||
if self.opts.include?('categories') | ||
cat_para = list_revision.add_paragraph('/blog/page','categories', | ||
{ | ||
:detail_page => sub.id, | ||
:blog_id => self.blog_id, | ||
:list_page_id => nd.id | ||
}, | ||
:zone => 3 | ||
) | ||
cat_para.save | ||
cat_para.add_paragraph_input!(:input,list_para,:category,:category) | ||
end | ||
|
||
|
||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
<div class='admin_content'> | ||
<% cms_form_for :blog, @blog, :html => { :class => 'admin_form' } do |f| -%> | ||
<% cms_form_for :blog, @blog,:vertical => true, :html => { :class => 'admin_form' } do |f| -%> | ||
<%= f.header 'Blog Information' %> | ||
<%= f.text_field :name, :vertical => true, :required => true %> | ||
<%= f.text_area :description, :vertical => true %> | ||
<%= f.select :content_filter, Blog::BlogBlog.filter_options, :vertical => true %> | ||
<%= f.filemanager_folder :folder_id, :vertical => true %> | ||
<%= f.check_boxes :add_to_site, [["Run the add to site wizard".t,true]],:single => true, :vertical => true -%> | ||
<%= f.submit_tag 'Create Blog', :vertical => true%> | ||
<% end -%> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class='admin_content'> | ||
|
||
<% admin_form_for :wizard, @blog_wizard do |f| -%> | ||
<%= f.select :blog_id, Blog::BlogBlog.select_options_with_nil('Blog'), :label => 'Blog to Add' -%> | ||
<%= f.add_page_selector :add_to -%> | ||
<%= f.text_field :detail_page_url, :label => "Detail Page", :size => 10 -%> | ||
<%= f.check_boxes :opts, [['Add a comments paragraph','comments'], | ||
['Add Categories to list page','categories']], | ||
:label => 'Options', :separator => '<br/>'-%> | ||
<%= f.spacer -%> | ||
<%= f.cancel_submit_buttons 'Cancel', 'Add to Site' -%> | ||
<% end -%> | ||
</div> |
30 changes: 30 additions & 0 deletions
30
vendor/modules/blog/spec/models/blog/add_blog_wizard_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (C) 2009 Pascal Rettig. | ||
|
||
require File.expand_path(File.dirname(__FILE__)) + "/../../../../../../spec/spec_helper" | ||
|
||
|
||
describe Blog::AddBlogWizard do | ||
|
||
|
||
reset_domain_tables :blog_blogs, :blog_posts, :blog_post_revisions, :blog_posts_categories, :blog_categories, :content_nodes, :content_types, :site_nodes, :page_paragraphs,:page_revisions | ||
|
||
before(:each) do | ||
@blog = Blog::BlogBlog.create(:name => 'Test Blog',:content_filter => 'full_html') | ||
end | ||
|
||
it "should add the blog to site" do | ||
root_node = SiteVersion.default.root_node.add_subpage('tester') | ||
wizard = Blog::AddBlogWizard.new( | ||
:blog_id => @blog.id, | ||
:add_to_id => root_node.id, | ||
:add_to_subpage => 'blog', | ||
:detail_page_url => 'myview' | ||
) | ||
wizard.add_to_site! | ||
|
||
SiteNode.find_by_node_path('/blog').should_not be_nil | ||
SiteNode.find_by_node_path('/blog/myview').should_not be_nil | ||
|
||
end | ||
|
||
end |