diff --git a/lib/integrity/helpers/breadcrumbs.rb b/lib/integrity/helpers/breadcrumbs.rb
index ec237595..7fe08565 100644
--- a/lib/integrity/helpers/breadcrumbs.rb
+++ b/lib/integrity/helpers/breadcrumbs.rb
@@ -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(#{page_data.first})
+ %Q(#{page_data.first})
elsif @project && @project.permalink == crumb
- %Q(#{@project.permalink})
+ %Q(#{@project.permalink})
end
end + [crumbs.last]
end
diff --git a/lib/integrity/helpers/urls.rb b/lib/integrity/helpers/urls.rb
index 59973575..e7936f13 100644
--- a/lib/integrity/helpers/urls.rb
+++ b/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}"
@@ -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)
@@ -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)
diff --git a/views/error.haml b/views/error.haml
index e43f3729..ca21190e 100644
--- a/views/error.haml
+++ b/views/error.haml
@@ -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?
diff --git a/views/home.haml b/views/home.haml
index b85604af..2b5596a5 100644
--- a/views/home.haml
+++ b/views/home.haml
@@ -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|
@@ -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
diff --git a/views/layout.haml b/views/layout.haml
index f749336a..0123cac1 100644
--- a/views/layout.haml
+++ b/views/layout.haml
@@ -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"}
@@ -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
diff --git a/views/new.haml b/views/new.haml
index 24d0d80f..03ea3612 100644
--- a/views/new.haml
+++ b/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" }
diff --git a/views/not_found.haml b/views/not_found.haml
index 0f784a0e..a46f08f6 100644
--- a/views/not_found.haml
+++ b/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?
@@ -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
diff --git a/views/unauthorized.haml b/views/unauthorized.haml
index 6cd85daa..bf528b8e 100644
--- a/views/unauthorized.haml
+++ b/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...
@@ -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