diff options
author | friendica <info@friendica.com> | 2012-07-23 04:11:59 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-07-23 04:11:59 -0700 |
commit | 3decf67e6d6aa0ae077aa48bcdd37afc05a36dd1 (patch) | |
tree | 890749f2ac3bca28745ff93089c4c9e68e49ae63 | |
parent | 33ea8737b71466be84dfaaa0fa16cd2850805158 (diff) | |
download | volse-hubzilla-3decf67e6d6aa0ae077aa48bcdd37afc05a36dd1.tar.gz volse-hubzilla-3decf67e6d6aa0ae077aa48bcdd37afc05a36dd1.tar.bz2 volse-hubzilla-3decf67e6d6aa0ae077aa48bcdd37afc05a36dd1.zip |
realtime updates of "6 minutes ago" with fallback to iso8601 timestamps (available on tooltip)
-rw-r--r-- | include/conversation.php | 12 | ||||
-rw-r--r-- | index.php | 24 | ||||
-rw-r--r-- | js/main.js | 28 | ||||
-rw-r--r-- | library/jquery.timeago.js | 2 | ||||
-rw-r--r-- | view/head.tpl | 20 | ||||
-rw-r--r-- | view/search_item.tpl | 3 | ||||
-rw-r--r-- | view/wall_item.tpl | 2 | ||||
-rw-r--r-- | view/wallwall_item.tpl | 2 |
8 files changed, 85 insertions, 8 deletions
diff --git a/include/conversation.php b/include/conversation.php index 06b643a05..958400db3 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -457,7 +457,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $body = prepare_body($item,true); - + //$tmp_item = replace_macros($tpl,array( $tmp_item = array( 'template' => $tpl, @@ -473,7 +473,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { 'title' => template_escape($item['title']), 'body' => template_escape($body), 'text' => strip_tags(template_escape($body)), - 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), + 'ago' => relative_date($item['created']), + 'app' => $item['app'], + 'str_app' => sprintf( t(' from %s'), $item['app']), + 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'), 'location' => template_escape($location), 'indent' => '', 'owner_name' => template_escape($owner_name), @@ -832,7 +835,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { 'osparkle' => $osparkle, 'sparkle' => $sparkle, 'title' => template_escape($item['title']), - 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), + 'ago' => datetime_convert('UTC',date_default_timezone_get(),$item['created'],'r'), // relative_date($item['created']), + 'app' => $item['app'], + 'str_app' => sprintf( t(' from %s'), $item['app']), + 'localtime' => datetime_convert('UTC', 'UTC', $item['created'], 'c'), 'lock' => $lock, 'location' => template_escape($location), 'indent' => $indent, @@ -390,7 +390,29 @@ if(! file_exists($module_css)) '$page_css' => $a->get_baseurl() . '/' . $page_css, '$module_css' => (($module_css) ? $a->get_baseurl() . '/' . $module_css : null), '$stylesheet' => current_theme_url(), - '$theme' => current_theme() + '$theme' => current_theme(), + +// localisations for jquery.timeago.js, see https://github.com/rmm5t/jquery-timeago +// TRANSLATORS - only translate the conditionals if you require them! + + '$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : 'null'), + '$t02' => ((t('timeago.suffixAgo') != 'timeago.suffixAgo') ? t('timeago.suffixAgo') : 'null'), + '$t03' => t('ago'), + '$t04' => t('from now'), + '$t05' => t('less than a minute'), + '$t06' => t('about a minute'), + '$t07' => t('%d minutes'), + '$t08' => t('about an hour'), + '$t09' => t('about %d hours'), + '$t10' => t('a day'), + '$t11' => t('%d days'), + '$t12' => t('about a month'), + '$t13' => t('%d months'), + '$t14' => t('about a year'), + '$t15' => t('%d years'), + '$t16' => t(' '), // wordSeparator + '$t17' => ((t('timeago.numbers') != 'timeago.numbers') ? t('timeago.numbers') : '[]') + )); $page = $a->page; diff --git a/js/main.js b/js/main.js index e8c5b060e..e434ee4a5 100644 --- a/js/main.js +++ b/js/main.js @@ -686,3 +686,31 @@ function previewTheme(elm) { }); }; })(jQuery); + + + +$(document).ready(function() { + +jQuery.timeago.settings.strings = { + prefixAgo: t01, + prefixFromNow: t02, + suffixAgo: t03, + suffixFromNow: t04, + seconds: t05, + minute: t06, + minutes: t07, + hour: t08, + hours: t09, + day: t10, + days: t11, + month: t12, + months: t13, + year: t14, + years: t15, + wordSeparator: t16, + numbers: t17 +}; + + +$("abbr.wall-item-ago-time").timeago(); +});
\ No newline at end of file diff --git a/library/jquery.timeago.js b/library/jquery.timeago.js index c61405dfc..f7a657e93 100644 --- a/library/jquery.timeago.js +++ b/library/jquery.timeago.js @@ -121,7 +121,7 @@ function refresh() { var data = prepareData(this); if (!isNaN(data.datetime)) { - $(this).text(inWords(data.atetime)); + $(this).text(inWords(data.datetime)); } return this; } diff --git a/view/head.tpl b/view/head.tpl index 78e2a2abc..fbe2ded83 100644 --- a/view/head.tpl +++ b/view/head.tpl @@ -26,6 +26,7 @@ <script type="text/javascript" src="$baseurl/js/jquery.textinputs.js" ></script> <script type="text/javascript" src="$baseurl/js/fk.autocomplete.js" ></script> <script type="text/javascript" src="$baseurl/library/fancybox/jquery.fancybox-1.3.4.pack.js"></script> +<script type="text/javascript" src="$baseurl/library/jquery.timeago.js"></script> <script type="text/javascript" src="$baseurl/library/tiptip/jquery.tipTip.minified.js"></script> <script type="text/javascript" src="$baseurl/library/jgrowl/jquery.jgrowl_minimized.js"></script> <script type="text/javascript" src="$baseurl/library/tinymce/jscripts/tiny_mce/tiny_mce_src.js" ></script> @@ -104,6 +105,25 @@ } } + // jquery.timeago localisations + + var t01 = $t01 ; + var t02 = $t02 ; + var t03 = "$t03" ; + var t04 = "$t04" ; + var t05 = "$t05" ; + var t06 = "$t06" ; + var t07 = "$t07" ; + var t08 = "$t08" ; + var t09 = "$t09" ; + var t10 = "$t10" ; + var t11 = "$t11" ; + var t12 = "$t12" ; + var t13 = "$t13" ; + var t14 = "$t14" ; + var t15 = "$t15" ; + var t16 = "$t16" ; + var t17 = $t17 ; </script> diff --git a/view/search_item.tpl b/view/search_item.tpl index 8089d306e..e13c1e5a7 100644 --- a/view/search_item.tpl +++ b/view/search_item.tpl @@ -23,7 +23,8 @@ </div> <div class="wall-item-author"> <a href="$item.profile_url" target="redir" title="$item.linktitle" class="wall-item-name-link"><span class="wall-item-name$item.sparkle" id="wall-item-name-$item.id" >$item.name</span></a> - <div class="wall-item-ago" id="wall-item-ago-$item.id">$item.ago</div> + + <div id="wall-item-ago-$item.id" class="wall-item-ago"><abbr class="wall-item-ago-time" title="$item.localtime">$item.ago</abbr>{{ if $item.app }}<span class="item.app">$item.str_app</span>{{ endif }}</div> </div> <div class="wall-item-content" id="wall-item-content-$item.id" > diff --git a/view/wall_item.tpl b/view/wall_item.tpl index 60dde7600..2510a8c0d 100644 --- a/view/wall_item.tpl +++ b/view/wall_item.tpl @@ -24,7 +24,7 @@ </div> <div class="wall-item-author"> <a href="$item.profile_url" target="redir" title="$item.linktitle" class="wall-item-name-link"><span class="wall-item-name$item.sparkle" id="wall-item-name-$item.id" >$item.name</span></a> - <div class="wall-item-ago" id="wall-item-ago-$item.id">$item.ago</div> + <div id="wall-item-ago-$item.id" class="wall-item-ago"><abbr class="wall-item-ago-time" title="$item.localtime">$item.ago</abbr>{{ if $item.app }}<span class="item.app">$item.str_app</span>{{ endif }}</div> </div> <div class="wall-item-content" id="wall-item-content-$item.id" > diff --git a/view/wallwall_item.tpl b/view/wallwall_item.tpl index b7cca3fab..478df8e88 100644 --- a/view/wallwall_item.tpl +++ b/view/wallwall_item.tpl @@ -29,7 +29,7 @@ </div> <div class="wall-item-author"> <a href="$item.profile_url" target="redir" title="$item.linktitle" class="wall-item-name-link"><span class="wall-item-name$item.sparkle" id="wall-item-name-$item.id" >$item.name</span></a> $item.to <a href="$item.owner_url" target="redir" title="$item.olinktitle" class="wall-item-name-link"><span class="wall-item-name$item.osparkle" id="wall-item-ownername-$item.id">$item.owner_name</span></a> $item.vwall<br /> - <div class="wall-item-ago" id="wall-item-ago-$item.id">$item.ago</div> + <div id="wall-item-ago-$item.id" class="wall-item-ago"><abbr class="wall-item-ago-time" title="$item.localtime">$item.ago</abbr>{{ if $item.app }}<span class="item.app">$item.str_app</span>{{ endif }}</div> </div> <div class="wall-item-content" id="wall-item-content-$item.id" > <div class="wall-item-title" id="wall-item-title-$item.id">$item.title</div> |