added options to disable quoting and open links in new tabs

fixed a some regressions
removed some dead code
fixed messages about constants being re-defined
This commit is contained in:
Sam 2013-03-12 20:06:58 -07:00
parent 5a2d8e344f
commit 38f185355d
16 changed files with 64 additions and 2072 deletions

View File

@ -93,7 +93,14 @@ Discourse.ClickTrack = {
} }
// Otherwise, use a custom URL with a redirect // Otherwise, use a custom URL with a redirect
if (Discourse.get('currentUser.external_links_in_new_tab')) {
var win = window.open(trackingUrl, '_blank');
win.focus();
}
else {
window.location = trackingUrl; window.location = trackingUrl;
}
return false; return false;
} }
}; };

View File

@ -65,7 +65,7 @@ Discourse.PreferencesController = Discourse.ObjectController.extend({
Discourse.currentUser.set('name', model.get('name')); Discourse.currentUser.set('name', model.get('name'));
} }
_this.set('content.bio_cooked', Discourse.Utilities.cook(_this.get('content.bio_raw'))); _this.set('content.bio_cooked', Discourse.Markdown.cook(_this.get('content.bio_raw')));
return _this.set('saved', true); return _this.set('saved', true);
} else { } else {
return alert('failed'); return alert('failed');

View File

@ -407,7 +407,7 @@ Discourse.TopicController = Discourse.ObjectController.extend({
if (Discourse.get('currentUser.moderator')) { if (Discourse.get('currentUser.moderator')) {
post.set('deleted_at', new Date()); post.set('deleted_at', new Date());
} else { } else {
post.set('cooked', Discourse.Utilities.cook(Em.String.i18n("post.deleted_by_author"))); post.set('cooked', Discourse.Markdown.cook(Em.String.i18n("post.deleted_by_author")));
post.set('can_delete', false); post.set('can_delete', false);
post.set('version', post.get('version') + 1); post.set('version', post.get('version') + 1);
} }

View File

@ -67,9 +67,15 @@ Discourse.User = Discourse.Model.extend({
'email_direct', 'email_direct',
'email_private_messages', 'email_private_messages',
'digest_after_days', 'digest_after_days',
'new_topic_duration_minutes'), 'new_topic_duration_minutes',
'external_links_in_new_tab',
'enable_quoting'),
type: 'PUT', type: 'PUT',
success: function() { return finished(true); }, success: function() {
Discourse.set('currentUser.enable_quoting', _this.get('enable_quoting'));
Discourse.set('currentUser.external_links_in_new_tab', _this.get('external_links_in_new_tab'));
return finished(true);
},
error: function() { return finished(false); } error: function() { return finished(false); }
}); });
}, },

View File

@ -101,6 +101,13 @@
<label>{{i18n user.new_topic_duration.label}}</label> <label>{{i18n user.new_topic_duration.label}}</label>
{{view Discourse.ComboboxView valueAttribute="value" contentBinding="controller.considerNewTopicOptions" valueBinding="content.new_topic_duration_minutes"}} {{view Discourse.ComboboxView valueAttribute="value" contentBinding="controller.considerNewTopicOptions" valueBinding="content.new_topic_duration_minutes"}}
</div> </div>
<div class="controls">
<label>{{view Ember.Checkbox checkedBinding="content.external_links_in_new_tab"}}
{{i18n user.external_links_in_new_tab}}</label>
<label>{{view Ember.Checkbox checkedBinding="content.enable_quoting"}}
{{i18n user.enable_quoting}}</label>
</div>
</div> </div>
<div class="control-group"> <div class="control-group">

View File

