Merge pull request #720 from opf/fix/sub_uri_deployment

pull/725/head
Hagen Schink 11 years ago
commit 70e30e5e05
  1. 26
      app/assets/stylesheets/timelines.css.erb
  2. 2
      app/controllers/settings_controller.rb
  3. 2
      app/helpers/application_helper.rb
  4. 2
      app/mailers/user_mailer.rb
  5. 2
      app/views/timelines/_timeline.html.erb
  6. 6
      config/application.rb
  7. 11
      config/configuration.yml.example
  8. 2
      doc/CHANGELOG.md
  9. 21
      lib/open_project/configuration.rb
  10. 33
      lib/open_project/journal_formatter/diff.rb
  11. 37
      lib/redmine/utils.rb
  12. 18
      lib/tasks/plugins.rake
  13. 6
      test/functional/user_mailer_test.rb
  14. 4
      test/integration/lib/redmine/themes_test.rb

@ -50,7 +50,7 @@ li.select2-result.select2-visible-selected-parent {
}
.tl-under-construction {
background: url("../../../assets/loadingAnimation.gif") no-repeat center;
background: url(<%= asset_path "loadingAnimation.gif" %>) no-repeat center;
border: 1px solid #ddd;
height: 48px;
}
@ -208,31 +208,31 @@ not be applied in anything that is not display:table-cell */
.tl-icon-postponed {
cursor: default;
background: url("../assets/bullet_red.png") no-repeat center;
background: url(<%= asset_path "bullet_red.png" %>) no-repeat center;
}
.tl-icon-preponed {
cursor: default;
background: url("../assets/bullet_green.png") no-repeat center;
background: url(<%= asset_path "bullet_green.png" %>) no-repeat center;
}
.tl-icon-added {
cursor: default;
background: url("../assets/added.png") no-repeat center;
background: url(<%= asset_path "added.png" %>) no-repeat center;
display: inline;
width: 16px;
background-position: 2px 2px;
}
.tl-icon-deleted {
cursor: default;
background: url("../assets/webalys/deleted.png") no-repeat center;
background: url(<%= asset_path "webalys/deleted.png" %>) no-repeat center;
display: inline;
width: 16px;
background-position: 2px 2px;
}
.tl-icon-changed {
cursor: default;
background: url("../assets/webalys/arrow_left_right.png") no-repeat center;
background: url(<%= asset_path "webalys/arrow_left_right.png" %>) no-repeat center;
display: inline;
width: 16px;
background-position: 2px 2px;
@ -240,21 +240,21 @@ not be applied in anything that is not display:table-cell */
.tl-icon-calendar {
cursor: default;
background: url("../assets/webalys/calendar.png") no-repeat center;
background: url(<%= asset_path "webalys/calendar.png" %>) no-repeat center;
display: inline;
width: 16px;
}
.tl-icon-zoomin {
background: url("../../../assets/webalys/zoom_in.png") no-repeat center;
background: url(<%= asset_path "webalys/zoom_in.png" %>) no-repeat center;
}
.tl-icon-zoomout {
background: url("../../../assets/webalys/zoom_out.png") no-repeat center;
background: url(<%= asset_path "webalys/zoom_out.png" %>) no-repeat center;
}
.tl-icon-outline {
background: url("../assets/webalys/outline.png") no-repeat center;
background: url(<%= asset_path "webalys/outline.png" %>) no-repeat center;
}
/* ╭───────────────────────────────────────────────────────────────────╮ *
@ -339,11 +339,11 @@ a.tl-discreet-link:hover, input.icon:hover {
}
.tl-expanded > a {
background: url("../assets/arrow_expanded.png") no-repeat center;
background: url(<%= asset_path "arrow_expanded.png" %>) no-repeat center;
}
.tl-collapsed > a {
background: url("../assets/arrow_collapsed.png") no-repeat center;
background: url(<%= asset_path "arrow_collapsed.png" %>) no-repeat center;
}
.tl-expanded > a, .tl-collapsed > a {
@ -584,7 +584,7 @@ a:hover.tl-project, a.tl-project, .tl-project {
/* Icons for activity view */
dt.timelines\2F planning-element {
background-image: url(../assets/webalys/new_planning_element.png);
background-image: url(<%= asset_path 'webalys/new_planning_element.png' %>);
}
#history .journal {

@ -53,7 +53,7 @@ class SettingsController < ApplicationController
@options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
@deliveries = ActionMailer::Base.perform_deliveries
@guessed_host_and_path = request.host_with_port.dup + Redmine::Utils.relative_url_root.to_s
@guessed_host_and_path = request.host_with_port.dup + OpenProject::Configuration.rails_relative_url_root
end
end

@ -950,7 +950,7 @@ module ApplicationHelper
tags = ''
tags += javascript_tag(%Q{
window.openProject = new OpenProject({
urlRoot : '#{Redmine::Utils.relative_url_root}',
urlRoot : '#{OpenProject::Configuration.rails_relative_url_root}',
loginUrl: '#{url_for :controller => "/account", :action => "login"}'
});
I18n.defaultLocale = "#{I18n.default_locale}";

@ -328,7 +328,7 @@ private
end
def self.host
if Redmine::Utils.relative_url_root.blank?
if OpenProject::Configuration.rails_relative_url_root.blank?
Setting.host_name
else
Setting.host_name.to_s.gsub(%r{\/.*\z}, '')

@ -80,7 +80,7 @@ See doc/COPYRIGHT.rdoc for more details.
var config = jQuery.extend({
i18n: i18n,
project_id: '<%= timeline.project.identifier %>',
url_prefix: '<%= Redmine::Utils.relative_url_root %>',
url_prefix: '<%= OpenProject::Configuration.rails_relative_url_root %>',
ui_root: jQuery("#<%= timeline_div_id %>")
}, <%= timeline.json_options %>);
jQuery(function(jQuery) {

@ -55,6 +55,8 @@ if defined?(Bundler)
end
end
require File.dirname(__FILE__) + '/../lib/open_project/configuration'
module OpenProject
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
@ -121,6 +123,10 @@ module OpenProject
# initialize variable for register plugin tests
config.plugins_to_test_paths = []
# Configure the relative url root to be whatever the configuration is set to.
# This allows for setting the root either via config file or via environment variable.
config.action_controller.relative_url_root = OpenProject::Configuration['rails_relative_url_root']
config.to_prepare do
# Rails loads app/views paths of all plugin on each request and appends it to the view_paths.
# Thus, they end up behind the core view path and core views are found before plugin views.

@ -111,6 +111,17 @@ default:
smtp_user_name: "openproject@example.net"
smtp_password: "my_openproject_password"
# Prefix to the url-path. This path is then prepended to all
# the routes and is used to correclty identify the path to the assets.
# Defaults to having no prefix.
# Examples:
# For OpenProject to be reachable as
# https://example.org/open_project
# the setting has o be:
# rails_relative_url_root: "/open_project"
#
# rails_relative_url_root: ""
# Absolute path to the directory where attachments are stored.
# The default is the 'files' directory in your OpenProject instance.
# Your OpenProject instance needs to have write permission on this

@ -29,6 +29,8 @@ See doc/COPYRIGHT.rdoc for more details.
# Changelog
* `#2289` Fix: Deploying in a subdirectory
## 3.0.0pre36
* `#3155` Icons from icon font in content area

@ -42,6 +42,8 @@ module OpenProject
'disable_browser_cache' => true,
# default cache_store is :file_store in production and :memory_store in development
'rails_cache_store' => :default,
# url-path prefix
'rails_relative_url_root' => "",
# email configuration
'email_delivery_method' => nil,
@ -60,7 +62,7 @@ module OpenProject
@config = nil
class << self
# Loads the Redmine configuration file
# Loads the OpenProject configuration file
# Valid options:
# * <tt>:file</tt>: the configuration file to load (default: config/configuration.yml)
# * <tt>:env</tt>: the environment to load the configuration for (default: Rails.env)
@ -80,6 +82,8 @@ module OpenProject
configure_action_mailer(@config)
end
define_config_methods
@config
end
@ -97,6 +101,12 @@ module OpenProject
@config[name]
end
# Sets configuration setting
def []=(name, value)
load unless @config
@config[name] = value
end
# Yields a block with the specified hash configuration settings
def with(settings)
settings.stringify_keys!
@ -186,6 +196,15 @@ module OpenProject
filtered_hash
end
def define_config_methods
@config.keys.each do |setting|
(class << self; self; end).class_eval do
define_method setting do
self[setting]
end
end
end
end
end
end
end

@ -66,20 +66,15 @@ class OpenProject::JournalFormatter::Diff < JournalFormatter::Base
# url_for wants to access the controller method, which we do not have in our Diff class.
# see: http://stackoverflow.com/questions/3659455/is-there-a-new-syntax-for-url-for-in-rails-3
def controller; @controller; end
def controller
nil
end
def link(key, options)
url_attr = { :controller => '/journals',
:action => 'diff',
:id => @journal.id,
:field => key.downcase,
:only_path => options[:only_path],
:protocol => Setting.protocol,
# the link params should better be defined with the
# skip_relative_url_root => true
# option. But this method is flawed in 2.3
# revise when on 3.2
:host => Setting.host_name.gsub(Redmine::Utils.relative_url_root.to_s, "") }
url_attr = default_attributes(options).merge({ :controller => '/journals',
:action => 'diff',
:id => @journal.id,
:field => key.downcase })
if options[:no_html]
url_for url_attr
@ -89,5 +84,19 @@ class OpenProject::JournalFormatter::Diff < JournalFormatter::Base
:class => 'description-details')
end
end
def default_attributes(options)
if options[:only_path]
{ :only_path => options[:only_path],
# setting :script_name is a hack that allows for setting the sub uri.
# I am not yet sure why url_for normally returns the sub uri but does not within
# this class.
:script_name => ::OpenProject::Configuration.rails_relative_url_root }
else
{ :only_path => options[:only_path],
:protocol => Setting.protocol,
:host => Setting.host_name }
end
end
end

@ -1,37 +0,0 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2013 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
module Redmine
module Utils
class << self
attr_accessor :relative_url_root
end
end
end

@ -64,24 +64,6 @@ namespace :redmine do
PluginSourceAnnotationExtractor.enumerate 'call_hook'
end
desc 'Copies plugins assets into the public directory.'
task :assets => :environment do
name = ENV['NAME']
begin
Redmine::Plugin.mirror_assets(name)
rescue Redmine::PluginNotFound
abort "Plugin #{name} was not found."
end
end
desc 'Runs the plugins tests.'
task :test do
Rake::Task["redmine:plugins:test:units"].invoke
Rake::Task["redmine:plugins:test:functionals"].invoke
Rake::Task["redmine:plugins:test:integration"].invoke
end
namespace :test do
desc 'Runs the plugins unit tests.'
Rake::TestTask.new :units => "db:test:prepare" do |t|

@ -164,10 +164,10 @@ class UserMailerTest < ActionMailer::TestCase
def test_generated_links_with_prefix_and_no_relative_url_root
Setting.default_language = 'en'
relative_url_root = Redmine::Utils.relative_url_root
relative_url_root = OpenProject::Configuration['rails_relative_url_root']
Setting.host_name = 'mydomain.foo/rdm'
Setting.protocol = 'http'
Redmine::Utils.relative_url_root = nil
OpenProject::Configuration['rails_relative_url_root'] = nil
User.current = FactoryGirl.create(:admin)
@ -206,7 +206,7 @@ class UserMailerTest < ActionMailer::TestCase
end
ensure
# restore it
Redmine::Utils.relative_url_root = relative_url_root
OpenProject::Configuration['rails_relative_url_root'] = relative_url_root
end
def test_email_headers

@ -74,7 +74,7 @@ class ThemesTest < ActionDispatch::IntegrationTest
should_eventually 'test_with_sub_uri' do
begin
Redmine::Utils.relative_url_root = '/foo'
OpenProject::Configuration['rails_relative_url_root'] = '/foo'
@theme.javascripts << 'theme'
get '/'
@ -84,7 +84,7 @@ class ThemesTest < ActionDispatch::IntegrationTest
assert_tag :tag => 'script',
:attributes => {:src => '/foo/assets/default.js'}
ensure
Redmine::Utils.relative_url_root = ''
OpenProject::Configuration['rails_relative_url_root'] = ''
end
end
end

Loading…
Cancel
Save