Merge branch 'master' of github.com:discourse/discourse
This commit is contained in:
commit
fe3693cdef
|
@ -229,21 +229,3 @@ Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
|
|||
|
||||
Discourse.Router = Discourse.Router.reopen({ location: 'discourse_location' });
|
||||
|
||||
Discourse.initializer({
|
||||
name: 'currentUser',
|
||||
|
||||
initialize: function(container) {
|
||||
container.register('user:current', Discourse.User.current(), { instantiate: false });
|
||||
}
|
||||
});
|
||||
|
||||
Discourse.initializer({
|
||||
name: 'injectCurrentUser',
|
||||
|
||||
initialize: function(container) {
|
||||
if (container.lookup('user:current')) {
|
||||
container.injection('controller', 'currentUser', 'user:current');
|
||||
container.injection('route', 'currentUser', 'user:current');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -103,7 +103,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
|||
opts = opts || {};
|
||||
composerController.close();
|
||||
|
||||
var currentUser = this.get('currentUser');
|
||||
var currentUser = Discourse.User.current();
|
||||
if (composer.get('creatingTopic')) {
|
||||
currentUser.set('topic_count', currentUser.get('topic_count') + 1);
|
||||
} else {
|
||||
|
@ -198,6 +198,9 @@ Discourse.ComposerController = Discourse.Controller.extend({
|
|||
open: function(opts) {
|
||||
if (!opts) opts = {};
|
||||
|
||||
var composerMessages = this.get('controllers.composerMessages');
|
||||
composerMessages.reset();
|
||||
|
||||
var promise = opts.promise || Ember.Deferred.create();
|
||||
opts.promise = promise;
|
||||
this.set('typedReply', false);
|
||||
|
|
|
@ -26,6 +26,11 @@ Discourse.ComposerMessagesController = Ember.ArrayController.extend({
|
|||
|
||||
closeMessage: function(message) {
|
||||
this.removeObject(message);
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
this.clear();
|
||||
this.set('messagesByTemplate', {});
|
||||
}
|
||||
|
||||
});
|
|
@ -7,4 +7,4 @@
|
|||
@uses Discourse.Presence
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.Controller = Ember.Controller.extend(Discourse.Presence);
|
||||
Discourse.Controller = Ember.Controller.extend(Discourse.Presence, Discourse.HasCurrentUser);
|
||||
|
|
|
@ -21,8 +21,8 @@ Discourse.HeaderController = Discourse.Controller.extend({
|
|||
}.property(),
|
||||
|
||||
showFavoriteButton: function() {
|
||||
return this.get('currentUser') && !this.get('topic.isPrivateMessage');
|
||||
}.property('currentUser', 'topic.isPrivateMessage'),
|
||||
return Discourse.User.current() && !this.get('topic.isPrivateMessage');
|
||||
}.property('topic.isPrivateMessage'),
|
||||
|
||||
mobileDevice: function() {
|
||||
return Discourse.Mobile.isMobileDevice;
|
||||
|
|
|
@ -13,7 +13,7 @@ Discourse.ListController = Discourse.Controller.extend({
|
|||
needs: ['composer', 'modal', 'listTopics'],
|
||||
|
||||
availableNavItems: function() {
|
||||
var loggedOn = !!this.get('currentUser');
|
||||
var loggedOn = !!Discourse.User.current();
|
||||
|
||||
return Discourse.SiteSettings.top_menu.split("|").map(function(i) {
|
||||
return Discourse.NavItem.fromText(i, {
|
||||
|
@ -22,7 +22,7 @@ Discourse.ListController = Discourse.Controller.extend({
|
|||
}).filter(function(i) {
|
||||
return i !== null;
|
||||
});
|
||||
}.property('currentUser'),
|
||||
}.property(),
|
||||
|
||||
createTopicText: function() {
|
||||
if (this.get('category.name')) {
|
||||
|
@ -125,12 +125,12 @@ Discourse.ListController = Discourse.Controller.extend({
|
|||
|
||||
canEditCategory: function() {
|
||||
if( this.present('category') ) {
|
||||
var u = this.get('currentUser');
|
||||
var u = Discourse.User.current();
|
||||
return u && u.staff;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}.property('currentUser', 'category')
|
||||
}.property('category')
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -7,4 +7,6 @@
|
|||
@uses Discourse.Presence
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.ObjectController = Ember.ObjectController.extend(Discourse.Presence);
|
||||
Discourse.ObjectController = Ember.ObjectController.extend(Discourse.Presence, Discourse.HasCurrentUser);
|
||||
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ Discourse.QuoteButtonController = Discourse.Controller.extend({
|
|||
**/
|
||||
selectText: function(postId) {
|
||||
// anonymous users cannot "quote-reply"
|
||||
if (!this.get('currentUser')) return;
|
||||
if (!Discourse.User.current()) return;
|
||||
|
||||
// don't display the "quote-reply" button if we can't create a post
|
||||
if (!this.get('controllers.topic.model.details.can_create_post')) return;
|
||||
|
|
|
@ -260,8 +260,8 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
|
|||
},
|
||||
|
||||
showFavoriteButton: function() {
|
||||
return this.get('currentUser') && !this.get('isPrivateMessage');
|
||||
}.property('currentUser', 'isPrivateMessage'),
|
||||
return Discourse.User.current() && !this.get('isPrivateMessage');
|
||||
}.property('isPrivateMessage'),
|
||||
|
||||
recoverTopic: function() {
|
||||
this.get('content').recover();
|
||||
|
@ -269,7 +269,7 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
|
|||
|
||||
deleteTopic: function() {
|
||||
this.unsubscribe();
|
||||
this.get('content').destroy(this.get('currentUser'));
|
||||
this.get('content').destroy(Discourse.User.current());
|
||||
},
|
||||
|
||||
resetRead: function() {
|
||||
|
@ -417,7 +417,7 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
|
|||
},
|
||||
|
||||
toggleBookmark: function(post) {
|
||||
if (!this.get('currentUser')) {
|
||||
if (!Discourse.User.current()) {
|
||||
alert(I18n.t("bookmarks.not_bookmarked"));
|
||||
return;
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
|
|||
},
|
||||
|
||||
deletePost: function(post) {
|
||||
var user = this.get('currentUser'),
|
||||
var user = Discourse.User.current(),
|
||||
replyCount = post.get('reply_count'),
|
||||
self = this;
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
This mixin provides a `currentUser` property that can be used to retrieve information
|
||||
about the currently logged in user. It is mostly useful to controllers so it can be
|
||||
exposted to templates.
|
||||
|
||||
Outside of templates, code should probably use `Discourse.User.current()` instead of
|
||||
this property.
|
||||
|
||||
@class Discourse.HasCurrentUser
|
||||
@extends Ember.Mixin
|
||||
@namespace Discourse
|
||||
@module HasCurrentUser
|
||||
**/
|
||||
Discourse.HasCurrentUser = Em.Mixin.create({
|
||||
|
||||
/**
|
||||
Returns a reference to the currently logged in user.
|
||||
|
||||
@method currentUser
|
||||
@return {Discourse.User} the currently logged in user if present.
|
||||
*/
|
||||
currentUser: function() {
|
||||
return Discourse.User.current();
|
||||
}.property().volatile()
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ Discourse.UserRoute = Discourse.Route.extend({
|
|||
|
||||
// If we're viewing the currently logged in user, return that object
|
||||
// instead.
|
||||
var currentUser = this.get('currentUser');
|
||||
var currentUser = Discourse.User.current();
|
||||
if (currentUser && (params.username.toLowerCase() === currentUser.get('username_lower'))) {
|
||||
return currentUser;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ Discourse.UserActivityRoute = Discourse.Route.extend({
|
|||
|
||||
var composerController = this.controllerFor('composer');
|
||||
controller.set('model', user);
|
||||
if (this.get('currentUser')) {
|
||||
if (Discourse.User.current()) {
|
||||
Discourse.Draft.get('new_private_message').then(function(data) {
|
||||
if (data.draft) {
|
||||
composerController.open({
|
||||
|
|
|
@ -125,7 +125,9 @@
|
|||
</div>
|
||||
|
||||
{{render share}}
|
||||
{{#if currentUser.enable_quoting}}
|
||||
{{render quoteButton}}
|
||||
{{/if}}
|
||||
|
||||
{{#if currentUser.staff}}
|
||||
{{render topicAdminMenu content}}
|
||||
|
|
|
@ -47,8 +47,6 @@ Discourse.QuoteButtonView = Discourse.View.extend({
|
|||
.on("mousedown.quote-button", function(e) {
|
||||
view.set('isMouseDown', true);
|
||||
if ($(e.target).hasClass('quote-button') || $(e.target).hasClass('create')) return;
|
||||
// do *not* deselect when quoting has been disabled by the user
|
||||
if (!Discourse.User.currentProp('enable_quoting')) return;
|
||||
// deselects only when the user left click
|
||||
// (allows anyone to `extend` their selection using shift+click)
|
||||
if (e.which === 1 && !e.shiftKey) controller.deselectText();
|
||||
|
|
|
@ -381,8 +381,8 @@ div.ac-wrap {
|
|||
}
|
||||
}
|
||||
.wmd-controls {
|
||||
left: 30px;
|
||||
right: 30px;
|
||||
left: 10px;
|
||||
right: 10px;
|
||||
position: absolute;
|
||||
top: 60px;
|
||||
bottom: 54px;
|
||||
|
@ -455,8 +455,7 @@ div.ac-wrap {
|
|||
}
|
||||
|
||||
.control-row.reply-area {
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1550px) {
|
||||
|
|
|
@ -83,7 +83,7 @@ body {
|
|||
height: 100%;
|
||||
@include border-radius-all(5px);
|
||||
.contents {
|
||||
padding: 10px 20px 10px 20px;
|
||||
padding: 10px 10px 10px 10px;
|
||||
}
|
||||
&.white {
|
||||
background-color: $white;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
// --------------------------------------------------
|
||||
|
||||
.d-header {
|
||||
padding-left: 20px !important;
|
||||
padding-right: 40px;
|
||||
padding-left: 10px !important;
|
||||
padding-right: 10px !important;
|
||||
min-width: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
@ -43,7 +43,7 @@ box-shadow: 0 0 3px #aaa;
|
|||
.panel {
|
||||
float: right;
|
||||
position: relative;
|
||||
margin-right: 30px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
.current-username {
|
||||
float: left;
|
||||
|
|
|
@ -99,7 +99,7 @@ button {
|
|||
}
|
||||
|
||||
.post-actions {
|
||||
margin-left: 20px;
|
||||
margin-left: 10px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ a.star {
|
|||
}
|
||||
|
||||
border-radius: 5px;
|
||||
margin: 15px 20px 20px 20px;
|
||||
margin: 15px 10px 20px 10px;
|
||||
border: 1px solid #ddd;
|
||||
|
||||
h3 {
|
||||
|
@ -246,16 +246,16 @@ a.star {
|
|||
|
||||
#topic-footer-buttons {
|
||||
border-top: 1px solid #ddd;
|
||||
padding: 20px 20px 0 20px;
|
||||
padding: 20px 10px 0 10px;
|
||||
}
|
||||
|
||||
#suggested-topics {
|
||||
float: left;
|
||||
clear: left;
|
||||
margin-top: 10px;
|
||||
padding: 0 20px 0 20px;
|
||||
padding: 0 10px 0 10px;
|
||||
|
||||
th.views, td.views, td.activity, th.activity {
|
||||
th.views, td.views, td.activity, th.activity, th.likes, td.likes {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ span.post-count {
|
|||
z-index: 1000;
|
||||
background: #eee;
|
||||
margin: 0 0 0 0 !important;
|
||||
padding: 15px 20px 15px 20px;
|
||||
padding: 15px 10px 15px 10px;
|
||||
}
|
||||
|
||||
.topic-post article.boxed img {
|
||||
|
|
|
@ -9,12 +9,12 @@ class DraftController < ApplicationController
|
|||
|
||||
def update
|
||||
Draft.set(current_user, params[:draft_key], params[:sequence].to_i, params[:data])
|
||||
render text: 'ok'
|
||||
render json: success_json
|
||||
end
|
||||
|
||||
def destroy
|
||||
Draft.clear(current_user, params[:draft_key], params[:sequence].to_i)
|
||||
render text: 'ok'
|
||||
render json: success_json
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -329,8 +329,6 @@ class TopicsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def move_posts_to_destination(topic)
|
||||
args = {}
|
||||
args[:title] = params[:title] if params[:title].present?
|
||||
|
|
|
@ -14,7 +14,7 @@ class PostActionUserSerializer < BasicUserSerializer
|
|||
end
|
||||
|
||||
def post_url
|
||||
object.related_post.url if object.related_post.id
|
||||
object.related_post.url if object.related_post_id && object.related_post
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue