* add new bit_flags column to posts
* conditionally enable embedded notes on a per post basis
This commit is contained in:
@@ -4,8 +4,15 @@ Danbooru.Note = {
|
||||
var $inner_border = $('<div/>');
|
||||
$inner_border.addClass("note-box-inner-border");
|
||||
|
||||
var opacity = 0;
|
||||
if (Danbooru.meta("post-has-embedded-notes") === "true") {
|
||||
opacity = 0.9
|
||||
} else {
|
||||
opacity = 0.5
|
||||
}
|
||||
|
||||
$inner_border.css({
|
||||
opacity: 0.5,
|
||||
opacity: opacity,
|
||||
"-ms-filter": "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)",
|
||||
"filter": "alpha(opacity=50)",
|
||||
zoom: 1
|
||||
@@ -269,7 +276,9 @@ Danbooru.Note = {
|
||||
|
||||
set_text: function($note_body, $note_box, text) {
|
||||
Danbooru.Note.Body.display_text($note_body, text);
|
||||
Danbooru.Note.Body.display_text($note_box.children("div"), text);
|
||||
if (Danbooru.meta("post-has-embedded-notes") === "true") {
|
||||
Danbooru.Note.Body.display_text($note_box.children("div"), text);
|
||||
}
|
||||
Danbooru.Note.Body.resize($note_body);
|
||||
Danbooru.Note.Body.bound_position($note_body);
|
||||
},
|
||||
@@ -663,7 +672,9 @@ Danbooru.Note = {
|
||||
$note_body.data("original-body", text);
|
||||
Danbooru.Note.Box.scale($note_box);
|
||||
Danbooru.Note.Body.display_text($note_body, text);
|
||||
Danbooru.Note.Body.display_text($note_box.children("div"), text);
|
||||
if (Danbooru.meta("post-has-embedded-notes") === "true") {
|
||||
Danbooru.Note.Body.display_text($note_box.children("div"), text);
|
||||
}
|
||||
},
|
||||
|
||||
create: function(x, y, w, h) {
|
||||
|
||||
@@ -3,6 +3,10 @@ class Post < ActiveRecord::Base
|
||||
class DisapprovalError < Exception ; end
|
||||
class SearchError < Exception ; end
|
||||
|
||||
BOOLEAN_ATTRIBUTES = {
|
||||
:has_embedded_notes => 0x0001
|
||||
}
|
||||
|
||||
attr_accessor :old_tag_string, :old_parent_id, :old_source, :old_rating, :has_constraints, :disable_versioning
|
||||
after_destroy :delete_files
|
||||
after_destroy :delete_remote_files
|
||||
@@ -38,7 +42,7 @@ class Post < ActiveRecord::Base
|
||||
has_many :favorites, :dependent => :destroy
|
||||
validates_uniqueness_of :md5
|
||||
validate :post_is_not_its_own_parent
|
||||
attr_accessible :source, :rating, :tag_string, :old_tag_string, :old_parent_id, :old_source, :old_rating, :last_noted_at, :parent_id, :as => [:member, :builder, :gold, :platinum, :contributor, :janitor, :moderator, :admin, :default]
|
||||
attr_accessible :source, :rating, :tag_string, :old_tag_string, :old_parent_id, :old_source, :old_rating, :last_noted_at, :parent_id, :has_embedded_notes, :as => [:member, :builder, :gold, :platinum, :contributor, :janitor, :moderator, :admin, :default]
|
||||
attr_accessible :is_rating_locked, :is_note_locked, :as => [:builder, :contributor, :janitor, :moderator, :admin]
|
||||
attr_accessible :is_status_locked, :as => [:admin]
|
||||
|
||||
@@ -1486,6 +1490,24 @@ class Post < ActiveRecord::Base
|
||||
include PixivMethods
|
||||
include IqdbMethods
|
||||
|
||||
BOOLEAN_ATTRIBUTES.each do |boolean_attribute, bit_flag|
|
||||
define_method(boolean_attribute) do
|
||||
bit_flags & bit_flag > 0
|
||||
end
|
||||
|
||||
define_method("#{boolean_attribute}?") do
|
||||
bit_flags & bit_flag > 0
|
||||
end
|
||||
|
||||
define_method("#{boolean_attribute}=") do |val|
|
||||
if val.to_s =~ /t|1|y/
|
||||
self.bit_flags |= bit_flag
|
||||
else
|
||||
self.bit_flags &= ~bit_flag
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def visible?
|
||||
return false if !Danbooru.config.can_user_see_post?(CurrentUser.user, self)
|
||||
return false if CurrentUser.safe_mode? && rating != "s"
|
||||
|
||||
@@ -33,6 +33,11 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<%= f.label :has_embedded_notes, "Embed notes" %>
|
||||
<%= f.check_box :has_embedded_notes %>
|
||||
</div>
|
||||
|
||||
<% if CurrentUser.is_builder? %>
|
||||
<div class="input">
|
||||
<%= f.label :blank, "Lock" %>
|
||||
|
||||
@@ -120,6 +120,7 @@
|
||||
<meta name="post-is-deleted" content="<%= @post.is_deleted? %>">
|
||||
<meta name="post-is-flagged" content="<%= @post.is_flagged? %>">
|
||||
<meta name="config-large-width" content="<%= Danbooru.config.large_image_width %>">
|
||||
<meta name="post-has-embedded-notes" content="<%= @post.has_embedded_notes? %>">
|
||||
<meta name="always-resize-images" content="<%= CurrentUser.user.always_resize_images? %>">
|
||||
<meta property="og:title" content="<%= @post.presenter.humanized_essential_tag_string %> - <%= Danbooru.config.app_name %>">
|
||||
<meta property="og:description" content="<%= @post.presenter.humanized_tag_string %>">
|
||||
|
||||
Reference in New Issue
Block a user