Skip to content

Commit

Permalink
Improved capistrano tasks on site rename.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed May 26, 2011
1 parent b89a8c0 commit 6e1a820
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 14 deletions.
5 changes: 5 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
== 1.0.0

* minor changes
* Fixed login redirect to not leave ssh.

== 1.0.0.rc3 2011-05-26

* major changes
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/user_sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create
# FIXME: find a better way to lock without blocking the process.
# Also lock longer and longer (exponentially).
sleep(2)
redirect_to login_url
redirect_to login_path
end
end
end
Expand Down Expand Up @@ -49,7 +49,7 @@ def set_visitor
end

def redirect_after_login
session.delete(:after_login_url) || home_path(:prefix => AUTHENTICATED_PREFIX)
session.delete(:after_login_path) || home_path(:prefix => AUTHENTICATED_PREFIX)
end

end
4 changes: 2 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def rescue
if visitor.is_admin?
dev_skin(-1)
else
save_after_login_url
redirect_to login_url
save_after_login_path
redirect_to login_path
end
end

Expand Down
1 change: 1 addition & 0 deletions lib/zena/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def nodes(zip_or_name)
def find(query)
default_scope = 'site'
query = {:qb => query} unless query.kind_of?(Hash)
query[:_find] = Node.plural_relation?(method.split(' ').first) ? :all : :first
nodes = secure(Node) { Node.search_records(query, :node => current_site.root_node, :default => {:scope => default_scope}) }
end

Expand Down
4 changes: 4 additions & 0 deletions lib/zena/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ def ancestry(path)
awstat_conf = "/etc/awstats/awstats.#{self[:old_host]}.conf"
run "test -e#{awstat_conf} && rm #{awstat_conf} || true"

# remove cron task for awstats
awstats = '/etc/cron.d/awstats'
run %Q{sed "/config=#{self[:host]} /d" #{awstats} >#{awstats}.tmp && mv #{awstats}.tmp #{awstats}}

logrotate_conf = "/etc/logrotate.d/#{self[:old_host]}"
run "test -e #{logrotate_conf} && rm #{logrotate_conf} || true"

Expand Down
2 changes: 1 addition & 1 deletion lib/zena/info.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Zena
VERSION = '1.0.0.rc3'
VERSION = '1.0.0.rc4'
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
end
2 changes: 1 addition & 1 deletion lib/zena/use/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def next_in_list_i(nb, list)
# Is this used ? Or do we just use the zafu tag alone ?
# def login_link(opts={})
# if visitor.is_anon?
# link_to _('login'), login_url
# link_to _('login'), login_path
# else
# link_to _('logout'), logout_url
# end
Expand Down
8 changes: 4 additions & 4 deletions lib/zena/use/authlogic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def self.included(base)

private

def save_after_login_url
def save_after_login_path
# prevent redirect to favicon or css
return unless request.format == Mime::HTML
path = params[:path]
if path && path.last =~ /\.(.+)\Z/
return if $1 != 'html'
end

session[:after_login_url] = request.parameters
session[:after_login_path] = request.parameters
end

def set_visitor
Expand Down Expand Up @@ -122,8 +122,8 @@ def force_authentication?

if current_site.authentication? || params[:prefix] == AUTHENTICATED_PREFIX
# Ask for login
save_after_login_url
redirect_to login_url
save_after_login_path
redirect_to login_path
elsif request.format == Mime::XML && (self != NodesController || !params[:prefix])
# Allow xml without :prefix in NodesController because it is rendered with zafu.

Expand Down
2 changes: 1 addition & 1 deletion lib/zena/use/query_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def get_finder(query, count)
# Returns :all, :first or :count depending on the parameters and some introspection in the zafu tree
def get_count(method, params)
(%w{first all count}.include?(params[:find]) ? params[:find].to_sym : nil) ||
((params[:paginate] || child['each'] || child['group'] || Node.plural_relation?(method)) ? :all : :first)
((params[:paginate] || child['each'] || child['group'] || Node.plural_relation?(method.split(' ').first)) ? :all : :first)
end

# Build SQLiss from the parameters
Expand Down
4 changes: 2 additions & 2 deletions test/functional/user_sessions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class UserSessionsControllerTest < Zena::Controller::TestCase
should "redirect to login page if login failed" do
post 'create', :login=>'ant', :password=>'boom'
assert !assigns(:user_session).persisting?
assert_redirected_to login_url
assert_redirected_to login_path
end

end
Expand Down Expand Up @@ -51,7 +51,7 @@ class UserSessionsControllerTest < Zena::Controller::TestCase
should 'not be allowed to login' do
post 'create', :login => 'ant', :password => 'ant'
assert !assigns(:user_session).persisting?
assert_redirected_to login_url
assert_redirected_to login_path
end
end

Expand Down
2 changes: 1 addition & 1 deletion zena.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Gem::Specification.new do |s|
s.name = %q{zena}
s.version = "1.0.0.rc3"
s.version = "1.0.0.rc4"

s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["Gaspard Bucher"]
Expand Down

0 comments on commit 6e1a820

Please sign in to comment.