From 6717639caa4f02369f442ea5549484229494a93a Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 15 Aug 2012 10:43:28 +0100 Subject: [PATCH 01/11] update readme to clarify ui-* and shm-* --- README.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.txt b/README.txt index b0b5e521..30e22af2 100644 --- a/README.txt +++ b/README.txt @@ -101,6 +101,12 @@ For a list of permissions, see core/userclass.class.php Development Info ~~~~~~~~~~~~~~~~ +ui-* cookies are for the client-side scripts only; in some configurations +(eg with varnish cache) they will be stripped before they reach the server + +shm-* CSS classes are for javascript to hook into; if you're customising +themes, be careful with these, and avoid styling them + http://shimmie.shishnet.org/doc/ Please tell me if those docs are lacking in any way, so that they can be From fd4e80175625dcdf51b98eb32eea36120ede5cd8 Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 15 Aug 2012 11:13:25 +0100 Subject: [PATCH 02/11] convert blotter to use ui-* and shm-* --- ext/blotter/script.js | 15 +++++++-------- ext/blotter/theme.php | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ext/blotter/script.js b/ext/blotter/script.js index 9527de26..e2f4f892 100644 --- a/ext/blotter/script.js +++ b/ext/blotter/script.js @@ -1,16 +1,15 @@ - $(document).ready(function() { - $("#blotter2-toggle").click(function() { - $("#blotter2").slideToggle("slow", function() { - if($("#blotter2").is(":hidden")) { - $.cookie("blotter2-hidden", 'true', {path: '/'}); + $(".shm-blotter2-toggle").click(function() { + $(".shm-blotter2").slideToggle("slow", function() { + if($(".shm-blotter2").is(":hidden")) { + $.cookie("ui-blotter2-hidden", 'true', {path: '/'}); } else { - $.cookie("blotter2-hidden", 'false', {path: '/'}); + $.cookie("ui-blotter2-hidden", 'false', {path: '/'}); } }); }); - if($.cookie("blotter2-hidden") == 'true') { - $("#blotter2").hide(); + if($.cookie("ui-blotter2-hidden") == 'true') { + $(".shm-blotter2").hide(); } }); diff --git a/ext/blotter/theme.php b/ext/blotter/theme.php index 29581c1d..3099eed4 100644 --- a/ext/blotter/theme.php +++ b/ext/blotter/theme.php @@ -161,8 +161,8 @@ class BlotterTheme extends Themelet { $in_text = ""; } $html = ""; - $html .= "
$out_text{$pos_break}Show/Hide Show All
"; - $html .= "
$in_text
"; + $html .= "
$out_text{$pos_break}Show/Hide Show All
"; + $html .= "
$in_text
"; return $html; } } From 61e9909327343c5c5f1e5bcc1b4a5fd61f30e9da Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 15 Aug 2012 18:31:28 +0100 Subject: [PATCH 03/11] hardcoded config too (unrelated) --- core/config.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/config.class.php b/core/config.class.php index 8fc7b4d9..4fdfc2b4 100644 --- a/core/config.class.php +++ b/core/config.class.php @@ -120,6 +120,20 @@ abstract class BaseConfig implements Config { } +/** + * For testing, mostly + */ +class HardcodeConfig extends BaseConfig { + public function __construct($dict) { + $this->values = $dict; + } + + public function save(/*string*/ $name=null) { + // static config is static + } +} + + /** * Loads the config list from a PHP file; the file should be in the format: * From f5d787efbfbf05dd367060b17054b707e64b0bf7 Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 15 Aug 2012 19:46:36 +0100 Subject: [PATCH 04/11] while we're here, fix the blotter in general... --- ext/blotter/main.php | 5 ++++- ext/blotter/theme.php | 39 ++++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/ext/blotter/main.php b/ext/blotter/main.php index 21c87d8c..f02e1461 100644 --- a/ext/blotter/main.php +++ b/ext/blotter/main.php @@ -43,6 +43,7 @@ class Blotter extends Extension { $config->set_default_string("blotter_position", "subheading"); } + public function onSetupBuilding(SetupBuildingEvent $event) { global $config; $sb = new SetupBlock("Blotter"); @@ -51,12 +52,14 @@ class Blotter extends Extension { $sb->add_choice_option("blotter_position", array("Top of page" => "subheading", "In navigation bar" => "left"), "
Position: "); $event->panel->add_block($sb); } + public function onUserBlockBuilding(UserBlockBuildingEvent $event) { global $user; if($user->is_admin()) { $event->add_link("Blotter Editor", make_link("blotter/editor")); } } + public function onPageRequest(PageRequestEvent $event) { global $page, $database, $user; if($event->page_matches("blotter")) { @@ -105,7 +108,7 @@ class Blotter extends Extension { $page->set_redirect(make_link("blotter/editor")); } break; - case "": + case "list": /** * Displays all blotter entries */ diff --git a/ext/blotter/theme.php b/ext/blotter/theme.php index 3099eed4..9fe9dd79 100644 --- a/ext/blotter/theme.php +++ b/ext/blotter/theme.php @@ -12,8 +12,9 @@ class BlotterTheme extends Themelet { public function display_blotter_page($entries) { global $page; $html = $this->get_html_for_blotter_page($entries); - $page->set_mode("data"); - $page->set_data($html); + $page->set_title("Blotter"); + $page->set_heading("Blotter"); + $page->add_block(new Block("Blotter Entries", $html, "main", 10)); } public function display_blotter($entries) { @@ -95,10 +96,8 @@ class BlotterTheme extends Themelet { * This one displays a list of all blotter entries. */ global $config; - $i_color = $config->get_string("blotter_color","#FF0000"); - $html = ""; - $html .= "Blotter -
";
+		$i_color = $config->get_string("blotter_color", "#FF0000");
+		$html = "
";
 
 		$num_entries = count($entries);
 		for ($i = 0 ; $i < $num_entries ; $i++) {
@@ -110,13 +109,15 @@ class BlotterTheme extends Themelet {
 			$i_close = "";
 			$id = $entries[$i]['id'];
 			$messy_date = $entries[$i]['entry_date'];
-			$clean_date = date("m/d/y",strtotime($messy_date));
+			$clean_date = date("y/m/d", strtotime($messy_date));
 			$entry_text = $entries[$i]['entry_text'];
-			if($entries[$i]['important'] == 'Y') { $i_open = ""; $i_close=""; }
+			if($entries[$i]['important'] == 'Y') {
+				$i_open = "";
+				$i_close="";
+			}
 			$html .= "{$i_open}{$clean_date} - {$entry_text}{$i_close}

"; } - - $html .= "
"; + $html .= "
"; return $html; } @@ -143,14 +144,17 @@ class BlotterTheme extends Themelet { } $entries_list .= "
  • {$i_open}{$clean_date} - {$entry_text}{$i_close}
  • "; } + $out_text = ""; $in_text = ""; $pos_break = ""; $pos_align = "text-align: right; position: absolute; right: 0px;"; + if($position === "left") { $pos_break = "
    "; $pos_align = ""; } + if(count($entries) === 0) { $out_text = "No blotter entries yet."; $in_text = "Empty."; @@ -160,9 +164,18 @@ class BlotterTheme extends Themelet { $out_text = "Blotter updated: {$clean_date}"; $in_text = "
      $entries_list
    "; } - $html = ""; - $html .= "
    $out_text{$pos_break}Show/Hide Show All
    "; - $html .= "
    $in_text
    "; + + $html = " +
    + $out_text + {$pos_break} + + Show/Hide + Show All + +
    +
    $in_text
    + "; return $html; } } From 4470d937a448bbcca8b2cba10a7a5fa64e722e9a Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 15 Aug 2012 19:46:51 +0100 Subject: [PATCH 05/11] handle_pixel -> shm-* --- ext/handle_pixel/main.php | 2 +- ext/handle_pixel/script.js | 8 ++++---- ext/handle_pixel/theme.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php index cd82160f..9546699a 100644 --- a/ext/handle_pixel/main.php +++ b/ext/handle_pixel/main.php @@ -73,7 +73,7 @@ class PixelFileHandler extends DataHandlerExtension { public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) { $event->add_part("
    - diff --git a/ext/handle_pixel/script.js b/ext/handle_pixel/script.js index c95bc3e0..aa83fa16 100644 --- a/ext/handle_pixel/script.js +++ b/ext/handle_pixel/script.js @@ -1,9 +1,9 @@ $(function() { - $("#zoomer").change(function(e) { + $(".shm-zoomer").change(function(e) { zoom(this.options[this.selectedIndex].value); }); - $("#main_image").click(function(e) { + $(".shm-main-image").click(function(e) { switch($.cookie("ui-image-zoom")) { case "full": zoom("width"); break; default: zoom("full"); break; @@ -16,7 +16,7 @@ $(function() { }); function zoom(zoom) { - var img = $('#main_image'); + var img = $('.shm-main-image'); if(zoom == "full") { img.css('max-width', img.data('width') + 'px'); img.css('max-height', img.data('height') + 'px'); @@ -34,7 +34,7 @@ function zoom(zoom) { img.css('max-height', (window.innerHeight * 0.95) + 'px'); } - $("#zoomer").val(zoom); + $(".shm-zoomer").val(zoom); $.cookie("ui-image-zoom", zoom, {path: '/', expires: 365}); } diff --git a/ext/handle_pixel/theme.php b/ext/handle_pixel/theme.php index 03e6c99f..4099e97f 100644 --- a/ext/handle_pixel/theme.php +++ b/ext/handle_pixel/theme.php @@ -23,7 +23,7 @@ class PixelFileHandlerTheme extends Themelet { } } - $html = "main image"; + $html = "main image"; $page->add_block(new Block("Image", $html, "main", 10)); } } From d6f15527e29b771684d001c1aa6c96f2b561433b Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 15 Aug 2012 20:08:16 +0100 Subject: [PATCH 06/11] playing with eclipse... --- .buildpath | 5 +++++ .project | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .buildpath create mode 100644 .project diff --git a/.buildpath b/.buildpath new file mode 100644 index 00000000..8bcb4b5f --- /dev/null +++ b/.buildpath @@ -0,0 +1,5 @@ + + + + + diff --git a/.project b/.project new file mode 100644 index 00000000..092bd500 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + Shimmie 2 + + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.dltk.core.scriptbuilder + + + + + + org.eclipse.php.core.PHPNature + + + From ec16baecfeced2b298ea6f3009677928abbe948c Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 15 Aug 2012 20:20:26 +0100 Subject: [PATCH 07/11] make some over-eager CSS more controlled --- lib/shimmie.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/shimmie.css b/lib/shimmie.css index 411ed805..958e8dd9 100644 --- a/lib/shimmie.css +++ b/lib/shimmie.css @@ -44,7 +44,7 @@ IMG.lazy {display: none;} #installer A:hover { text-decoration: underline; } -#installer H1, H3 { +#installer H1, #installer H3 { background: #DDD; text-align: center; margin: 0px; From 8c39c295288d95f8209a74417da10751ce207f26 Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 15 Aug 2012 20:22:25 +0100 Subject: [PATCH 08/11] make tag hiding a little more consistent --- ext/index/script.js | 11 +++-------- ext/index/theme.php | 3 ++- themes/danbooru/index.theme.php | 3 ++- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ext/index/script.js b/ext/index/script.js index 6c3078c0..c220d53b 100644 --- a/ext/index/script.js +++ b/ext/index/script.js @@ -1,5 +1,5 @@ $(function() { - var blocked_tags = ($.cookie("ui-blocked-tags") || $.cookie("blocked-tags") || "").split(" "); + var blocked_tags = ($.cookie("ui-blocked-tags") || "").split(" "); var themecheck = $(".thumb[data-tags]").parent().attr('class'); var needs_refresh = false; for(i=0; ibuild_thumb_html($image, $query); } + $table .= ""; return $table; } } diff --git a/themes/danbooru/index.theme.php b/themes/danbooru/index.theme.php index eb8d424a..79e02e6a 100644 --- a/themes/danbooru/index.theme.php +++ b/themes/danbooru/index.theme.php @@ -49,10 +49,11 @@ class CustomIndexTheme extends IndexTheme { } protected function build_table($images, $query) { - $table = ""; + $table = "
    "; foreach($images as $image) { $table .= "\t" . $this->build_thumb_html($image, $query) . "\n"; } + $table .= "
    "; return $table; } } From 6394cd8100927da255ff9d64cb4b53e4c5cbdad3 Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 15 Aug 2012 20:42:56 +0100 Subject: [PATCH 09/11] make shm-thumb use consistent across themes, with data-tags and data-post-id --- README.txt | 4 ++++ core/basethemelet.class.php | 6 +++--- ext/index/script.js | 8 +------- ext/mass_tagger/script.js | 32 ++++-------------------------- themes/danbooru/themelet.class.php | 4 +++- themes/futaba/themelet.class.php | 4 +++- themes/lite/themelet.class.php | 4 ++-- 7 files changed, 20 insertions(+), 42 deletions(-) diff --git a/README.txt b/README.txt index 30e22af2..f25c4e40 100644 --- a/README.txt +++ b/README.txt @@ -107,6 +107,10 @@ ui-* cookies are for the client-side scripts only; in some configurations shm-* CSS classes are for javascript to hook into; if you're customising themes, be careful with these, and avoid styling them +- shm-thumb = outermost element of a thumbnail + - data-tags + - data-post-id + http://shimmie.shishnet.org/doc/ Please tell me if those docs are lacking in any way, so that they can be diff --git a/core/basethemelet.class.php b/core/basethemelet.class.php index ef9b3a42..70e01ab1 100644 --- a/core/basethemelet.class.php +++ b/core/basethemelet.class.php @@ -54,9 +54,9 @@ class BaseThemelet { $tsize = get_thumbnail_size($image->width, $image->height); } - return ''. - ''.$h_tip.''. - ''. + return "". + "$h_tip". + "". "\n"; } diff --git a/ext/index/script.js b/ext/index/script.js index c220d53b..4a3663bf 100644 --- a/ext/index/script.js +++ b/ext/index/script.js @@ -1,16 +1,10 @@ $(function() { var blocked_tags = ($.cookie("ui-blocked-tags") || "").split(" "); - var themecheck = $(".thumb[data-tags]").parent().attr('class'); var needs_refresh = false; for(i=0; i'); img.attr( "src", image_link+'/ext/mass_tagger/toggle.gif' ); diff --git a/themes/danbooru/themelet.class.php b/themes/danbooru/themelet.class.php index 7880429f..6ef57ee8 100644 --- a/themes/danbooru/themelet.class.php +++ b/themes/danbooru/themelet.class.php @@ -5,6 +5,8 @@ class Themelet extends BaseThemelet { $h_view_link = make_link("post/view/{$image->id}", $query); $h_thumb_link = $image->get_thumb_link(); $h_tip = html_escape($image->get_tooltip()); + $i_id = int_escape($image->id); + $h_tags = strtolower($image->get_tag_list()); // If file is flash or svg then sets thumbnail to max size. if($image->ext == 'swf' || $image->ext == 'svg') { @@ -14,7 +16,7 @@ class Themelet extends BaseThemelet { $tsize = get_thumbnail_size($image->width, $image->height); } - return "$h_tip$h_tip"; } diff --git a/themes/futaba/themelet.class.php b/themes/futaba/themelet.class.php index 7d4955e6..cfff9d50 100644 --- a/themes/futaba/themelet.class.php +++ b/themes/futaba/themelet.class.php @@ -9,6 +9,8 @@ class Themelet extends BaseThemelet { $h_view_link = make_link("post/view/{$image->id}", $query); $h_thumb_link = $image->get_thumb_link(); $h_tip = html_escape($image->get_tooltip()); + $i_id = int_escape($image->id); + $h_tags = strtolower($image->get_tag_list()); // If file is flash or svg then sets thumbnail to max size. if($image->ext == 'swf' || $image->ext == 'svg') { @@ -18,7 +20,7 @@ class Themelet extends BaseThemelet { $tsize = get_thumbnail_size($image->width, $image->height); } - return "$h_tip$h_tip"; } diff --git a/themes/lite/themelet.class.php b/themes/lite/themelet.class.php index 3633860b..c61c9e4a 100644 --- a/themes/lite/themelet.class.php +++ b/themes/lite/themelet.class.php @@ -21,8 +21,8 @@ class Themelet extends BaseThemelet { $tsize = get_thumbnail_size($image->width, $image->height); } - return '
    '. - ''. + return '
    \n"; From 887c746e3562be0b7d46dcadd3aec9616e9567bd Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 15 Aug 2012 21:05:08 +0100 Subject: [PATCH 10/11] mass tagger -> shm-*, specify what data tags shm-thumb has, now it works with all themes --- ext/mass_tagger/main.php | 2 - ext/mass_tagger/script.js | 79 ++++++++++++++------------------------- ext/mass_tagger/style.css | 8 ---- ext/mass_tagger/theme.php | 2 +- 4 files changed, 29 insertions(+), 62 deletions(-) delete mode 100644 ext/mass_tagger/style.css diff --git a/ext/mass_tagger/main.php b/ext/mass_tagger/main.php index ff3d91d7..7170dae8 100644 --- a/ext/mass_tagger/main.php +++ b/ext/mass_tagger/main.php @@ -10,8 +10,6 @@ * add buttons to each image to mark them for tagging, and a field for * inputting tags will appear. Once the "Tag" button is clicked, the tags in * the text field will be added to marked images. - * - * As of now only compatible with the lite theme. */ class MassTagger extends Extension { diff --git a/ext/mass_tagger/script.js b/ext/mass_tagger/script.js index 6b8ae791..1cc4077c 100644 --- a/ext/mass_tagger/script.js +++ b/ext/mass_tagger/script.js @@ -1,57 +1,34 @@ +function activate_mass_tagger ( image_link ) { + $(".shm-thumb").each( + function ( index, block ) { + add_mass_tag_button( $(block), image_link ); + } + ); + $('#mass_tagger_controls').show(); + $('#mass_tagger_activate').hide(); +} + +function add_mass_tag_button($block, image_link) { + + var c = function() { toggle_tag(this, $block.data("post-id")); return false; }; + + $block.find("A").click(c); + $block.click(c); // sometimes the thumbs *is* the A +} + function toggle_tag( button, id ) { id += ":"; var list = $('#mass_tagger_ids'); var string = list.val(); - if( string.indexOf( id ) > -1 ) return remove_mass_tag_id( button, list, id, string ); - - return add_mass_tag_id( button, list, id, string ); -} - -function add_mass_tag_id( button, list, id, string ) { - $(button).attr( 'style', 'display:block;border: 3px solid blue;' ); - string += id; - list.val( string ); - return false; -} - -function remove_mass_tag_id( button, list, id, string ) { - $(button).attr( 'style', '' ); - string = string.replace( id, '' ); - list.val( string ); - return false; -} - -function activate_mass_tagger ( image_link ) { - $(".shm-thumb").each( - function ( index, block ) { - add_mass_tag_button( block, image_link ); - } - ); - $('#mass_tagger_controls').show(); - $('#mass_tagger_activate').hide(); - return false; -} - -function add_mass_tag_button ( block, image_link ) { - var id = $(block).data("post-id"); - - var button = create_mass_tag_button( id, image_link ); - $(block).append( button ); - - return; -} - -function create_mass_tag_button ( id, image_link ) { - var img = $(''); - img.attr( "src", image_link+'/ext/mass_tagger/toggle.gif' ); - - var link = $(''); - link.attr("class",'zoom'); - link.attr("onclick",'return toggle_tag( this, "'+id+'")'); - link.attr("href",'#'); - - link.append( img ); - - return link; + if( string.indexOf( id ) > -1 ) { + $(button).css('border', 'none'); + string = string.replace(id, ''); + list.val(string); + } + else { + $(button).css('border', '3px solid blue'); + string += id; + list.val(string); + } } diff --git a/ext/mass_tagger/style.css b/ext/mass_tagger/style.css deleted file mode 100644 index 13467ae1..00000000 --- a/ext/mass_tagger/style.css +++ /dev/null @@ -1,8 +0,0 @@ - -.zoom{ position:absolute;display:none;margin:-110px 27px; } -.thumbblock:hover .zoom{ display:block; } -.zoom:hover{ border: 3px solid blue; } -/*.zoom img:hover{ background:url(/contrib/simpletest/data/pbx_screenshot.jpg) no-repeat;}*/ - -.zoom img { width: 100px; height: 100px; } -#mass_tagger_controls { display:none; } diff --git a/ext/mass_tagger/theme.php b/ext/mass_tagger/theme.php index 28197b3e..0f0b009e 100644 --- a/ext/mass_tagger/theme.php +++ b/ext/mass_tagger/theme.php @@ -9,7 +9,7 @@ class MassTaggerTheme extends Themelet { $body = " -
    +