Skip to content

Commit

Permalink
use path_prefix everywhere (I hope so)...
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Petry committed Feb 6, 2009
1 parent bd5ec46 commit a361888
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lib/integrity/helpers/breadcrumbs.rb
Expand Up @@ -8,9 +8,9 @@ def pages
def breadcrumbs(*crumbs)
crumbs[0..-2].map do |crumb|
if page_data = pages.detect {|c| c.first == crumb }
%Q(<a href="#{page_data.last}">#{page_data.first}</a>)
%Q(<a href="#{path_prefix}#{page_data.last}">#{page_data.first}</a>)
elsif @project && @project.permalink == crumb
%Q(<a href="#{project_url(@project)}">#{@project.permalink}</a>)
%Q(<a href="#{project_path(@project)}">#{@project.permalink}</a>)
end
end + [crumbs.last]
end
Expand Down
19 changes: 16 additions & 3 deletions lib/integrity/helpers/urls.rb
@@ -1,6 +1,11 @@
module Integrity
module Helpers
module Urls

def path_prefix
env['SCRIPT_NAME']
end

def url(path)
url = "#{request.scheme}://#{request.host}"

Expand All @@ -13,12 +18,20 @@ def url(path)
url << path
end

def login_path
"#{path_prefix}/login"
end

def home_path
"#{path_prefix}/"
end

def root_url
url("/")
url(home_path)
end

def project_path(project, *path)
"/" << [project.permalink, *path].join("/")
"#{path_prefix}/" << [project.permalink, *path].join("/")
end

def project_url(project, *path)
Expand All @@ -36,7 +49,7 @@ def push_url_for(project)
end

def build_path(build)
"/#{build.project.permalink}/builds/#{build.commit_identifier}"
"#{path_prefix}/#{build.project.permalink}/builds/#{build.commit_identifier}"
end

def build_url(build)
Expand Down
2 changes: 1 addition & 1 deletion views/error.haml
Expand Up @@ -14,7 +14,7 @@
%dt What can I do?
%dd
Is your
%a{ :href => project_url(@project, :edit) } config
%a{ :href => project_path(@project, :edit) } config
ok?
Need
%a{ :href => "http://integrityapp.com/configure" } help?
Expand Down
4 changes: 2 additions & 2 deletions views/home.haml
Expand Up @@ -4,7 +4,7 @@
%h1
Why don't you
= succeed "?" do
%a{ :href => "/new" } create your first project
%a{ :href => "#{path_prefix}/new" } create your first project
- else
%ul#projects
- @projects.each do |project|
Expand All @@ -20,4 +20,4 @@
= pretty_date(project.last_build.created_at)
= project.last_build.successful? ? "successfully" : "and failed"
%p#new
%a{ :href => "/new" } Add a new project
%a{ :href => "#{path_prefix}/new" } Add a new project
8 changes: 4 additions & 4 deletions views/layout.haml
Expand Up @@ -4,9 +4,9 @@
%meta{ :content => "text/html; charset=utf-8", :"http-equiv" => "Content-Type" }
%meta{ :content => "en", :"http-equiv" => "Content-Language" }
%title= "#{@title.last} | integrity"
%link{ :media => "screen", :type => "text/css", :href => "/reset.css", :rel => "stylesheet" }
%link{ :media => "screen", :type => "text/css", :href => "/buttons.css", :rel => "stylesheet" }
%link{ :media => "screen", :type => "text/css", :href => "/integrity.css", :rel => "stylesheet" }
%link{ :media => "screen", :type => "text/css", :href => "#{path_prefix}/reset.css", :rel => "stylesheet" }
%link{ :media => "screen", :type => "text/css", :href => "#{path_prefix}/buttons.css", :rel => "stylesheet" }
%link{ :media => "screen", :type => "text/css", :href => "#{path_prefix}/integrity.css", :rel => "stylesheet" }
- unless @project.nil?
%link{ :rel => "alternate", :type => "application/atom+xml", :title => "Build history Atom", :href => "#{project_path(@project)}.atom"}

Expand All @@ -24,5 +24,5 @@
%strong&= current_user
- else
Hey there!
%a{ :href => "/login" } Log In
%a{ :href => login_path } Log In
if you have a user
2 changes: 1 addition & 1 deletion views/new.haml
@@ -1,4 +1,4 @@
%form{ :method => "post", :action => (@project.new_record? ? "/" : project_path(@project)) }
%form{ :method => "post", :action => (@project.new_record? ? "#{path_prefix}/" : project_path(@project)) }
- unless @project.new_record?
.hidden
%input{ :name => "_method", :type => "hidden", :value => "put" }
Expand Down
4 changes: 2 additions & 2 deletions views/not_found.haml
@@ -1,7 +1,7 @@
.error
%h1
Ehm, you seem a bit lost, sir. Maybe going to the
%a{ :href => "/", :rel => "home" } list of projects
%a{ :href => home_path, :rel => "home" } list of projects
will help?
%dl
%dt Ouch. This is a 404 error-thingie, right?
Expand All @@ -14,7 +14,7 @@
%strong DON'T PANIC
/ if you didn't get the reference you aren't as nerd as you should be
You should probably just go back to
%a{ :href => "/", :rel => "home" } the projects list
%a{ :href => home_path, :rel => "home" } the projects list
or, alternatively, go
= succeed "." do
%a{ :href => request.referer } back from whence you came
Expand Down
8 changes: 4 additions & 4 deletions views/unauthorized.haml
@@ -1,10 +1,10 @@
.error
%h1
So... you don't know the password? Hmm... You can
%a{ :href => "/login" } try again
%a{ :href => login_path } try again
or
= succeed "." do
%a{ :href => "/", :rel => "home" } go back
%a{ :href => home_path, :rel => "home" } go back

%dl
%dt Er... So... I'm trying to login without a password...
Expand All @@ -19,12 +19,12 @@
%dd
This just means that you can't access some part of this Integrity
server, but that shouldn't let you out of some of the
%a{ :href => "/" } awesome projects
%a{ :href => home_path } awesome projects
hosted here. If this was just a misunderstanding and you
%strong do
have a password, then
= succeed "." do
%a{ :href => "/login" } click here to try again
%a{ :href => login_path } click here to try again

%dt
So what the hell is
Expand Down

3 comments on commit a361888

@foca
Copy link

@foca foca commented on a361888 Feb 11, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m all for merging this, but could you add tests? Just adding one on helpers_test that sets env[“SCRIPT_NAME”] and makes sure urls are generated with the prefix? :)

@Arthur
Copy link
Owner

@Arthur Arthur commented on a361888 Mar 11, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll try to do that !
Thanks

@will
Copy link

@will will commented on a361888 Mar 16, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m looking forward to this being merged in so I can run it with some other things in passenger.

Please sign in to comment.