From 5ac53ceb84451d2a1992eda4f5f45a6e23d9302c Mon Sep 17 00:00:00 2001 From: Daku Date: Tue, 17 Jan 2012 03:52:38 +0000 Subject: [PATCH 1/7] Small holiday feature for lite theme. Loads extra stylesheet on certain holidays. --- themes/lite/holidays/style_aprilfools.css | 21 +++++++++++++ themes/lite/layout.class.php | 37 +++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 themes/lite/holidays/style_aprilfools.css diff --git a/themes/lite/holidays/style_aprilfools.css b/themes/lite/holidays/style_aprilfools.css new file mode 100644 index 00000000..0f3f3080 --- /dev/null +++ b/themes/lite/holidays/style_aprilfools.css @@ -0,0 +1,21 @@ + /* + If you wish to play about with colors, the main two colors to replace are: + Main color: #CEDFF0 + Secondary color: #E3EFFA + */ + +BODY { + background: #F0F7FF; + font-family: sans-serif; + font-size: 14px; + margin: 0px; + /* It's a bit crazy but, april fools is supposed to be crazy. + This flips the entire page upside down. + TODO: Add a way for the user to disable this */ + + -webkit-transform: rotate(-180deg); /*Safari*/ + -moz-transform: rotate(-180deg); /*Firefox*/ + -o-transform: rotate(-180deg); /*Opera*/ + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2); /*IE6*/ + ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=2)"; /*IE7+?*/ +} diff --git a/themes/lite/layout.class.php b/themes/lite/layout.class.php index 00fd54c9..363f466b 100644 --- a/themes/lite/layout.class.php +++ b/themes/lite/layout.class.php @@ -24,6 +24,33 @@ class Layout { $header_html .= "\t\t$line\n"; } + /* Holiday Stuff! + If the current day is one of the set holidays, it will use a seperate stylesheet. Aswell as a few extra things depending on the day. + This only adds April Fools for now. + TODO: Add setup block to make the whole holiday thing "optional". / Choose what holidays you wish to use. + */ + if(/*date('d/m') == '01/01' || date('d/m') == '14/02' || */date('d/m') == '01/04'/* || date('d/m') == '24/12' || date('d/m') == '25/12' || date('d/m') == '31/12'*/){ + + $csssheet = " @@ -153,6 +180,14 @@ class Layout { $main_block_html = "
$main_block_html
"; } + // This is required for the holiday feature. + if(empty($csssheet)){ + $csssheet = ""; + } + if(empty($banner)){ + $holiday = ""; + } + print << @@ -160,10 +195,12 @@ class Layout { {$page->title} + $csssheet $header_html + $banner $menu $custom_sublinks From 77597001609df7cf640e76ed7ee79edf38d39f47 Mon Sep 17 00:00:00 2001 From: Daku Date: Tue, 17 Jan 2012 03:58:28 +0000 Subject: [PATCH 2/7] fixes tag_edit__locked/locked errors --- ext/upload/main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/upload/main.php b/ext/upload/main.php index ebe48b69..2620ac34 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -314,7 +314,7 @@ class Upload implements Extension { } // Checks if user is admin > check if you want locked. - if($user->is_admin()){ + if($user->is_admin() && !empty($_GET['locked'])){ $locked = bool_escape($_GET['locked']); } From fcb8307f58d18e72960d315e2220cd1569625907 Mon Sep 17 00:00:00 2001 From: Daku Date: Tue, 17 Jan 2012 04:03:32 +0000 Subject: [PATCH 3/7] Booru bookmarklet now works with shimmie sites + is now loaded via .js script on the site. --- ext/upload/bookmarklet.js | 42 +++++++++++++++++++++++++++++++++++++++ ext/upload/theme.php | 35 ++++++++------------------------ 2 files changed, 50 insertions(+), 27 deletions(-) create mode 100644 ext/upload/bookmarklet.js diff --git a/ext/upload/bookmarklet.js b/ext/upload/bookmarklet.js new file mode 100644 index 00000000..b32b8009 --- /dev/null +++ b/ext/upload/bookmarklet.js @@ -0,0 +1,42 @@ +/* Imageboard to Shimmie */ +// This should work with "most" sites running Danbooru/Gelbooru/Shimmie +// Danbooru +if(document.getElementById("post_tags") !== null){ + var tag=document.getElementById("post_tags").value; + var rtg=document.documentElement.innerHTML.match("
  • Rating: (.*)<\/li>")[1]; + var srx="http://" + document.location.hostname + document.location.href.match("\/post\/show\/[0-9]+\/"); + if(tag.search(/\bflash\b/)==-1){ + location.href=ste+document.getElementById("highres").href+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx; + }else{ + location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx; + } +} +/* Shimmie +Shimmie doesn't seem to have any way to grab tags via id unless you have the ability to edit tags. +Have to go the round about way of checking the title for tags. +This crazy way of checking "should" work with older releases though (Seems to work with 2009~ ver) */ +else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.-]+\: ")==0){ + var tag=document.getElementsByTagName("title")[0].innerHTML.match("Image [0-9.-]+\: (.*)")[1]; + //TODO: Make rating show in statistics. + var srx="http://" + document.location.hostname + document.location.href.match("\/post\/view\/[0-9]+"); + /*TODO: Figure out regex for shortening file link. + I.E http://blah.net/_images/1234abcd/everysingletag.png > http://blah.net/_images/1234abcd.png + .match("WEBSITE.NET\/_images\/[A-Za-z0-9]+", "(\\.[a-z][a-z]+)")*/ + if(tag.search(/\bflash\b/)==-1){ + location.href=ste+document.getElementById("main_image").src+"&tags="+tag+"&source="+srx; + }else{ + location.href=ste+document.location.hostname+document.getElementsByName("movie")[0].value+"&tags="+tag+"&source="+srx; + } +}/* +// Gelbooru +else if(document.getElementById("tags") !== null){ + //Gelbooru has an annoying anti-hotlinking thing which doesn't seem to like the bookmarklet... + //So if someone can figure out how to bypass the hotlinking, please update the code :< + var ste="http://localhost/shimmie_trunk/upload?url="; + var tag=document.getElementById("tags").value; + var rtg=document.documentElement.innerHTML.match("
  • Rating: (.*)<\/li>")[1]; + var srx="http://" + document.location.hostname + document.location.href.match("\/index\.php\\?page=post&s=view&id=.*"); //Gelbooru has really ugly urls.. + var gmi=document.getElementById("image").src.match(".*img[0-9]+\.gelbooru\.com\/\/images\/[0-9]+\/[a-z0-9]+\.[a-z0-9]+")[0]; + //Since Gelbooru does not allow flash, no need to search for flash tag. + location.href=ste+gmi+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx'; +}*/ diff --git a/ext/upload/theme.php b/ext/upload/theme.php index 1b13bf9e..6f83a0b2 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -140,34 +140,15 @@ class UploadTheme extends Themelet { $html .= '

    Upload to '.$title.' (Drag & drop onto your bookmarks toolbar, then click when looking at an image)'; } { - /* Danbooru > Shimmie Bookmarklet. - This "should" work on any site running danbooru, unless for some odd reason they switched around the id's or aren't using post/list. - Most likely this will stop working when Danbooru updates to v2, all depends if they switch the ids or not >_>. - Clicking the link on a danbooru image page should give you something along the lines of: - 'http://www.website.com/shimmie/upload?url="http://sonohara.donmai.us/data/crazylongurl.jpg&tags="too many tags"&rating="s"&source="http://danbooru.donmai.us/post/show/012345/"' - TODO: Possibly make the entire/most of the script into a .js file, and just make the bookmarklet load it on click (Something like that?) + /* Imageboard > Shimmie Bookmarklet + This is more or less, an upgraded version of the "Danbooru>Shimmie" bookmarklet. + At the moment this works with Shimmie & Danbooru. + It would also work with Gelbooru but unless someone can figure out how to bypass their hotlinking..meh. + The bookmarklet is now also loaded via the .js file in this folder. */ - $title = "Danbooru to " . $config->get_string('title'); - $html .= '

    ' . - $title . ' (As above, Click on a Danbooru-run image page. (This also grabs the tags/rating/source!))'; - + $title = "Booru to " . $config->get_string('title'); + $html .= '

    '. + $title . ' (Click when looking at an image page. Works on sites running Shimmie or Danbooru. (This also grabs the tags/rating/source!))'; } } From 9f5465c0e5480b1a8904e13e5ebbd26b7c541540 Mon Sep 17 00:00:00 2001 From: Daku Date: Tue, 17 Jan 2012 04:28:45 +0000 Subject: [PATCH 4/7] Bookmarklet now asks if you want to use current/new tags again. --- ext/upload/bookmarklet.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ext/upload/bookmarklet.js b/ext/upload/bookmarklet.js index b32b8009..6cde44fa 100644 --- a/ext/upload/bookmarklet.js +++ b/ext/upload/bookmarklet.js @@ -1,8 +1,10 @@ /* Imageboard to Shimmie */ // This should work with "most" sites running Danbooru/Gelbooru/Shimmie + +if (confirm("OK = Use Current tags.\nCancel = Use new tags.")==true){}else{var tag=prompt("Enter Tags","");var chk=1;}; // Danbooru if(document.getElementById("post_tags") !== null){ - var tag=document.getElementById("post_tags").value; + if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("post_tags").value;} var rtg=document.documentElement.innerHTML.match("

  • Rating: (.*)<\/li>")[1]; var srx="http://" + document.location.hostname + document.location.href.match("\/post\/show\/[0-9]+\/"); if(tag.search(/\bflash\b/)==-1){ @@ -16,7 +18,7 @@ Shimmie doesn't seem to have any way to grab tags via id unless you have the abi Have to go the round about way of checking the title for tags. This crazy way of checking "should" work with older releases though (Seems to work with 2009~ ver) */ else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.-]+\: ")==0){ - var tag=document.getElementsByTagName("title")[0].innerHTML.match("Image [0-9.-]+\: (.*)")[1]; + if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementsByTagName("title")[0].innerHTML.match("Image [0-9.-]+\: (.*)")[1];} //TODO: Make rating show in statistics. var srx="http://" + document.location.hostname + document.location.href.match("\/post\/view\/[0-9]+"); /*TODO: Figure out regex for shortening file link. @@ -32,8 +34,7 @@ else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.- else if(document.getElementById("tags") !== null){ //Gelbooru has an annoying anti-hotlinking thing which doesn't seem to like the bookmarklet... //So if someone can figure out how to bypass the hotlinking, please update the code :< - var ste="http://localhost/shimmie_trunk/upload?url="; - var tag=document.getElementById("tags").value; + if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("tags").value;} var rtg=document.documentElement.innerHTML.match("
  • Rating: (.*)<\/li>")[1]; var srx="http://" + document.location.hostname + document.location.href.match("\/index\.php\\?page=post&s=view&id=.*"); //Gelbooru has really ugly urls.. var gmi=document.getElementById("image").src.match(".*img[0-9]+\.gelbooru\.com\/\/images\/[0-9]+\/[a-z0-9]+\.[a-z0-9]+")[0]; From 433197e1871e405fe71983ae1a0e541dc53e2181 Mon Sep 17 00:00:00 2001 From: Daku Date: Tue, 17 Jan 2012 04:57:14 +0000 Subject: [PATCH 5/7] Bookmarklet seems to work fine with Gelbooru now... --- ext/upload/bookmarklet.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/upload/bookmarklet.js b/ext/upload/bookmarklet.js index 6cde44fa..5ca4cca0 100644 --- a/ext/upload/bookmarklet.js +++ b/ext/upload/bookmarklet.js @@ -29,15 +29,15 @@ else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.- }else{ location.href=ste+document.location.hostname+document.getElementsByName("movie")[0].value+"&tags="+tag+"&source="+srx; } -}/* +} // Gelbooru else if(document.getElementById("tags") !== null){ //Gelbooru has an annoying anti-hotlinking thing which doesn't seem to like the bookmarklet... - //So if someone can figure out how to bypass the hotlinking, please update the code :< if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("tags").value;} var rtg=document.documentElement.innerHTML.match("
  • Rating: (.*)<\/li>")[1]; - var srx="http://" + document.location.hostname + document.location.href.match("\/index\.php\\?page=post&s=view&id=.*"); //Gelbooru has really ugly urls.. + //Can't seem to grab source due to url containing a & + //var srx="http://" + document.location.hostname + document.location.href.match("\/index\.php?page=post&s=view\\&id=.*"); var gmi=document.getElementById("image").src.match(".*img[0-9]+\.gelbooru\.com\/\/images\/[0-9]+\/[a-z0-9]+\.[a-z0-9]+")[0]; //Since Gelbooru does not allow flash, no need to search for flash tag. - location.href=ste+gmi+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx'; -}*/ + location.href=ste+gmi+"&tags="+tag+"&rating="+rtg[1];//+"&source="+srx; +} From a45c09b2b6967df5608926b8816e25c54e6aa96e Mon Sep 17 00:00:00 2001 From: Daku Date: Tue, 17 Jan 2012 07:57:58 +0000 Subject: [PATCH 6/7] Bookmarklet now checks if ext is supported/filesize is lower than limit before attempting to upload. --- ext/upload/bookmarklet.js | 45 +++++++++++++++++++++++++++++---------- ext/upload/theme.php | 10 +++++++-- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/ext/upload/bookmarklet.js b/ext/upload/bookmarklet.js index 5ca4cca0..05646134 100644 --- a/ext/upload/bookmarklet.js +++ b/ext/upload/bookmarklet.js @@ -1,16 +1,31 @@ /* Imageboard to Shimmie */ // This should work with "most" sites running Danbooru/Gelbooru/Shimmie +var maxsze = (maxsze.match("(?:\.*[0-9])")) * 1024; //This assumes we are only working with MB. +var toobig = "The file you are trying to upload is too big to upload!"; +var notsup = "The file you are trying to upload is not supported!"; + if (confirm("OK = Use Current tags.\nCancel = Use new tags.")==true){}else{var tag=prompt("Enter Tags","");var chk=1;}; + // Danbooru if(document.getElementById("post_tags") !== null){ if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("post_tags").value;} - var rtg=document.documentElement.innerHTML.match("
  • Rating: (.*)<\/li>")[1]; + var rtg=document.getElementById("stats").innerHTML.match("
  • Rating: (.*)<\/li>")[1]; var srx="http://" + document.location.hostname + document.location.href.match("\/post\/show\/[0-9]+\/"); + var filesze=document.getElementById("stats").innerHTML.match("[0-9] \\(((?:\.*[0-9])) ([a-zA-Z]+)"); + if(filesze[2] == "MB"){var filesze = filesze[1] * 1024;}else{var filesze = filesze[2].match("[0-9]+");} if(tag.search(/\bflash\b/)==-1){ - location.href=ste+document.getElementById("highres").href+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx; + if(supext.search(document.getElementById("highres").href.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){ + if(filesze <= maxsze){ + location.href=ste+document.getElementById("highres").href+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx; + }else{alert(toobig);} + }else{alert(notsup);} }else{ - location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx; + if(supext.search(document.getElementById("highres").href.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){ + if(filesze <= maxsze){ + location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx; + }else{alert(toobig);} + }else{alert(notsup);} } } /* Shimmie @@ -21,23 +36,31 @@ else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.- if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementsByTagName("title")[0].innerHTML.match("Image [0-9.-]+\: (.*)")[1];} //TODO: Make rating show in statistics. var srx="http://" + document.location.hostname + document.location.href.match("\/post\/view\/[0-9]+"); - /*TODO: Figure out regex for shortening file link. - I.E http://blah.net/_images/1234abcd/everysingletag.png > http://blah.net/_images/1234abcd.png - .match("WEBSITE.NET\/_images\/[A-Za-z0-9]+", "(\\.[a-z][a-z]+)")*/ + /*TODO: Figure out regex for shortening file link. I.E http://blah.net/_images/1234abcd/everysingletag.png > http://blah.net/_images/1234abcd.png*/ + /*TODO: Make file size show on all themes (Only seems to show in lite/Danbooru themes.)*/ if(tag.search(/\bflash\b/)==-1){ - location.href=ste+document.getElementById("main_image").src+"&tags="+tag+"&source="+srx; + var img = document.getElementById("main_image").src; + if(supext.search(img.match(".*\\.([a-z0-9]+)")[1]) !== -1){ + location.href=ste+img+"&tags="+tag+"&source="+srx; + }else{alert(notsup);} }else{ - location.href=ste+document.location.hostname+document.getElementsByName("movie")[0].value+"&tags="+tag+"&source="+srx; + var mov = document.location.hostname+document.getElementsByName("movie")[0].value; + if(supext.search(mov.match(".*\\.([a-z0-9]+)")[1]) !== -1){ + location.href=ste+mov+"&tags="+tag+"&source="+srx; + }else{alert(notsup);} } } // Gelbooru else if(document.getElementById("tags") !== null){ - //Gelbooru has an annoying anti-hotlinking thing which doesn't seem to like the bookmarklet... + //Gelbooru has an annoying anti-hotlinking thing which doesn't seem to like the bookmarklet. if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("tags").value;} - var rtg=document.documentElement.innerHTML.match("
  • Rating: (.*)<\/li>")[1]; + var rtg=document.getElementById("stats").innerHTML.match("
  • Rating: (.*)<\/li>")[1]; //Can't seem to grab source due to url containing a & //var srx="http://" + document.location.hostname + document.location.href.match("\/index\.php?page=post&s=view\\&id=.*"); var gmi=document.getElementById("image").src.match(".*img[0-9]+\.gelbooru\.com\/\/images\/[0-9]+\/[a-z0-9]+\.[a-z0-9]+")[0]; //Since Gelbooru does not allow flash, no need to search for flash tag. - location.href=ste+gmi+"&tags="+tag+"&rating="+rtg[1];//+"&source="+srx; + //Gelbooru doesn't show file size in statistics either... + if(supext.search(gmi.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){ + location.href=ste+gmi+"&tags="+tag+"&rating="+rtg[1];//+"&source="+srx; + }else{alert(notsup);} } diff --git a/ext/upload/theme.php b/ext/upload/theme.php index 6f83a0b2..ecdc64a5 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -146,9 +146,15 @@ class UploadTheme extends Themelet { It would also work with Gelbooru but unless someone can figure out how to bypass their hotlinking..meh. The bookmarklet is now also loaded via the .js file in this folder. */ + //Bookmarklet checks if shimmie supports ext. If not, won't upload to site/shows alert saying not supported. + $supported_ext = "jpg jpeg gif png"; + if(file_exists("ext/handle_flash")){$supported_ext .= " swf";} + if(file_exists("ext/handle_ico")){$supported_ext .= " ico ani cur";} + if(file_exists("ext/handle_mp3")){$supported_ext .= " mp3";} + if(file_exists("ext/handle_svg")){$supported_ext .= " svg";} $title = "Booru to " . $config->get_string('title'); - $html .= '

    '. - $title . ' (Click when looking at an image page. Works on sites running Shimmie or Danbooru. (This also grabs the tags/rating/source!))'; + $html .= '

    '. + $title . ' (Click when looking at an image page. Works on sites running Shimmie/Danbooru/Gelbooru. (This also grabs the tags/rating/source!))'; } } From a336944b11d1da0cf874e5b24ee42ebbf71e503f Mon Sep 17 00:00:00 2001 From: Daku Date: Tue, 17 Jan 2012 10:56:52 +0000 Subject: [PATCH 7/7] uploader fixes --- ext/upload/theme.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/upload/theme.php b/ext/upload/theme.php index ecdc64a5..fc6d5f59 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -34,7 +34,7 @@ class UploadTheme extends Themelet { $("#hide'.$i.'").hide(); $("#hide'.$a.'").show();});'; - $upload_list .= "

    " . + $upload_list .= "
    " . "". "
    "; } else { @@ -51,7 +51,7 @@ class UploadTheme extends Themelet { ""; if($a==$config->get_int('upload_count')){ - $upload_list .=""; + $upload_list .=""; }else{ $js1 = 'javascript:$(function() { $("#row'.$a.'").show(); @@ -66,12 +66,12 @@ class UploadTheme extends Themelet { } $js2 = 'javascript:$(function() { - $("#url'.$i.'").show(); + $("#url'.$i.'").hide(); $("#url'.$i.'").val(""); $("#data'.$i.'").show(); });'; $upload_list .= - " File
    "; + "
    File
    "; if($tl_enabled) { $js = 'javascript:$(function() { @@ -80,7 +80,7 @@ class UploadTheme extends Themelet { $("#url'.$i.'").show(); });'; $upload_list .= - " URL + " URL