mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Merge pull request #3953 from techAPJ/wiki
FEATURE: allow users to wikify their own posts based on trust level
This commit is contained in:
@@ -349,6 +349,21 @@ const PostMenuComponent = Ember.Component.extend(StringBuffer, {
|
||||
this.sendAction('toggleBookmark', post);
|
||||
},
|
||||
|
||||
// Wiki button
|
||||
buttonForWiki(post) {
|
||||
if (!post.get('can_wiki')) return;
|
||||
|
||||
if (post.get('wiki')) {
|
||||
return new Button('wiki', 'post.controls.unwiki', 'pencil-square-o', {className: 'wiki wikied'});
|
||||
} else {
|
||||
return new Button('wiki', 'post.controls.wiki', 'pencil-square-o', {className: 'wiki'});
|
||||
}
|
||||
},
|
||||
|
||||
clickWiki(post) {
|
||||
this.sendAction('toggleWiki', post);
|
||||
},
|
||||
|
||||
buttonForAdmin() {
|
||||
if (!Discourse.User.currentProp('canManageTopic')) { return; }
|
||||
return new Button('admin', 'post.controls.admin', 'wrench');
|
||||
@@ -357,10 +372,7 @@ const PostMenuComponent = Ember.Component.extend(StringBuffer, {
|
||||
renderAdminPopup(post, buffer) {
|
||||
if (!Discourse.User.currentProp('canManageTopic')) { return; }
|
||||
|
||||
const isWiki = post.get('wiki'),
|
||||
wikiIcon = iconHTML('pencil-square-o'),
|
||||
wikiText = isWiki ? I18n.t('post.controls.unwiki') : I18n.t('post.controls.wiki'),
|
||||
isModerator = post.get('post_type') === this.site.get('post_types.moderator_action'),
|
||||
const isModerator = post.get('post_type') === this.site.get('post_types.moderator_action'),
|
||||
postTypeIcon = iconHTML('shield'),
|
||||
postTypeText = isModerator ? I18n.t('post.controls.revert_to_regular') : I18n.t('post.controls.convert_to_moderator'),
|
||||
rebakePostIcon = iconHTML('cog'),
|
||||
@@ -373,7 +385,6 @@ const PostMenuComponent = Ember.Component.extend(StringBuffer, {
|
||||
const html = '<div class="post-admin-menu popup-menu">' +
|
||||
'<h3>' + I18n.t('admin_title') + '</h3>' +
|
||||
'<ul>' +
|
||||
'<li class="btn" data-action="toggleWiki">' + wikiIcon + wikiText + '</li>' +
|
||||
(Discourse.User.currentProp('staff') ? '<li class="btn" data-action="togglePostType">' + postTypeIcon + postTypeText + '</li>' : '') +
|
||||
'<li class="btn" data-action="rebakePost">' + rebakePostIcon + rebakePostText + '</li>' +
|
||||
(post.hidden ? '<li class="btn" data-action="unhidePost">' + unhidePostIcon + unhidePostText + '</li>' : '') +
|
||||
@@ -393,10 +404,6 @@ const PostMenuComponent = Ember.Component.extend(StringBuffer, {
|
||||
});
|
||||
},
|
||||
|
||||
clickToggleWiki() {
|
||||
this.sendAction('toggleWiki', this.get('post'));
|
||||
},
|
||||
|
||||
clickTogglePostType() {
|
||||
this.sendAction("togglePostType", this.get("post"));
|
||||
},
|
||||
|
||||
@@ -174,6 +174,10 @@ nav.post-controls {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
&.wikied {
|
||||
color: green;
|
||||
}
|
||||
|
||||
&.bookmark {padding: 8px 11px; }
|
||||
|
||||
.read-icon {
|
||||
|
||||
@@ -58,6 +58,7 @@ button {
|
||||
margin:10px 0 10px 0;
|
||||
}
|
||||
&.has-like {color: $love;}
|
||||
&.wikied { color: green; }
|
||||
.read-icon {
|
||||
&:before {
|
||||
font-family: "FontAwesome";
|
||||
|
||||
@@ -305,9 +305,9 @@ class PostsController < ApplicationController
|
||||
end
|
||||
|
||||
def wiki
|
||||
guardian.ensure_can_wiki!
|
||||
|
||||
post = find_post_from_params
|
||||
guardian.ensure_can_wiki!(post)
|
||||
|
||||
post.revise(current_user, { wiki: params[:wiki] })
|
||||
|
||||
render nothing: true
|
||||
|
||||
@@ -38,6 +38,7 @@ class PostSerializer < BasicPostSerializer
|
||||
:can_edit,
|
||||
:can_delete,
|
||||
:can_recover,
|
||||
:can_wiki,
|
||||
:link_counts,
|
||||
:read,
|
||||
:user_title,
|
||||
@@ -130,6 +131,10 @@ class PostSerializer < BasicPostSerializer
|
||||
scope.can_recover_post?(object)
|
||||
end
|
||||
|
||||
def can_wiki
|
||||
scope.can_wiki?(object)
|
||||
end
|
||||
|
||||
def display_username
|
||||
object.user.try(:name)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user