Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
cykod committed Mar 30, 2010
2 parents f083c01 + 2974e02 commit 3a0dcb4
Show file tree
Hide file tree
Showing 137 changed files with 1,431 additions and 1,081 deletions.
1 change: 1 addition & 0 deletions .ackrc
@@ -0,0 +1 @@
--ignore-dir=rails --ignore-dir=coverage
8 changes: 5 additions & 3 deletions .autotest
Expand Up @@ -45,9 +45,11 @@ Autotest.add_hook :initialize do |at|
end
end
else
at.add_mapping %r%^lib/(.*)\.rb$% do |filename,matches|
at.files_matching(/^spec\/lib\/#{matches[1]}_spec.rb$/)
end
if !(ENV['COMPONENT'] || files)
at.add_mapping %r%^lib/(.*)\.rb$% do |filename,matches|
at.files_matching(/^spec\/lib\/#{matches[1]}_spec.rb$/)
end
end

modules.each do |mod|
%w(controllers models views).each do |type|
Expand Down
10 changes: 8 additions & 2 deletions app/controllers/application_controller.rb
Expand Up @@ -247,10 +247,16 @@ def set_language #:nodoc:

end

@@ignored_session_keys = [:domain, :cms_language, :domain_version]
def session_safe_clear
session.delete_if do |k,v|
! @@ignored_session_keys.include?(k)
end
end

# Convenience method to log a user in
# sets the session and remember cookie
def process_login(usr,remember = false)
# session.clear
session[:user_id] = usr.id
session[:user_model] = usr.class.to_s
reset_myself
Expand All @@ -267,7 +273,7 @@ def process_logout
session[:user_id] = nil
session[:user_model] = nil
reset_myself
session.clear
session_safe_clear
myself
end

Expand Down
4 changes: 3 additions & 1 deletion app/controllers/content_controller.rb
Expand Up @@ -263,7 +263,7 @@ def new
cms_page_info([ [ 'Content', url_for(:action => 'index') ] , ['Custom Content', url_for(:action => 'custom' ) ], 'Create a Content Model' ],'content')


if request.post?
if request.post? && params[:commit]
@content_model.customized = true
@content_model.model_preset = 'custom'
if @content_model.save
Expand Down Expand Up @@ -293,6 +293,8 @@ def new
return
end
end
elsif request.post?
redirect_to :action => 'custom'
end

end
Expand Down
34 changes: 17 additions & 17 deletions app/controllers/editor/action_renderer.rb
Expand Up @@ -21,29 +21,29 @@ def triggered_action
def html_headers

@options = paragraph_options(:html_headers)

if !editor?
@options.css_files.each do |file|
if(file =~ /^images\/(.*)$/)
df = DomainFile.find_by_file_path("/#{$1}")
file = df.url if df
@options.css_files.each do |file|
if(file =~ /^images\/(.*)$/)
df = DomainFile.find_by_file_path("/#{$1}")
file = df.url if df
end
require_css(file)
end
require_css(file)
end

@options.js_files.each do |file|
if(file =~ /^images\/(.*)$/)
df = DomainFile.find_by_file_path("/#{$1}")
file = df.url if df
@options.js_files.each do |file|
if(file =~ /^images\/(.*)$/)
df = DomainFile.find_by_file_path("/#{$1}")
file = df.url if df
end
require_js(file)
end
require_js(file)
end

if !@options.html_header.blank?
include_in_head(@options.html_header)
end
if !@options.html_header.blank?
include_in_head(@options.html_header)
end
end

render_paragraph :nothing => true

end
Expand Down
54 changes: 51 additions & 3 deletions app/controllers/editor/auth_controller.rb
Expand Up @@ -3,7 +3,7 @@
class Editor::AuthController < ParagraphController #:nodoc:all
permit 'editor_editor'

user_actions [:add_feature ]
user_actions [:add_feature, :add_login_feature]

# Editor for authorization paragraphs
editor_header "Member Paragraphs", :paragraph_member
Expand Down Expand Up @@ -321,7 +321,11 @@ def publication
def publication_options
content_model_ids = ContentModelField.find(:all, :conditions => "field_type = 'belongs_to' AND field_module = 'content/core_field'").collect { |fld| fld.content_model_id if fld.relation_class == EndUser }.uniq.compact

ContentPublication.select_options_with_nil('Publication',:conditions => { :publication_type => 'create', :publication_module => 'content/core_publication', :content_model_id => content_model_ids }) unless content_model_ids.empty?
if content_model_ids.empty?
[]
else
ContentPublication.select_options_with_nil('Publication',:conditions => { :publication_type => 'create', :publication_module => 'content/core_publication', :content_model_id => content_model_ids }) unless content_model_ids.empty?
end
end

def publication_field_options
Expand All @@ -330,7 +334,10 @@ def publication_field_options
end

class LoginOptions < HashModel
default_options :login_type => 'email',:success_page => nil, :forward_login => 'no',:failure_page => nil
# For feature stuff
include HandlerActions

default_options :login_type => 'email',:success_page => nil, :forward_login => 'no',:failure_page => nil, :features => []
integer_options :success_page, :failure_page
validates_presence_of :forward_login

Expand All @@ -340,6 +347,23 @@ class LoginOptions < HashModel
fld(:forward_login, :radio_buttons, :options => :forward_login_options, :description => 'If users were locked out of a previous, forward them back to that page.')
)

def validate
if !self.features.is_a?(Array)
self.features = self.features.to_a.sort { |a,b| a[0] <=> b[0] }.map { |elm| obj = Handlers::ParagraphFeature.new(elm[1]); obj.to_hash }

self.login_features.each do |feature|
if !feature.options.valid?
self.errors.add_to_base('Feature Error')
end
end

end
end

def options_partial
nil
end

def self.login_type_options
[['By Email','email'], ['By Username','username'], ['Either','both']]
end
Expand All @@ -351,6 +375,16 @@ def self.page_options
def self.forward_login_options
[['Yes','yes'], ['No','no']]
end

def available_features
[['--Select a feature to add--','']] + get_handler_options(:editor,:auth_login_feature)
end

def login_features
@login_features ||= self.features.map do |feature|
Handlers::ParagraphFeature.new(feature.merge({ :feature_type => 'editor_auth_login_feature'}))
end
end
end

def edit_account
Expand Down Expand Up @@ -475,4 +509,18 @@ def add_feature
end

end

def add_login_feature
@info = get_handler_info(:editor,:auth_login_feature,params[:feature_handler])

if @info && myself.editor?
@feature = Handlers::ParagraphFeature.new({ })
@feature.feature_handler = @info[:identifier]
@feature.feature_type = 'editor_auth_login_feature'
render :partial => 'login_feature', :locals => { :feature => @feature, :idx => params[:index] }
else
render :nothing => true
end

end
end
4 changes: 4 additions & 0 deletions app/controllers/editor/auth_feature.rb
Expand Up @@ -347,6 +347,10 @@ def login_feature(data)

c.define_expansion_tag('use_username') { |tag| data[:type] =='username' }
c.define_expansion_tag('use_email') { |tag| data[:type] =='email'|| data[:type]=='both' }

data[:options].login_features.each do |feature|
feature.feature_instance.feature_tags(c,data[:feature])
end
end
end

Expand Down
26 changes: 23 additions & 3 deletions app/controllers/editor/auth_renderer.rb
Expand Up @@ -303,15 +303,23 @@ def user_edit_account
def login
opts = paragraph_options(:login)


opts.login_features.each do |feature|
return if feature.feature_instance.logged_in(self, opts)
end

data = {}
if myself.id
data[:user] = myself
end

data[:login_user] = myself

data[:options] = opts

if params[:cms_logout]
opts.login_features.each do |feature|
feature.feature_instance.logout
end

paragraph_action(myself.action('/editor/auth/logout'))
process_logout
redirect_paragraph :page
Expand Down Expand Up @@ -357,11 +365,23 @@ def login
data[:error] = true
end
end
else
opts.login_features.each do |feature|
return if feature.feature_instance.login(params)
end
end
end
data[:error] = true if flash[:auth_user_login_error]
data[:type] = opts.login_type


@feature = { }

opts.login_features.each do |feature|
feature.feature_instance.feature_data(@feature)
end

data[:feature] = @feature

render_paragraph :text => login_feature(data)
end

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/editor/menu_controller.rb
Expand Up @@ -82,8 +82,9 @@ def build_preview(root,levels,excluded,cur_level=1)
elsif rev && !rev.title.blank?
title = rev.title
else
title = pg.title.humanize
title = pg.title.humanize
end
title = "[blank]".t if title.blank?
children,subelem_ids = levels > 1 ? build_preview(pg,levels-1,excluded,cur_level+1) : [ nil,[]]
mnu << { :title => title,
:node_id => pg.id,
Expand Down
16 changes: 6 additions & 10 deletions app/controllers/editor/menu_feature.rb
Expand Up @@ -21,18 +21,14 @@ class Editor::MenuFeature < ParagraphFeature #:nodoc:all
}
] },
:default_feature => <<-FEATURE
<div>
<ul class='menu'>
<cms:section>
<div class='menu_item'>
<cms:link selected_class='selected'><cms:title/></cms:link>
<cms:selected>
<cms:section>
&nbsp;&nbsp;<cms:link selected_class='selected'><cms:title/></cms:link><br/>
</cms:section>
</cms:selected>
</div>
<li><cms:link selected_class='selected'><cms:title/></cms:link></li>
<cms:menu><ul> <cms:section>
<li><cms:link selected_class='selected'><cms:title/></cms:link></li>
</cms:section></ul></cms:menu>
</cms:section>
</div>
</ul>
FEATURE

def item_selected(item,url)
Expand Down
9 changes: 4 additions & 5 deletions app/controllers/editor/publication_controller.rb
Expand Up @@ -50,19 +50,18 @@ def validate
def edit
@publication = @paragraph.content_publication

@options = EditOptions.new(params[:pub] || @paragraph.data || {})
@options = EditOptions.new(params[:edit] || @paragraph.data || {})
@options.additional_vars(@publication.filter_variables)

return if handle_paragraph_update(@options)

@pages = [['No Return Page', nil ]] + SiteNode.page_options()
end

class EditOptions < HashModel
default_options :return_page => nil, :options => [], :entry_id => nil, :allow_entry_creation => false
attributes :return_page_id => nil, :options => [], :entry_id => nil, :allow_entry_creation => false

page_options :return_page_id

boolean_options :allow_entry_creation
integer_options :return_page,:entry_id
end

def view
Expand Down
30 changes: 6 additions & 24 deletions app/controllers/editor/publication_renderer.rb
Expand Up @@ -171,11 +171,9 @@ def view


def edit

publication = paragraph.content_publication
content_connection,entry_id = page_connection()
options = paragraph.data || {}
pub_options = paragraph_options(:edit) # publication.data || {}
pub_options = paragraph_options(:edit)


if entry_id && entry_id.to_i != 0
Expand All @@ -188,36 +186,20 @@ def edit
render_paragraph :text => ''
return
end

