RF Eclectica Wiki

Try to learn something about everything, and everything about something - Thomas Huxley

User Tools

Site Tools


public:computers:dokuwiki_tweaks

02 : Computers

DokuWiki Tweaks

Dokuwiki Timezone

  • I noticed the timestamps on file creation/modification were in UTC
  • I'd rather have “local time” so I don't have to think too hard
  • I used the first option, after successfully testing the second (editing php.ini)
  • I created conf/local.protected.php with
<?php
date_default_timezone_set("Europe/London");
  • I did sudo chown www-data:www-data local.protected.php too, just to be sure
  • All looks good - pages created/modified while in summer time show the time in BST and pages modified in winter time show the time in GMT

Add DW2PDF

  1. To allow export of pages from Wiki → PDF format install plugin dw2pdf
  2. to enable functionality it was necessary to install php-mbstring package on the VPS
    1. sudo apt-get install php-mbstring
  3. sudo service apache2 restart

UPDATE

John Pumford-Green 26/04/23 10:04

removed dw2pdf plugin, it is largely unused and adds pointless bloat.

Increase maximum file size upload for Media Manager

  1. edit php.ini
    1. sudo vi /etc/php/XX/apache2/php.ini
    2. change upload_max_filesize = 2M to upload_max_filesize = 20M
    3. change post_max_size = 2M to post_max_size = 20M
    4. sudo service apache2 restart

Allow any file-type upload

From https://forum.dokuwiki.org/d/3318-allow-upload-of-any-filetype/5

Edit /var/www/html/www/dokuwiki/inc/media.php and comment out :

    // because a temp file was created already
    //if (!preg_match('/\.(' . $regex . ')$/i', $fn)) {
    //    return [$lang['uploadwrong'], -1];
    //}

Acronyms & Abbreviations

I find the underlining and “explanation” of some abbreviations/acronyms by dokuwiki, when rendering a page, to be annoying.

The process is described HERE

To disable this I simply copied the default conf/acronyms.conf to a local version conf/acronyms.local.conf and then edited the local version to remove all the explanations.

# Acronyms.

ACL
AFAICS
AFAIK
AFAIR
API
ASAP
ASCII
BTW
CMS
CSS
DNS
EOF
EOL
EOM
EOT
FAQ
FTP
FOSS
FLOSS
FUD
FYI
GB
GHz
GPL
GUI
HTML
IANAL
IE
IIRC
IMHO
IMO
IOW
IRC
IRL
KISS
LAN
LGPL
LOL
MathML
MB
MHz
MSIE
OMG
OS
OSS
OTOH
PITA
RFC
ROTFL
RTFM
spec
TIA
TL;DR
TOC
URI
URL
W3C
WTF?
WYSIWYG
YMMV

This supresses the annoyance.

John Pumford-Green 30/04/23 13:49

Add folded plugin

make a clickable hide/reveal section with

++++ visible text | hidden text blah blah ++++

e.g.

There is a table here...

Increase TAGCLOUD font size

edit /var/www/html/dokuwiki/lib/plugins/cloud/style.less

increase size factor

/* Size factor. */
@sF: 1.2;

force re-fresh of browser to show new font size.

Keyboard Plugin

  • tweak the size, border and colour

example keys

Ctrl+C

Tweaks

/var/www/html/dokuwiki/lib/plugins/keyboard/all.css

kbd.__keyboard {
  color: #0000ff;
  background-color: #defede;
  text-align: center;
  border-left: 1px solid #cfcfcf;
  border-top: 1px solid #cfcfcf;
  border-right: 3px solid #666666;
  border-bottom: 3px solid #666666;
  -moz-border-radius: 4px 4px 4px 4px;
  padding-left: 3px;
  padding-top: 0px;
  padding-right: 3px;
  padding-bottom: 0px;
  margin-left: 2px;
  margin-right: 2px;
  vertical-align: top;
  font-family: sans-serif;
  white-space: nowrap;
  font-size: 1.2em;
 
}

Dokuwiki Template monospace font

  • 1st for nice rounded boxes around code blocks change the border-radius in the pre,code,samp,kbd section
