Commit a410bc12898ba7cd422997d332d87ef8ff20d48e
Exists in
master
and in
4 other branches
Merge pull request #4670 from anezi/relative-url-patch
More fixes for supporting Relative URL
Showing
6 changed files
with
18 additions
and
4 deletions
Show diff stats
app/assets/javascripts/wall.js.coffee
| ... | ... | @@ -64,7 +64,7 @@ class Wall |
| 64 | 64 | template = template.replace('{{text}}', simpleFormat(note.body)) |
| 65 | 65 | |
| 66 | 66 | if note.attachment |
| 67 | - file = '<i class="icon-paper-clip"/><a href="/files/note/' + note.id + '/' + note.attachment + '">' + note.attachment + '</a>' | |
| 67 | + file = '<i class="icon-paper-clip"/><a href="' + gon.relative_url_root + '/files/note/' + note.id + '/' + note.attachment + '">' + note.attachment + '</a>' | |
| 68 | 68 | else |
| 69 | 69 | file = '' |
| 70 | 70 | template = template.replace('{{file}}', file) | ... | ... |
app/uploaders/attachment_uploader.rb
| ... | ... | @@ -21,7 +21,7 @@ class AttachmentUploader < CarrierWave::Uploader::Base |
| 21 | 21 | end |
| 22 | 22 | |
| 23 | 23 | def secure_url |
| 24 | - "/files/#{model.class.to_s.underscore}/#{model.id}/#{file.filename}" | |
| 24 | + Gitlab.config.gitlab.relative_url_root + "/files/#{model.class.to_s.underscore}/#{model.id}/#{file.filename}" | |
| 25 | 25 | end |
| 26 | 26 | |
| 27 | 27 | def file_storage? | ... | ... |
config/application.rb
| ... | ... | @@ -67,5 +67,9 @@ module Gitlab |
| 67 | 67 | |
| 68 | 68 | # Version of your assets, change this if you want to expire all your assets |
| 69 | 69 | config.assets.version = '1.0' |
| 70 | + | |
| 71 | + # Uncomment this if you are using a subdirectory | |
| 72 | + # Note that ENV['RAILS_RELATIVE_URL_ROOT'] in config/puma.rb may need to be changed | |
| 73 | + # config.relative_url_root = "/gitlab" | |
| 70 | 74 | end |
| 71 | 75 | end | ... | ... |
config/gitlab.yml.example
| ... | ... | @@ -21,6 +21,7 @@ production: &base |
| 21 | 21 | # WARNING: This feature is no longer supported |
| 22 | 22 | # Uncomment and customize to run in non-root path |
| 23 | 23 | # Note that ENV['RAILS_RELATIVE_URL_ROOT'] in config/puma.rb may need to be changed |
| 24 | + # You need to uncomment config.relative_url_root in config/application.rb | |
| 24 | 25 | # relative_url_root: /gitlab |
| 25 | 26 | |
| 26 | 27 | # Uncomment and customize if you can't use the default user to run GitLab (default: 'git') | ... | ... |
config/initializers/session_store.rb
| ... | ... | @@ -2,7 +2,8 @@ |
| 2 | 2 | |
| 3 | 3 | Gitlab::Application.config.session_store :cookie_store, key: '_gitlab_session', |
| 4 | 4 | secure: Gitlab::Application.config.force_ssl, |
| 5 | - httponly: true | |
| 5 | + httponly: true, | |
| 6 | + path: (Rails.application.config.relative_url_root.nil?) ? '/' : Rails.application.config.relative_url_root | |
| 6 | 7 | |
| 7 | 8 | # Use the database for sessions instead of the cookie-based default, |
| 8 | 9 | # which shouldn't be used to store highly confidential information | ... | ... |
lib/gitlab/backend/grack_auth.rb
| ... | ... | @@ -15,7 +15,15 @@ module Grack |
| 15 | 15 | @auth = Request.new(env) |
| 16 | 16 | |
| 17 | 17 | # Need this patch due to the rails mount |
| 18 | - @env['PATH_INFO'] = @request.path | |
| 18 | + | |
| 19 | + # Need this if under RELATIVE_URL_ROOT | |
| 20 | + unless Gitlab.config.gitlab.relative_url_root.empty? | |
| 21 | + # If website is mounted using relative_url_root need to remove it first | |
| 22 | + @env['PATH_INFO'] = @request.path.sub(Gitlab.config.gitlab.relative_url_root,'') | |
| 23 | + else | |
| 24 | + @env['PATH_INFO'] = @request.path | |
| 25 | + end | |
| 26 | + | |
| 19 | 27 | @env['SCRIPT_NAME'] = "" |
| 20 | 28 | |
| 21 | 29 | auth! | ... | ... |