Skip to content

Commit

Permalink
Merge branch 'development' of git://github.com/cykod/Webiva into quota
Browse files Browse the repository at this point in the history
  • Loading branch information
Doug Youch committed Jun 21, 2010
2 parents 492c0bf + 703ec73 commit add30cd
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/helpers/page_helper.rb
Expand Up @@ -25,7 +25,7 @@ def end_user_table_for(tbl,options = {},&block)
extra_class = " " + options[:class]
end

div_id = options[:container_id] || "cmspara_#{paragraph.id}"
div_id = options[:container_id] || "cmspara_#{tbl.renderer.paragraph.id}"
concat(register_table_js(tbl,div_id,options[:refresh_url]))
concat("<form id='#{tbl.name}_update_form' action='' onsubmit='return false;'>") unless options[:no_form]
concat("<input type='hidden' name='page_connection_hash' value='#{tbl.page_connection_hash}' />") unless options[:no_form]
Expand Down
2 changes: 1 addition & 1 deletion app/models/site_template.rb
Expand Up @@ -317,7 +317,7 @@ def localized_values(lang)

def localized_options
loc_opt = []

self.options[:options] ||= []
self.options[:options].each do |opt|
if(opt[5])
loc_opt << opt
Expand Down
12 changes: 6 additions & 6 deletions app/views/layouts/page.rhtml
@@ -1,7 +1,7 @@
<% unless @partial_page -%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%= tag 'html', {:xmlns => "http://www.w3.org/1999/xhtml"}.merge(@output.includes[:html_tag] || {}), true %>
<head>
<% unless @partial_page || @output.partial -%>
<%= @output.doctype || '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' %>
<%= tag 'html', {:xmlns => "http://www.w3.org/1999/xhtml"}.merge(@output.includes[:html_tag] || {}), true %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><%= @cms_module_page_title || @output.title %></title>
<meta http-equiv='Content-Language' content='<%= @output.language %>' />
Expand Down Expand Up @@ -45,7 +45,7 @@
<%= @output.head %>

</head>
</head>
<body>
<div id="overDiv" style="position:absolute; left:0px; top:0px; visibility:hidden; z-index:1000;"></div>
<% if page_editor? -%>
Expand All @@ -63,7 +63,7 @@
<%= render_output(@page,@output) -%>
<% unless @partial_page -%>
<% unless @partial_page || @output.partial -%>
<% if @google_analytics[:enabled] == 'enabled' -%>
<script type='text/javascript'>
Expand Down
6 changes: 4 additions & 2 deletions app/views/templates/_template_options.rhtml
@@ -1,6 +1,8 @@
<% tabled_fields_for :site_template, @site_template do |f| -%>
<% admin_fields_for :site_template, @site_template do |f| -%>
<%= f.text_field :name %>
<%= f.text_area :description, :cols => 40, :rows => 3 %>
<%= f.text_field :doctype, :size => 120, :label => 'Doctype',:description => 'Override the default doctype of XHTML 4.01 Transitional' %>
<%= f.yes_no :partial, :label => 'Partial Template', :description => 'Skip HTML header and footer (useful for AJAX template)' %>
<% end -%>
<% unless @site_template.parent_template %>
Expand All @@ -10,4 +12,4 @@
<%= render :partial => 'template_custom_fields' %>

</div>
<% end -%>
<% end -%>
11 changes: 11 additions & 0 deletions db/migrate/20100618172845_template_headers.rb
@@ -0,0 +1,11 @@
class TemplateHeaders < ActiveRecord::Migration
def self.up
add_column :site_templates, :doctype,:string
add_column :site_templates, :partial, :boolean, :default => false
end

def self.down
remove_column :site_templates, :doctype
remove_column :site_templates, :partial
end
end
9 changes: 8 additions & 1 deletion lib/site_node_engine.rb
Expand Up @@ -447,6 +447,8 @@ class PageOutput < Output #:nodoc:all
attr_accessor :css_site_template_id
attr_accessor :head
attr_accessor :body
attr_accessor :partial
attr_accessor :doctype
attr_accessor :revision
attr_accessor :includes
attr_accessor :page_connections
Expand Down Expand Up @@ -778,6 +780,8 @@ def run(controller,user,options = {})
@output.head = @page_information.head
@output.paction = @page_information.paction
@output.content_nodes = @page_information.content_nodes
@output.partial = @page_information.partial
@output.doctype = @page_information.doctype
@output
end