@ -64,25 +64,18 @@ Discourse.PostView = Discourse.View.extend({
return this.set('context', this.get('content')); return this.set('context', this.get('content'));
}, },
mouseDown: function(e) {
var qbc;
if (qbc = Discourse.get('router.quoteButtonController')) {
return qbc.mouseDown(e);
}
},
mouseUp: function(e) { mouseUp: function(e) {
var $target, qbc; var $target, qbc;
if (qbc = Discourse.get('router.quoteButtonController')) {
qbc.mouseUp(e);
}
if (this.get('controller.multiSelect') && (e.metaKey || e.ctrlKey)) { if (this.get('controller.multiSelect') && (e.metaKey || e.ctrlKey)) {
this.toggleProperty('post.selected'); this.toggleProperty('post.selected');
} }
$target = $(e.target); $target = $(e.target);
if ($target.closest('.cooked').length === 0) return; if ($target.closest('.cooked').length === 0) return;
if (qbc = this.get('controller.controllers.quoteButton')) { qbc = this.get('controller.controllers.quoteButton');
if (qbc && Discourse.get('currentUser.enable_quoting')) {
e.context = this.get('post'); e.context = this.get('post');
return qbc.selectText(e); return qbc.selectText(e);
} }

View File

@ -43,7 +43,8 @@ class UsersController < ApplicationController
u.auto_track_topics_after_msecs = params[:auto_track_topics_after_msecs].to_i if params[:auto_track_topics_after_msecs] u.auto_track_topics_after_msecs = params[:auto_track_topics_after_msecs].to_i if params[:auto_track_topics_after_msecs]
u.new_topic_duration_minutes = params[:new_topic_duration_minutes].to_i if params[:new_topic_duration_minutes] u.new_topic_duration_minutes = params[:new_topic_duration_minutes].to_i if params[:new_topic_duration_minutes]
[:email_digests, :email_direct, :email_private_messages].each do |i| [:email_digests, :email_direct, :email_private_messages,
:external_links_in_new_tab, :enable_quoting].each do |i|
if params[i].present? if params[i].present?
u.send("#{i.to_s}=", params[i] == 'true') u.send("#{i.to_s}=", params[i] == 'true')
end end

View File

@ -1,4 +1,3 @@
require_dependency 'message_bus'
require_dependency 'discourse_observer' require_dependency 'discourse_observer'
# This class is responsible for notifying the message bus of various # This class is responsible for notifying the message bus of various

View File

@ -1,6 +1,3 @@
require_dependency 'message_bus'
require_dependency 'sql_builder'
class UserAction < ActiveRecord::Base class UserAction < ActiveRecord::Base
belongs_to :user belongs_to :user
belongs_to :target_post, :class_name => "Post" belongs_to :target_post, :class_name => "Post"

View File

@ -8,7 +8,9 @@ class CurrentUserSerializer < BasicUserSerializer
:site_flagged_posts_count, :site_flagged_posts_count,
:moderator?, :moderator?,
:reply_count, :reply_count,
:topic_count :topic_count,
:enable_quoting,
:external_links_in_new_tab
# we probably want to move this into site, but that json is cached so hanging it off current user seems okish # we probably want to move this into site, but that json is cached so hanging it off current user seems okish

View File

@ -44,7 +44,10 @@ class UserSerializer < BasicUserSerializer
:email_direct, :email_direct,
:digest_after_days, :digest_after_days,
:auto_track_topics_after_msecs, :auto_track_topics_after_msecs,
:new_topic_duration_minutes :new_topic_duration_minutes,
:external_links_in_new_tab,
:enable_quoting
def auto_track_topics_after_msecs def auto_track_topics_after_msecs
object.auto_track_topics_after_msecs || SiteSetting.auto_track_topics_after object.auto_track_topics_after_msecs || SiteSetting.auto_track_topics_after

View File

@ -63,6 +63,8 @@ en:
change_password: "change" change_password: "change"
invited_by: "Invited By" invited_by: "Invited By"
trust_level: "Trust Level" trust_level: "Trust Level"
external_links_in_new_tab: "Open all external links in a new tab"
enable_quoting: "Enable quote reply for highlighted text"
change_username: change_username:
action: "change" action: "change"

View File

@ -0,0 +1,6 @@
class AddExternalLinksInNewTabAnDisableQuotingToUser < ActiveRecord::Migration
def change
add_column :users, :external_links_in_new_tab, :boolean, default: false, null: false
add_column :users, :enable_quoting, :boolean, default: true, null: false
end
end

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,6 @@
module Discourse module Discourse
# work around reloader
unless defined? ::Discourse::VERSION
module VERSION #:nodoc: module VERSION #:nodoc:
MAJOR = 0 MAJOR = 0
MINOR = 8 MINOR = 8
@ -8,3 +10,4 @@ module Discourse
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end end
end end
end