Revisión | 4105374f95c18e0a446092e6ccec77cf84a9d4a0 (tree) |
---|---|
Tiempo | 2017-09-12 01:16:33 |
Autor | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack/2213 Improve Canonical URL and reload links
@@ -733,6 +733,10 @@ function get_base_uri($uri_type = PKWK_URI_RELATIVE) | ||
733 | 733 | */ |
734 | 734 | function get_page_uri($page, $uri_type = PKWK_URI_RELATIVE) |
735 | 735 | { |
736 | + global $defaultpage; | |
737 | + if ($page === $defaultpage) { | |
738 | + return get_base_uri($uri_type); | |
739 | + } | |
736 | 740 | return get_base_uri($uri_type) . '?' . pagename_urlencode($page); |
737 | 741 | } |
738 | 742 |
@@ -48,11 +48,7 @@ function catbody($title, $page, $body) | ||
48 | 48 | $r_page = pagename_urlencode($_page); |
49 | 49 | |
50 | 50 | // Canonical URL |
51 | - if ($_page === $defaultpage) { | |
52 | - $canonical_url = get_base_uri(PKWK_URI_ABSOLUTE); | |
53 | - } else { | |
54 | - $canonical_url = get_page_uri($_page, PKWK_URI_ABSOLUTE); | |
55 | - } | |
51 | + $canonical_url = get_page_uri($_page, PKWK_URI_ABSOLUTE); | |
56 | 52 | |
57 | 53 | // Set $_LINK for skin |
58 | 54 | $_LINK['add'] = "$script?cmd=add&page=$r_page"; |
@@ -62,20 +58,21 @@ function catbody($title, $page, $body) | ||
62 | 58 | $_LINK['edit'] = "$script?cmd=edit&page=$r_page"; |
63 | 59 | $_LINK['filelist'] = "$script?cmd=filelist"; |
64 | 60 | $_LINK['freeze'] = "$script?cmd=freeze&page=$r_page"; |
65 | - $_LINK['help'] = "$script?" . pagename_urlencode($help_page); | |
61 | + $_LINK['help'] = get_page_uri($help_page); | |
66 | 62 | $_LINK['list'] = "$script?cmd=list"; |
67 | 63 | $_LINK['new'] = "$script?plugin=newpage&refer=$r_page"; |
68 | 64 | $_LINK['rdf'] = "$script?cmd=rss&ver=1.0"; |
69 | - $_LINK['recent'] = "$script?" . pagename_urlencode($whatsnew); | |
70 | - $_LINK['reload'] = $canonical_url; | |
65 | + $_LINK['recent'] = get_page_uri($whatsnew); | |
66 | + $_LINK['reload'] = get_page_uri($_page); | |
71 | 67 | $_LINK['rename'] = "$script?plugin=rename&refer=$r_page"; |
72 | 68 | $_LINK['rss'] = "$script?cmd=rss"; |
73 | 69 | $_LINK['rss10'] = "$script?cmd=rss&ver=1.0"; // Same as 'rdf' |
74 | 70 | $_LINK['rss20'] = "$script?cmd=rss&ver=2.0"; |
75 | 71 | $_LINK['search'] = "$script?cmd=search"; |
76 | - $_LINK['top'] = "$script?" . pagename_urlencode($defaultpage); | |
72 | + $_LINK['top'] = get_page_uri($defaultpage); | |
77 | 73 | $_LINK['unfreeze'] = "$script?cmd=unfreeze&page=$r_page"; |
78 | 74 | $_LINK['upload'] = "$script?plugin=attach&pcmd=upload&page=$r_page"; |
75 | + $_LINK['canonical_url'] = $canonical_url; | |
79 | 76 | $login_link = "#LOGIN_ERROR"; // dummy link that is not used |
80 | 77 | switch ($auth_type) { |
81 | 78 | case AUTH_TYPE_FORM: |
@@ -375,7 +372,7 @@ $template | ||
375 | 372 | EOD; |
376 | 373 | |
377 | 374 | $body .= '<ul><li><a href="' . |
378 | - $script . '?' . pagename_urlencode($rule_page) . | |
375 | + get_page_uri($rule_page) . | |
379 | 376 | '" target="_blank">' . $_msg_help . '</a></li></ul>'; |
380 | 377 | return $body; |
381 | 378 | } |
@@ -399,13 +396,13 @@ function make_related($page, $tag = '') | ||
399 | 396 | foreach ($links as $page=>$lastmod) { |
400 | 397 | if (check_non_list($page)) continue; |
401 | 398 | |
402 | - $r_page = pagename_urlencode($page); | |
399 | + $page_uri = get_page_uri($page); | |
403 | 400 | $s_page = htmlsc($page); |
404 | 401 | $passage = get_passage($lastmod); |
405 | 402 | $_links[] = $tag ? |
406 | - '<a href="' . $script . '?' . $r_page . '" title="' . | |
403 | + '<a href="' . $page_uri . '" title="' . | |
407 | 404 | $s_page . ' ' . $passage . '">' . $s_page . '</a>' : |
408 | - '<a href="' . $script . '?' . $r_page . '">' . | |
405 | + '<a href="' . $page_uri . '">' . | |
409 | 406 | $s_page . '</a>' . $passage; |
410 | 407 | } |
411 | 408 | if (empty($_links)) return ''; // Nothing |
@@ -81,7 +81,7 @@ header('Content-Type: text/html; charset=' . CONTENT_CHARSET); | ||
81 | 81 | |
82 | 82 | <?php if ($is_page) { ?> |
83 | 83 | <?php if(SKIN_DEFAULT_DISABLE_TOPICPATH) { ?> |
84 | - <a href="<?php echo $link['reload'] ?>"><span class="small"><?php echo $link['reload'] ?></span></a> | |
84 | + <a href="<?php echo $link['canonical_url'] ?>"><span class="small"><?php echo $link['canonical_url'] ?></span></a> | |
85 | 85 | <?php } else { ?> |
86 | 86 | <span class="small"> |
87 | 87 | <?php require_once(PLUGIN_DIR . 'topicpath.inc.php'); echo plugin_topicpath_inline(); ?> |
@@ -2,7 +2,7 @@ | ||
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone. |
3 | 3 | // tdiary.skin.php |
4 | 4 | // Copyright |
5 | -// 2002-2016 PukiWiki Development Team | |
5 | +// 2002-2017 PukiWiki Development Team | |
6 | 6 | // 2001-2002 Originally written by yu-ji |
7 | 7 | // License: GPL v2 or (at your option) any later version |
8 | 8 | // |
@@ -651,7 +651,7 @@ function _navigator($key, $value = '', $javascript = ''){ | ||
651 | 651 | <div class="calendar"> |
652 | 652 | <?php if ($is_page && TDIARY_CALENDAR_DESIGN !== NULL) { ?> |
653 | 653 | <?php if(TDIARY_CALENDAR_DESIGN) { ?> |
654 | - <a href="<?php echo $link['reload'] ?>"><span class="small"><?php echo $link['reload'] ?></span></a> | |
654 | + <a href="<?php echo $link['canonical_url'] ?>"><span class="small"><?php echo $link['canonical_url'] ?></span></a> | |
655 | 655 | <?php } else { ?> |
656 | 656 | <?php require_once(PLUGIN_DIR . 'topicpath.inc.php'); echo plugin_topicpath_inline(); ?> |
657 | 657 | <?php } ?> |