本wiki的個性化修改

本wiki的系統管理員在安裝DokuWiki時,發現有些功能未如理想,稍作修改。本wiki系統管理員支持開源軟件精神,故特此在這兒公開所有對DokuWiki或附加元件作出的修改。

Dokuwiki版本

2017-02-19a “Frusterick Manners”

語法附加元件

以下是本wiki安裝的語法附加元件:

另外﹐管理員亦自行開發了自動進行異體字轉換的附加元件canonicalchinese

Patch files

以下是本wiki的系統管理員,對DokuWiki作出的修改(patch file):

DokuWiki主程式

  • 加入DokuWiki預設裏欠缺的wiki間互連(interwiki)。
    創建 <dokuwiki_path>/conf/interwiki.local.conf
  • 修改預設CSS
    創建 <dokuwiki_path>/conf/userall.css
  • 使用Javascript改變tag和討論區的排序
    創建 <dokuwiki_path>/conf/userscript.js
  • 修改連結顯示方式:內部連結顯示分類名稱,wiki間互連顯示所連結的wiki名稱。
    patch file: cd <dokuwiki_path>; patch -p1 < <patch file>
    dokuwiki-xhtml.patch
    --- dokuwiki/inc/parser/xhtml.php.orig	2015-03-18 14:49:54.209461889 +0800
    +++ dokuwiki/inc/parser/xhtml.php	2015-03-18 14:52:03.659325511 +0800
    @@ -816,10 +816,10 @@
             }
     
             // default name is based on $id as given
    -        $default = $this->_simpleTitle($id);
    +        $default = $id;
     
             // now first resolve and clean up the $id
    -        resolve_pageid(getNS($ID), $id, $exists, $this->date_at, true);
    +        resolve_pageid(getNS($id), $id, $exists, $this->date_at, true);
     
             $name = $this->_getLinkTitle($name, $default, $isImage, $id, $linktype);
             if(!$isImage) {
  • 修改連結顯示方式:[[somelink]]連往主 namespace,而不是當前頁面的namespace
    patch file: cd <dokuwiki_path>; patch -p1 < <patch file>
    dokuwiki-pageutils.patch
    --- dokuwiki/inc/pageutils.php.orig	2015-03-18 14:54:42.733615088 +0800
    +++ dokuwiki/inc/pageutils.php	2015-03-18 14:55:10.362012523 +0800
    @@ -477,7 +477,7 @@
             $id = implode(':', $result);
         }elseif($ns !== false && strpos($id,':') === false){
             //if link contains no namespace. add current namespace (if any)
    -        $id = $ns.':'.$id;
    +        $id = ':'.$id;
         }
     
         if($clean) $id = cleanID($id);
    • 創建<dokuwiki_path>/conf/lang/zh-tw/lang.php
      lang.php
      <?php
      $lang['qb_code']               = '英文等寬體';
      ?>

Dokubook主題

  • 局部中文化 dokubook:
    • 創建 <dokuwiki_path>/lib/tpl/dokubook/lang/zh-tw/lang.php
      lang.php
      <?php
      $lang['toolbox']    = '工具箱';
      $lang['navigation'] = '導航';
      ?>
    • 創建 <dokuwiki_path>/lib/tpl/dokubook/lang/zh-tw/settings.php (未有中文化管理介面,直接使用英文版)
      settings.php
      <?php
      $lang['sb_pagename'] = "Pagename to use for the navigation";
      $lang['sb_position'] = "Sidebar position";
      $lang['ft_pagename'] = "Pagename to use for the footer";
      $lang['closedwiki']  = "Closed Wiki (Navigation shows only the login form if not logged in)";
      $lang['logo']        = "Path to an image used as logo";
      ?>

