return is_page($page) ? filemtime(get_filename($page)) - LOCALZONE : 0;
}
+/**
+ * Get last-modified filemtime (plain value) of the page.
+ *
+ * @param $page
+ */
+function get_page_date_atom($page)
+{
+ if (is_page($page)) {
+ return get_date_atom(filemtime(get_filename($page)));
+ }
+ return null;
+}
+
// Get physical file name of the page
function get_filename($page)
{
return null;
}
-function get_date_atom($timestamp)
-{
- // Compatible with DATE_ATOM format
- // return date(DATE_ATOM, $timestamp);
- $zmin = abs(LOCALZONE / 60);
- return date('Y-m-d\TH:i:s', $timestamp) . sprintf('%s%02d:%02d',
- (LOCALZONE < 0 ? '-' : '+') , $zmin / 60, $zmin % 60);
-}
-
// Generate ID
function generate_fixed_heading_anchor_id($seed)
{
return $regex; // For all words
}
+function get_passage_date_html_span($date_atom)
+{
+ return '<span class="page_passage" data-mtime="' . $date_atom . '"></span>';
+}
+
+function get_passage_mtime_html_span($mtime)
+{
+ $date_atom = get_date_atom($mtime);
+ return get_passage_date_html_span($date_atom);
+}
+
+/**
+ * Get passage span html
+ *
+ * @param $page
+ */
+function get_passage_html_span($page)
+{
+ $date_atom = get_page_date_atom($page);
+ return get_passage_date_html_span($date_atom);
+}
+
+function get_link_passage_class() {
+ return 'link_page_passage';
+}
+
+/**
+ * Get page link general attributes
+ * @param $page
+ * @return array('data_mtime' => page mtime or null, 'class' => additinal classes)
+ */
+function get_page_link_a_attrs($page)
+{
+ global $show_passage;
+ if ($show_passage) {
+ $pagemtime = get_page_date_atom($page);
+ return array(
+ 'data_mtime' => $pagemtime,
+ 'class' => get_link_passage_class(),
+ );
+ }
+ return array(
+ 'data_mtime' => '',
+ 'class' => ''
+ );
+}
+
// 'Search' main function
function do_search($word, $type = 'AND', $non_format = FALSE, $base = '')
{
foreach (array_keys($pages) as $page) {
$r_page = rawurlencode($page);
$s_page = htmlsc($page);
- $passage = $show_passage ? ' ' . get_passage(get_filetime($page)) : '';
+ $passage = $show_passage ? ' ' . get_passage_html_span($page) : '';
$retval .= ' <li><a href="' . get_base_uri() . '?cmd=read&page=' .
$r_page . '&word=' . $r_word . '">' . $s_page .
'</a>' . $passage . '</li>' . "\n";
foreach($pages as $file=>$page) {
$r_page = pagename_urlencode($page);
$s_page = htmlsc($page, ENT_QUOTES);
- $passage = get_pg_passage($page);
-
$str = ' <li><a href="' . $href . $r_page . '">' .
- $s_page . '</a>' . $passage;
-
+ $s_page . '</a>' . get_passage_html_span($page);
if ($withfilename) {
$s_file = htmlsc($file);
$str .= "\n" . ' <ul><li>' . $s_file . '</li></ul>' .
$head = (preg_match('/^([A-Za-z])/', $page, $matches)) ? strtoupper($matches[1]) :
(preg_match('/^([ -~])/', $page) ? $symbol : $other);
}
-
$list[$head][$page] = $str;
}
uksort($pages, 'strnatcmp');
return $paren ? '(' . $date . ')' : $date;
}
+/**
+ * Format date in DATE_ATOM format.
+ */
+function get_date_atom($timestamp)
+{
+ // Compatible with DATE_ATOM format
+ // return date(DATE_ATOM, $timestamp);
+ $zmin = abs(LOCALZONE / 60);
+ return date('Y-m-d\TH:i:s', $timestamp) . sprintf('%s%02d:%02d',
+ (LOCALZONE < 0 ? '-' : '+') , $zmin / 60, $zmin % 60);
+}
+
// Get short string of the passage, 'N seconds/minutes/hours/days/years ago'
function get_passage($time, $paren = TRUE)
{
// Last modification date (string) of the page
$lastmodified = $is_read ? format_date(get_filetime($_page)) .
- ' ' . get_pg_passage($_page, FALSE) : '';
+ get_passage_html_span($_page) : '';
// List of attached files to the page
$show_attaches = $is_read || arg_check('edit');
$_links = array();
foreach ($links as $page=>$lastmod) {
if (check_non_list($page)) continue;
-
$page_uri = get_page_uri($page);
$s_page = htmlsc($page);
- $passage = get_passage($lastmod);
- $_links[] = $tag ?
- '<a href="' . $page_uri . '" title="' .
- $s_page . ' ' . $passage . '">' . $s_page . '</a>' :
- '<a href="' . $page_uri . '">' .
- $s_page . '</a>' . $passage;
+ if ($tag) {
+ $attrs = get_page_link_a_attrs($page);
+ $_links[] = '<a href="' . $page_uri . '" class="' .
+ $attrs['class'] . '" data-mtime="' . $attrs['data_mtime'] .
+ '">' . $s_page . '</a>';
+ } else {
+ $mtime_span = get_passage_mtime_html_span($lastmod + LOCALZONE);
+ $_links[] = '<a href="' . $page_uri . '">' .
+ $s_page . '</a>' . $mtime_span;
+ }
}
if (empty($_links)) return ''; // Nothing
if ($isautolink || is_page($page)) {
// Hyperlink to the page
- if ($link_compact) {
- $title = '';
- } else {
- $title = ' title="' . $s_page . get_pg_passage($page, FALSE) . '"';
- }
-
+ $attrs = get_page_link_a_attrs($page);
// AutoLink marker
if ($isautolink) {
$al_left = '<!--autolink-->';
} else {
$al_left = $al_right = '';
}
-
+ $title_attr_html = '';
+ if ($s_page !== $s_alias) {
+ $title_attr_html = ' title="' . $s_page . '"';
+ }
return $al_left . '<a ' . 'href="' . $script . '?' . $r_page . $anchor .
- '"' . $title . '>' . $s_alias . '</a>' . $al_right;
+ '"' . $title_attr_html . ' class="' .
+ $attrs['class'] . '" data-mtime="' . $attrs['data_mtime'] .
+ '">' . $s_alias . '</a>' . $al_right;
} else {
// Support Page redirection
$redirect_page = get_pagename_on_redirect($page);
<?php
// PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: filelist.inc.php,v 1.3 2005/01/09 08:16:28 henoheno Exp $
+// filelist.inc.php
+// Copyright 2003-2017 PukiWiki Development Team
+// License: GPL v2 or (at your option) any later version
//
// Filelist plugin: redirect to list plugin
// cmd=filelist
{
return do_plugin_action('list');
}
-?>
<?php
// PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: list.inc.php,v 1.6 2006/05/13 07:36:41 henoheno Exp $
+// list.inc.php
+// Copyright 2003-2017 PukiWiki Development Team
+// License: GPL v2 or (at your option) any later version
//
// IndexPages plugin: Show a list of page names
global $vars, $_title_list, $_title_filelist, $whatsnew;
// Redirected from filelist plugin?
- $filelist = (isset($vars['cmd']) && $vars['cmd'] == 'filelist');
+ $filelist = (isset($vars['cmd']) && $vars['cmd'] === 'filelist');
return array(
'msg'=>$filelist ? $_title_filelist : $_title_list,
return page_list($pages, 'read', $withfilename);
}
-?>
if (! $is_done) $params["page_$page"] = ++$_ls2_anchor;
$s_page = htmlsc($page);
- $title = $s_page . ' ' . get_pg_passage($page, FALSE);
+ $attrs = get_page_link_a_attrs($page);
$href = get_page_uri($page);
plugin_ls2_list_push($params, $level);
$ret = $include ? '<li>include ' : '<li>';
if ($is_done) {
- $ret .= '<a href="' . $href . '" title="' . $title . '">' . $s_page . '</a> ';
+ $ret .= '<a href="' . $href . '" class="' .
+ $attrs['class'] . '" data-mtime="' . $attrs['data_mtime'] .
+ '">' . $s_page . '</a> ';
$ret .= '<a href="#list_' . $params["page_$page"] . '"><sup>↑</sup></a>';
array_push($params['result'], $ret);
return;
}
$ret .= '<a id="list_' . $params["page_$page"] . '" href="' . $href .
- '" title="' . $title . '">' . $s_page . '</a>';
+ '" class="' . $attrs['class'] . '" data-mtime="' .
+ $attrs['data_mtime'] . '">' . $s_page . '</a>';
array_push($params['result'], $ret);
$anchor = PLUGIN_LS2_ANCHOR_ORIGIN;
$s_page = htmlsc($page);
if ($page === $vars['page']) {
// No need to link itself, notifies where you just read
- $pg_passage = get_pg_passage($page,FALSE);
- $items .= ' <li><span title="' . $s_page . ' ' . $pg_passage . '">' .
- $s_page . '<span class="counter">(' . $count .
+ $attrs = get_page_link_a_attrs($page);
+ $items .= ' <li><span class="' .
+ $attrs['class'] . '" data-mtime="' . $attrs['data_mtime'] .
+ '">' . $s_page . '<span class="counter">(' . $count .
')</span></span></li>' . "\n";
} else {
$items .= ' <li>' . make_pagelink($page,
function plugin_recent_convert()
{
- global $vars, $date_format, $_recent_plugin_frame, $show_passage;
+ global $vars, $date_format, $_recent_plugin_frame;
static $exec_count = 1;
$recent_lines = PLUGIN_RECENT_DEFAULT_LINES;
// No need to link to the page you just read, or notify where you just read
$items .= ' <li>' . $s_page . '</li>' . "\n";
} else {
- $passage = $show_passage ? ' ' . get_passage($time) : '';
- $items .= ' <li><a href="' . get_page_uri($page) . '"' .
- ' title="' . $s_page . $passage . '">' . $s_page . '</a></li>' . "\n";
+ $attrs = get_page_link_a_attrs($page);
+ $items .= ' <li><a href="' . get_page_uri($page) . '" class="' .
+ $attrs['class'] . '" data-mtime="' . $attrs['data_mtime'] .
+ '">' . $s_page . '</a></li>' . "\n";
}
}
// End of the day
<?php
// PukiWiki - Yet another WikiWikiWeb clone
-// $Id: related.inc.php,v 1.11 2011/01/25 15:01:01 henoheno Exp $
-// Copyright (C) 2005, 2007 PukiWiki Developers Team
+// related.inc.php
+// Copyright 2005-2017 PukiWiki Development Team
// License: GPL v2 or (at your option) any later version
//
// Related plugin: Show Backlinks for the page
// Show Backlinks: via related caches for the page
function plugin_related_action()
{
- global $vars, $script, $defaultpage, $whatsnew;
+ global $vars, $defaultpage, $whatsnew;
$_page = isset($vars['page']) ? $vars['page'] : '';
if ($_page == '') $_page = $defaultpage;
check_non_list($page))
unset($data[$page]);
}
-
// Result
- $r_word = pagename_urlencode($_page);
$s_word = htmlsc($_page);
$msg = 'Backlinks for: ' . $s_word;
- $retval = '<a href="' . $script . '?' . $r_word . '">' .
+ $retval = '<a href="' . get_page_uri($_page) . '">' .
'Return to ' . $s_word .'</a><br />'. "\n";
-
if (empty($data)) {
$retval .= '<ul><li>No related pages found.</li></ul>' . "\n";
} else {
ksort($data, SORT_STRING);
$retval .= '<ul>' . "\n";
foreach ($data as $page=>$time) {
- $r_page = pagename_urlencode($page);
$s_page = htmlsc($page);
- $passage = get_passage($time);
- $retval .= ' <li><a href="' . $script . '?' . $r_page . '">' . $s_page .
- '</a> ' . $passage . '</li>' . "\n";
+ $mtime_span = get_passage_mtime_html_span($time + LOCALZONE);
+ $retval .= ' <li><a href="' . get_page_uri($page) . '">' . $s_page .
+ '</a>' . $mtime_span . '</li>' . "\n";
}
$retval .= '</ul>' . "\n";
}
return array('msg'=>$msg, 'body'=>$retval);
}
-
foreach ($items as $item) {
$link = $item['LINK'];
$title = $item['TITLE'];
- $passage = get_passage($item['_TIMESTAMP']);
- $link = '<a href="' . $link . '" title="' . $title . ' ' .
- $passage . '" rel="nofollow">' . $title . '</a>';
+ $date = get_date_atom($item['_TIMESTAMP'] + LOCALZONE);
+ $link = '<a href="' . $link . '" data-mtime="' .
+ $date . '" class="' . get_link_passage_class() .
+ '" rel="nofollow">' . $title . '</a>';
$this->items[$date][] = $this->format_link($link);
}
}
// PukiWiki JavaScript client script
window.addEventListener && window.addEventListener('DOMContentLoaded', function() { // eslint-disable-line no-unused-expressions
'use strict';
+ /**
+ * @param {NodeList} nodeList
+ * @param {function(Node, number): void} func
+ */
+ function forEach(nodeList, func) {
+ if (nodeList.forEach) {
+ nodeList.forEach(func);
+ } else {
+ for (var i = 0, n = nodeList.length; i < n; i++) {
+ func(nodeList[i], i);
+ }
+ }
+ }
// Name for comment
function setYourName() {
var NAME_KEY_ID = 'pukiwiki_comment_plugin_name';
e.returnValue = message;
}, false);
}
+ function showPagePassage() {
+ /**
+ * @param {Date} now
+ * @param {string} dateText
+ */
+ function getPassage(dateText, now) {
+ if (!dateText) {
+ return '';
+ }
+ var units = [{u: 'm', max: 60}, {u: 'h', max: 24}, {u: 'd', max: 1}];
+ var d = new Date();
+ d.setTime(Date.parse(dateText));
+ var t = (now.getTime() - d.getTime()) / (1000 * 60); // minutes
+ var unit = units[0].u; var card = units[0].max;
+ for (var i = 0; i < units.length; i++) {
+ unit = units[i].u; card = units[i].max;
+ if (t < card) break;
+ t = t / card;
+ }
+ return '(' + Math.floor(t) + unit + ')';
+ }
+ var now = new Date();
+ var elements = document.getElementsByClassName('page_passage');
+ forEach(elements, function(e) {
+ var dt = e.getAttribute('data-mtime');
+ if (dt) {
+ var d = new Date(dt);
+ e.textContent = ' ' + getPassage(d, now);
+ }
+ });
+ var links = document.getElementsByClassName('link_page_passage');
+ forEach(links, function(e) {
+ var dt = e.getAttribute('data-mtime');
+ if (dt) {
+ var d = new Date(dt);
+ if (e.title) {
+ e.title = e.title + ' ' + getPassage(d, now);
+ } else {
+ e.title = e.textContent + ' ' + getPassage(d, now);
+ }
+ }
+ });
+ }
setYourName();
autoTicketLink();
confirmEditFormLeaving();
+ showPagePassage();
});
padding:0px;
margin:16px 0px 0px 0px;
}
+div#related .page_passage {
+ font-size:60%;
+}
div#footer {
font-size:70%;
vertical-align:super;
}
+/* list.inc.php */
+.page_passage {
+ font-size: small;
+}
+
/* br.inc.php */
br.spacer {}
padding:0px;
margin:0px 0px 0px 0px;
}
+div#related .page_passage {
+ font-size:60%;
+}
div#footer {
font-size:70%;
vertical-align:super;
}
+/* list.inc.php */
+.page_passage {
+ font-size: small;
+}
+
/* br.inc.php */
br.spacer {}