[#1850] Disable atom feeds via setting

pull/420/head
Christian Ratz 11 years ago
parent a5eb7443d6
commit b86f8d65d7
  1. 17
      app/controllers/application_controller.rb
  2. 9
      app/helpers/application_helper.rb
  3. 2
      app/models/user.rb
  4. 20
      app/views/my/_sidebar.html.erb
  5. 2
      app/views/settings/_general.html.erb
  6. 8
      config/initializers/10-patches.rb
  7. 1
      config/locales/de.yml
  8. 1
      config/locales/en.yml
  9. 2
      config/settings.yml
  10. 1
      doc/CHANGELOG.md
  11. 1
      lib/redmine/views/other_formats_builder.rb

@ -69,7 +69,8 @@ class ApplicationController < ActionController::Base
:log_requesting_user,
:reset_i18n_fallbacks,
:set_localization,
:check_session_lifetime
:check_session_lifetime,
:check_if_feeds_enabled
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
@ -646,6 +647,20 @@ class ApplicationController < ActionController::Base
session[:updated_at] = Time.now
end
def atom_request?
if params[:format].nil?
%w(application/rss+xml application/atom+xml).include? request.format.to_s
else
%w(atom).include? params[:format]
end
end
def check_if_feeds_enabled
if atom_request? && Setting.feeds_disabled?
render_404({:message => I18n.t('label_disabled')})
end
end
private
def session_expired?

@ -402,10 +402,11 @@ module ApplicationHelper
end
def other_formats_links(&block)
content_tag 'p', :class => 'other-formats' do
formats = capture(Redmine::Views::OtherFormatsBuilder.new(self), &block)
(l(:label_export_to) + formats).html_safe
formats = capture(Redmine::Views::OtherFormatsBuilder.new(self), &block)
unless formats.nil? || formats.strip.empty?
content_tag 'p', :class => 'other-formats' do
(l(:label_export_to) + formats).html_safe
end
end
end

@ -459,7 +459,7 @@ class User < Principal
def self.find_by_rss_key(key)
token = Token.find_by_value(key)
token && token.user.active? ? token.user : nil
token && token.user.active? && !Setting.feeds_disabled? ? token.user : nil
end
def self.find_by_api_key(key)

@ -21,16 +21,18 @@ See doc/COPYRIGHT.rdoc for more details.
<%= User.human_attribute_name(:created_on) %>: <%= format_time(@user.created_on) %></p>
<h3><%= l(:label_feeds_access_key) %></h3>
<p>
<% if @user.rss_token %>
<%= l(:label_feeds_access_key_created_on, distance_of_time_in_words(Time.now, @user.rss_token.created_on)) %>
<% else %>
<%= l(:label_missing_feeds_access_key) %>
<% unless Setting.feeds_disabled? %>
<h3><%= l(:label_feeds_access_key) %></h3>
<p>
<% if @user.rss_token %>
<%= l(:label_feeds_access_key_created_on, distance_of_time_in_words(Time.now, @user.rss_token.created_on)) %>
<% else %>
<%= l(:label_missing_feeds_access_key) %>
<% end %>
(<%= link_to l(:button_reset), {:action => 'reset_rss_key'}, :method => :post %>)
</p>
<% end %>
(<%= link_to l(:button_reset), {:action => 'reset_rss_key'}, :method => :post %>)
</p>
<% if Setting.rest_api_enabled? %>
<h3><%= l(:label_api_access_key) %></h3>

@ -36,6 +36,8 @@ See doc/COPYRIGHT.rdoc for more details.
<p><%= setting_select :wiki_compression, [['Gzip', 'gzip']], :blank => :label_none %></p>
<p><%= setting_check_box :feeds_disabled, :size => 6 %></p>
<p><%= setting_text_field :feeds_limit, :size => 6 %></p>
<p><%= setting_text_field :file_max_size_displayed, :size => 6 %> <%= l(:"number.human.storage_units.units.kb") %></p>

@ -211,6 +211,14 @@ module ActionView
end
end
end
module AssetTagHelper
def auto_discovery_link_tag_with_no_atom_feeds(type = :rss, url_options = {}, tag_options = {})
return if (type == :atom) && Setting.table_exists? && Setting.feeds_disabled?
auto_discovery_link_tag_without_no_atom_feeds(type, url_options, tag_options)
end
alias_method_chain :auto_discovery_link_tag, :no_atom_feeds
end
end
end

@ -1148,6 +1148,7 @@ de:
setting_emails_footer: "E-Mail-Fußzeile"
setting_emails_header: "Emailkopf"
setting_enabled_scm: "Aktivierte Versionskontrollsysteme"
setting_feeds_disabled: "Atom-Feeds deaktivieren"
setting_feeds_limit: "Max. Anzahl Einträge pro Atom-Feed"
setting_file_max_size_displayed: "Maximale Größe inline angezeigter Textdateien"
setting_gravatar_default: "Standard-Gravatar-Bild"

@ -1124,6 +1124,7 @@ en:
setting_emails_footer: "Emails footer"
setting_emails_header: "Emails header"
setting_enabled_scm: "Enabled SCM"
setting_feeds_disabled: "Disable Feeds"
setting_feeds_limit: "Feed content limit"
setting_file_max_size_displayed: "Max size of text files displayed inline"
setting_gravatar_default: "Default Gravatar image"

@ -81,6 +81,8 @@ host_name:
default: localhost:3000
protocol:
default: http
feeds_disabled:
default: 0
feeds_limit:
format: int
default: 15

@ -15,6 +15,7 @@ See doc/COPYRIGHT.rdoc for more details.
* `#1418` Additional changes: Change links to issues/planning elements to use work_packages controller
* `#1898` Separate action for changing wiki parent page (was same as rename before)
* `#1923` Add permission that allows hiding repository statistics on commits per author
* `#1850` Disable atom feeds via setting
## 3.0.0pre15

@ -18,6 +18,7 @@ module Redmine
end
def link_to(name, options={})
return if Setting.table_exists? && Setting.feeds_disabled? && name == "Atom"
url = { :format => name.to_s.downcase }.merge(options.delete(:url) || {})
caption = options.delete(:caption) || name
html_options = { :class => name.to_s.downcase, :rel => 'nofollow' }.merge(options)

Loading…
Cancel
Save