diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index fb775d1963e7563dfec9104e5f0c87498355f96f..c3b0ebd7f55c7c8e72b834b3a9e4a9a44a198383 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -1,5 +1,5 @@ # redMine - project management software -# Copyright (C) 2006 Jean-Philippe Lang +# Copyright (C) 2006-2007 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -95,7 +95,7 @@ class AccountController < ApplicationController # User self-registration def register - redirect_to :controller => '' and return if $RDM_SELF_REGISTRATION == false + redirect_to :controller => '' and return unless Setting.self_registration? if params[:token] token = Token.find_by_action_and_value("register", params[:token]) redirect_to :controller => '' and return unless token and !token.expired? @@ -110,7 +110,7 @@ class AccountController < ApplicationController end else if request.get? - @user = User.new(:language => $RDM_DEFAULT_LANG) + @user = User.new(:language => Setting.default_language) @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) } else @user = User.new(params[:user]) diff --git a/app/controllers/application.rb b/app/controllers/application.rb index da01e09c8736766b0a10fc90d42f0589b50c1c48..bae05ce1b8c017ba17ef7f8b8d579d1789833dc9 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -1,5 +1,5 @@ # redMine - project management software -# Copyright (C) 2006 Jean-Philippe Lang +# Copyright (C) 2006-2007 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -33,7 +33,7 @@ class ApplicationController < ActionController::Base # check if login is globally required to access the application def check_if_login_required - require_login if $RDM_LOGIN_REQUIRED + require_login if Setting.login_required? end def set_localization @@ -48,7 +48,7 @@ class ApplicationController < ActionController::Base end rescue nil - end || $RDM_DEFAULT_LANG + end || Setting.default_language set_language_if_valid(lang) end diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..229a4ab3c050f1d66061df27ebb756f05feda0a0 --- /dev/null +++ b/app/controllers/settings_controller.rb @@ -0,0 +1,33 @@ +# redMine - project management software +# Copyright (C) 2006-2007 Jean-Philippe Lang +# +# 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. + +class SettingsController < ApplicationController + layout 'base' + before_filter :require_admin + + def index + edit + render :action => 'edit' + end + + def edit + if request.post? and params[:settings] and params[:settings].is_a? Hash + params[:settings].each { |name, value| Setting[name] = value } + redirect_to :action => 'edit' and return + end + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4c403a8d6bd8fddd5cf3c7ea95e7cff405b64ffa..14f8ecff3b72776633ad7d03e218fec2c1e458fb 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,5 @@ # redMine - project management software -# Copyright (C) 2006 Jean-Philippe Lang +# Copyright (C) 2006-2007 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -45,7 +45,7 @@ class UsersController < ApplicationController def add if request.get? - @user = User.new(:language => $RDM_DEFAULT_LANG) + @user = User.new(:language => Setting.default_language) @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) } else @user = User.new(params[:user]) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0f0d577eee00ae037334c7f5e4e65a962ba1a3ae..748a1d7e912d15fdff034d5bcf7539b980a4dd00 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,5 +1,5 @@ # redMine - project management software -# Copyright (C) 2006 Jean-Philippe Lang +# Copyright (C) 2006-2007 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -93,7 +93,7 @@ module ApplicationHelper end def textilizable(text) - $RDM_TEXTILE_DISABLED ? simple_format(auto_link(h(text))) : RedCloth.new(h(text)).to_html + (Setting.text_formatting == 'textile') && (ActionView::Helpers::TextHelper.method_defined? "textilize") ? RedCloth.new(h(text)).to_html : simple_format(auto_link(h(text))) end def error_messages_for(object_name, options = {}) @@ -131,8 +131,9 @@ module ApplicationHelper end end - def lang_options_for_select - [["(auto)", ""]] + (GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }).collect {|lang| [ l_lang_name(lang.to_s, lang), lang.to_s]} + def lang_options_for_select(blank=true) + (blank ? [["(auto)", ""]] : []) + + (GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }).collect {|lang| [ l_lang_name(lang.to_s, lang), lang.to_s]} end def label_tag_for(name, option_tags = nil, options = {}) diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..f53314c40b771e198f974d47110134ead520805b --- /dev/null +++ b/app/helpers/settings_helper.rb @@ -0,0 +1,19 @@ +# redMine - project management software +# Copyright (C) 2006-2007 Jean-Philippe Lang +# +# 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. + +module SettingsHelper +end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index cdf5a3e4787d79e57eb22500c951846ef56f1c6c..773f2ebe9c94a18d01c45306ac29200d90ddc32d 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -1,5 +1,5 @@ # redMine - project management software -# Copyright (C) 2006 Jean-Philippe Lang +# Copyright (C) 2006-2007 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -21,12 +21,15 @@ class Attachment < ActiveRecord::Base belongs_to :container, :polymorphic => true belongs_to :author, :class_name => "User", :foreign_key => "author_id" - @@max_size = $RDM_ATTACHMENT_MAX_SIZE || 5*1024*1024 - cattr_reader :max_size - validates_presence_of :container, :filename - validates_inclusion_of :filesize, :in => 1..@@max_size + cattr_accessor :storage_path + @@storage_path = "#{RAILS_ROOT}/files" + + def validate + errors.add_to_base :too_long if self.filesize > Setting.attachment_max_size.to_i.kilobytes + end + def file=(incomming_file) unless incomming_file.nil? @temp_file = incomming_file @@ -63,7 +66,7 @@ class Attachment < ActiveRecord::Base # Returns file's location on disk def diskfile - "#{$RDM_STORAGE_PATH}/#{self.disk_filename}" + "#{@@storage_path}/#{self.disk_filename}" end def increment_download diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 968beb49ed69e071a2c79e46ebf1c5442fef0fc6..ba93b5bc7402738d8757f5894fbe4a64ab417990 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -1,5 +1,5 @@ # redMine - project management software -# Copyright (C) 2006 Jean-Philippe Lang +# Copyright (C) 2006-2007 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -16,13 +16,12 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Mailer < ActionMailer::Base - helper IssuesHelper def issue_add(issue) # Sends to all project members @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact - @from = $RDM_MAIL_FROM + @from = Setting.mail_from @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" @body['issue'] = issue end @@ -31,7 +30,7 @@ class Mailer < ActionMailer::Base # Sends to all project members issue = journal.journalized @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact - @from = $RDM_MAIL_FROM + @from = Setting.mail_from @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" @body['issue'] = issue @body['journal']= journal @@ -39,14 +38,14 @@ class Mailer < ActionMailer::Base def lost_password(token) @recipients = token.user.mail - @from = $RDM_MAIL_FROM + @from = Setting.mail_from @subject = l(:mail_subject_lost_password) @body['token'] = token end def register(token) @recipients = token.user.mail - @from = $RDM_MAIL_FROM + @from = Setting.mail_from @subject = l(:mail_subject_register) @body['token'] = token end diff --git a/app/models/setting.rb b/app/models/setting.rb new file mode 100644 index 0000000000000000000000000000000000000000..7350d9123eed653c451c9d68f99b313ac1d1e1ff --- /dev/null +++ b/app/models/setting.rb @@ -0,0 +1,61 @@ +# redMine - project management software +# Copyright (C) 2006-2007 Jean-Philippe Lang +# +# 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. + +class Setting < ActiveRecord::Base + + cattr_accessor :available_settings + @@available_settings = YAML::load(File.open("#{RAILS_ROOT}/config/settings.yml")) + + validates_uniqueness_of :name + validates_inclusion_of :name, :in => @@available_settings.keys + validates_numericality_of :value, :only_integer => true, :if => Proc.new { |setting| @@available_settings[setting.name]['format'] == 'int' } + + def self.get(name) + name = name.to_s + setting = find_by_name(name) + setting ||= new(:name => name, :value => @@available_settings[name]['default']) if @@available_settings.has_key? name + setting + end + + def self.[](name) + get(name).value + end + + def self.[]=(name, value) + setting = get(name) + setting.value = value + setting.save + setting.value + end + + @@available_settings.each do |name, params| + src = <<-END_SRC + def self.#{name} + self[:#{name}] + end + + def self.#{name}? + self[:#{name}].to_s == "1" + end + + def self.#{name}=(value) + self[:#{name}] = values + end + END_SRC + class_eval src, __FILE__, __LINE__ + end +end diff --git a/app/models/user.rb b/app/models/user.rb index b798860d29e13970ef88db47aa6a92ecefebcdf2..8a596168e2267500e69d0bc86ceb15234c49a55f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,5 @@ # redMine - project management software -# Copyright (C) 2006 Jean-Philippe Lang +# Copyright (C) 2006-2007 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -69,7 +69,7 @@ class User < ActiveRecord::Base if attrs onthefly = new(*attrs) onthefly.login = login - onthefly.language = $RDM_DEFAULT_LANG + onthefly.language = Setting.default_language if onthefly.save user = find(:first, :conditions => ["login=?", login]) logger.info("User '#{user.login}' created on the fly.") if logger diff --git a/app/views/account/login.rhtml b/app/views/account/login.rhtml index 8f092b5258c9a080b4ed2a2557a028a64bcf8dc0..346f7d52bce848087475f79009ef4180f269a2fd 100644 --- a/app/views/account/login.rhtml +++ b/app/views/account/login.rhtml @@ -12,7 +12,7 @@ <p><center><input type="submit" name="login" value="<%=l(:button_login)%> »" class="primary" /></center> <%= end_form_tag %> -<br><% unless $RDM_SELF_REGISTRATION == false %><%= link_to l(:label_register), :action => 'register' %> |<% end %> +<br><% if Setting.self_registration? %><%= link_to l(:label_register), :action => 'register' %> |<% end %> <%= link_to l(:label_password_lost), :action => 'lost_password' %></p> </div> </center> \ No newline at end of file diff --git a/app/views/admin/index.rhtml b/app/views/admin/index.rhtml index 901134c277f2e948732f5423051c29a0ffa20e13..535a90b59abe18763dcf666a03ba594b41379782 100644 --- a/app/views/admin/index.rhtml +++ b/app/views/admin/index.rhtml @@ -36,6 +36,10 @@ <%= link_to l(:label_authentication), :controller => 'auth_sources' %> </p> +<p class="icon22 icon22-settings"> +<%= link_to l(:label_settings), :controller => 'settings' %> +</p> + <p class="icon22 icon22-info"> <%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %> </p> \ No newline at end of file diff --git a/app/views/documents/_form.rhtml b/app/views/documents/_form.rhtml index 873c9632990b4498fe7e523e97fb3763e1b7e1ae..b075b4657c440666f474539ba7c6f946be2eadc0 100644 --- a/app/views/documents/_form.rhtml +++ b/app/views/documents/_form.rhtml @@ -14,7 +14,7 @@ <!--[eoform:document]--> </div> -<% unless $RDM_TEXTILE_DISABLED %> +<% if Setting.text_formatting == 'textile' %> <%= javascript_include_tag 'jstoolbar' %> <script type="text/javascript"> //<![CDATA[ diff --git a/app/views/documents/show.rhtml b/app/views/documents/show.rhtml index dab360edaf10e7bf9aea5f5bbf1ed4f3e8dbc40f..d756aad622b514850682682184f5a70f24877f5e 100644 --- a/app/views/documents/show.rhtml +++ b/app/views/documents/show.rhtml @@ -31,7 +31,7 @@ <%= start_form_tag ({ :controller => 'documents', :action => 'add_attachment', :id => @document }, :multipart => true, :class => "tabular") %> <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%> <%= image_to_function "add.png", "addFileField();return false" %></label> - <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p> + <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p> <%= submit_tag l(:button_add) %> <%= end_form_tag %> <% end %> diff --git a/app/views/feeds/news.rxml b/app/views/feeds/news.rxml index 50d4a9aba03a0d9bf900db394abbaa62e1a06711..41fb0cade6c2de7ce1d65d113218aef94ac17e9b 100644 --- a/app/views/feeds/news.rxml +++ b/app/views/feeds/news.rxml @@ -1,10 +1,10 @@ xml.instruct! xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do xml.channel do - xml.title "#{$RDM_HEADER_TITLE}: #{l(:label_news_latest)}" + xml.title "#{Setting.header_title}: #{l(:label_news_latest)}" xml.link url_for(:controller => '', :only_path => false) xml.pubDate CGI.rfc1123_date(@news.first.created_on) - xml.description "#{$RDM_HEADER_TITLE}: #{l(:label_news_latest)}" + xml.description l(:label_news_latest) @news.each do |news| xml.item do xml.title "#{news.project.name}: #{news.title}" diff --git a/app/views/issues/edit.rhtml b/app/views/issues/edit.rhtml index da3805c29fc9c5d22ba5bf620c58f10286691716..78fc4a7a8606b366dcd0c7138ae096b2b80882cb 100644 --- a/app/views/issues/edit.rhtml +++ b/app/views/issues/edit.rhtml @@ -34,7 +34,7 @@ <%= submit_tag l(:button_save) %> <% end %> -<% unless $RDM_TEXTILE_DISABLED %> +<% if Setting.text_formatting == 'textile' %> <%= javascript_include_tag 'jstoolbar' %> <script type="text/javascript"> //<![CDATA[ diff --git a/app/views/issues/show.rhtml b/app/views/issues/show.rhtml index f2441f9641c9161fc4ee6274f41cd3967a8735e7..29adf66aed351e26194fe46e5cb169542ebe6c73 100644 --- a/app/views/issues/show.rhtml +++ b/app/views/issues/show.rhtml @@ -93,7 +93,7 @@ end %> <%= start_form_tag ({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true, :class => "tabular") %> <p id="attachments_p"><label><%=l(:label_attachment_new)%> <%= image_to_function "add.png", "addFileField();return false" %></label> - <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p> + <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p> <%= submit_tag l(:button_add) %> <%= end_form_tag %> <% end %> diff --git a/app/views/layouts/base.rhtml b/app/views/layouts/base.rhtml index 4768f29dd26a30ffdc2ea932fbbf7e83ac4871e9..e4c35b6bd9e039637bf9b9dc9f9e93ad84825353 100644 --- a/app/views/layouts/base.rhtml +++ b/app/views/layouts/base.rhtml @@ -1,7 +1,7 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> -<title><%= $RDM_HEADER_TITLE + (@html_title ? ": #{@html_title}" : "") %></title> +<title><%= Setting.header_title + (@html_title ? ": #{@html_title}" : "") %></title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="description" content="redMine" /> <meta name="keywords" content="issue,bug,tracker" /> @@ -23,8 +23,8 @@ <div id="header"> <div style="float: left;"> - <h1><%= $RDM_HEADER_TITLE %></h1> - <h2><%= $RDM_HEADER_SUBTITLE %></h2> + <h1><%= Setting.header_title %></h1> + <h2><%= Setting.header_subtitle %></h2> </div> <div style="float: right; padding-right: 1em; padding-top: 0.2em;"> <% if loggedin? %><small><%=l(:label_logged_as)%> <b><%= @logged_in_user.login %></b></small><% end %> @@ -69,6 +69,7 @@ <a class="menuItem" href="/enumerations"><%=l(:label_enumerations)%></a> <a class="menuItem" href="/admin/mail_options"><%=l(:field_mail_notification)%></a> <a class="menuItem" href="/auth_sources"><%=l(:label_authentication)%></a> + <a class="menuItem" href="/settings"><%=l(:label_settings)%></a> <a class="menuItem" href="/admin/info"><%=l(:label_information_plural)%></a> </div> <div id="menuTrackers" class="menu"> @@ -134,10 +135,7 @@ </div> <div id="footer"> - <p> - <%= auto_link $RDM_FOOTER_SIG %> | - <a href="http://redmine.rubyforge.org/"><%= RDM_APP_NAME %></a> <%= RDM_APP_VERSION %> - </p> + <p><a href="http://redmine.rubyforge.org/"><%= RDM_APP_NAME %></a> <%= RDM_APP_VERSION %></p> </div> </div> diff --git a/app/views/mailer/_issue.rhtml b/app/views/mailer/_issue.rhtml index c123ae30c1a6c29f91c2967de22558f08bfeb8ba..4c5255d3e2103f7cbbf186b34fe13b72f6810039 100644 --- a/app/views/mailer/_issue.rhtml +++ b/app/views/mailer/_issue.rhtml @@ -4,4 +4,4 @@ <%= issue.description %> -http://<%= $RDM_HOST_NAME %>/issues/show/<%= issue.id %> \ No newline at end of file +http://<%= Setting.host_name %>/issues/show/<%= issue.id %> \ No newline at end of file diff --git a/app/views/mailer/lost_password_de.rhtml b/app/views/mailer/lost_password_de.rhtml index 2593edbda1e23dfa75e63bf171f62a3cd8ff4ae6..0b391498b861edaf67988ab8ba2b291f64555d73 100644 --- a/app/views/mailer/lost_password_de.rhtml +++ b/app/views/mailer/lost_password_de.rhtml @@ -1,3 +1,3 @@ To change your password, use the following link: -http://<%= $RDM_HOST_NAME %>/account/lost_password?token=<%= @token.value %> \ No newline at end of file +http://<%= Setting.host_name %>/account/lost_password?token=<%= @token.value %> \ No newline at end of file diff --git a/app/views/mailer/lost_password_en.rhtml b/app/views/mailer/lost_password_en.rhtml index 2593edbda1e23dfa75e63bf171f62a3cd8ff4ae6..0b391498b861edaf67988ab8ba2b291f64555d73 100644 --- a/app/views/mailer/lost_password_en.rhtml +++ b/app/views/mailer/lost_password_en.rhtml @@ -1,3 +1,3 @@ To change your password, use the following link: -http://<%= $RDM_HOST_NAME %>/account/lost_password?token=<%= @token.value %> \ No newline at end of file +http://<%= Setting.host_name %>/account/lost_password?token=<%= @token.value %> \ No newline at end of file diff --git a/app/views/mailer/lost_password_es.rhtml b/app/views/mailer/lost_password_es.rhtml index 2593edbda1e23dfa75e63bf171f62a3cd8ff4ae6..0b391498b861edaf67988ab8ba2b291f64555d73 100644 --- a/app/views/mailer/lost_password_es.rhtml +++ b/app/views/mailer/lost_password_es.rhtml @@ -1,3 +1,3 @@ To change your password, use the following link: -http://<%= $RDM_HOST_NAME %>/account/lost_password?token=<%= @token.value %> \ No newline at end of file +http://<%= Setting.host_name %>/account/lost_password?token=<%= @token.value %> \ No newline at end of file diff --git a/app/views/mailer/lost_password_fr.rhtml b/app/views/mailer/lost_password_fr.rhtml index 30996f1180f5c36ee82ab1276dfb755592a40dbf..18b6bf6ae824c6a8bfe3339db3b9c689dc911abf 100644 --- a/app/views/mailer/lost_password_fr.rhtml +++ b/app/views/mailer/lost_password_fr.rhtml @@ -1,3 +1,3 @@ Pour changer votre mot de passe, utilisez le lien suivant: -http://<%= $RDM_HOST_NAME %>/account/lost_password?token=<%= @token.value %> \ No newline at end of file +http://<%= Setting.host_name %>/account/lost_password?token=<%= @token.value %> \ No newline at end of file diff --git a/app/views/mailer/register_de.rhtml b/app/views/mailer/register_de.rhtml index 2c0341b24a7d9a652dcee876b397bf0508f35c37..95cc7c4a6047ef584a7e1283de5b777ca56be202 100644 --- a/app/views/mailer/register_de.rhtml +++ b/app/views/mailer/register_de.rhtml @@ -1,3 +1,3 @@ To activate your redMine account, use the following link: -http://<%= $RDM_HOST_NAME %>/account/register?token=<%= @token.value %> \ No newline at end of file +http://<%= Setting.host_name %>/account/register?token=<%= @token.value %> \ No newline at end of file diff --git a/app/views/mailer/register_en.rhtml b/app/views/mailer/register_en.rhtml index 2c0341b24a7d9a652dcee876b397bf0508f35c37..95cc7c4a6047ef584a7e1283de5b777ca56be202 100644 --- a/app/views/mailer/register_en.rhtml +++ b/app/views/mailer/register_en.rhtml @@ -1,3 +1,3 @@ To activate your redMine account, use the following link: -http://<%= $RDM_HOST_NAME %>/account/register?token=<%= @token.value %> \ No newline at end of file +http://<%= Setting.host_name %>/account/register?token=<%= @token.value %> \ No newline at end of file diff --git a/app/views/mailer/register_es.rhtml b/app/views/mailer/register_es.rhtml index 2c0341b24a7d9a652dcee876b397bf0508f35c37..95cc7c4a6047ef584a7e1283de5b777ca56be202 100644 --- a/app/views/mailer/register_es.rhtml +++ b/app/views/mailer/register_es.rhtml @@ -1,3 +1,3 @@ To activate your redMine account, use the following link: -http://<%= $RDM_HOST_NAME %>/account/register?token=<%= @token.value %> \ No newline at end of file +http://<%= Setting.host_name %>/account/register?token=<%= @token.value %> \ No newline at end of file diff --git a/app/views/mailer/register_fr.rhtml b/app/views/mailer/register_fr.rhtml index 3f5d0ccafad1c5857d0fe0017c7371d30e1896c1..402b2a5d45f5d0cc347f0667e669be183f12e65f 100644 --- a/app/views/mailer/register_fr.rhtml +++ b/app/views/mailer/register_fr.rhtml @@ -1,3 +1,3 @@ Pour activer votre compte sur redMine, utilisez le lien suivant: -http://<%= $RDM_HOST_NAME %>/account/register?token=<%= @token.value %> \ No newline at end of file +http://<%= Setting.host_name %>/account/register?token=<%= @token.value %> \ No newline at end of file diff --git a/app/views/news/_form.rhtml b/app/views/news/_form.rhtml index 2dcdc9f8043328e8ace7f02b48fd243f163b185d..497c071c1c62c6f35e93960e22ade829d3bf2532 100644 --- a/app/views/news/_form.rhtml +++ b/app/views/news/_form.rhtml @@ -5,7 +5,7 @@ <p><%= f.text_area :description, :required => true, :cols => 60, :rows => 15 %></p> </div> -<% unless $RDM_TEXTILE_DISABLED %> +<% if Setting.text_formatting == 'textile' %> <%= javascript_include_tag 'jstoolbar' %> <script type="text/javascript"> //<![CDATA[ diff --git a/app/views/projects/add_document.rhtml b/app/views/projects/add_document.rhtml index b570eabbdb2a5e947a381f085b7f31ffe625e786..57a62756b6dc1f4ab104c29a7c45a7c722a51a94 100644 --- a/app/views/projects/add_document.rhtml +++ b/app/views/projects/add_document.rhtml @@ -6,7 +6,7 @@ <div class="box"> <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%> <%= image_to_function "add.png", "addFileField();return false" %></label> -<%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p> +<%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p> </div> <%= submit_tag l(:button_create) %> diff --git a/app/views/projects/add_file.rhtml b/app/views/projects/add_file.rhtml index baffbe8e8f846a4a390318db668e4277216e61aa..6efc1d2c5b9712a30549b9a333f63da734b31961 100644 --- a/app/views/projects/add_file.rhtml +++ b/app/views/projects/add_file.rhtml @@ -9,7 +9,7 @@ <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%> <%= image_to_function "add.png", "addFileField();return false" %></label> -<%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p> +<%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p> </div> <%= submit_tag l(:button_add) %> <%= end_form_tag %> \ No newline at end of file diff --git a/app/views/projects/add_issue.rhtml b/app/views/projects/add_issue.rhtml index 951b53bb9d31769fb3512b4f2afc03634020eb34..fd463b5b4eee9f08bef2c1d54ea734de3dc17fe2 100644 --- a/app/views/projects/add_issue.rhtml +++ b/app/views/projects/add_issue.rhtml @@ -27,7 +27,7 @@ <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%> <%= image_to_function "add.png", "addFileField();return false" %></label> -<%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Attachment.max_size) %>)</em></p> +<%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p> </div> <!--[eoform:issue]--> @@ -35,7 +35,7 @@ <%= submit_tag l(:button_create) %> <% end %> -<% unless $RDM_TEXTILE_DISABLED %> +<% if Setting.text_formatting == 'textile' %> <%= javascript_include_tag 'jstoolbar' %> <script type="text/javascript"> //<![CDATA[ diff --git a/app/views/settings/edit.rhtml b/app/views/settings/edit.rhtml new file mode 100644 index 0000000000000000000000000000000000000000..fcbb40f9156f3dfd3cfeafcb21b02549eb48be2f --- /dev/null +++ b/app/views/settings/edit.rhtml @@ -0,0 +1,37 @@ +<h2><%= l(:label_settings) %></h2> + +<%= start_form_tag({:action => 'edit'}, :class => "tabular") %> +<div class="box"> +<p><label>header_title</label> +<%= text_field_tag 'settings[header_title]', Setting.header_title, :size => 30 %></p> + +<p><label>header_subtitle</label> +<%= text_field_tag 'settings[header_subtitle]', Setting.header_subtitle, :size => 60 %></p> + +<p><label>welcome_text</label> +<%= text_area_tag 'settings[welcome_text]', Setting.welcome_text, :cols => 60, :rows => 5 %></p> + +<p><label>default_language</label> +<%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(false), Setting.default_language) %></p> + +<p><label>login_required</label> +<%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %><%= hidden_field_tag 'settings[login_required]', 0 %></p> + +<p><label>self_registration</label> +<%= check_box_tag 'settings[self_registration]', 1, Setting.self_registration? %><%= hidden_field_tag 'settings[self_registration]', 0 %></p> + +<p><label>attachment_max_size</label> +<%= text_field_tag 'settings[attachment_max_size]', Setting.attachment_max_size, :size => 6 %></p> + +<p><label>mail_from</label> +<%= text_field_tag 'settings[mail_from]', Setting.mail_from, :size => 60 %></p> + +<p><label>host_name</label> +<%= text_field_tag 'settings[host_name]', Setting.host_name, :size => 60 %></p> + +<p><label>text_formatting</label> +<%= select_tag 'settings[text_formatting]', options_for_select( [[l(:label_none), 0], ["textile", "textile"]], Setting.text_formatting) %></p> + +</div> +<%= submit_tag l(:button_save) %> +<%= end_form_tag %> \ No newline at end of file diff --git a/app/views/welcome/index.rhtml b/app/views/welcome/index.rhtml index d32771c0feab5fd9ff0f43eeca4986cab1390861..95683c849c723f50d935ccc23613e17f9c91594c 100644 --- a/app/views/welcome/index.rhtml +++ b/app/views/welcome/index.rhtml @@ -1,7 +1,7 @@ -<h2><%= $RDM_WELCOME_TITLE || l(:label_home) %></h2> +<h2><%= l(:label_home) %></h2> <div class="splitcontentleft"> - <% if $RDM_WELCOME_TEXT %><p><%= $RDM_WELCOME_TEXT %></p><br /><% end %> + <p><%= Setting.welcome_text %></p> <div class="box"> <h3><%=l(:label_news_latest)%></h3> <%= render :partial => 'news/news', :collection => @news %> diff --git a/config/config_custom.example.rb b/config/config_custom.example.rb deleted file mode 100644 index b00e716b10e3672a6cdaedccb46f0a792b8035a5..0000000000000000000000000000000000000000 --- a/config/config_custom.example.rb +++ /dev/null @@ -1,69 +0,0 @@ -# redMine - project management software -# Copyright (C) 2006 Jean-Philippe Lang -# -# 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. - - -# To set your own configuration, rename this file to config_custom.rb -# and edit parameters below -# Don't forget to restart the application after any change. - - -# Application host name -# Used to provide absolute links in mail notifications -# $RDM_HOST_NAME = "somenet.foo" - -# File storage path -# Directory used to store uploaded files -# #{RAILS_ROOT} represents application's home directory -# $RDM_STORAGE_PATH = "#{RAILS_ROOT}/files" - -# Set $RDM_LOGIN_REQUIRED to true if you want to force users to login -# to access any page of the application -# $RDM_LOGIN_REQUIRED = false - -# Uncomment to disable user self-registration -# $RDM_SELF_REGISTRATION = false - -# Default langage ('en', 'es', 'de', 'fr' are available) -# $RDM_DEFAULT_LANG = 'en' - -# Email adress used to send mail notifications -# $RDM_MAIL_FROM = "redmine@somenet.foo" - -# Page title -# $RDM_HEADER_TITLE = "Title" - -# Page sub-title -# $RDM_HEADER_SUBTITLE = "Sub title" - -# Welcome page title -# $RDM_WELCOME_TITLE = "Welcome" - -# Welcome page text -# $RDM_WELCOME_TEXT = "" - -# Signature displayed in footer -# Email adresses will be automatically displayed as a mailto link -# $RDM_FOOTER_SIG = "admin@somenet.foo" - -# Textile formatting (only available if RedCloth is installed) -# Textile formatting is automativaly disabled if RedCloth is not available -# Set to true to manually disable. -# $RDM_TEXTILE_DISABLED = true - -# Maximum size for attachments (in bytes) -# Default to 5 MB -# $RDM_ATTACHMENT_MAX_SIZE = 5*1024*1024 diff --git a/config/environment.rb b/config/environment.rb index 201051b1355dcc4f529804915544f7e502803cce..3edc93ed7149a4be6a870624652140afbc95aede 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -68,47 +68,11 @@ end # inflect.uncountable %w( fish sheep ) # end -if File.exist? File.join(File.dirname(__FILE__), 'config_custom.rb') - begin - print "=> Loading config_custom.rb... " - require File.join(File.dirname(__FILE__), 'config_custom') - puts "done." - rescue Exception => detail - puts - puts detail - puts detail.backtrace.join("\n") - puts "=> Error in config_custom.rb. Check your configuration." - exit - end -end - # IMPORTANT !!! DO NOT MODIFY PARAMETERS HERE # Instead, rename config_custom.example.rb to config_custom.rb # and set your own configuration in that file # Parameters defined in config_custom.rb override those defined below -# application host name -$RDM_HOST_NAME ||= "localhost:3000" -# file storage path -$RDM_STORAGE_PATH ||= "#{RAILS_ROOT}/files" -# if RDM_LOGIN_REQUIRED is set to true, login is required to access the application -$RDM_LOGIN_REQUIRED ||= false -# default langage -$RDM_DEFAULT_LANG ||= 'en' -# email sender adress -$RDM_MAIL_FROM ||= "redmine@somenet.foo" - -# page title -$RDM_HEADER_TITLE ||= "redMine" -# page sub-title -$RDM_HEADER_SUBTITLE ||= "Project management" -# footer signature -$RDM_FOOTER_SIG = "admin@somenet.foo" - -# textile formatting -# automaticaly disabled if 'textile' method is not defined (RedCloth unavailable) -$RDM_TEXTILE_DISABLED = true unless ActionView::Helpers::TextHelper.method_defined? "textilize" - # application name RDM_APP_NAME = "redMine" # application version @@ -131,7 +95,7 @@ ActiveRecord::Errors.default_error_messages = { ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" } -GLoc.set_config :default_language => $RDM_DEFAULT_LANG +GLoc.set_config :default_language => :en GLoc.clear_strings GLoc.set_kcode GLoc.load_localized_strings diff --git a/config/settings.yml b/config/settings.yml new file mode 100644 index 0000000000000000000000000000000000000000..d6b3dfc25b7c1d9ca7b20315b382a937866aaaab --- /dev/null +++ b/config/settings.yml @@ -0,0 +1,42 @@ +# redMine - project management software +# Copyright (C) 2006-2007 Jean-Philippe Lang +# +# 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. + + +# DO NOT MODIFY THIS FILE !!! +# Settings can be defined through the application in Admin -> Settings + +header_title: + default: redMine +header_subtitle: + default: Project management +welcome_text: + default: +login_required: + default: 0 +self_registration: + default: 1 +attachment_max_size: + format: int + default: 5120 +mail_from: + default: redmine@somenet.foo +text_formatting: + default: textile +default_language: + default: en +host_name: + default: localhost:3000 \ No newline at end of file diff --git a/db/migrate/017_create_settings.rb b/db/migrate/017_create_settings.rb new file mode 100644 index 0000000000000000000000000000000000000000..99f96adf842a9e68427857d07e9c91e7f8d75553 --- /dev/null +++ b/db/migrate/017_create_settings.rb @@ -0,0 +1,12 @@ +class CreateSettings < ActiveRecord::Migration + def self.up + create_table :settings, :force => true do |t| + t.column "name", :string, :limit => 30, :default => "", :null => false + t.column "value", :text + end + end + + def self.down + drop_table :settings + end +end diff --git a/doc/CHANGELOG b/doc/CHANGELOG index bbd824da16c3e02afb5276100ede26d5b0931d4b..0373e46a1fe70134db99505447d86365c40c804b 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -5,7 +5,16 @@ Copyright (C) 2006-2007 Jean-Philippe Lang http://redmine.rubyforge.org/ -== 03/02/2006 v0.4.1 +== xx/xx/2006 v0.4.2 + +* settings are now stored in the database (config_custom.rb no more used) and editable through the application in: Admin -> Settings +* tooltips added on Gantt chart and calender to view the details of the issues +* all icons replaced (new icons are based on GPL icon set: "KDE Crystal Diamond 2.5" -by paolino- and "kNeu! Alpha v0.1" -by Pablo Fabregat-) +* added back "fixed version" field on issue screen and in filters +* fixed: subprojects count is always 0 on projects list + + +== 01/03/2006 v0.4.1 * fixed: emails have no recipient when one of the project members has notifications disabled diff --git a/doc/INSTALL b/doc/INSTALL index f55b81a6042f9769fb80fcd3218661e4a44dcbba..4afe11ad1775c1b5e99d024c4398b36b93fd8f6d 100644 --- a/doc/INSTALL +++ b/doc/INSTALL @@ -13,6 +13,7 @@ http://redmine.rubyforge.org/ Optional: * RedCloth (to enable textile formatting) +* SVN binaries (needed for repository browsing, must be available in PATH) Supported databases: * MySQL (tested with MySQL 5) @@ -57,14 +58,12 @@ Supported databases: == Configuration -A sample configuration file is provided: "config/config_custom.example.rb" -Rename it to config_custom.rb and set your parameters. -Don't forget to restart the application after any change. - In config/environment.rb, you can set parameters for your SMTP server: config.action_mailer.server_settings: SMTP server configuration config.action_mailer.perform_deliveries: set to false to disable mail delivering +Don't forget to restart the application after any change. + == Upgrading diff --git a/doc/UPGRADING b/doc/UPGRADING index cc4008a8e97895f8a159288e39ae1bbc2eee56b1..f42b5b3524679df1f7d4650a2e3e679b1b57d6d3 100644 --- a/doc/UPGRADING +++ b/doc/UPGRADING @@ -4,19 +4,19 @@ redMine - project management software Copyright (C) 2006-2007 Jean-Philippe Lang http://redmine.rubyforge.org/ -== From 0.3.0 + +== From 0.3.0 and above 1. Uncompress program archive in a new directory: tar zxvf <filename> -3. Copy your database (database.yml) and configuration settings (config_custom.rb) - into the new config directory +3. Copy your database settings (database.yml) into the new config directory 4. Migrate your database: rake migrate RAILS_ENV="production" -== From 0.2.x and previous +== From 0.2.x and below Due to major database changes since 0.2.x, there is no migration support from 0.2.x and previous versions. diff --git a/lib/tasks/load_default_data.rake b/lib/tasks/load_default_data.rake index f5a160545af668ed6bcb42d9fe942ecca926bb0c..12e0efd3581fbc1dc8c51c49b47954e5f52adfab 100644 --- a/lib/tasks/load_default_data.rake +++ b/lib/tasks/load_default_data.rake @@ -2,7 +2,7 @@ desc 'Load default configuration data' task :load_default_data => :environment do include GLoc - set_language_if_valid($RDM_DEFAULT_LANG) + set_language_if_valid('en') puts while true diff --git a/public/images/22x22/settings.png b/public/images/22x22/settings.png new file mode 100644 index 0000000000000000000000000000000000000000..54a3b4730651339e9d1f3beab6a3dc4d87fec89b Binary files /dev/null and b/public/images/22x22/settings.png differ diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index bb18b5fbba677df3980aa21c74f3903bd20e6a8d..0a3a3f400eb40410b5f33b3214c73195281d0a23 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -176,6 +176,7 @@ vertical-align: middle; .icon22-info { background-image: url(../images/22x22/info.png); } .icon22-comment { background-image: url(../images/22x22/comment.png); } .icon22-package { background-image: url(../images/22x22/package.png); } +.icon22-settings { background-image: url(../images/22x22/settings.png); } /**************** Content styles ****************/ diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index 9c8f0c97e69ca83e574910f695148f24ef9e667f..d8d29c61478c595a0164d1bb4233786d11a7f796 100644 --- a/test/unit/project_test.rb +++ b/test/unit/project_test.rb @@ -42,7 +42,7 @@ class ProjectTest < Test::Unit::TestCase @ecookbook.name = "" assert !@ecookbook.save assert_equal 1, @ecookbook.errors.count - assert_equal l(:activerecord_error_blank), @ecookbook.errors.on(:name) + assert_equal "activerecord_error_blank", @ecookbook.errors.on(:name) end def test_public_projects