Merge branch 'master' of github.com:shish/shimmie2
This commit is contained in:
commit
153e3ca3db
66
ext/upload/bookmarklet.js
Normal file
66
ext/upload/bookmarklet.js
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/* 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.getElementById("stats").innerHTML.match("<li>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){
|
||||||
|
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{
|
||||||
|
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
|
||||||
|
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){
|
||||||
|
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*/
|
||||||
|
/*TODO: Make file size show on all themes (Only seems to show in lite/Danbooru themes.)*/
|
||||||
|
if(tag.search(/\bflash\b/)==-1){
|
||||||
|
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{
|
||||||
|
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.
|
||||||
|
if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("tags").value;}
|
||||||
|
var rtg=document.getElementById("stats").innerHTML.match("<li>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.
|
||||||
|
//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);}
|
||||||
|
}
|
@ -314,7 +314,7 @@ class Upload implements Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checks if user is admin > check if you want locked.
|
// 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']);
|
$locked = bool_escape($_GET['locked']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class UploadTheme extends Themelet {
|
|||||||
$("#hide'.$i.'").hide();
|
$("#hide'.$i.'").hide();
|
||||||
$("#hide'.$a.'").show();});';
|
$("#hide'.$a.'").show();});';
|
||||||
|
|
||||||
$upload_list .= "<div id='hide$i'><img id='wrapper$i' src='ext/upload/minus.png' />" .
|
$upload_list .= "<div id='hide$i'><img id='wrapper' src='ext/upload/minus.png' />" .
|
||||||
"<a href='#' onclick='$js'>".
|
"<a href='#' onclick='$js'>".
|
||||||
"<img src='ext/upload/plus.png'></a></div></td>";
|
"<img src='ext/upload/plus.png'></a></div></td>";
|
||||||
} else {
|
} else {
|
||||||
@ -51,7 +51,7 @@ class UploadTheme extends Themelet {
|
|||||||
"<img src='ext/upload/minus.png' /></a>";
|
"<img src='ext/upload/minus.png' /></a>";
|
||||||
|
|
||||||
if($a==$config->get_int('upload_count')){
|
if($a==$config->get_int('upload_count')){
|
||||||
$upload_list .="<img id='wrapper$i' src='ext/upload/plus.png' />";
|
$upload_list .="<img id='wrapper' src='ext/upload/plus.png' />";
|
||||||
}else{
|
}else{
|
||||||
$js1 = 'javascript:$(function() {
|
$js1 = 'javascript:$(function() {
|
||||||
$("#row'.$a.'").show();
|
$("#row'.$a.'").show();
|
||||||
@ -66,12 +66,12 @@ class UploadTheme extends Themelet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$js2 = 'javascript:$(function() {
|
$js2 = 'javascript:$(function() {
|
||||||
$("#url'.$i.'").show();
|
$("#url'.$i.'").hide();
|
||||||
$("#url'.$i.'").val("");
|
$("#url'.$i.'").val("");
|
||||||
$("#data'.$i.'").show(); });';
|
$("#data'.$i.'").show(); });';
|
||||||
|
|
||||||
$upload_list .=
|
$upload_list .=
|
||||||
"<td width='60'><input id='radio_button_a$i' type='radio' name='method' value='file' checked='checked' onclick='$js2' /> File<br>";
|
"<form><td width='60'><input id='radio_button_a$i' type='radio' name='method' value='file' checked='checked' onclick='$js2' /> File<br>";
|
||||||
|
|
||||||
if($tl_enabled) {
|
if($tl_enabled) {
|
||||||
$js = 'javascript:$(function() {
|
$js = 'javascript:$(function() {
|
||||||
@ -80,7 +80,7 @@ class UploadTheme extends Themelet {
|
|||||||
$("#url'.$i.'").show(); });';
|
$("#url'.$i.'").show(); });';
|
||||||
|
|
||||||
$upload_list .=
|
$upload_list .=
|
||||||
"<input id='radio_button_b$i' type='radio' name='method' value='url' onclick='$js' /> URL</ br></td>
|
"<input id='radio_button_b$i' type='radio' name='method' value='url' onclick='$js' /> URL</ br></td></form>
|
||||||
<td>
|
<td>
|
||||||
<input id='data$i' name='data$i' class='wid' type='file'>
|
<input id='data$i' name='data$i' class='wid' type='file'>
|
||||||
<input id='url$i' name='url$i' class='wid' type='text' style='display:none'>
|
<input id='url$i' name='url$i' class='wid' type='text' style='display:none'>
|
||||||
@ -140,34 +140,21 @@ class UploadTheme extends Themelet {
|
|||||||
$html .= '<p><a href=\''.$js.'\'>Upload to '.$title.'</a> (Drag & drop onto your bookmarks toolbar, then click when looking at an image)';
|
$html .= '<p><a href=\''.$js.'\'>Upload to '.$title.'</a> (Drag & drop onto your bookmarks toolbar, then click when looking at an image)';
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
/* Danbooru > Shimmie Bookmarklet.
|
/* Imageboard > 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.
|
This is more or less, an upgraded version of the "Danbooru>Shimmie" bookmarklet.
|
||||||
Most likely this will stop working when Danbooru updates to v2, all depends if they switch the ids or not >_>.
|
At the moment this works with Shimmie & Danbooru.
|
||||||
Clicking the link on a danbooru image page should give you something along the lines of:
|
It would also work with Gelbooru but unless someone can figure out how to bypass their hotlinking..meh.
|
||||||
'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/"'
|
The bookmarklet is now also loaded via the .js file in this folder.
|
||||||
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?)
|
|
||||||
*/
|
*/
|
||||||
$title = "Danbooru to " . $config->get_string('title');
|
//Bookmarklet checks if shimmie supports ext. If not, won't upload to site/shows alert saying not supported.
|
||||||
$html .= '<p><a href="javascript:'.
|
$supported_ext = "jpg jpeg gif png";
|
||||||
/* This should stop the bookmarklet being insanely long...not that it's already huge or anything. */
|
if(file_exists("ext/handle_flash")){$supported_ext .= " swf";}
|
||||||
'var ste="'. $link . $delimiter .'url=";var tag=document.getElementById("post_tags").value;var rtg=document.documentElement.innerHTML.match("<li>Rating: (.*)<\/li>");var srx="http://" + document.location.hostname+document.location.href.match("\/post\/show\/.*\/");' .
|
if(file_exists("ext/handle_ico")){$supported_ext .= " ico ani cur";}
|
||||||
//The default confirm sucks, mainly due to being unable to change the text in the Ok/Cancel box (Yes/No would be better.)
|
if(file_exists("ext/handle_mp3")){$supported_ext .= " mp3";}
|
||||||
'if (confirm("OK = Use Current tags.\nCancel = Use new tags.")==true){' . //Just incase some people don't want the insane amount of tags danbooru has.
|
if(file_exists("ext/handle_svg")){$supported_ext .= " svg";}
|
||||||
//The flash check is kind of picky, although it should work on "most" images..there will be either some old or extremely new ones that lack the flash tag.
|
$title = "Booru to " . $config->get_string('title');
|
||||||
'if(tag.search(/\bflash\b/)==-1){'.
|
$html .= '<p><a href="javascript:var ste="'. $link . $delimiter .'url="; var supext="'.$supported_ext.'"; var maxsze="'.$max_kb.'"; void(document.body.appendChild(document.createElement("script")).src="'.make_http(make_link("ext/upload/bookmarklet.js")).'")">'.
|
||||||
'location.href=ste+document.getElementById("highres").href+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;}'.
|
$title . '</a> (Click when looking at an image page. Works on sites running Shimmie/Danbooru/Gelbooru. (This also grabs the tags/rating/source!))';
|
||||||
'else{'.
|
|
||||||
'location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;}'.
|
|
||||||
//The following is more or less the same as above, instead using the tags on danbooru, should load a prompt box instead.
|
|
||||||
'}else{'.
|
|
||||||
'var p=prompt("Enter Tags","");'.
|
|
||||||
'if(tag.search(/\bflash\b/)==-1){'.
|
|
||||||
'location.href=ste+document.getElementById("highres").href+"&tags="+p+"&rating="+rtg[1]+"&source="+srx;}' .
|
|
||||||
'else{'.
|
|
||||||
'location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+p+"&rating="+rtg[1]+"&source="+srx;}'.
|
|
||||||
'}">' .
|
|
||||||
$title . '</a> (As above, Click on a Danbooru-run image page. (This also grabs the tags/rating/source!))';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
21
themes/lite/holidays/style_aprilfools.css
Normal file
21
themes/lite/holidays/style_aprilfools.css
Normal file
@ -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+?*/
|
||||||
|
}
|
@ -24,6 +24,33 @@ class Layout {
|
|||||||
$header_html .= "\t\t$line\n";
|
$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 = "<link rel='stylesheet' href='$data_href/themes/$theme_name/holidays/";
|
||||||
|
|
||||||
|
// April Fools
|
||||||
|
// Flips the entire page upside down!
|
||||||
|
// TODO: Make it possible for the user to turn this off!
|
||||||
|
if(date('d/m') == '01/04'){
|
||||||
|
$csssheet .= "style_aprilfools.css";
|
||||||
|
$holtag = "april_fools";
|
||||||
|
}
|
||||||
|
$csssheet .= "' type='text/css'>";
|
||||||
|
//Optional! Uses a random image with a size lower then 800x91 & using the holiday tag and sticks it at top of page like a banner.
|
||||||
|
/*$banner = "<div>";
|
||||||
|
if(file_exists("ext/random_image")){
|
||||||
|
$banner .= "<center><img src='$data_href/random_image/download/size<800x91+$holtag'></center>";
|
||||||
|
}
|
||||||
|
$banner .= "</div>";*/
|
||||||
|
}else{
|
||||||
|
$banner = "";
|
||||||
|
}
|
||||||
|
|
||||||
$menu = "<div class='menu'>
|
$menu = "<div class='menu'>
|
||||||
<script type='text/javascript' src='$data_href/themes/$theme_name/wz_tooltip.js'></script>
|
<script type='text/javascript' src='$data_href/themes/$theme_name/wz_tooltip.js'></script>
|
||||||
<a href='".make_link()."' onmouseover='Tip('Home', BGCOLOR, '#C3D2E0', FADEIN, 100)' onmouseout='UnTip()'><img src='$data_href/favicon.ico' style='position: relative; top: 3px;'></a>
|
<a href='".make_link()."' onmouseover='Tip('Home', BGCOLOR, '#C3D2E0', FADEIN, 100)' onmouseout='UnTip()'><img src='$data_href/favicon.ico' style='position: relative; top: 3px;'></a>
|
||||||
@ -153,6 +180,14 @@ class Layout {
|
|||||||
$main_block_html = "<div id='body'>$main_block_html</div>";
|
$main_block_html = "<div id='body'>$main_block_html</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is required for the holiday feature.
|
||||||
|
if(empty($csssheet)){
|
||||||
|
$csssheet = "";
|
||||||
|
}
|
||||||
|
if(empty($banner)){
|
||||||
|
$holiday = "";
|
||||||
|
}
|
||||||
|
|
||||||
print <<<EOD
|
print <<<EOD
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
<html>
|
<html>
|
||||||
@ -160,10 +195,12 @@ class Layout {
|
|||||||
<title>{$page->title}</title>
|
<title>{$page->title}</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
<link rel="stylesheet" href="$data_href/themes/$theme_name/style.css" type="text/css">
|
<link rel="stylesheet" href="$data_href/themes/$theme_name/style.css" type="text/css">
|
||||||
|
$csssheet
|
||||||
$header_html
|
$header_html
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
$banner
|
||||||
$menu
|
$menu
|
||||||
$custom_sublinks
|
$custom_sublinks
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user