colorpicker附加元件

  • patch file: cd <dokuwiki_path>/lib/plugins/colorpicker; patch -p1 < <patch file>
    (https://github.com/gbirke/colorpicker/issues/2)
    script.js.patch
    --- colorpicker/script.js.orig  2014-01-04 18:21:00.224688000 +0800
    +++ colorpicker/script.js   2014-01-04 18:22:02.515250800 +0800
    @@ -28,7 +28,7 @@
         };
       }
     
    -    var $picker              = jQuery('<div class="picker" id="' + id + '"></div>');
    +    var $picker              = jQuery('<div class="picker a11y" id="' + id + '" aria-hidden="true"></div>');
         $picker.css({position:'absolute', 'marginLeft': '-10000px'});
     
         for(var key in list){
  • 創建<dokuwiki_path>/lib/plugins/colorpicker/lang/zh-tw/lang.php
    lang.php
    <?php
    $lang['colorpicker'] = '文字顏色';
    $lang['js']['buttontext'] ='文字';
    ?>
  • 創建<dokuwiki_path>/lib/plugins/colorpicker/lang/zh-tw/settings.php (未有中文化)
    settings.php
    <?php
    $lang['colorscheme'] = 'Color scheme.<br/><span style="font-size:80%">The color name, followed by a an equals sign and a text color name. A background color can be added with a slash after the foreground color.<br/><br/>Example:<br/><pre style="margin:0;padding:5px;font-size:100%;background:#c0c0c0;">Info=green<br/>Attention=black/red</pre></span>';
    ?>
  • 色板設定:
    初音未來=#008080
    鏡音鈴=#ED6F00
    鏡音連=#BFAA15
    巡音流歌=#FF00FF
    Kaito=#0000FF
    Meiko=#FF0000
    Gumi=#008000
    神威樂步=#5F00BD
    Lily=#FF9900
    亞北音留=#000000
    弱音鉑=#808080
    重音Teto=#FF8080
    洛天依=#66CCFF
    言和=#66FFCC
    歌愛雪=#BA0033
    冰山清輝=#000080
    貓村伊呂波=#FF4E00
    龍斗=#7FB80E
    VY1 Mizki=#E54C4C
    VY2 Yuma=#D6006F
    歌手音Piko=#534948
    結月緣=#AE35FF
    蒼姬瑾瑜=#2A5CAA
    兔眠莉音=#800080
    IA=#8567B6
    Cul=#700000
    SeeU=#897B52
    Oliver=#FFCE00

fontsize2附加元件

  • 創建<dokuwiki_path>/lib/plugins/fontsize2/lang/zh-tw/lang.php
    lang.php
    <?php
    /**
     * German language file
     *
     * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
     * @author     Esther Brunner <wikidesign@gmail.com>
     */
     
    // custom language strings for the plugin
    $lang['fs_picker']  = '文字大小';
     
    $lang['fs_xxs']            = 'Tiny Text';
    $lang['fs_xxs_sample']     = 'This is a tiny text';
    $lang['fs_xs']             = 'Very Small Text';
    $lang['fs_xs_sample']      = 'This is a very small text';
    $lang['fs_s']              = 'Small Text';
    $lang['fs_s_sample']       = 'This is a small text';
    $lang['fs_m']              = 'Medium Text (is bigger than default)';
    $lang['fs_m_sample']       = 'This is a medium size text';
    $lang['fs_l']              = 'Large Text';
    $lang['fs_l_sample']       = 'This is a large text';
    $lang['fs_xl']             = 'Very Large Text';
    $lang['fs_xl_sample']      = 'This is a very large text';
    $lang['fs_xxl']            = 'Huge Text';
    $lang['fs_xxl_sample']     = 'This is a huge text';
    $lang['fs_smaller']        = 'Smaller than default text';
    $lang['fs_smaller_sample'] = 'This text is smaller than default text';
    $lang['fs_larger']         = 'Larger than default text';
    $lang['fs_larger_sampel']  = 'This text is larger than default text';
     
     
    //Setup VIM: ex: et ts=2 enc=utf-8 :

hidden附加元件

  • 創建<dokuwiki_path>/lib/plugins/hidden/lang/zh-tw/lang.php
    lang.php
    <?php
    /**
     * English language file
     *
     * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
     * @author     Guillaume Turri <guillaume.turri@gmail.com>
     */
     
    $lang['encoding']              = 'utf-8';
    $lang['direction']             = 'ltr';
    $lang['onHidden']              = 'Click to display ⇲';
    $lang['onVisible']             = 'Click to hide ⇱';
    $lang['edit']                  = 'Edit hidden section';
    $lang['button']                = '隱藏段落';

Pagelist附加元件

  • 改變tag頁面連結顯示方式。
    patch file: cd <dokuwiki_path>/lib/plugins/pagelist; patch -p1 < <patch file>
    (ref: https://github.com/dokufreaks/plugin-pagelist/issues/26)
    helper.php.patch
    --- pagelist.org/helper.php 2012-09-03 10:57:52.765809097 +0800
    +++ pagelist/helper.php 2012-09-03 10:58:00.144807653 +0800
    @@ -324,7 +324,7 @@
     
             // produce output
             $content = '<a href="'.wl($id).($this->page['section'] ? '#'.$this->page['section'] : '').
    -            '" class="'.$class.'" title="'.$id.'">'.$title.'</a>';
    +            '" class="'.$class.'" title="'.$id.'">'.$id.'</a>';
             if ($this->style == 'list') $content = '<ul><li>'.$content.'</li></ul>';
             return $this->_printCell('page', $content);
         }

Tag附加元件

  • 無論與tag同名的條目是否存在,tag 連結均永遠連往頁面清單
    patch file: cd <dokuwiki_path>/lib/plugins/tag; patch -p1 < <patch file>
    helper.php.patch
    --- tag/helper.php.orig     2017-02-02 22:44:34.386799642 +0800
    +++ tag/helper.php  2017-02-02 22:45:15.467440201 +0800
    @@ -130,7 +130,7 @@
             $svtag = $tag;
             $tag_title = str_replace('_', ' ', noNS($tag));
             resolve_pageid($this->namespace, $tag, $exists); // resolve shortcuts
    -        if ($exists) {
    +        /*if ($exists) {
                 $class = 'wikilink1';
                 $url   = wl($tag);
                 if ($conf['useheading']) {
    @@ -138,7 +138,7 @@
                     $heading = p_get_first_heading($tag, false);
                     if ($heading) $tag_title = $heading;
                 }
    -        } else {
    +        } else {*/
                 if ($dynamic) {
                     $pages = $this->getTopic('', 1, $svtag);
                     if (empty($pages)) {
    @@ -159,9 +159,9 @@
                 'title' => hsc($title)
             );
             trigger_event('PLUGIN_TAG_LINK', $link);
    -        $link = '<a href="'.$link['href'].'" class="'.$link['class'].'" title="'.$link['tooltip'].'" rel="tag">'.$link['title'].'</a>';
    +        $link = '<a href="'.$link['href'].'" class="'.$link['class'].'" title="'.$link['tooltip'].'" rel="tag">'.$link['tooltip'].'</a>';
             return $link;
    -    }
    +    //}
     
         /**
          * Returns a list of pages with a certain tag; very similar to ft_backlinks()

Wrap附加元件

  • 加入文字對齊按鈕
    • 下載 http://canto.acgvlyric.org/_upload/wrap_align.zip ,解壓至 <dokuwiki_path>/lib/plugins/wrap/images/toolbar
    • patch file: cd <dokuwiki_path>/lib/plugins/wrap; patch -p1 < <patch file>
      action.php.diff
      diff -ru dokuwiki_plugin_wrap-stable.orig/action.php dokuwiki_plugin_wrap-stable/action.php
      --- dokuwiki_plugin_wrap-stable.orig/action.php 2014-02-04 18:59:07.000000000 +0800
      +++ dokuwiki_plugin_wrap-stable/action.php      2014-06-08 14:22:33.886052654 +0800
      @@ -35,6 +35,34 @@
                   'list' => array(
                       array(
                           'type'   => 'format',
      +                    'title'  => $this->getLang('pleft'),
      +                    'icon'   => '../../plugins/wrap/images/toolbar/pleft.png',
      +                    'open'   => '<WRAP leftalign>\n',
      +                    'close'  => '\n</WRAP>\n',
      +                ),
      +                array(
      +                    'type'   => 'format',
      +                    'title'  => $this->getLang('pright'),
      +                    'icon'   => '../../plugins/wrap/images/toolbar/pright.png',
      +                    'open'   => '<WRAP rightalign>\n',
      +                    'close'  => '\n</WRAP>\n',
      +                ),
      +                array(
      +                    'type'   => 'format',
      +                    'title'  => $this->getLang('pcenter'),
      +                    'icon'   => '../../plugins/wrap/images/toolbar/pcenter.png',
      +                    'open'   => '<WRAP centeralign>\n',
      +                    'close'  => '\n</WRAP>\n',
      +                ),
      +                array(
      +                    'type'   => 'format',
      +                    'title'  => $this->getLang('pjustify'),
      +                    'icon'   => '../../plugins/wrap/images/toolbar/pjustify.png',
      +                    'open'   => '<WRAP justify>\n',
      +                    'close'  => '\n</WRAP>\n',
      +                ),
      +                array(
      +                    'type'   => 'format',
                           'title'  => $this->getLang('column'),
                           'icon'   => '../../plugins/wrap/images/toolbar/column.png',
                           'open'   => '<'.$syntaxDiv.' group>\n<'.$syntaxDiv.' half column>\n',
      diff -ru dokuwiki_plugin_wrap-stable.orig/helper.php dokuwiki_plugin_wrap-stable/helper.php
      --- dokuwiki_plugin_wrap-stable.orig/helper.php 2014-02-04 18:59:07.000000000 +0800
      +++ dokuwiki_plugin_wrap-stable/helper.php      2014-06-08 14:23:09.078548277 +0800
      @@ -44,12 +44,26 @@
                       continue;
                   }
       
      +            //get bgcolor
      +            $token_match = array();
      +            if (preg_match('/bgcolor=(.*)/', $token, $token_match)) {
      +                $attr['bgcolor'] = $token_match[1];
      +                continue;
      +            }
      +
      +            //get color
      +            if (preg_match('/color=(.*)/', $token, $token_match)) {
      +                $attr['color'] = $token_match[1];
      +                continue;
      +            }
      +
                   //get id
                   if (preg_match('/#([A-Za-z0-9_-]+)/', $token)) {
                       $attr['id'] = trim($token,'#');
                       continue;
                   }
       
      +
                   //get classes
                   //restrict token (class names) characters to prevent any malicious data
                   if (preg_match('/[^A-Za-z0-9_-]/',$token)) continue;
      @@ -93,13 +107,17 @@
                   elseif($addClass)  $out .= ' class="'.$addClass.'"';
                   if($attr['id'])    $out .= ' id="'.hsc($attr['id']).'"';
                   // width on spans normally doesn't make much sense, but in the case of floating elements it could be used
      -            if($attr['width']) {
      +            if($attr['width'] || $attr['bgcolor'] || $attr['color']) {
      +                 $out .= ' style="';
                       if (strpos($attr['width'],'%') !== false) {
      -                    $out .= ' style="width: '.hsc($attr['width']).';"';
      +                    $out .= ' width: '.hsc($attr['width']).';';
                       } else {
                           // anything but % should be 100% when the screen gets smaller
      -                    $out .= ' style="width: '.hsc($attr['width']).'; max-width: 100%;"';
      +                    $out .= ' width: '.hsc($attr['width']).'; max-width: 100%;';
                       }
      +                if($attr['bgcolor']) $out .= ' background-color:'.hsc($attr['bgcolor']).'; ';
      +                if($attr['color'])   $out .= ' color:'.hsc($attr['color']).'; ';
      +                $out .= '"';
                   }
                   // only write lang if it's a language in lang2dir.conf
                   if($attr['dir'])   $out .= ' lang="'.$attr['lang'].'" xml:lang="'.$attr['lang'].'" dir="'.$attr['dir'].'"';
      diff -ru dokuwiki_plugin_wrap-stable.orig/lang/en/lang.php dokuwiki_plugin_wrap-stable/lang/en/lang.php
      --- dokuwiki_plugin_wrap-stable.orig/lang/en/lang.php   2014-02-04 18:59:07.000000000 +0800
      +++ dokuwiki_plugin_wrap-stable/lang/en/lang.php        2014-06-08 14:22:33.886052654 +0800
      @@ -17,3 +17,8 @@
       $lang['em']        = 'especially emphasised';
       $lang['hi']        = 'highlighted';
       $lang['lo']        = 'less significant';
      +
      +$lang['pleft']     = 'left align';
      +$lang['pright']    = 'right align';
      +$lang['pcenter']   = 'center align';
      +$lang['pjustify']  = 'justify';
      diff -ru dokuwiki_plugin_wrap-stable.orig/lang/zh-tw/lang.php dokuwiki_plugin_wrap-stable/lang/zh-tw/lang.php
      --- dokuwiki_plugin_wrap-stable.orig/lang/zh-tw/lang.php        2014-02-04 18:59:07.000000000 +0800
      +++ dokuwiki_plugin_wrap-stable/lang/zh-tw/lang.php     2014-06-08 14:22:33.886052654 +0800
      @@ -17,3 +17,8 @@
       $lang['em']        = '特別強調';
       $lang['hi']        = '醒目標記';
       $lang['lo']        = '不重要';
      +
      +$lang['pleft']     = '靠左對齊';
      +$lang['pright']    = '靠右對齊';
      +$lang['pcenter']   = '置中對齊';
      +$lang['pjustify']  = '左右對齊';
  • 修改<dokuwiki_path>/lib/plugins/wrap/lang/zh-tw/lang.php,找出
    $lang['picker']

    一行,並將其值改爲

    進階格式
w/siteconfig.txt · 上一次變更: 2017/02/25 18:44 +0800 由 leeyc0
回到頁頂
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0