basic NSFW filtering for authors who say their post is nsfw

This commit is contained in:
Maxwell Salzberg 2011-12-08 18:22:27 -08:00
parent dea01600aa
commit 8f8769aab5
7 changed files with 45 additions and 8 deletions

View file

@ -16,4 +16,12 @@ module StreamElementHelper
link_to image_tag('deletelabel.png'), share_visibility_path(:id => "42", :post_id => post.id), :method => :put, :remote => true, :class => "delete remove_post control_icon vis_hide", :title => t('.hide_and_mute')
end
end
def nsfw_sheild(post)
if post.respond_to?(:nsfw?) && post.nsfw?
content_tag(:div, :class => 'shield') do
I18n.translate('shared.stream_element.nsfw', :link => link_to(I18n.translate('shared.stream_element.show'), '#')).html_safe
end
end
end
end

View file

@ -63,9 +63,14 @@ class StatusMessage < Post
def raw_message
read_attribute(:text)
end
def raw_message=(text)
write_attribute(:text, text)
end
def nsfw?
self.raw_message.include?('#nsfw')
end
def formatted_message(opts={})
return self.raw_message unless self.raw_message

View file

@ -23,7 +23,7 @@
.sm_body
= person_image_link(post.author, :size => :thumb_small)
.content
%div.post_initial_info
.post_initial_info
%span.from
= person_link(post.author, :class => 'hovercardable')
%time.time.timeago{:datetime => post.created_at, :integer => time_for_sort(post).to_i}
@ -33,12 +33,14 @@
%span.timeago
= link_to(how_long_ago(post), post_path(post))
- if post.activity_streams?
= link_to image_tag(post.image_url, 'data-small-photo' => post.image_url, 'data-full-photo' => post.image_url, :class => 'stream-photo'), post.object_url, :class => "stream-photo-link"
- elsif reshare?(post)
= render 'reshares/reshare', :reshare => post, :post => post.root
- else
= render 'status_messages/status_message', :post => post, :photos => post.photos
.post-content
= nsfw_sheild(post)
- if post.activity_streams?
= link_to image_tag(post.image_url, 'data-small-photo' => post.image_url, 'data-full-photo' => post.image_url, :class => 'stream-photo'), post.object_url, :class => "stream-photo-link"
- elsif reshare?(post)
= render 'reshares/reshare', :reshare => post, :post => post.root
- else
= render 'status_messages/status_message', :post => post, :photos => post.photos
.info
%span.via

View file

@ -2,7 +2,6 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
- if photos.size > 0
.photo_attachments
.big_stream_photo

View file

@ -811,6 +811,8 @@ en:
unlike: "Unlike"
dislike: "Dislike"
shared_with: "Shared with: %{aspect_names}"
nsfw: "This post has been flagged as NSFW by its author. %{link}"
show: "show"
footer:
logged_in_as: "logged in as %{name}"
your_aspects: "your aspects"

View file

@ -5,6 +5,7 @@
var Stream = {
selector: "#main_stream",
nsfw_links: ".shield a",
initialize: function() {
Diaspora.page.directionDetector.updateBinds();
@ -13,6 +14,8 @@ var Stream = {
},
initializeLives: function(){
Stream.setUpNsfwLinks();
// reshare button action
$(".reshare_button", this.selector).live("click", function(evt) {
evt.preventDefault();
@ -24,6 +27,14 @@ var Stream = {
box.toggle();
}
});
},
setUpNsfwLinks:function(){
$(this.nsfw_links).click(function(e){
e.preventDefault();
$(this).parent().fadeOut();
});
},
setUpAudioLinks: function() {

View file

@ -3492,3 +3492,13 @@ a.toggle_selector
&:hover
@include opacity(1)
.post-content
:position relative
.shield
:z-index 3
:background-color #eee
:position absolute
:width 100%
:height 100%
:padding 5px