From 13e8574c649a4d4e6d34679dc11a5c0cc42e97dc Mon Sep 17 00:00:00 2001 From: albert Date: Mon, 10 Oct 2011 18:14:00 -0400 Subject: [PATCH] better formatting for notes --- app/assets/javascripts/notes.js | 13 +++++++++---- app/logical/d_text.rb | 11 ++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 27ff7a5f5..0abd468dc 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -218,13 +218,18 @@ Danbooru.Note = { }, set_text: function($note_body, text) { - text = text.replace('', '

'); - text = text.replace('', '

'); - $note_body.html(text); + Danbooru.Note.Body.display_text($note_body, text); Danbooru.Note.Body.resize($note_body); Danbooru.Note.Body.bound_position($note_body); }, + display_text: function($note_body, text) { + text = text.replace(//g, '

'); + text = text.replace(/<\/tn>/g, '

'); + text = text.replace(/\n/g, '
'); + $note_body.html(text); + }, + bind_events: function($note_body) { $note_body.mouseover(function(e) { var $note_body_inner = $(e.currentTarget); @@ -304,7 +309,7 @@ Danbooru.Note = { y: $note_box.position().top / ratio, width: $note_box.width() / ratio, height: $note_box.height() / ratio, - body: $note_body.html(), + body: $note_body.data("original-body"), post_id: Danbooru.meta("post-id") } } diff --git a/app/logical/d_text.rb b/app/logical/d_text.rb index 7bd84b5d7..732170318 100644 --- a/app/logical/d_text.rb +++ b/app/logical/d_text.rb @@ -199,12 +199,13 @@ class DText def self.sanitize(text) Sanitize.clean( text, - :elements => %w(h1 h2 h3 h4 h5 h6 a span div blockquote br p ul li ol em strong), + :elements => %w(tn h1 h2 h3 h4 h5 h6 a span div blockquote br p ul li ol em strong small big b i font), :attributes => { - "a" => %w(href title), - "span" => %w(class), - "div" => %w(class), - "p" => %w(class) + "a" => %w(href title style), + "span" => %w(class style), + "div" => %w(class style), + "p" => %w(class style), + "font" => %w(color size style) }, :protocols => { "a" => {