• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision616ab7044653846bc4f62a2fdcd6dfe8a58f791a (tree)
Zeit2017-09-24 22:09:30
Autorumorigu <umorigu@gmai...>
Commiterumorigu

Log Message

search2: Shor page summary

Ändern Zusammenfassung

Diff

--- a/skin/pukiwiki.css
+++ b/skin/pukiwiki.css
@@ -642,12 +642,19 @@ tr.bugtrack_state_undef td {
642642 }
643643
644644 /* search2.inc.php */
645-input#_plugin_search2_detail:checked ~ ul > pre {
645+input#_plugin_search2_detail:checked ~ ul > div.search-result-detail {
646646 display: block;
647647 }
648-input#_plugin_search2_detail ~ ul > pre {
648+input#_plugin_search2_detail ~ ul > div.search-result-detail {
649649 display: none;
650650 }
651+.search-result-page-summary {
652+ font-size: 70%;
653+ color: gray;
654+ overflow: hidden;
655+ text-overflow: ellipsis;
656+ white-space: nowrap;
657+}
651658
652659 @media print {
653660 a:link,
--- a/skin/search2.js
+++ b/skin/search2.js
@@ -148,14 +148,23 @@ window.addEventListener && window.addEventListener('DOMContentLoaded', function(
148148 } else {
149149 updatedAt = val.updated_at;
150150 }
151- li.innerHTML = '<a href="' + href + '">' + decoratedName + '</a> ' + getPassage(now, updatedAt);
151+ var liHtml = '<a href="' + href + '">' + decoratedName + '</a> ' +
152+ getPassage(now, updatedAt);
153+ li.innerHTML = liHtml;
152154 fragment.appendChild(li);
155+ var div = document.createElement('div');
156+ div.classList.add('search-result-detail');
157+ var head = document.createElement('div');
158+ head.classList.add('search-result-page-summary');
159+ head.innerHTML = escapeHTML(getBodySummary(val.body));
160+ div.appendChild(head);
153161 var summary = getSummary(val.body, searchRegex);
154162 for (var i = 0; i < summary.length; i++) {
155163 var pre = document.createElement('pre');
156164 pre.innerHTML = summary[i].lines.join('\n');
157- fragment.appendChild(pre);
165+ div.appendChild(pre);
158166 }
167+ fragment.appendChild(div);
159168 ul.appendChild(fragment);
160169 });
161170 if (!obj.search_done && obj.next_start_index) {
@@ -362,6 +371,40 @@ window.addEventListener && window.addEventListener('DOMContentLoaded', function(
362371 }
363372 }
364373 }
374+ function getBodySummary(body) {
375+ var lines = body.split('\n');
376+ var isInAuthorHeader = true;
377+ var summary = [];
378+ var lineCount = 0;
379+ for (var index = 0, length = lines.length; index < length; index++) {
380+ var line = lines[index];
381+ if (isInAuthorHeader) {
382+ // '#author line is not search target'
383+ if (line.match(/^#author\(/)) {
384+ // Remove this line from search target
385+ continue;
386+ } else if (line.match(/^#freeze(\W|$)/)) {
387+ continue;
388+ // Still in header
389+ } else {
390+ // Already in body
391+ isInAuthorHeader = false;
392+ }
393+ }
394+ line = line.replace(/^\s+|\s+$/g, '');
395+ if (line.length === 0) continue; // Empty line
396+ if (line.match(/^#\w+/)) continue; // Block-type plugin
397+ if (line.match(/^\/\//)) continue; // Comment
398+ if (line.substr(0, 1) === '*') {
399+ line = line.replace(/\s*\[\#\w+\]$/, ''); // Remove anchor
400+ }
401+ summary.push(line);
402+ if (summary.length >= 10) {
403+ continue;
404+ }
405+ }
406+ return summary.join(' ').substring(0, 150);
407+ }
365408 function removeEncodeHint() {
366409 var form = document.querySelector('form');
367410 if (form && form.encode_hint && (typeof form.encode_hint.removeAttribute === 'function')) {
--- a/skin/tdiary.css
+++ b/skin/tdiary.css
@@ -518,12 +518,19 @@ tr.bugtrack_state_undef td {
518518 }
519519
520520 /* search2.inc.php */
521-input#_plugin_search2_detail:checked ~ ul > pre {
521+input#_plugin_search2_detail:checked ~ ul > div.search-result-detail {
522522 display: block;
523523 }
524-input#_plugin_search2_detail ~ ul > pre {
524+input#_plugin_search2_detail ~ ul > div.search-result-detail {
525525 display: none;
526526 }
527+.search-result-page-summary {
528+ font-size: 70%;
529+ color: gray;
530+ overflow: hidden;
531+ text-overflow: ellipsis;
532+ white-space: nowrap;
533+}
527534
528535 @media print {
529536 img#logo,