pre,
code,
samp,
kbd {
    font-family: Consolas, "Andale Mono WT", "Andale Mono", "Bitstream Vera Sans Mono", "Nimbus Mono L", Monaco, "Courier New", monospace;
    /* same font stack should be used for ".dokuwiki table.diff td" in _diff.css */
    font-size: 1em;
    direction: ltr;
    text-align: left;
    background-color: @ini_background_site;
    color: @ini_text;
    box-shadow: inset 0 0 .3em @ini_border;
    border-radius: 5px;
    }
  • the colour of the mono font is the same as general text and doesn't stand out as well as in other templates.
  • edit /var/www/html/dokuwiki/lib/tpl/dokuwiki/css/basic.less with a hex code for a better colour.
  • reset the border radius for mono-blocks (confusingly the CSS calls these code
code {
    color: #c72522;
    font-size: 1.1em;
    padding: 0.1em 0.3em;
    border-radius: 0;
    }
  • edit /var/www/html/dokuwiki/lib/tpl/dokuwiki/tpl_footer.php
  • comment out ( <!-- ///// --> ) the license stanza and the <div> that contains the “buttons”
<?php
/**
 * Template footer, included in the main and detail files
 */
 
// must be run from within DokuWiki
if (!defined('DOKU_INC')) die();
?>
 
<!-- ********** FOOTER ********** -->
 
 
 
<div id="dokuwiki__footer"><div class="pad">
<!--    <?php tpl_license(''); // license text ?> -->
 
<!--    <div class="buttons">
        <?php
            tpl_license('button', true, false, false); // license button, no wrapper
            $target = ($conf['target']['extern']) ? 'target="'.$conf['target']['extern'].'"' : '';
        ?>
        <a href="https://www.dokuwiki.org/donate" title="Donate" <?php echo $target?>><img
            src="<?php echo tpl_basedir(); ?>images/button-donate.gif" width="80" height="15" alt="Donate" /></a>
        <a href="https://php.net" title="Powered by PHP" <?php echo $target?>><img
            src="<?php echo tpl_basedir(); ?>images/button-php.gif" width="80" height="15" alt="Powered by PHP" /></a>
        <a href="//validator.w3.org/check/referer" title="Valid HTML5" <?php echo $target?>><img
            src="<?php echo tpl_basedir(); ?>images/button-html5.png" width="80" height="15" alt="Valid HTML5" /></a>
        <a href="//jigsaw.w3.org/css-validator/check/referer?profile=css3" title="Valid CSS" <?php echo $target?>><img
            src="<?php echo tpl_basedir(); ?>images/button-css.png" width="80" height="15" alt="Valid CSS" /></a>
        <a href="https://dokuwiki.org/" title="Driven by DokuWiki" <?php echo $target?>><img
            src="<?php echo tpl_basedir(); ?>images/button-dw.png" width="80" height="15"
            alt="Driven by DokuWiki" /></a>
    </div>
-->
 
 
</div></div><!-- /footer -->
 
 
<?php
tpl_includeFile('footer.html');
 
 

Bootstrap3 ThemeByNamespace

To force specific bootstrap/bootswatch themes dependant on the namespace

  • enable ThemeByNamespace option
  • create a file in <dokuwiki>/conf called bootstrap3.themes.conf
  • chown www-data:www-data bootstrap3.themes.conf
  • add the required theme/namespace mapping:
# Namespace  Bootswatch Theme
start                   bootswatch/darkly
public                  bootswatch/darkly
public:calculator       bootswatch/slate
public:journal          bootswatch/journal
private                 bootswatch/flatly
playground              bootswatch/united
private:wire2waves      bootswatch/paper
blog                    bootswatch/yeti
  • it seems necessary to disable showThemeSwitcher and to select a default theme to be used outside of any listed in the conf file

Vector / Monobook tweaks

I like the Vector and Monobook templates, very similar feel to Wikipedia

Logout errors with later versions of Dokuwiki

After upgrading Dokuwiki to Igor it became impossible to log out due to a warning

Security Token did not match. Possible CSRF attack.

I initially ignored it but then downgraded back to Hogfather as there seemed to be no fix - other than to use a different template.

I recently upgraded to the latest Dokuwiki (Jack Jackrum), and upgraded all plugins and templates where possible. However the problem with logout with Vector and Monobook re-appeared.

I found there was a fix described on the forum:

https://forum.dokuwiki.org/d/20248-security-token-did-not-match-possible-csrf-attack-cannot-log-out

and the cure is to edit the appropriate line in main.php for each template, as the author seems not to be maintaining these templates any more, at least not the official ones accessed via Dokuwiki's Template/Extension installer. The github repository shows that the fix has been applied to Vector, and a pull request submitted to fix Monobook, the fixes haven't appeared in the official versions.

The FIXME does work, though…

For Vector edit /var/www/html/dokuwiki/lib/tpl/vector/main.php to add , 'sectok' ⇒ getSecurityToken() in the array statement after “do” ⇒ “logout”

 echo  "      <li id=\"pt-logout\"><a href=\"".wl(cleanID(getId()), array("do" => "logout", 'sectok' => getSecurityToken()))."\" rel=\"nofollow\">".hsc($lang["btn_logout"])."</a></li>\n"; //language comes from DokuWiki core

and the same for Monobook

 echo  "          <li id=\"pt-logout\"><a href=\"".wl(cleanID(getId()), array("do" => "logout", 'sectok' => getSecurityToken()))."\" rel=\"nofollow\">".hsc($lang["btn_logout"])."</a></li>\n"; //language comes from DokuWiki core

Monospace font

I found the style applied to monospace text was a little underwhelming.

I found the place to change it:

/var/www/html/dokuwiki/lib/tpl/{vector|monobook}/user/screen.css

add the the following and adjust as needed:

div#content .dokuwiki code {
  font-size: 100%;
  padding-left: 5px;
  padding-right: 5px;
  background-color: #eee;
  color: #00f;
  direction: ltr;
  text-align: left;
}

Remove the default footer buttons by editing {vector|monobook}/user/buttons.php and adding

For Monobook, change to
$_monobook_btns = array();
//delete all (defaults)
$_vector_btns = array();

this suppresses the inclusion of footer buttons from vector/conf/buttons.php

Add just the Dokuwiki and Vector/Monobook Buttons

Edit {vector|monobook}/user/buttons.php

Swap monobook for vector as appropriate
<?php
 
//check if we are running within the DokuWiki environment
if (!defined("DOKU_INC")){
    die();
}
//delete all (defaults)
$_vector_btns = array();  
 
//note: The buttons will be rendered in the order they were defined. Means:
//      first button will be rendered first, last button will be rendered at
//      last.
//DokuWiki button
$_vector_btns["dw"]["img"]      = DOKU_TPL."static/img/button-dw.png";
$_vector_btns["dw"]["href"]     = "https://www.dokuwiki.org/";
$_vector_btns["dw"]["width"]    = 80;
$_vector_btns["dw"]["height"]   = 15;
$_vector_btns["dw"]["title"]    = "DokuWiki";
$_vector_btns["dw"]["nofollow"] = !(cleanID(getID()) === "start");
 
//"vector for DokuWiki" button
$_vector_btns["vecfdw"]["img"]      = DOKU_TPL."static/img/button-vector.png";
$_vector_btns["vecfdw"]["href"]     = "https://www.dokuwiki.org/template:vector";
$_vector_btns["vecfdw"]["width"]    = 80;
$_vector_btns["vecfdw"]["height"]   = 15;
$_vector_btns["vecfdw"]["title"]    = $lang["vector_mdtemplatefordw"];
$_vector_btns["vecfdw"]["nofollow"] = !(cleanID(getID()) === "start");

Mobile Scaling

The layout on a phone isn't too good, and can't be zoomed/scaled.

I found this thread:

https://forum.dokuwiki.org/d/12469-vector-template-doesn-t-display-correctly-on-mobile-devices/6

and applied the comment-out of the line :

//echo "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\" />";

in main.php and mediamanager.php

the page now scales/zooms okay to make it useable on a phone.

Alternative

Using the loadskin plugin

it's possible to switch to the default dokuwiki template when on a mobile device and the vector template when on a computer.

The loadskin plugin seems to lead to problems switching between monobook and vector - the navigation sidebar seems to disappear on one or the other. Not sure where the problem is.

Note Plugin

Various Coloured notes:

<note>
This is my note ! Remember it!!
</note>

<note important>
Warning ! You're about to lose your mind ;-)
</note>

<note tip>
The clues are in the images.
</note>

<note warning>
Beware of the cat when you open the door !!
</note>


++++Note in a Folded section|
<note warning>
Ça fonctionne seulement avec le //div// pas le //span//.
</note>
++++
This is my note ! Remember it!!
Warning ! You're about to lose your mind ;-)
The clues are in the images.
Beware of the cat when you open the door !!

Note in a Folded section

Monobook Tweaks

PDF Export Tab

The dw2pdf plugin provides a button on many templates to trigger export to PDF but not on monobook. It's possible to add a tab to the top of the page, beside the edit etc. tabs, to do the the pdf export function.

add the following code to to monobook/user/tabs.php
//PDF plugin: export tab
if (file_exists(DOKU_PLUGIN."dw2pdf/action.php") &&
    !plugin_isdisabled("dw2pdf")){
    $_monobook_tabs["tab-export-pdf"]["text"] = "pdf export";
    $_monobook_tabs["tab-export-pdf"]["href"] = wl(getID(), array("do" => "export_pdf"), false, "&");
}

Vector Interwiki Icons

The icon shown on interwiki links almost always appears as a small “lock” rather than the correct icon

commenting out the .link-https section in /vector/static/3rd/vector/main-ltr.css stops this :

div#content a.external,
div#content a[href ^="gopher://"] {
        background: url(static/3rd/vector/external-link-ltr-icon.png) center right no-repeat;
        padding: 0 13px 0 0;
}
 
/*
div#content a[href ^="https://"],
.link-https {
        background: url(static/3rd/vector/lock-icon.png) center right no-repeat;
        padding: 0 13px 0 0;
}
*/
 
div#content a[href ^="mailto:"],
.link-mailto {
        background: url(static/3rd/vector/mail-icon.png) center right no-repeat;
        padding: 0 13px 0 0;
}

Page Updated: 08/04/24 15:25 BST

public/computers/dokuwiki_tweaks.txt · Last modified: 08/04/24 15:25 BST by john