Merge branch 'master' of github.com:thepracticaldev/dev.to_core
This commit is contained in:
commit
8cbf9a216f
6 changed files with 148 additions and 6 deletions
20
app/controllers/moderations_controller.rb
Normal file
20
app/controllers/moderations_controller.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
class ModerationsController < ApplicationController
|
||||
|
||||
before_action :check_trusted
|
||||
|
||||
def article
|
||||
@moderatable = Article.find_by_slug(params[:slug])
|
||||
render template: "moderations/mod"
|
||||
end
|
||||
|
||||
def comment
|
||||
@moderatable = Comment.find(params[:id_code].to_i(26))
|
||||
render template: "moderations/mod"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_trusted
|
||||
not_found unless current_user&.has_role?(:trusted)
|
||||
end
|
||||
end
|
||||
|
|
@ -21,6 +21,7 @@ module ApplicationHelper
|
|||
controller_name == "users" ||
|
||||
controller_name == "pages" ||
|
||||
controller_name == "dashboards"||
|
||||
controller_name == "moderations"||
|
||||
controller_name == "stories" ||
|
||||
controller_name == "comments" ||
|
||||
controller_name == "notifications" ||
|
||||
|
|
|
|||
74
app/views/moderations/mod.html.erb
Normal file
74
app/views/moderations/mod.html.erb
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<style>
|
||||
.reaction-button{
|
||||
position: relative;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
background: white;
|
||||
border-color: white;
|
||||
margin: 100px 40px;
|
||||
border-radius:200px;
|
||||
}
|
||||
.reaction-button img {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 60px;
|
||||
left: 0;
|
||||
}
|
||||
.reaction-button .reacted-emoji {
|
||||
display: none;
|
||||
}
|
||||
.reaction-button.reacted .reacted-emoji {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container" style="text-align: center">
|
||||
<h2>MODERATE: <a href="<%= @moderatable.path %>"><%= @moderatable.title %></a></h2>
|
||||
|
||||
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(@moderatable, current_user, "thumbsdown") ? "reacted" : "" %>" data-reactable-id="<%= @moderatable.id %>" data-category="thumbsdown" data-reactable-type="<%= @moderatable.class.name %>">
|
||||
<%= image_tag "emoji/emoji-one-thumbs-down-gray.png" %>
|
||||
<img class="reacted-emoji" src="<%= asset_path("emoji/emoji-one-thumbs-down.png") %>"/>
|
||||
</button>
|
||||
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(@moderatable, current_user, "vomit") ? "reacted" : "" %>" data-reactable-id="<%= @moderatable.id %>" data-category="vomit" data-reactable-type="<%= @moderatable.class.name %>">
|
||||
<%= image_tag "emoji/emoji-one-nausea-face-gray.png" %>
|
||||
<img class="reacted-emoji" src="<%= asset_path("emoji/emoji-one-nausea-face.png") %>"/>
|
||||
</button>
|
||||
<p style="width: 80%;margin:50px auto">
|
||||
Negative reactions are private. Use the :thumbsdown: to move something "down" for any reason. The :vomit: is for clear code of conduct violations.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<script defer>
|
||||
setTimeout(function(){
|
||||
var butts = document.getElementsByClassName('reaction-button');
|
||||
for (var i = 0; i < butts.length; i++) {
|
||||
var butt = butts[i];
|
||||
butt.onclick = function (event) {
|
||||
event.preventDefault();
|
||||
var thisButt = this;
|
||||
thisButt.classList.add('reacted');
|
||||
|
||||
function successCb(response) {
|
||||
if (response.result === 'create') {
|
||||
thisButt.classList.add('reacted');
|
||||
} else {
|
||||
thisButt.classList.remove('reacted');
|
||||
}
|
||||
}
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append('reactable_type', thisButt.dataset.reactableType);
|
||||
formData.append('category', thisButt.dataset.category);
|
||||
formData.append('reactable_id', thisButt.dataset.reactableId);
|
||||
|
||||
getCsrfToken()
|
||||
.then(sendFetch('reaction-creation', formData))
|
||||
.then(function (response) {
|
||||
if (response.status === 200) {
|
||||
response.json().then(successCb);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
}, 200)
|
||||
</script>
|
||||
|
|
@ -107,6 +107,11 @@
|
|||
<br>
|
||||
Include `cover_image: [url]` in the front matter of your post. For more information on our editor, check out our <a href="/p/editor_guide">editor guide</a>.
|
||||
</p>
|
||||
<p>
|
||||
<b>How does comment threading work?</b>
|
||||
<br>
|
||||
Comments are threaded with a maximum depth, and then they become flat. You can respond to flattened-out threads by replying to the last comment in the overall thread.
|
||||
</p>
|
||||
<p>
|
||||
<b>I heard you were planning on open sourcing the code. Is that ever going to happen?</b>
|
||||
<br>
|
||||
|
|
@ -126,7 +131,7 @@
|
|||
<br>We mail out the sticker packs separately from the shirts. Please be patient! If you don't recieve the stickers within three weeks (domestic) or six weeks (international), e-mail members@dev.to for help.
|
||||
</p>
|
||||
<p>
|
||||
<b>How do I cancel my membership?</b>
|
||||
<b>How do I cancel my sustaining membership?</b>
|
||||
<br>
|
||||
Go to your settings page and click 'cancel membership'.
|
||||
</p>
|
||||
|
|
@ -135,11 +140,6 @@
|
|||
<br>
|
||||
Please e-mail members@dev.to immediately.
|
||||
</p>
|
||||
<p>
|
||||
<b>How do scholarships work?</b>
|
||||
<br>
|
||||
Scholarship recipients receive a yearly 'workshop pass' that provides full access to dev.to workshops and webinars.
|
||||
</p>
|
||||
<p>
|
||||
<b>How are scholarships provided?</b>
|
||||
<br>
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@ Rails.application.routes.draw do
|
|||
|
||||
get "/:timeframe" => "stories#index", constraints: { timeframe: /latest/}
|
||||
|
||||
#Lagacy comment format (might still be floating around app, and external links)
|
||||
get "/:username/:slug/comments/new/:parent_id_code" => "comments#new"
|
||||
get "/:username/:slug/comments/new" => "comments#new"
|
||||
get "/:username/:slug/comments" => "comments#index"
|
||||
|
|
@ -227,11 +228,15 @@ Rails.application.routes.draw do
|
|||
get "/:username/:slug/comments/:id_code/edit" => "comments#edit"
|
||||
get "/:username/:slug/comments/:id_code/delete_confirm" => "comments#delete_confirm"
|
||||
|
||||
#Proper link format
|
||||
get "/:username/comment/:id_code" => "comments#index"
|
||||
get "/:username/comment/:id_code/edit" => "comments#edit"
|
||||
get "/:username/comment/:id_code/delete_confirm" => "comments#delete_confirm"
|
||||
get "/:username/comment/:id_code/mod" => "moderations#comment"
|
||||
|
||||
|
||||
get "/:username/:slug/:view" => "stories#show", constraints: { view: /moderate/}
|
||||
get "/:username/:slug/mod" => "moderations#article"
|
||||
get "/:username/:slug/edit" => "articles#edit"
|
||||
get "/:username/:slug/delete_confirm" => "articles#delete_confirm"
|
||||
get "/:username/:view" => "stories#index", constraints: { view: /comments|moderate|admin/}
|
||||
|
|
|
|||
42
spec/requests/moderations_spec.rb
Normal file
42
spec/requests/moderations_spec.rb
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe "Moderations", type: :request do
|
||||
let(:user) { create(:user) }
|
||||
let(:article) { create(:article, user_id: user.id) }
|
||||
let(:comment) do
|
||||
create(:comment,
|
||||
commentable_id: article.id,
|
||||
commentable_type: "Article",
|
||||
user_id: user.id)
|
||||
end
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
describe "GET moderations article" do
|
||||
it "returns 200 if user trusted" do
|
||||
user.add_role :trusted
|
||||
get article.path + "/mod"
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
it "returns 404 if user trusted not trusted" do
|
||||
expect do
|
||||
get article.path + "/mod"
|
||||
end.to raise_error(ActionController::RoutingError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET moderations comment" do
|
||||
it "returns 200 if user trusted" do
|
||||
user.add_role :trusted
|
||||
get comment.path + "/mod"
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
it "returns 404 if user trusted not trusted" do
|
||||
expect do
|
||||
get comment.path + "/mod"
|
||||
end.to raise_error(ActionController::RoutingError)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue