コミットメタ情報

リビジョンa81938a8f6c6dd827008ed2cf3484765725c9de5 (tree)
日時2017-04-02 17:00:29
作者umorigu <umorigu@gmai...>
コミッターumorigu

ログメッセージ

BugTrack/2420 AutoTicketLink: Support title for ticket link

変更サマリ

差分

--- a/pukiwiki.ini.php
+++ b/pukiwiki.ini.php
@@ -293,11 +293,23 @@ $ticket_link_sites = array(
293293 /*
294294 array(
295295 'key' => 'phpbug',
296- 'type' => 'redmine', // type: redmine or jira
297- 'name' => 'PHP :: Bug #$1',
296+ 'type' => 'redmine', // type: redmine, jira or git
297+ 'title' => 'PHP :: Bug #$1',
298298 'base_url' => 'https://bugs.php.net/bug.php?id=',
299299 ),
300- */
300+ array(
301+ 'key' => 'asfjira',
302+ 'type' => 'jira',
303+ 'title' => 'ASF JIRA [$1]',
304+ 'base_url' => 'https://issues.apache.org/jira/browse/',
305+ ),
306+ array(
307+ 'key' => 'pukiwiki-commit',
308+ 'type' => 'git',
309+ 'title' => 'PukiWiki revision $1',
310+ 'base_url' => 'https://ja.osdn.net/projects/pukiwiki/scm/git/pukiwiki/commits/',
311+ ),
312+*/
301313 );
302314
303315 /////////////////////////////////////////////////
--- a/skin/ticketlink.js
+++ b/skin/ticketlink.js
@@ -7,16 +7,24 @@ if (window.addEventListener) {
77 var headReText = '([\\s\\b]|^)';
88 var tailReText = '\\b';
99 var _siteList = getSiteListFromBody();
10- function ticketToUrl(keyText) {
10+ function ticketToLink(keyText) {
1111 var siteList = getSiteList();
1212 for (var i = 0; i < siteList.length; i++) {
1313 var site = siteList[i];
1414 var m = keyText.match(site.re);
1515 if (m) {
16- return site.base_url + m[3];
16+ var title = site.title;
17+ var ticketKey = m[3]
18+ if (title) {
19+ title = title.replace(/\$1/g, ticketKey);
20+ }
21+ return {
22+ url: site.base_url + m[3],
23+ title: title
24+ };
1725 }
1826 }
19- return '';
27+ return null;
2028 }
2129 function regexEscape(key) {
2230 return key.replace(/[\-\.]/g, function (m) {
@@ -65,7 +73,7 @@ if (window.addEventListener) {
6573 function textToSiteInfo(siteDef) {
6674 if (!siteDef) return null;
6775 var info = JSON.parse(siteDef);
68- if (info && info.key && info.type && info.name && info.base_url) {
76+ if (info && info.key && info.type && info.base_url) {
6977 return info;
7078 }
7179 return null;
@@ -101,7 +109,9 @@ if (window.addEventListener) {
101109 }
102110 var a = document.createElement('a');
103111 a.textContent = m[2];
104- a.href = ticketToUrl(a.textContent);
112+ var linkInfo = ticketToLink(a.textContent);
113+ a.href = linkInfo.url;
114+ a.title = linkInfo.title;
105115 f.appendChild(a);
106116 text = text.substr(m.index + m[0].length);
107117 }
旧リポジトリブラウザで表示