Expand Down Expand Up @@ -885,7 +889,7 @@ def compile_page_information(user)
# Handle Pages / Frameworks
unless @revision
@revision = @container.page_revisions.find(:first,
:conditions => "revision_type = 'real' AND active=1",
:conditions => "revision_type = 'real'" + (@mode !='edit' ? "AND active=1" : ""),
:order => "language=#{SiteNode.quote_value(@language)} DESC"
)
end
Expand Down Expand Up @@ -951,6 +955,9 @@ def compile_page_information(user)
@page_information[:css_site_template_id] = @active_template.parent_id ? @active_template.parent_id : @active_template.id

@page_information[:head] = SiteTemplate.render_template_head(@page_information[:css_site_template_id],@language)
@page_information[:doctype] = @active_template.doctype.blank? ? nil : @active_template.doctype
@page_information[:partial] = @active_template.partial?


if @mode == 'edit'
@page_information[:revision] = @revision
Expand Down
20 changes: 18 additions & 2 deletions vendor/modules/blog/app/controllers/blog/manage_controller.rb
Expand Up @@ -4,9 +4,9 @@ class Blog::ManageController < ModuleController

permit 'blog_writer', :except => [ :configure]

permit 'blog_config', :only => [ :configure, :delete ]
permit 'blog_config', :only => [ :configure, :delete, :import ]

before_filter :check_view_permission, :except => [ :configure, :delete, :display_blog_list_table, :list, :generate_mail, :generate_mail_generate ]
before_filter :check_view_permission, :except => [ :configure, :delete, :display_blog_list_table, :list, :generate_mail, :generate_mail_generate, :import ]

component_info 'Blog'

Expand Down Expand Up @@ -241,6 +241,20 @@ def list
cms_page_path ['Content'], 'Site Blogs'
display_blog_list_table(false)
end

def import
@blog = Blog::BlogBlog.find(params[:path][0])
blog_path(@blog,"Import Blog")

if request.post? && params[:import] && @file = DomainFile.find_by_id(params[:import][:import_file_id])
if params[:commit]
@blog.import_file(@file,myself)
end
redirect_to :action => 'index', :path => [ @blog.id ]
end


end

protected

Expand All @@ -266,4 +280,6 @@ def check_view_permission
end
end



end
2 changes: 1 addition & 1 deletion vendor/modules/blog/app/controllers/blog/page_renderer.rb
Expand Up @@ -57,7 +57,7 @@ def entry_list

result = renderer_cache(Blog::BlogPost, display_string) do |cache|
blog = get_blog
return render_paragraph :text => (@options.blog_id > 0 ? '[Configure paragraph]' : '') unless blog
return render_paragraph :text => (@options.blog_id.to_i > 0 ? '[Configure paragraph]' : '') unless blog

detail_page = get_detail_page
items_per_page = (@options.items_per_page || 1).to_i
Expand Down
8 changes: 6 additions & 2 deletions vendor/modules/blog/app/models/blog/add_blog_wizard.rb
Expand Up @@ -18,8 +18,12 @@ class Blog::AddBlogWizard < HashModel
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")
nd = SiteNode.find_by_id(self.add_to_id)
if (self.add_to_existing.blank? && self.add_to_subpage.blank?)
self.errors.add(:add_to," must have a subpage selected\nand add to existing must be checked")
end
if ( !self.add_to_existing.blank? && ( !nd || nd.node_type == 'R'))
self.errors.add(:add_to,"you cannot add the blog to the site root, please pick a page\nor uncheck 'Add to existing page'")
end
end

Expand Down
22 changes: 22 additions & 0 deletions vendor/modules/blog/app/models/blog/blog_blog.rb
Expand Up @@ -108,4 +108,26 @@ def send_pingbacks(post)
return unless self.trackback? && post.published?
post.run_pingbacks(post.active_revision.body_html)
end

@@import_fields = %w(title permalink author published_at preview body embedded_media).map(&:to_sym)

def import_file(domain_file,user)
filename = domain_file.filename
reader = CSV.open(filename,"r",',')
file_fields = reader.shift
reader.each do |row|
args = {}
@@import_fields.each_with_index { |fld,idx| args[fld] = row[idx] }

post = self.blog_posts.find_by_permalink(args[:permalink]) if !args[:permalink].blank?

args[:author] = user.name if args[:author].blank?
post ||= self.blog_posts.build

post.attributes = args
post.publish(args[:published_at]) if !args[:published_at].blank?
post.save
end
end

