This commit is contained in:
albert
2011-05-26 19:10:08 -04:00
parent ca68b2def1
commit 969185ad24
31 changed files with 629 additions and 575 deletions

View File

@@ -20,4 +20,4 @@ gem "mechanize"
gem "nokogiri"
gem "meta_search"
gem "will_paginate", :git => "git://github.com/wantful/will_paginate.git"
gem "silent-postgres"
gem "silent-postgres"

View File

@@ -1,347 +1,395 @@
(function() {
Danbooru.Note = function() {}
Danbooru.Note.initialize_all = function() {
$("#note-container").width($("#image").width());
$("#note-container").height($("#image").height());
Danbooru.Note = {
Box: {
create: function(id) {
var $inner_border = $('<div/>');
$inner_border.addClass("note-box-inner-border");
$inner_border.css({opacity: 0.7});
var $note_box = $('<div/>');
$note_box.addClass("note-box");
$note_box.data("id", id);
$note_box.attr("data-id", id);
$note_box.draggable({containment: "parent"});
$note_box.resizable({
containment: "parent",
handles: "se"
});
$note_box.append($inner_border);
Danbooru.Note.Box.bind_events($note_box);
return $note_box;
},
$("a#translate").click(function(e) {
e.preventDefault();
Danbooru.Note.create(1);
});
}
Danbooru.Note.prototype.getElement = function(name, unwrap) {
var element = $("#note-" + name + "-" + this.id);
bind_events: function($note_box) {
$note_box.bind(
"dragstart resizestart",
function(e) {
var $note_box_inner = $(e.currentTarget);
Danbooru.Note.dragging = true;
Danbooru.Note.clear_timeouts();
Danbooru.Note.Body.hide_all();
}
)
$note_box.bind(
"resize",
function(e) {
var $note_box_inner = $(e.currentTarget);
Danbooru.Note.Box.resize_inner_border($note_box_inner);
}
);
$note_box.bind(
"dragstop resizestop",
function(e) {
Danbooru.Note.dragging = false;
}
);
$note_box.bind(
"mouseover mouseout",
function(e) {
if (Danbooru.Note.dragging) {
return;
}
var $note_box_inner = $(e.currentTarget);
if (e.type === "mouseover") {
Danbooru.Note.Body.show($note_box_inner.data("id"));
} else if (e.type === "mouseout") {
Danbooru.Note.Body.hide($note_box_inner.data("id"));
}
}
);
},
if (unwrap) {
return element[0];
} else {
return element;
}
}
Danbooru.Note.prototype.getBox = function(unwrap) {
return this.getElement("box", unwrap);
}
Danbooru.Note.prototype.getImage = function(unwrap) {
return this.getElement("image", unwrap);
}
Danbooru.Note.prototype.getBody = function(unwrap) {
return this.getElement("body", unwrap);
}
Danbooru.Note.prototype.getCorner = function(unwrap) {
return this.getElement("corner", unwrap);
}
Danbooru.Note.prototype.initialize = function(id, is_new, raw_body) {
if (Note.debug) {
console.debug("Note#initialize (id=%d)", id);
}
resize_inner_border: function($note_box) {
var $inner_border = $note_box.find("div.note-box-inner-border");
$inner_border.css({
height: $note_box.height() - 2,
width: $note_box.width() - 2
});
},
this.id = id;
this.is_new = is_new;
// Cache the dimensions
this.fullsize = {
left: this.getBox().offset().left,
top: this.getBox().offset().top,
width: this.getBox().width(),
height: this.getBox().height()
}
scale: function($note_box) {
var $image = $("#image");
var original_width = parseFloat($image.data("width"));
var original_height = parseFloat($image.data("height"));
var ratio = $image.width() / original_width;
if (ratio < 1) {
var scaled_width = original_width * ratio;
var scaled_height = original_height * ratio;
var scaled_top = $note_box.offset().top * ratio;
var scaled_left = $note_box.offset().left * ratio;
$note_box.css({
top: scaled_top,
left: scaled_left,
width: scaled_width,
height: scaled_height
});
}
},
// Store the original values (in case the user clicks Cancel)
this.old = {
raw_body: raw_body,
formatted_body: this.getBody().html()
}
for (p in this.fullsize) {
this.old[p] = this.fullsize[p];
}
// Make the note translucent
if (is_new) {
this.getBox().css({opacity: 0.2});
} else {
this.getBox().css({opacity: 0.5});
}
if (is_new && raw_body == '') {
this.bodyfit = true;
this.getBody().css({height: 100});
}
// Attach the event listeners
this.getBox().mousedown(this.dragStart);
this.getBox().mouseout(this.bodyHideTimer);
this.getBox().mouseover(this.bodyShow);
this.getCorner().mousedown(this.resizeStart);
this.getBody().mouseover(this.bodyShow);
this.getBody().mouseout(this.bodyHideTimer);
this.getBody().click(this.showEditBox);
this.adjustScale();
}
// Returns the raw text value of this note
Danbooru.Note.prototype.textValue = function() {
if (Note.debug) {
console.debug("Note#textValue (id=%d)", this.id);
}
return this.old.raw_body.trim();
}
// Removes the edit box
Danbooru.Note.prototype.hideEditBox = function(e) {
if (Note.debug) {
console.debug("Note#hideEditBox (id=%d)", this.id)
}
var id = $("#edit-box").data("id");
if (id != null) {
$("#edit-box").unbind();
$("#note-save-" + id).unbind();
$("#note-cancel-" + id).unbind();
$("#note-remove-" + id).unbind();
$("#note-history-" + id).unbind();
$("#edit-box").remove();
}
}
// Shows the edit box
Danbooru.Note.prototype.showEditBox = function(e) {
if (Note.debug) {
console.debug("Note#showEditBox (id=%d)", this.id);
}
this.hideEditBox(e);
var insertionPosition = this.getInsertionPosition();
var top = insertionPosition[0];
var left = insertionPosition[1];
html += '<div id="edit-box" style="top: '+top+'px; left: '+left+'px; position: absolute; visibility: visible; z-index: 100; background: white; border: 1px solid black; padding: 12px;">';
html += '<form onsubmit="return false;" style="padding: 0; margin: 0;">';
html += '<textarea rows="7" id="edit-box-text" style="width: 350px; margin: 2px 2px 12px 2px;">' + this.textValue() + '</textarea>';
html += '<input type="submit" value="Save" name="save" id="note-save-' + this.id + '">';
html += '<input type="submit" value="Cancel" name="cancel" id="note-cancel-' + this.id + '">';
html += '<input type="submit" value="Delete" name="remove" id="note-remove-' + this.id + '">';
html += '<input type="submit" value="History" name="history" id="note-history-' + this.id + '">';
html += '</form>';
html += '</div>';
$("#note-container").append(html);
$('#edit-box').data("id", this.id);
$("#edit-box").mousedown(this.editDragStart);
$("#note-save-" + this.id).click(this.save);
$("#note-cancel-" + this.id).click(this.cancel);
$("#note-remove-" + this.id).click(this.remove);
$("#note-history-" + this.id).click(this.history)
$("#edit-box-text").focus();
}
// Shows the body text for the note
Danbooru.Note.prototype.bodyShow = function(e) {
if (Note.debug) {
console.debug("Note#bodyShow (id=%d)", this.id);
}
if (this.dragging) {
return;
}
if (this.hideTimer) {
this.hideTimer.clear();
}
if (Note.noteShowingBody == this) {
return;
}
if (Note.noteShowingBody) {
Note.noteShowingBody.bodyHide();
}
Note.noteShowingBody = this;
if (Note.zindex >= 9) {
/* don't use more than 10 layers (+1 for the body, which will always be above all notes) */
Note.zindex = 0;
for (var i=0; i< Note.all.length; ++i) {
Note.all[i].getBox().css({zIndex: 0});
descale: function($note_box) {
var $image = $("#image");
var original_width = parseFloat($image.data("width"));
var original_height = parseFloat($image.data("height"));
var ratio = $image.width() / original_width;
if (ratio < 1) {
var scaled_width = original_width * ratio;
var scaled_height = original_height * ratio;
var scaled_top = $note_box.offset().top * ratio;
var scaled_left = $note_box.offset().left * ratio;
$note_box.css({
top: scaled_top,
left: scaled_left,
width: scaled_width,
height: scaled_height
});
}
}
this.getBox().css({zIndex: ++Note.zindex});
this.getBody().css({zIndex: 10, top: 0, left: 0});
var dw = document.documentElement.scrollWidth;
this.getBody().css({visibility: "hidden", display: "block"});
if (!this.bodyfit) {
this.getBody().css({height: "auto", minWidth: 140});
var w = this.getBody(true).offsetWidth;
var h = this.getBody(true).offsetHeight;
var lo = null;
var hi = null;
var x = null;
var last = null;
if (this.getBody(true).scrollWidth <= this.getBody(true).clientWidth) {
/* for short notes (often a single line), make the box no wider than necessary */
// scroll test necessary for Firefox
lo = 20;
hi = w;
},
do {
x = (lo+hi)/2
this.getBody().css({minWidth: x});
if (this.getBody(true).offsetHeight > h) {
lo = x;
} else {
hi = x;
}
} while ((hi - lo) > 4);
if (this.getBody(true).offsetHeight > h) {
this.getBody().css({minWidth: hi});
}
Body: {
create: function(id) {
var $note_body = $('<div></div>');
$note_body.addClass("note-body");
$note_body.data("id", id);
$note_body.attr("data-id", id);
$note_body.hide();
Danbooru.Note.Body.bind_events($note_body);
return $note_body;
},
initialize: function($note_body) {
var $note_box = $("#note-container div.note-box[data-id=" + $note_body.data("id") + "]");
$note_body.css({
top: $note_box.position().top + $note_box.height() + 5,
left: $note_box.position().left
});
Danbooru.Note.Body.bound_position($note_body);
},
bound_position: function($note_body) {
var doc_width = $(window).width();
if ($note_body.offset().left + $note_body.width() > doc_width) {
$note_body.css({
// 30 is a magic number to factor in width of the scroll bar
left: $note_body.position().left - 30 - ($note_body.offset().left + $note_body.width() - doc_width)
});
}
},
show: function(id) {
if (Danbooru.Note.editing) {
return;
}
Danbooru.Note.Body.hide_all();
Danbooru.Note.clear_timeouts();
var $note_body = $("#note-container div.note-body[data-id=" + id + "]");
$note_body.show();
Danbooru.Note.Body.initialize($note_body);
},
hide: function(id) {
var $note_body = $("#note-container div.note-body[data-id=" + id + "]");
Danbooru.Note.timeouts.push($.timeout(250).done(function() {$note_body.hide();}));
},
hide_all: function() {
$(".note-body").hide();
},
resize: function($note_body) {
var w = $note_body.width();
var h = $note_body.height();
var golden_ratio = 1.6180339887;
while (w / h < golden_ratio) {
w = w * 1.025;
h = h / 1.025;
}
if ($.browser.msie) {
// IE7 adds scrollbars if the box is too small, obscuring the text
if (this.getBody(true).offsetHeight < 35) {
this.getBody().css({minHeight: 35});
}
if (this.getBody(true).offsetWidth < 47) {
this.getBody().css({minWidth: 47});
}
while (w / h > golden_ratio) {
w = w / 1.025;
h = h * 1.025;
}
this.bodyfit = true;
$note_body.css({
width: w,
height: "auto"
});
},
set_text: function($note_body, text) {
$note_body.html(text);
Danbooru.Note.Body.resize($note_body);
Danbooru.Note.Body.bound_position($note_body);
},
bind_events: function($note_body) {
$note_body.mouseover(function(e) {
var $note_body_inner = $(e.currentTarget);
Danbooru.Note.Body.show($note_body_inner.data("id"));
});
$note_body.mouseout(function(e) {
var $note_body_inner = $(e.currentTarget);
Danbooru.Note.Body.hide($note_body_inner.data("id"));
});
$note_body.click(function(e) {
var $note_body_inner = $(e.currentTarget);
Danbooru.Note.Edit.show($note_body_inner);
})
}
this.getBody().css({
top: this.getBox(true).offsetTop + this.getBox(true).clientHeight + 5
},
Edit: {
show: function($note_body) {
if (Danbooru.Note.editing) {
return;
}
$(".note-box").resizable("disable");
$(".note-box").draggable("disable");
$textarea = $('<textarea></textarea>');
$textarea.css({
width: "100%",
height: "10em"
});
if ($note_body.html() !== "<em>Click to edit</em>") {
$textarea.val($note_body.html());
}
$dialog = $('<div></div>');
$dialog.append($textarea);
$dialog.data("id", $note_body.data("id"));
$dialog.dialog({
modal: true,
width: 300,
dialogClass: "note-edit-dialog",
title: "Edit note",
buttons: {
"Save": Danbooru.Note.Edit.save,
"Cancel": Danbooru.Note.Edit.cancel,
"Delete": Danbooru.Note.Edit.delete,
"History": Danbooru.Note.Edit.history
}
});
$dialog.bind("dialogclose", function() {
Danbooru.Note.editing = false;
$(".note-box").resizable("enable");
$(".note-box").draggable("enable");
});
Danbooru.Note.editing = true;
},
save: function() {
var $this = $(this);
var $textarea = $this.find("textarea");
var id = $this.data("id");
var $note_body = $("#note-container .note-body[data-id=" + id + "]");
var $note_box = $("#note-container .note-box[data-id=" + id + "]");
var text = $textarea.val();
Danbooru.Note.Body.set_text($note_body, text);
$this.dialog("close");
$note_box.find(".note-box-inner-border").removeClass("unsaved");
console.log("save %d", id);
},
cancel: function() {
$(this).dialog("close");
},
delete: function() {
var $this = $(this);
var id = $this.data("id");
console.log("delete %d", id);
$("#note-container .note-box[data-id=" + id + "]").remove();
$("#note-container .note-body[data-id=" + id + "]").remove();
$(this).dialog("close");
},
history: function() {
var $this = $(this);
var id = $this.data("id");
console.log("history %d", id);
$(this).dialog("close");
}
},
TranslationMode: {
start: function() {
$("#note-container").click(Danbooru.Note.TranslationMode.create_note);
$("#translate-button").one("click", Danbooru.Note.TranslationMode.stop).html("Click on image");
},
stop: function() {
$("#note-container").unbind("click");
$("#translate-button").one("click", Danbooru.Note.TranslationMode.start).html("Translate");
},
create_note: function(e) {
var offset = $("#image").offset();
Danbooru.Note.new(e.pageX - offset.left, e.pageY - offset.top);
Danbooru.Note.TranslationMode.stop();
}
},
Image: {
resize: function() {
var $image = $("#image");
var max_width = parseInt($("meta[name=max-image-width]").attr("content"));
var current_width = $image.width();
var current_height = $image.height();
if (current_width > max_width) {
var ratio = max_width / current_width;
$image.attr("ratio", ratio);
$image.width(current_width * ratio).height(current_height * ratio).attr("resized", "1");
}
},
reset_size: function() {
var $image = $("#image");
$image.width($image.data("width")).height($image.data("height")).attr("resized", "0");
}
},
id: "x",
dragging: false,
editing: false,
timeouts: [],
pending: {},
scale: function() {
var $image = $("#image");
if ($image.attr("ratio")) {
}
},
add: function(id, x, y, w, h, text) {
var $note_box = Danbooru.Note.Box.create(id);
var $note_body = Danbooru.Note.Body.create(id);
$note_box.css({
left: x,
top: y,
width: w,
height: h
});
// keep the box within the document's width
var l = 0;
var e = this.getBox(true);
do {
l += e.offsetLeft
} while (e = e.offsetParent);
l += this.getBody(true).offsetWidth + 10 - dw;
if (l > 0) {
this.getBody().css({left: this.getBox(true).offsetLeft - l});
} else {
this.getBody().css({left: this.getBox(true).offsetLeft});
}
this.getBody().css({visibility: "visible"});
}
Danbooru.Note.prototype.bodyHideTimer = function(e) {
if (Note.debug) {
console.debug("Note#bodyHideTimer (id=%d)", this.id);
}
this.hideTimer = $.timeout(250).done(this.bodyHide);
}
// Start dragging the note
Danbooru.Note.prototype.dragStart = function(e) {
if (Note.debug) {
console.debug("Note#dragStart (id=%d)", this.id);
}
$(document).mousemove(this.drag);
$(document).mouseup(this.dragStop);
$(document).select(function(e) {e.preventDefault();});
this.cursorStartX = e.pageX;
this.cursorStartY = e.pageY;
this.boxStartX = this.getBox().offset().left;
this.boxStartY = this.getBox().offset().top;
this.boundsX = new ClipRange(5, this.getImage(true).clientWidth - this.getBox(true).clientWidth - 5);
this.boundsY = new ClipRange(5, this.getImage(true).clientHeight - this.getBox(true).clientHeight - 5);
this.dragging = true;
this.bodyHide();
}
$("div#note-container").append($note_box);
$("div#note-container").append($note_body);
Danbooru.Note.Box.scale($note_box);
Danbooru.Note.Box.resize_inner_border($note_box);
Danbooru.Note.Body.set_text($note_body, text);
},
// Stop dragging the note
Danbooru.Note.prototype.dragStop = function(e) {
if (Note.debug) {
console.debug("Note#dragStop (id=%d)", this.id);
}
$(document).unbind();
this.cursorStartX = null;
this.cursorStartY = null;
this.boxStartX = null;
this.boxStartY = null;
this.boundsX = null;
this.boundsY = null;
this.dragging = false;
this.bodyShow();
}
Danbooru.Note.prototype.ratio = function() {
return this.getImage().width() / parseFloat(this.getImage().data("original-width"));
}
// Scale the notes for when the image gets resized
Danbooru.Note.prototype.adjustScale = function() {
if (Note.debug) {
console.debug("Note#adjustScale (id=%d)", this.id);
}
var ratio = this.ratio();
this.getBox().css({
left: this.fullsize.left * ratio,
top: this.fullsize.top * ratio,
width: this.fullsize.width * ratio,
height: this.fullsize.height * ratio
new: function(x, y) {
var $note_box = Danbooru.Note.Box.create(Danbooru.Note.id);
var $note_body = Danbooru.Note.Body.create(Danbooru.Note.id);
$note_box.offset({
top: y,
left: x
});
}
$note_box.find(".note-box-inner-border").addClass("unsaved");
$note_body.html("<em>Click to edit</em>");
$("div#note-container").append($note_box);
$("div#note-container").append($note_body);
Danbooru.Note.Box.resize_inner_border($note_box);
Danbooru.Note.id += "x";
},
// Update the note's position as it gets dragged
Danbooru.Note.prototype.drag = function(e) {
var left = this.boxStartX + e.pageX - this.cursorStartX;
var top = this.boxStartY + e.pageY - this.cursorStartY;
left = this.boundsX.clip(left);
top = this.boundsY.clip(top);
this.getBox().css({left: left, top: top});
var ratio = this.ratio();
this.fullsize.left = left / ratio;
this.fullsize.top = top / ratio;
e.preventDefault();
}
// Start dragging the edit box
Danbooru.Note.prototype.editDragStart = function(e) {
if (Note.debug) {
console.debug("Note#editDragStart (id=%d)", this.id);
}
clear_timeouts: function() {
$.each(Danbooru.Note.timeouts, function(i, v) {
v.clear();
});
var node = e.element().nodeName;
if (node != 'FORM' && node != 'DIV') {
return
}
document.observe("mousemove", this.editDrag.bindAsEventListener(this))
document.observe("mouseup", this.editDragStop.bindAsEventListener(this))
document.observe("selectstart", function() {return false})
this.elements.editBox = $('edit-box');
this.cursorStartX = e.pointerX()
this.cursorStartY = e.pointerY()
this.editStartX = this.elements.editBox.offsetLeft
this.editStartY = this.elements.editBox.offsetTop
this.dragging = true
Danbooru.Note.timeouts = [];
}
})();
}
$(document).ready(function() {
Danbooru.Note.initialize_all();
if ($("#c-posts #a-show").size > 0) {
Danbooru.Note.Image.resize();
$("#translate-button").one("click", Danbooru.Note.TranslationMode.start);
$("#note-container").width($("#image").width()).height($("#image").height());
// $(document).bind("keydown", "ctrl+n", Danbooru.Note.TranslationMode.start);
$("#toggle-resize").click(function() {
var $image = $("#image");
if ($image.attr("resized") === "1") {
Danbooru.Note.Image.reset_size();
} else {
Danbooru.Note.Image.resize();
}
});
}
});

View File

@@ -166,38 +166,22 @@
Danbooru.Post = {};
Danbooru.Post.initialize_all = function() {
this.initialize_tag_and_wiki_menu();
this.initialize_tag_list();
this.initialize_post_sections();
this.initialize_wiki_page_excerpt();
}
Danbooru.Post.initialize_tag_list = function() {
$("#tag-box a.search-inc-tag").click(function(e) {
$("#tags").val($("#tags").val() + " " + $(e.target).parent("li").data("tag-name"));
return false;
});
$("#tag-box a.search-exl-tag").click(function(e) {
$("#tags").val($("#tags").val() + " -" + $(e.target).parent("li").data("tag-name"));
return false;
});
}
Danbooru.Post.initialize_tag_and_wiki_menu = function() {
$("#tag-and-wiki-box h1 a").click(function(e) {
$("#tag-box").hide();
$("#wiki-box").hide();
$("#tag-and-wiki-box menu li").toggleClass("active");
var name = e.target.hash;
$(name).show();
e.stopPropagation();
return false;
Danbooru.Post.initialize_wiki_page_excerpt = function() {
$("#close-wiki-page-excerpt").click(function() {
$("#wiki-page-excerpt").remove();
Danbooru.j_alert("Notice", "You can reenable the wiki excerpt by clearing your cookies.");
Danbooru.Cookie.put("hide-wiki-page-excerpt", "1");
});
$("#tag-and-wiki-box menu li:first-child").addClass("active");
$("#wiki-box").hide();
if (Danbooru.Cookie.get("hide-wiki-page-excerpt") === "1") {
$("#wiki-page-excerpt").remove();
}
}
Danbooru.Post.initialize_post_sections = function() {
$("#post-sections li a").click(function(e) {
$("#comments").hide();

View File

@@ -2,28 +2,61 @@
$link_color: #006FFA;
$link_hover_color: #9093FF;
$h1_size: 2em;
$h2_size: 1.5em;
$h3_size: 1.16667em;
$h1_padding: 1.25em 0;
$h2_padding: 1.45833em 0;
$h3_padding: 1.51785em 0;
.blacklisted {
display: none !important;
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
body, div, h1, h2, h3, h4, h5, h6, p, ul, li, dd, dt, header, aside {
font-family: Verdana, Geneva, sans-serif;
line-height: 1.25em;
}
body {
font-size: 87.5%;
}
h1, h2, h3, h4 {
font-family: Tahoma;
line-height: 1em;
}
/*** BEGIN CUSTOM STYLES ***/
body {
font-family: Verdana, Helvetica, sans-serif;
padding: 1em 2em;
margin: 0;
line-height: 1.25em;
}
article, section {
@@ -74,28 +107,40 @@ dt {
font-weight: bold;
}
h1, h2, h3 {
font-family: Tahoma;
font-weight: bold;
line-height: 1.25em;
}
h1 {
font-size: 2.1818em;
font-size: $h1_size;
}
h2 {
font-size: 1.9091em;
h2 {
font-size: $h2_size;
}
h3 {
font-size: 1.6364em;
h3 {
font-size: $h3_size;
}
h4 {
font-size: 1.4545em;
}
div.prose {
h1, h2, h3 {
line-height: 1em;
}
h1 {
padding: $h1_padding;
}
h5 {
font-size: 1.2727em;
}
h2 {
padding: $h2_padding;
}
h6 {
font-size: 1.090em;
h3 {
padding: $h3_padding;
}
}
header {
@@ -228,14 +273,18 @@ div#page {
aside#sidebar {
width: 20%;
float: left;
h1 {
font-size: 1.2em;
font-size: $h3_size;
}
ul {
list-style-type: none;
}
input[type=text] {
width: 10em;
}
}
aside#sidebar > section {
@@ -253,6 +302,7 @@ div.clearfix {
clear: both;
}
/*** Paginator ***/
div.paginator {
display: block;
@@ -294,14 +344,6 @@ div.paginator {
}
/*** Header ***/
body > header > h1 {
font-size: 3em;
font-family: Tahoma, Helvetica, sans-serif;
}
/*** Dialog Boxes ***/
div.ui-dialog {
ul {
@@ -542,65 +584,21 @@ div#c-posts {
margin-left: 1em;
}
section#tag-and-wiki-box {
padding: 0;
menu {
li {
display: inline-block;
}
li.active a {
color: #000;
}
}
div#tag-box {
h2 {
display: none;
}
li {
list-style-type: none;
}
}
div#wiki-box {
h2 {
display: none;
}
}
}
section#content > h1 {
display: none;
h1 {
font-size: $h3_size;
}
section#content {
section > h2 {
display: none;
}
menu#post-sections {
margin-bottom: 1em;
li {
font-size: 1.1em;
font-weight: bold;
}
li.active a {
color: black;
}
}
section#edit {
fieldset {
label {
display: inline;
}
}
}
div#wiki-page-excerpt {
position: relative;
width: 40em;
padding-right: 1em;
}
span#close-wiki-page-excerpt {
position: absolute;
top: 0;
right: 0;
cursor: pointer;
}
}
@@ -783,9 +781,6 @@ div#c-forum-topics {
}
div#a-show {
h1#forum-topic-title {
font-size: 2.1818em;
}
}
span.info {
@@ -867,15 +862,13 @@ div#note-container {
position: absolute;
div.note-body {
background: #FFE;
border: 1px solid black;
max-width: 300px;
min-width: 140px;
min-height: 10px;
position: absolute;
padding: 5px;
border: 1px solid black;
background: white;
min-width: 5em;
min-height: 1em;
cursor: pointer;
overflow: auto;
padding: 4px;
p.tn {
font-size: 0.8em;
@@ -885,41 +878,49 @@ div#note-container {
div.note-box {
position: absolute;
border: 1px solid black;
width: 150px;
height: 150px;
border: 1px solid white;
min-width: 100px;
min-height: 100px;
cursor: move;
background: #FFE;
div.note-corner {
background: black;
width: 7px;
height: 7px;
position: absolute;
bottom: 0;
right: 0;
cursor: se-resize;
div.note-box-inner-border {
border: 1px solid black;
background: white;
}
div.note-box-inner-border.unsaved {
border: 1px solid red;
}
}
div.unsaved {
background: #FFF;
border: 1px solid red;
div.note-corner {
background: red;
}
div.note-edit-dialog {
font-size: 70%;
}
}
div#jquery-test div.note {
background: #FFE;
border: 1px solid black;
max-width: 300px;
min-width: 140px;
min-height: 10px;
position: absolute;
padding: 5px;
cursor: pointer;
overflow: auto;
}
/*** Site Map ***/
div#c-static {
div#a-site-map {
width: 80em;
h1 {
display: none;
}
section {
width: 20em;
float: left;
h1 {
display: block;
font-size: $h3_size;
}
ul {
margin-bottom: 1.5em;
}
}
}
}

View File

@@ -5,7 +5,7 @@ class WikiPagesController < ApplicationController
before_filter :normalize_search_params, :only => [:index]
def new
@wiki_page = WikiPage.new
@wiki_page = WikiPage.new(params[:wiki_page])
respond_with(@wiki_page)
end

View File

@@ -40,8 +40,8 @@ module PostSets
def load_associations
if is_single_tag?
@wiki_page = WikiPage.find_by_title(tags)
@artist = Artist.find_by_name(tags)
@wiki_page = ::WikiPage.titled(tags).first
@artist = ::Artist.find_by_name(tags)
end
end
@@ -61,6 +61,10 @@ module PostSets
def tag_array
@tag_array ||= Tag.scan_query(tags)
end
def tag
tag_array.first
end
def validate
validate_page

View File

@@ -14,7 +14,7 @@ class Artist < ActiveRecord::Base
attr_accessible :name, :url_string, :other_names, :group_name, :wiki_page_attributes, :notes
scope :url_match, lambda {|string| where(["id in (?)", Artist.find_all_by_url(string).map(&:id)])}
scope :other_names_match, lambda {|string| where(["other_names_index @@ to_tsquery('danbooru', ?)", Artist.normalize_name(string)])}
search_method :url_match, :other_names_match
search_methods :url_match, :other_names_match
module UrlMethods
module ClassMethods

View File

@@ -8,7 +8,7 @@ class ForumPost < ActiveRecord::Base
validates_presence_of :body, :creator_id
validate :validate_topic_is_unlocked
scope :body_matches, lambda {|body| where(["text_index @@ plainto_tsquery(?)", body])}
search_method :body_matches
search_methods :body_matches
def self.new_reply(params)
if params[:topic_id]

View File

@@ -1,4 +1,13 @@
class WikiPagePresenter
attr_reader :wiki_page
def initialize(wiki_page)
@wiki_page = wiki_page
end
def excerpt
wiki_page.body.split(/\r\n|\r|\n/).first
end
# Produce a formatted page that shows the difference between two versions of a page.
def diff(other_version)

View File

@@ -13,15 +13,16 @@
<% if flash[:notice] =~ /error/ %>
<meta name="errors" content="true">
<% end %>
<meta name="max-image-width" content="500">
<%= auto_discovery_link_tag :atom, posts_path(:format => "atom", :tags => params[:tags]) %>
<link rel="stylesheet" href="/assets/application.css" media="screen" type="text/css">
<script src="/assets/application.js" type="text/javascript" charset="utf-8" async defer></script>
<%= stylesheet_link_tag "application", :media => "screen" %>
<%= javascript_include_tag "application" %>
<%= Danbooru.config.custom_html_header_content %>
<%= yield :html_header %>
</head>
<body>
<header>
<h1><%= Danbooru.config.app_name %></h1>
<h1><%= link_to Danbooru.config.app_name, "/" %></h1>
<nav>
<menu>
<% if CurrentUser.user.is_anonymous? %>

View File

@@ -22,7 +22,7 @@
<% end %>
<section id="blacklist-box">
<h1>Blacklisted</h1>
<h1>Blacklist</h1>
<%= link_to "Hidden", "#" %>
<ul>
</ul>
@@ -30,35 +30,18 @@
<%= render :partial => "posts/partials/index/explore", :locals => {:post_set => @post_set} %>
<section id="tag-and-wiki-box">
<menu>
<li><h1><a href="#tag-box">Tags</a></h1></li>
<% unless @post_set.tags.blank? %>
<li><h1><a href="#wiki-box">Wiki</a></h1></li>
<% end %>
</menu>
<div id="tag-box">
<h2>Tags</h2>
<%= @post_set.presenter.tag_list_html(self) %>
</div>
<div id="wiki-box">
<h2>Wiki</h2>
<%= @post_set.presenter.wiki_html(self) %>
</div>
<section id="tag-box">
<h1>Tags</h1>
<%= @post_set.presenter.tag_list_html(self) %>
</section>
</aside>
<section id="content">
<h1>Posts</h1>
<%= @post_set.presenter.post_previews_html %>
<div class="clearfix"></div>
<div class="paginator">
<%= @post_set.presenter.pagination_html(self) %>
</div>
<% if @post_set.has_wiki? && @post_set.page < 2 %>
<%= render :partial => "wiki_pages/excerpt", :locals => {:wiki_page => @post_set.wiki_page, :tag => @post_set.tag} %>
<% end %>
<%= render :partial => "posts/partials/index/posts", :locals => {:post_set => @post_set} %>
</section>
<% content_for(:page_title) do %>

View File

@@ -1,4 +1,4 @@
<%= form_tag(posts_path, :method => "get") do %>
<%= text_field_tag("tags", params[:tags], :size => 15) %>
<%= text_field_tag("tags", params[:tags]) %>
<%= submit_tag "Go" %>
<% end %>

View File

@@ -0,0 +1,9 @@
<h1>Posts</h1>
<%= post_set.presenter.post_previews_html %>
<div class="clearfix"></div>
<div class="paginator">
<%= post_set.presenter.pagination_html(self) %>
</div>

View File

@@ -1,26 +1,26 @@
<div class="static">
<div class="site_map">
<h2><%= link_to Danbooru.config.app_name, '/' %></h2>
<div>
<div id="c-static">
<div id="a-site-map">
<h1><%= Danbooru.config.app_name %></h1>
<section>
<ul>
<li><h4>Posts</h4></li>
<li><h1>Posts</h1></li>
<li><%= link_to("Help", wiki_pages_path(:title => "help:posts")) %></li>
<li><%= link_to("Listing", posts_path) %></li>
<li><%= link_to("Recent Changes", post_histories_path) %></li>
<li><%= link_to("Recent Changes", post_versions_path) %></li>
<li><%= link_to("Upload", new_upload_path) %></li>
</ul>
<ul>
<li><h4>Tools</h4></li>
<li><h1>Tools</h1></li>
<li><%= link_to("Bookmarklet", wiki_pages_path(:title => "help:bookmarklet")) %></li>
<li><%= link_to("API Documentation", wiki_pages_path(:title => "help:api")) %></li>
</ul>
<ul>
<li><h4>Reports</h4></li>
<li><h1>Reports</h1></li>
</ul>
</div>
<div>
</section>
<section>
<ul>
<li><h4>Tags</h4></li>
<li><h1>Tags</h1></li>
<li><%= link_to("Help", wiki_pages_path(:title => "help:tags")) %></li>
<li><%= link_to("Cheat sheet", wiki_pages_path(:title => "help:cheatsheet")) %></li>
<li><%= link_to("Aliases", tag_aliases_path) %></li>
@@ -28,63 +28,63 @@
<li><%= link_to("Listing", tags_path) %></li>
</ul>
<ul>
<li><h4>Notes</h4></li>
<li><h1>Notes</h1></li>
<li><%= link_to("Help", wiki_pages_path(:title => "help:notes")) %></li>
<li><%= link_to("History", note_versions_path) %></li>
<li><%= link_to("Listing", notes_path) %></li>
</ul>
<ul>
<li><h4>Artists</h4></li>
<li><h1>Artists</h1></li>
<li><%= link_to("Help", wiki_pages_path(:title => "help:artists")) %></li>
<li><%= link_to("Listing", artists_path) %></li>
</ul>
<ul>
<li><h4>Pools</h4></li>
<li><h1>Pools</h1></li>
<li><%= link_to("Help", wiki_pages_path(:title => "help:pools")) %></li>
<li><%= link_to("Listing", pools_path) %></li>
</ul>
</div>
<div>
</section>
<section>
<ul>
<li><h4>Comments</h4></li>
<li><h1>Comments</h1></li>
<li><%= link_to("Help", wiki_pages_path(:title => "help:comments")) %></li>
<li><%= link_to("Listing", comments_path) %></li>
<li><%= link_to("Trac", "http://trac.donmai.us") %></li>
</ul>
<ul>
<li><h4>Forum</h4></li>
<li><h1>Forum</h1></li>
<li><%= link_to("Help", wiki_pages_path(:title => "help:forum")) %></li>
<li><%= link_to("Listing", forum_topics_path) %></li>
</ul>
<ul>
<li><h4>Wiki</h4></li>
<li><h1>Wiki</h1></li>
<li><%= link_to("Help", wiki_pages_path(:title => "help:wiki")) %></li>
<li><%= link_to("Listing", wiki_pages_path) %></li>
<li><%= link_to("Recent Changes", wiki_page_versions_path) %></li>
</ul>
</div>
<div>
</section>
<section>
<ul>
<li><h4>Users</h4></li>
<li><h1>Users</h1></li>
<li><%= link_to("Help", wiki_pages_path(:title => "help:users")) %></li>
<li><%= link_to("Bans", bans_path) %></li>
<li><%= link_to("Listing", users_path) %></li>
<% unless CurrentUser.nil? %>
<li><%= link_to("Profile", user_path(CurrentUser.user)) %></li>
<% end %>
<li><%= link_to("Feedback", user_feedback_path) %></li>
<li><%= link_to("Feedback", user_feedback_index_path) %></li>
<li><%= link_to("Settings", edit_user_path(CurrentUser.user)) %></li>
<li><%= link_to("Signup", new_user_path) %></li>
<li><%= link_to("Terms of Service", terms_of_service_path) %></li>
</ul>
<% if CurrentUser.is_admin? %>
<ul>
<li><h4>Admin</h4></li>
<li><h1>Admin</h1></li>
<li><%= link_to("Edit User", admin_users_edit_path) %></li>
<li><%= link_to("Janitor Trials", janitor_trials_path) %></li>
<li><%= link_to("IP Bans", ip_bans_path) %></li>
</ul>
<% end %>
</div>
</section>
</div>
</div>

View File

@@ -0,0 +1,19 @@
<!--
- wiki_page
- tag
-->
<div id="wiki-page-excerpt">
<span class="ui-icon ui-icon-closethick" id="close-wiki-page-excerpt"></span>
<h1>Wiki</h1>
<% if wiki_page %>
<div id="wiki-page-excerpt" class="prose">
<%= format_text(wiki_page.presenter.excerpt) %>
<p>Read the <%= link_to "full article", wiki_page_path(wiki_page.id) %>.</p>
</div>
<% else %>
<p>There is currently no wiki page for the tag "<%= tag %>". You can <%= link_to "create one", new_wiki_page_path(:wiki_page => {:title => tag}) %>.</p>
<% end %>
</div>

View File

@@ -2,7 +2,7 @@ module Danbooru
class CustomConfiguration < Configuration
# Define your custom overloads here
def app_name
"."
"Lorem"
end
def posts_per_page

View File

@@ -1,10 +1,6 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
inflect.uncountable %w( user_feedback )
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@@ -59,26 +59,26 @@
.ui-widget { font-family: Verdana,Arial,sans-serif; font-size: 1.1em; }
.ui-widget .ui-widget { font-size: 1em; }
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; }
.ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; color: #222222; }
.ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(/images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; color: #222222; }
.ui-widget-content a { color: #222222; }
.ui-widget-header { border: 1px solid #aaaaaa; background: #cccccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x; color: #222222; font-weight: bold; }
.ui-widget-header { border: 1px solid #aaaaaa; background: #cccccc url(/images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x; color: #222222; font-weight: bold; }
.ui-widget-header a { color: #222222; }
/* Interaction states
----------------------------------*/
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3; background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #555555; }
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3; background: #e6e6e6 url(/images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #555555; }
.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #555555; text-decoration: none; }
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #999999; background: #dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #999999; background: #dadada url(/images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
.ui-state-hover a, .ui-state-hover a:hover { color: #212121; text-decoration: none; }
.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa; background: #ffffff url(/images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #212121; text-decoration: none; }
.ui-widget :active { outline: none; }
/* Interaction Cues
----------------------------------*/
.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fcefa1; background: #fbf9ee url(images/ui-bg_glass_55_fbf9ee_1x400.png) 50% 50% repeat-x; color: #363636; }
.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fcefa1; background: #fbf9ee url(/images/ui-bg_glass_55_fbf9ee_1x400.png) 50% 50% repeat-x; color: #363636; }
.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; }
.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x; color: #cd0a0a; }
.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(/images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x; color: #cd0a0a; }
.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cd0a0a; }
.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cd0a0a; }
.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; }
@@ -89,14 +89,14 @@
----------------------------------*/
/* states and images */
.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); }
.ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
.ui-widget-header .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
.ui-state-default .ui-icon { background-image: url(images/ui-icons_888888_256x240.png); }
.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); }
.ui-state-active .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); }
.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); }
.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); }
.ui-icon { width: 16px; height: 16px; background-image: url(/images/ui-icons_222222_256x240.png); }
.ui-widget-content .ui-icon {background-image: url(/images/ui-icons_222222_256x240.png); }
.ui-widget-header .ui-icon {background-image: url(/images/ui-icons_222222_256x240.png); }
.ui-state-default .ui-icon { background-image: url(/images/ui-icons_888888_256x240.png); }
.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(/images/ui-icons_454545_256x240.png); }
.ui-state-active .ui-icon {background-image: url(/images/ui-icons_454545_256x240.png); }
.ui-state-highlight .ui-icon {background-image: url(/images/ui-icons_2e83ff_256x240.png); }
.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(/images/ui-icons_cd0a0a_256x240.png); }
/* positioning */
.ui-icon-carat-1-n { background-position: 0 0; }
@@ -291,8 +291,8 @@
.ui-corner-all { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; }
/* Overlays */
.ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); }
.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/*
.ui-widget-overlay { background: #aaaaaa url(/images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); }
.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(/images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/*
* jQuery UI Resizable @VERSION
*
* Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)