Skip to content

Commit

Permalink
Add default_external_links_in_new_tab site setting
Browse files Browse the repository at this point in the history
  • Loading branch information
nlalonde committed Jan 2, 2014
1 parent ed2e53b commit a897c2b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class User < ActiveRecord::Base
before_save :ensure_password_is_hashed
after_initialize :add_trust_level
after_initialize :set_default_email_digest
after_initialize :set_default_external_links_in_new_tab

after_save :update_tracked_topics

Expand Down Expand Up @@ -596,6 +597,12 @@ def set_default_email_digest
end
end

def set_default_external_links_in_new_tab
if has_attribute?(:external_links_in_new_tab) && self.external_links_in_new_tab.nil?
self.external_links_in_new_tab = !SiteSetting.default_external_links_in_new_tab.blank?
end
end

private

def previous_visit_at_update_required?(timestamp)
Expand Down
1 change: 1 addition & 0 deletions config/locales/server.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ en:
allow_uploaded_avatars: "Allow users to upload their custom avatars"
allow_animated_avatars: "Allow users to use animated gif for avatars. WARNING: it is highly recommended to run the avatars:regenerate rake task after changing that setting."
default_digest_email_frequency: "How often users receive digest emails by default. They can change this setting in their preferences."
default_external_links_in_new_tab: "Open external links in a new tab. Users can change this in their preferences."

detect_custom_avatars: "Whether or not to check that users have uploaded custom avatars"
max_daily_gravatar_crawls: "The maximum amount of times Discourse will check gravatar for custom avatars in a day"
Expand Down
1 change: 1 addition & 0 deletions config/site_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ users:
client: true
default: 14
delete_all_posts_max: 15
default_external_links_in_new_tab: false

posting:
min_post_length:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class RemoveDefaultFromExternalLinksInNewTab < ActiveRecord::Migration
def up
change_column_default :users, :external_links_in_new_tab, nil
end

def down
change_column_default :users, :external_links_in_new_tab, false
end
end

0 comments on commit a897c2b

Please sign in to comment.