end
21 changes: 11 additions & 10 deletions vendor/modules/blog/app/models/blog/rss_handler.rb
Expand Up @@ -34,7 +34,7 @@ def get_feed
item = { :title => post.title,
:guid => post.id,
:published_at => post.published_at.to_s(:rfc822),
:description => replace_relative_urls(post.preview)
:description => replace_relative_urls(@options.full ? post.body_content : post.preview)
}
post.blog_categories.each do |cat|
item[:categories] ||= []
Expand Down Expand Up @@ -90,15 +90,16 @@ def replace_link_hrefs(txt)
end

class Options < Feed::AdminController::RssModuleOptions
attributes :feed_identifier => nil, :limit => 10
attributes :feed_identifier => nil, :limit => 10, :full => false

validates_presence_of :feed_identifier, :limit
validates_numericality_of :limit

integer_options :limit

options_form(fld(:feed_identifier, :select, :options => :feed_identifier_options, :label => 'Feed'),
fld(:limit, :text_field)
fld(:limit, :text_field),
fld(:full,:yes_no)
)

def validate
Expand All @@ -113,13 +114,13 @@ def feed_identifier_options
opts = [['--Select Feed--', nil]]

revisions.each do |rev|
par = rev.page_paragraphs[0]
blog = Blog::BlogBlog.find_by_id(par.data[:blog_id]) if par
detail_page = par.data[:detail_page] if par && par.data[:detail_page]
if par && blog && rev.revision_container.is_a?(SiteNode)
opts << [ blog.name + ' - ' + rev.revision_container.node_path, "#{rev.revision_container_id},#{blog.id},#{detail_page}" ]
end
par = rev.page_paragraphs.detect { |p| p.display_module =='/blog/page' && p.display_type == 'entry_list' }
blog = Blog::BlogBlog.find_by_id(par.data[:blog_id]) if par
detail_page = par.data[:detail_page] if par && par.data[:detail_page]

if par && blog && rev.revision_container.is_a?(SiteNode)
opts << [ blog.name + ' - ' + rev.revision_container.node_path, "#{rev.revision_container_id},#{blog.id},#{detail_page}" ]
end
end
opts
end
Expand Down
16 changes: 16 additions & 0 deletions vendor/modules/blog/app/views/blog/manage/import.rhtml
@@ -0,0 +1,16 @@
<div class='admin_content'>


<% admin_form_for :import do |f| %>
<%= f.header 'Select a CSV file to import' %>
<%= f.filemanager_file :import_file_id, :description => "File must be a CSV with the following columns:\n Title, permalink, author,published date, preview, body, embed\nOnly title and body are required to have non-empty values but all columns must be present" %>
<%= f.spacer %>
<%= f.cancel_submit_buttons "Cancel","Submit" %>
<% end -%>




</div>
1 change: 1 addition & 0 deletions vendor/modules/blog/app/views/blog/manage/index.rhtml
Expand Up @@ -15,6 +15,7 @@ var PostEditor = {
<%= p.link "Post a new Entry", :action => 'post', :path => @blog.id, :icon => 'add.gif' %>
<%= p.link "Blog Categories", :controller => 'categories', :path => @blog.id, :icon => 'edit.gif' %>
<%= p.link "Configure Blog", :action => 'configure', :path => @blog.id, :icon => 'configure.gif' if myself.has_role?('blog_config') %>
<%= p.link "Import Entries", :action => "import", :path => @blog.id, :icon => "upload.gif" if myself.has_role?('blog_config') %>
<%= p.link "Delete Blog", :action => 'delete', :path => @blog.id, :icon =>'delete.gif',:right => true if myself.has_role?('blog_config') %>
<% end -%>

Expand Down
2 changes: 1 addition & 1 deletion vendor/modules/feed/app/controllers/feed/rss_renderer.rb
Expand Up @@ -33,7 +33,7 @@ def feed
@options = handler_options_class.new(paragraph_data)
@handler = @handler_info[:class].new(@options)

results = renderer_cache(nil, nil, :skip => @options.timeout <= 0, :expires => @options.timeout*60) do |cache|
results = renderer_cache(nil,site_node.id.to_s, :skip => @options.timeout <= 0, :expires => @options.timeout*60) do |cache|
data = @handler.get_feed
if @handler_info[:custom]
cache[:output] = render_to_string(:partial => @handler_info[:custom],:locals => { :data => data})
Expand Down

0 comments on commit add30cd

Please sign in to comment.