Merge branch 'master' of git@github.com:shish/shimmie2
This commit is contained in:
commit
0c96603861
@ -33,11 +33,35 @@ class AdminPageTheme extends Themelet {
|
|||||||
";
|
";
|
||||||
$page->add_block(new Block("Misc Admin Tools", $html));
|
$page->add_block(new Block("Misc Admin Tools", $html));
|
||||||
|
|
||||||
|
/* First check
|
||||||
|
Requires you to click the checkbox to enable the delete by query form */
|
||||||
|
$dbqcheck = "
|
||||||
|
if(document.getElementById("dbqcheck").checked == false){
|
||||||
|
document.getElementById("dbqtags").disabled = true;
|
||||||
|
document.getElementById("dbqsubmit").disabled = true;
|
||||||
|
}else{
|
||||||
|
document.getElementById("dbqtags").disabled = false;
|
||||||
|
document.getElementById("dbqsubmit").disabled = false;
|
||||||
|
}";
|
||||||
|
|
||||||
|
/* Second check
|
||||||
|
Requires you to confirm the deletion by clicking ok. */
|
||||||
$html = "
|
$html = "
|
||||||
".make_form(make_link("admin_utils"))."
|
<script type='text/javascript'>
|
||||||
|
function checkform(){
|
||||||
|
if(confirm('Are you sure you wish to delete all images using these tags?')){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>"
|
||||||
|
|
||||||
|
.make_form(make_link("admin_utils"),"post",false,false,"return checkform()")."
|
||||||
|
<input type='checkbox' id='dbqcheck' name='action' onclick='$dbqcheck'>
|
||||||
<input type='hidden' name='action' value='delete by query'>
|
<input type='hidden' name='action' value='delete by query'>
|
||||||
<input type='text' name='query'>
|
<input type='text' id='dbqtags' disabled='true' name='query'>
|
||||||
<input type='submit' value='Go'>
|
<input type='submit' id='dbqsubmit' disabled='true' value='Go'>
|
||||||
</form>
|
</form>
|
||||||
";
|
";
|
||||||
$page->add_block(new Block("Delete by Query", $html));
|
$page->add_block(new Block("Delete by Query", $html));
|
||||||
|
@ -47,7 +47,7 @@ EOD
|
|||||||
$counter_html
|
$counter_html
|
||||||
<div class='space' id='foot'>
|
<div class='space' id='foot'>
|
||||||
<small><small>
|
<small><small>
|
||||||
<a href='$contact_link'>Contact</a> – Serving $num_comma posts –
|
<a href='mailto:$contact_link'>Contact</a> – Serving $num_comma posts –
|
||||||
Running <a href='http://code.shishnet.org/shimmie2/'>Shimmie</a>
|
Running <a href='http://code.shishnet.org/shimmie2/'>Shimmie</a>
|
||||||
</small></small>
|
</small></small>
|
||||||
</div>
|
</div>
|
||||||
|
@ -75,6 +75,7 @@ class MySQL extends DBEngine {
|
|||||||
$data = str_replace("SCORE_DATETIME", "DATETIME", $data);
|
$data = str_replace("SCORE_DATETIME", "DATETIME", $data);
|
||||||
$data = str_replace("SCORE_NOW", "\"1970-01-01\"", $data);
|
$data = str_replace("SCORE_NOW", "\"1970-01-01\"", $data);
|
||||||
$data = str_replace("SCORE_STRNORM", "", $data);
|
$data = str_replace("SCORE_STRNORM", "", $data);
|
||||||
|
$data = str_replace("SCORE_ILIKE", "LIKE", $data);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +97,7 @@ class PostgreSQL extends DBEngine {
|
|||||||
$data = str_replace("SCORE_DATETIME", "TIMESTAMP", $data);
|
$data = str_replace("SCORE_DATETIME", "TIMESTAMP", $data);
|
||||||
$data = str_replace("SCORE_NOW", "current_time", $data);
|
$data = str_replace("SCORE_NOW", "current_time", $data);
|
||||||
$data = str_replace("SCORE_STRNORM", "lower", $data);
|
$data = str_replace("SCORE_STRNORM", "lower", $data);
|
||||||
|
$data = str_replace("SCORE_ILIKE", "ILIKE", $data);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,6 +144,7 @@ class SQLite extends DBEngine {
|
|||||||
$data = str_replace("SCORE_BOOL", "CHAR(1)", $data);
|
$data = str_replace("SCORE_BOOL", "CHAR(1)", $data);
|
||||||
$data = str_replace("SCORE_NOW", "\"1970-01-01\"", $data);
|
$data = str_replace("SCORE_NOW", "\"1970-01-01\"", $data);
|
||||||
$data = str_replace("SCORE_STRNORM", "", $data);
|
$data = str_replace("SCORE_STRNORM", "", $data);
|
||||||
|
$data = str_replace("SCORE_ILIKE", "LIKE", $data);
|
||||||
$cols = array();
|
$cols = array();
|
||||||
$extras = "";
|
$extras = "";
|
||||||
foreach(explode(",", $data) as $bit) {
|
foreach(explode(",", $data) as $bit) {
|
||||||
|
@ -129,34 +129,9 @@ function to_shorthand_int($int) {
|
|||||||
* @retval string
|
* @retval string
|
||||||
*/
|
*/
|
||||||
function autodate($date, $html=true) {
|
function autodate($date, $html=true) {
|
||||||
global $config;
|
$cpu = date('c', strtotime($date));
|
||||||
|
$hum = date('F j, Y', strtotime($date));
|
||||||
$format = $config->get_string('autodate_format', "F j, Y");
|
return ($html ? "<time datetime='$cpu'>$hum</time>" : $hum);
|
||||||
$seconds = time() - strtotime($date);
|
|
||||||
$ago = seconds_to_time($seconds) . " ago";
|
|
||||||
$on = "on " . date($format, strtotime($date));
|
|
||||||
|
|
||||||
if($config->get_bool('use_autodate', true)) {
|
|
||||||
return ($html ? "<span title='$on'>$ago</span>" : $ago);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return $on;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turn a number of seconds into a vague human timespan, eg 142 -> "2 minutes"
|
|
||||||
*
|
|
||||||
* @retval string
|
|
||||||
*/
|
|
||||||
function seconds_to_time($seconds) {
|
|
||||||
if($seconds<60) return $seconds . " second" . plural($seconds); $seconds = round($seconds/60);
|
|
||||||
if($seconds<60) return $seconds . " minute" . plural($seconds); $seconds = round($seconds/60);
|
|
||||||
if($seconds<24) return $seconds . " hour" . plural($seconds); $seconds = round($seconds/24);
|
|
||||||
if($seconds<7) return $seconds . " day" . plural($seconds); $seconds = round($seconds/7);
|
|
||||||
if($seconds<4) return $seconds . " week" . plural($seconds); $seconds = round($seconds/4);
|
|
||||||
if($seconds<12) return $seconds . " month" . plural($seconds); $seconds = round($seconds/12);
|
|
||||||
return $seconds . " year" . plural($seconds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -279,13 +254,16 @@ function make_http($link) {
|
|||||||
*
|
*
|
||||||
* @retval string
|
* @retval string
|
||||||
*/
|
*/
|
||||||
function make_form($target, $method="POST", $multipart=False, $form_id="") {
|
function make_form($target, $method="POST", $multipart=False, $form_id="", $onsubmit="") {
|
||||||
global $user;
|
global $user;
|
||||||
$auth = $user->get_auth_html();
|
$auth = $user->get_auth_html();
|
||||||
$extra = empty($form_id) ? '' : " id='$form_id'";
|
$extra = empty($form_id) ? '' : " id='$form_id'";
|
||||||
if($multipart) {
|
if($multipart) {
|
||||||
$extra .= " enctype='multipart/form-data'";
|
$extra .= " enctype='multipart/form-data'";
|
||||||
}
|
}
|
||||||
|
if($onsubmit) {
|
||||||
|
$extra .= " onsubmit='$onsubmit'";
|
||||||
|
}
|
||||||
return "<form action='$target' method='$method'$extra>$auth";
|
return "<form action='$target' method='$method'$extra>$auth";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,6 +179,7 @@ class CommentListTheme extends Themelet {
|
|||||||
return "
|
return "
|
||||||
<a name='$i_comment_id'></a>
|
<a name='$i_comment_id'></a>
|
||||||
<div class='$oe comment'>
|
<div class='$oe comment'>
|
||||||
|
<!--<span class='timeago' style='float: right;'>$h_timestamp</span>-->
|
||||||
$h_userlink: $h_comment
|
$h_userlink: $h_comment
|
||||||
$h_dellink
|
$h_dellink
|
||||||
</div>
|
</div>
|
||||||
|
@ -169,10 +169,8 @@ class Setup extends SimpleExtension {
|
|||||||
$config->set_default_string("main_page", "post/list");
|
$config->set_default_string("main_page", "post/list");
|
||||||
$config->set_default_string("base_href", "./index.php?q=");
|
$config->set_default_string("base_href", "./index.php?q=");
|
||||||
$config->set_default_string("theme", "default");
|
$config->set_default_string("theme", "default");
|
||||||
$config->set_default_bool("use_autodate", true);
|
|
||||||
$config->set_default_bool("word_wrap", true);
|
$config->set_default_bool("word_wrap", true);
|
||||||
$config->set_default_bool("comment_captcha", false);
|
$config->set_default_bool("comment_captcha", false);
|
||||||
$config->set_default_string("autodate_format", "F j, Y");
|
|
||||||
// Automatic caching is disabled by default
|
// Automatic caching is disabled by default
|
||||||
$config->set_default_string("autocache_location", "data/cache");
|
$config->set_default_string("autocache_location", "data/cache");
|
||||||
$config->set_default_bool("autocache_css", false);
|
$config->set_default_bool("autocache_css", false);
|
||||||
|
@ -141,7 +141,7 @@ class TagList implements Extension {
|
|||||||
|
|
||||||
$tag_data = $database->get_col("
|
$tag_data = $database->get_col("
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
substr(tag, 1, 1)
|
SCORE_STRNORM(substr(tag, 1, 1))
|
||||||
FROM tags
|
FROM tags
|
||||||
WHERE count >= :tags_min
|
WHERE count >= :tags_min
|
||||||
ORDER BY substr(tag, 1, 1)
|
ORDER BY substr(tag, 1, 1)
|
||||||
@ -184,7 +184,7 @@ class TagList implements Extension {
|
|||||||
FLOOR(LOG(2.7, LOG(2.7, count - :tags_min2 + 1)+1)*1.5*100)/100 AS scaled
|
FLOOR(LOG(2.7, LOG(2.7, count - :tags_min2 + 1)+1)*1.5*100)/100 AS scaled
|
||||||
FROM tags
|
FROM tags
|
||||||
WHERE count >= :tags_min
|
WHERE count >= :tags_min
|
||||||
AND tag LIKE :starts_with
|
AND tag SCORE_ILIKE :starts_with
|
||||||
ORDER BY tag
|
ORDER BY tag
|
||||||
", array("tags_min"=>$tags_min, "tags_min2"=>$tags_min, "starts_with"=>$starts_with));
|
", array("tags_min"=>$tags_min, "tags_min2"=>$tags_min, "starts_with"=>$starts_with));
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ class TagList implements Extension {
|
|||||||
SELECT tag, count
|
SELECT tag, count
|
||||||
FROM tags
|
FROM tags
|
||||||
WHERE count >= :tags_min
|
WHERE count >= :tags_min
|
||||||
AND tag LIKE :starts_with
|
AND tag SCORE_ILIKE :starts_with
|
||||||
ORDER BY tag
|
ORDER BY tag
|
||||||
", array("tags_min"=>$tags_min, "starts_with"=>$starts_with));
|
", array("tags_min"=>$tags_min, "starts_with"=>$starts_with));
|
||||||
|
|
||||||
|
@ -53,7 +53,11 @@ class TagListTheme extends Themelet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$page->add_block(new Block("Related", $html, "left"));
|
if($config->get_string('tag_list_image_type')=="tags"){
|
||||||
|
$page->add_block(new Block("Tags", $html, "left", 10));}
|
||||||
|
else{
|
||||||
|
$page->add_block(new Block("Related Tags", $html, "left", 10));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,11 +27,11 @@ class UploadTheme extends Themelet {
|
|||||||
|
|
||||||
if($i==0){
|
if($i==0){
|
||||||
$upload_list .= "<div id='hide$i'><img id='wrapper' src='ext/upload/minus.png' />" .
|
$upload_list .= "<div id='hide$i'><img id='wrapper' src='ext/upload/minus.png' />" .
|
||||||
"<a href='javascript:document.getElementById("row$a").style.display = "";javascript:document.getElementById("hide$i").style.display = "none";javascript:document.getElementById("hide$a").style.display = "";'>".
|
"<a href='#' onclick='javascript:document.getElementById("row$a").style.display = "";document.getElementById("hide$i").style.display = "none";document.getElementById("hide$a").style.display = "";'>".
|
||||||
"<img src='ext/upload/plus.png'></a></div></td>";
|
"<img src='ext/upload/plus.png'></a></div></td>";
|
||||||
}else{
|
}else{
|
||||||
$upload_list .="<div id='hide$i'>
|
$upload_list .="<div id='hide$i'>
|
||||||
<a href='javascript:document.getElementById("row$i").style.display = "none";".
|
<a href='#' onclick='javascript:document.getElementById("row$i").style.display = "none";".
|
||||||
"document.getElementById("hide$i").style.display = "none";".
|
"document.getElementById("hide$i").style.display = "none";".
|
||||||
"document.getElementById("hide$s").style.display = "";".
|
"document.getElementById("hide$s").style.display = "";".
|
||||||
"document.getElementById("data$i").value = "";".
|
"document.getElementById("data$i").value = "";".
|
||||||
@ -41,7 +41,7 @@ class UploadTheme extends Themelet {
|
|||||||
$upload_list .="<img id='wrapper' src='ext/upload/plus.png' />";
|
$upload_list .="<img id='wrapper' src='ext/upload/plus.png' />";
|
||||||
}else{
|
}else{
|
||||||
$upload_list .=
|
$upload_list .=
|
||||||
"<a href='javascript:document.getElementById("row$a").style.display = "";".
|
"<a href='#' onclick='javascript:document.getElementById("row$a").style.display = "";".
|
||||||
"document.getElementById("hide$i").style.display = "none";".
|
"document.getElementById("hide$i").style.display = "none";".
|
||||||
"document.getElementById("hide$a").style.display = "";'>".
|
"document.getElementById("hide$a").style.display = "";'>".
|
||||||
"<img src='ext/upload/plus.png' /></a>";
|
"<img src='ext/upload/plus.png' /></a>";
|
||||||
@ -113,15 +113,31 @@ class UploadTheme extends Themelet {
|
|||||||
{
|
{
|
||||||
/* Danbooru > Shimmie Bookmarklet.
|
/* 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.
|
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?)
|
||||||
*/
|
*/
|
||||||
$title = "Danbooru to " . $config->get_string('title');
|
$title = "Danbooru to " . $config->get_string('title');
|
||||||
$html .= '<p><a href="javascript:var img=document.getElementById("highres").href;var ste="' .
|
$html .= '<p><a href="javascript:'.
|
||||||
$link . $delimiter . 'url=";var tag=document.getElementById("post_old_tags").value;var doc=document.documentElement.innerHTML;var rtg=doc.match("<li>Rating: (.*)<\/li>");var srx="http://" + document.location.hostname + document.location.href.match("\/post\/show\/.*\/");' .
|
/* This should stop the bookmarklet being insanely long...not that it's already huge or anything. */
|
||||||
'if (confirm("OK = Use Current tags.\nCancel = Use new tags.")==true)' .
|
'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(tag.search(/\bflash\b/)==-1){location.href=ste+img+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;}else{location.href=ste+document.getElementsByName("movie")[0].value' .
|
//The default confirm sucks, mainly due to being unable to change the text in the Ok/Cancel box (Yes/No would be better.)
|
||||||
'+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;}}else{var p=prompt("Enter Tags","");if(tag.search(/\bflash\b/)==-1){location.href=ste+img+"&tags="+p+"&rating="+rtg[1]+"&source="+srx;}' .
|
'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.
|
||||||
'else{location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+p+"&rating="+rtg[1]+"&source="+srx;}}">' .
|
//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 . '</a> (As above, Click on a Danbooru-run image page. (This also grabs the tags, rating & source!))';
|
'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;}'.
|
||||||
|
//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!))';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,8 +166,8 @@ class UserPage extends SimpleExtension {
|
|||||||
public function onUserPageBuilding(Event $event) {
|
public function onUserPageBuilding(Event $event) {
|
||||||
global $page, $user, $config;
|
global $page, $user, $config;
|
||||||
|
|
||||||
$h_join_date = html_escape($event->display_user->join_date);
|
$h_join_date = autodate($event->display_user->join_date);
|
||||||
$event->add_stats("Join date: $h_join_date", 10);
|
$event->add_stats("Joined: $h_join_date", 10);
|
||||||
|
|
||||||
$av = $event->display_user->get_avatar_html();
|
$av = $event->display_user->get_avatar_html();
|
||||||
if($av) $event->add_stats($av, 0);
|
if($av) $event->add_stats($av, 0);
|
||||||
|
146
lib/jquery.timeago.js
Normal file
146
lib/jquery.timeago.js
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
/**
|
||||||
|
* Timeago is a jQuery plugin that makes it easy to support automatically
|
||||||
|
* updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
|
||||||
|
*
|
||||||
|
* @name timeago
|
||||||
|
* @version 0.10.0
|
||||||
|
* @requires jQuery v1.2.3+
|
||||||
|
* @author Ryan McGeary
|
||||||
|
* @license MIT License - http://www.opensource.org/licenses/mit-license.php
|
||||||
|
*
|
||||||
|
* For usage and examples, visit:
|
||||||
|
* http://timeago.yarp.com/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2008-2011, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
|
||||||
|
*/
|
||||||
|
(function($) {
|
||||||
|
$.timeago = function(timestamp) {
|
||||||
|
if (timestamp instanceof Date) {
|
||||||
|
return inWords(timestamp);
|
||||||
|
} else if (typeof timestamp === "string") {
|
||||||
|
return inWords($.timeago.parse(timestamp));
|
||||||
|
} else {
|
||||||
|
return inWords($.timeago.datetime(timestamp));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var $t = $.timeago;
|
||||||
|
|
||||||
|
$.extend($.timeago, {
|
||||||
|
settings: {
|
||||||
|
refreshMillis: 60000,
|
||||||
|
allowFuture: false,
|
||||||
|
strings: {
|
||||||
|
prefixAgo: null,
|
||||||
|
prefixFromNow: null,
|
||||||
|
suffixAgo: "ago",
|
||||||
|
suffixFromNow: "from now",
|
||||||
|
seconds: "less than a minute",
|
||||||
|
minute: "about a minute",
|
||||||
|
minutes: "%d minutes",
|
||||||
|
hour: "about an hour",
|
||||||
|
hours: "about %d hours",
|
||||||
|
day: "a day",
|
||||||
|
days: "%d days",
|
||||||
|
month: "about a month",
|
||||||
|
months: "%d months",
|
||||||
|
year: "about a year",
|
||||||
|
years: "%d years",
|
||||||
|
numbers: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
inWords: function(distanceMillis) {
|
||||||
|
var $l = this.settings.strings;
|
||||||
|
var prefix = $l.prefixAgo;
|
||||||
|
var suffix = $l.suffixAgo;
|
||||||
|
if (this.settings.allowFuture) {
|
||||||
|
if (distanceMillis < 0) {
|
||||||
|
prefix = $l.prefixFromNow;
|
||||||
|
suffix = $l.suffixFromNow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var seconds = Math.abs(distanceMillis) / 1000;
|
||||||
|
var minutes = seconds / 60;
|
||||||
|
var hours = minutes / 60;
|
||||||
|
var days = hours / 24;
|
||||||
|
var years = days / 365;
|
||||||
|
|
||||||
|
function substitute(stringOrFunction, number) {
|
||||||
|
var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;
|
||||||
|
var value = ($l.numbers && $l.numbers[number]) || number;
|
||||||
|
return string.replace(/%d/i, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
|
||||||
|
seconds < 90 && substitute($l.minute, 1) ||
|
||||||
|
minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
|
||||||
|
minutes < 90 && substitute($l.hour, 1) ||
|
||||||
|
hours < 24 && substitute($l.hours, Math.round(hours)) ||
|
||||||
|
hours < 48 && substitute($l.day, 1) ||
|
||||||
|
days < 30 && substitute($l.days, Math.floor(days)) ||
|
||||||
|
days < 60 && substitute($l.month, 1) ||
|
||||||
|
days < 365 && substitute($l.months, Math.floor(days / 30)) ||
|
||||||
|
years < 2 && substitute($l.year, 1) ||
|
||||||
|
substitute($l.years, Math.floor(years));
|
||||||
|
|
||||||
|
return $.trim([prefix, words, suffix].join(" "));
|
||||||
|
},
|
||||||
|
parse: function(iso8601) {
|
||||||
|
var s = $.trim(iso8601);
|
||||||
|
s = s.replace(/\.\d\d\d+/,""); // remove milliseconds
|
||||||
|
s = s.replace(/-/,"/").replace(/-/,"/");
|
||||||
|
s = s.replace(/T/," ").replace(/Z/," UTC");
|
||||||
|
s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
|
||||||
|
return new Date(s);
|
||||||
|
},
|
||||||
|
datetime: function(elem) {
|
||||||
|
// jQuery's `is()` doesn't play well with HTML5 in IE
|
||||||
|
var isTime = $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
|
||||||
|
var iso8601 = isTime ? $(elem).attr("datetime") : $(elem).attr("title");
|
||||||
|
return $t.parse(iso8601);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$.fn.timeago = function() {
|
||||||
|
var self = this;
|
||||||
|
self.each(refresh);
|
||||||
|
|
||||||
|
var $s = $t.settings;
|
||||||
|
if ($s.refreshMillis > 0) {
|
||||||
|
setInterval(function() { self.each(refresh); }, $s.refreshMillis);
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
};
|
||||||
|
|
||||||
|
function refresh() {
|
||||||
|
var data = prepareData(this);
|
||||||
|
if (!isNaN(data.datetime)) {
|
||||||
|
$(this).text(inWords(data.datetime));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepareData(element) {
|
||||||
|
element = $(element);
|
||||||
|
if (!element.data("timeago")) {
|
||||||
|
element.data("timeago", { datetime: $t.datetime(element) });
|
||||||
|
var text = $.trim(element.text());
|
||||||
|
if (text.length > 0) {
|
||||||
|
element.attr("title", text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return element.data("timeago");
|
||||||
|
}
|
||||||
|
|
||||||
|
function inWords(date) {
|
||||||
|
return $t.inWords(distance(date));
|
||||||
|
}
|
||||||
|
|
||||||
|
function distance(date) {
|
||||||
|
return (new Date().getTime() - date.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
// fix for IE6 suckage
|
||||||
|
document.createElement("abbr");
|
||||||
|
document.createElement("time");
|
||||||
|
}(jQuery));
|
@ -26,6 +26,7 @@ $(document).ready(function() {
|
|||||||
$confirm.dialog('open');
|
$confirm.dialog('open');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("time").timeago();
|
||||||
});
|
});
|
||||||
|
|
||||||
var defaultTexts = new Array();
|
var defaultTexts = new Array();
|
||||||
|
@ -88,7 +88,7 @@ class Layout {
|
|||||||
|
|
||||||
$debug = get_debug_info();
|
$debug = get_debug_info();
|
||||||
|
|
||||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
$contact = empty($contact_link) ? "" : "<br><a href='mailto:$contact_link'>Contact</a>";
|
||||||
|
|
||||||
if(empty($this->subheading)) {
|
if(empty($this->subheading)) {
|
||||||
$subheading = "";
|
$subheading = "";
|
||||||
|
@ -6,7 +6,7 @@ class CustomViewImageTheme extends ViewImageTheme {
|
|||||||
$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list()));
|
$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list()));
|
||||||
$page->set_heading(html_escape($image->get_tag_list()));
|
$page->set_heading(html_escape($image->get_tag_list()));
|
||||||
$page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0));
|
$page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0));
|
||||||
$page->add_block(new Block("Statistics", $this->build_stats($image), "left", 10));
|
$page->add_block(new Block("Statistics", $this->build_stats($image), "left", 15));
|
||||||
$page->add_block(new Block(null, $this->build_image_editor($image, $editor_parts), "main", 10));
|
$page->add_block(new Block(null, $this->build_image_editor($image, $editor_parts), "main", 10));
|
||||||
$page->add_block(new Block(null, $this->build_pin($image), "main", 11));
|
$page->add_block(new Block(null, $this->build_pin($image), "main", 11));
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class Layout {
|
|||||||
|
|
||||||
$debug = get_debug_info();
|
$debug = get_debug_info();
|
||||||
|
|
||||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
$contact = empty($contact_link) ? "" : "<br><a href='mailto:$contact_link'>Contact</a>";
|
||||||
|
|
||||||
$wrapper = "";
|
$wrapper = "";
|
||||||
if(strlen($page->heading) > 100) {
|
if(strlen($page->heading) > 100) {
|
||||||
|
@ -128,6 +128,10 @@ UL {
|
|||||||
.comment {
|
.comment {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
.comment .timeago {
|
||||||
|
float: right;
|
||||||
|
font-size: 75%;
|
||||||
|
}
|
||||||
|
|
||||||
.more:after {
|
.more:after {
|
||||||
content: " >>>";
|
content: " >>>";
|
||||||
|
@ -42,7 +42,7 @@ class Layout {
|
|||||||
|
|
||||||
$debug = get_debug_info();
|
$debug = get_debug_info();
|
||||||
|
|
||||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
$contact = empty($contact_link) ? "" : "<br><a href='mailto:$contact_link'>Contact</a>";
|
||||||
$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
|
$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
|
||||||
|
|
||||||
$wrapper = "";
|
$wrapper = "";
|
||||||
|
@ -37,7 +37,7 @@ class Layout {
|
|||||||
|
|
||||||
$debug = get_debug_info();
|
$debug = get_debug_info();
|
||||||
|
|
||||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
$contact = empty($contact_link) ? "" : "<br><a href='mailto:$contact_link'>Contact</a>";
|
||||||
|
|
||||||
if(empty($page->subheading)) {
|
if(empty($page->subheading)) {
|
||||||
$subheading = "";
|
$subheading = "";
|
||||||
|
@ -138,7 +138,7 @@ class Layout {
|
|||||||
|
|
||||||
$debug = get_debug_info();
|
$debug = get_debug_info();
|
||||||
|
|
||||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
$contact = empty($contact_link) ? "" : "<br><a href='mailto:$contact_link'>Contact</a>";
|
||||||
$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
|
$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
|
||||||
|
|
||||||
$wrapper = "";
|
$wrapper = "";
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
class CustomViewImageTheme extends ViewImageTheme {
|
class CustomViewImageTheme extends ViewImageTheme {
|
||||||
public function display_page($image, $editor_parts) {
|
public function display_page($image, $editor_parts) {
|
||||||
global $page;
|
global $page;
|
||||||
|
$metatags = str_replace(" ", ", ", html_escape($image->get_tag_list()));
|
||||||
$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list()));
|
$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list()));
|
||||||
$page->set_heading(html_escape($image->get_tag_list()));
|
$page->set_heading(html_escape($image->get_tag_list()));
|
||||||
$page->add_html_header("<meta name=\"keywords\" content=\"$metatags\">");
|
$page->add_html_header("<meta name=\"keywords\" content=\"$metatags\">");
|
||||||
@ -11,7 +12,7 @@ class CustomViewImageTheme extends ViewImageTheme {
|
|||||||
$page->add_html_header("<meta property=\"og:image\" content=\"".make_http($image->get_thumb_link())."\">");
|
$page->add_html_header("<meta property=\"og:image\" content=\"".make_http($image->get_thumb_link())."\">");
|
||||||
$page->add_html_header("<meta property=\"og:url\" content=\"".make_http(make_link("post/view/{$image->id}"))."\">");
|
$page->add_html_header("<meta property=\"og:url\" content=\"".make_http(make_link("post/view/{$image->id}"))."\">");
|
||||||
$page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0));
|
$page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0));
|
||||||
$page->add_block(new Block("Statistics", $this->build_stats($image), "left", 10));
|
$page->add_block(new Block("Statistics", $this->build_stats($image), "left", 15));
|
||||||
$page->add_block(new Block(null, $this->build_image_editor($image, $editor_parts), "main", 10));
|
$page->add_block(new Block(null, $this->build_image_editor($image, $editor_parts), "main", 10));
|
||||||
$page->add_block(new Block(null, $this->build_pin($image), "main", 11));
|
$page->add_block(new Block(null, $this->build_pin($image), "main", 11));
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ class Layout {
|
|||||||
|
|
||||||
$debug = get_debug_info();
|
$debug = get_debug_info();
|
||||||
|
|
||||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
$contact = empty($contact_link) ? "" : "<br><a href='mailto:$contact_link'>Contact</a>";
|
||||||
$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
|
$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
|
||||||
|
|
||||||
$wrapper = "";
|
$wrapper = "";
|
||||||
|
@ -47,7 +47,7 @@ class Layout {
|
|||||||
|
|
||||||
$debug = get_debug_info();
|
$debug = get_debug_info();
|
||||||
|
|
||||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
$contact = empty($contact_link) ? "" : "<br><a href='mailto:$contact_link'>Contact</a>";
|
||||||
$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
|
$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>";
|
||||||
|
|
||||||
$wrapper = "";
|
$wrapper = "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user