if paragraph.data[:return_page]
redirect_node = SiteNode.find_by_id(paragraph.data[:return_page])
if redirect_node
return_page = redirect_node.node_path
end
end

return_page = '#' unless return_page

return_page = pub_options.return_page_url

if request.post? && params['entry_' + publication.id.to_s]

publication.update_entry(entry,params['entry_' + publication.id.to_s],
{:user => myself, :renderer => self, :controller => controller })

publication.update_entry(entry,params['entry_' + publication.id.to_s],renderer_state)
new_entry = entry.id ? false : true

if entry.save
expire_content(publication.content_model_id)
if publication.update_action_count > 0
if new_entry
publication.run_triggered_actions(entry,'create',myself)
else
publication.run_triggered_actions(entry,'edit',myself)
end
publication.run_triggered_actions(entry,new_entry ? 'create' : 'edit',myself)
end
if return_page
redirect_paragraph redirect_node.node_path
return
end
return redirect_paragraph(return_page) if return_page
end
else
if publication.view_action_count > 0
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/module_app_controller.rb
Expand Up @@ -139,6 +139,12 @@ def handle_page
handle_document_node(@output,@page)
return false
elsif @output.page?
# if we made it here - need to jump over to the application
get_handlers(:page,:post_process).each do |req|
cls = req[0].constantize.new(self)
cls.post_process @output
end

@cms_site_node_engine = engine
set_robots!
return true
Expand Down

0 comments on commit 3a0dcb4

Please sign in to comment.