DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:owncloud

ownCloud Plugin

Compatible with DokuWiki

"Weatherwax", "Binky"

plugin Use your ownCloud instance as media-backend for DokuWiki

Last updated on
2013-06-01
Provides
Syntax, Helper, Action
Repository
Source

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with !experimental, cloud, file, mediamanager, owncloud

This is the first version of the plugin. I tested it extensively, but there may be some bugs. If you use this plugin and find some bugs, please report them using the Bugtracker.

Description and Features

This plugin lets you manage your DokuWiki media files with ownCloud. You also have to install the ownCloud-App (plugin) for DokuWiki, as described below. The media directory (<dokuwiki dir>/data/media) will be included as an external storage into your ownCloud.

Using this plugin, you can handle media files both using the DokuWiki Media Manager or ownCloud. You can upload files via the ownCloud webinterface, webDAV or the sync client. This will also update the media meta files and store revisions.

You can also rename and move files with ownCloud, this will have no effect to the wikipage using this file, because the plugin will store the “fileid” (a unique number for each file in the ownCloud Database). The plugin use his fileid to find the correct file, even if the file got another name.

:!: This plugin reimplements the imagebox plugin.

New DokuWiki features

Some additional features come with this plugin as well. Because for every wikipage the fileid of the used media is saved in the ownCloud database, you can add a “Table of figures” to each wiki page.

You can use a folder name as a link. The content of this folder will be displayed directly on the wiki page (see fig.). You can navigate through sub folders or download files. Filelist

Detail pageThere is an new detail.php included, using this you can display more information about a file. E.g. all versions are displayed and a link to the corresponding file of this revision. Also, all pages using this file are listed.

You can enter the URLs (also as regExp) of external images you want to allow to include into your wiki.

New ownCloud features

The DokuWiki app for ownCloud overwrites some default behaviour of ownCloud in the specified folder for the DokuWiki media files. You can only create files with a valid file name (as configured in DokuWiki: lowercase, deaccent, etc.). Renaming will clean the file name automatically.

You can add a description to each file. This description will be added to the corresponding media meta file.

wiki dropdown in ownCloudEach file has a menu which provides (see fig.)

  • A link to the DokuWiki detail page
  • A link to the DokuWiki Media Manager
  • A popup for wiki pages using this file
  • A popup with all authors of this file
  • A dialog to create a wiki link for this file (nearly the same as the DokuWiki media manager uses)
  • A popup with all versions of this file and a link to the corresponding file revision.

If you hit the delete button, you will be forwarded to the DokuWiki Media Manager. If you have enough rights, you can delete the file there in the Media Manager.

Installation

First you have to install ownCloud1).
Then install the ownCloud App. Just create a folder dokuwiki in <owncloud-path>/apps/ and extract the content of the downloaded archive there.

Refer to “Configure ownCloud” to find out how to configure the app.

After this install this DokuWiki plugin using the Plugin Manager and the download URL above, which points to the latest version of the plugin. Refer to Plugins on how to install plugins manually.

:!: You should also install the authowncloud plugin to have the same usernames in ownCloud and DokuWiki.

Refer to “Configure this plugin” to find out more.

Configuration and Settings

Configure this plugin

You can configure this plugin by using the Configuration Manager. There are 8 config options. You have to set at least the path to your ownCloud files and the URL to your ownCloud instance.

Config optionDescription Default
Path to ownCloud-files This is the directory where you installed ownCloud. E.g. here is the index.php located./var/www/owncloud
URL of the ownCloud-instance The URL which points to you ownCloud instance. http://example.org/owncloud
The indentation of files of a sub folder in the file list to the parent folder (in px). If you display the content of a folder directly on a page, you can navigate through its sub folders. The content of a sub folder is indented by this value. 20
Link authors in file list and history (authorlist plugin required)? If you installed the authorlist plugin, you can link the authors displayed in the file list to their eMail or user homepage. No
Allow external images? (If not selected, use the next two options to specify which URLs are allowed.) If enabled, every external image can be include into a wiki page. Yes
Allow external images from these URLs (it will be tested if the statement exists in the URL. Separate multiple URLs with a comma). If you disabled the last option, you can enter some URLs here, from which images are allowed to be included into wiki page. E.g. if you enter http://upload.wikimedia.org every image of the Wikimedia Commons project can be included.
Regular expressions for URLs from which images should be included (only pattern, no delimiter. Separate multiple expressions with a comma). The same as above, but you can enter regular expression. E.g. http://.*\.staticflickr\.com will allow all images from flickr, because they have URLs like http://.farm1.staticflickr.com/..., http://.farm2.staticflickr.com/..., …
Caption style in Imagebox. Decide how to display the caption in an imagebox. Normal

Configure ownCloud

The ownCloud App was developed from the source of the ownCloud Versions app. It extends its behavior for the needs of the wiki. So at first you have to disable the Versions app. Then download the ownCloud app. Create a folder dokuwiki in <owncloud-path>/apps/ and extract the content of the downloaded archive there. Then enable the app using the app configuration (right top corner → App).

You also need to enable the External Storage Support app. After this change into the admin menu and scroll down to the External Storage section. There you have to create a mountpoint, which must have the name wiki. Choose Local as external storage type. In the third field enter the path to the DokuWiki media directory, This normally looks like <path-to-dokuwiki>/data/media. At least choose the group of users which is allowed to upload files to your wiki.  External storage setup

The wiki folderAfter this your users will find a folder wiki in the root of the ownCloud view. Every file you put inside this folder can be used in your wiki. You can also rename and move it, because internally not the file name will be used but the unique fileid from the ownCloud database.

Change to the admin menu and scroll down to the section DokuWiki app configuration. There you have to set 4 settings:

Config item Description Default
URL to DokuWiki The URL which points to your DokuWiki installation http://example.org/dokuwiki
Path to DokuWiki This is the directory where you installed DokuWiki. E.g. here is the doku.php located./var/www/dokuwiki
Clean page names This has to be exactly the same value as you choose for deaccent (How to clean page names) in your DokuWiki configuration.
:!: If you don't want to clean page names, and you use e.g. umlauts in file names, you have to set fnencode (Method for encoding non-ASCII file names) in your DokuWiki configuration to utf-8
0
Word separator in file names This specifies how to replace spaces in file names. This has to be the same as sepchar (Page name word separator) in your DokuWiki configuration

app config

:!: You should fix one thing inside the ownCloud core files. If you want to overwrite a file, e.g. foo.bar using drag&drop, ownCloud first creates a file like foo (2).bar. If you choose replace, this file will be renamed to the original file. But the DokuWiki app will rename this file to foo_2.bar, because this is a valid file name for DokuWiki. Replacing will work, but there will be continuously a loading icon, because ownCloud will be searching the database for foo (2).bar. To avoid this, open <path-to-owncloud>/lib/helper.php and scroll down to line 616. Replace the content of function buildNotExistingFileName() that it looks like this:

public static function buildNotExistingFileName($path, $filename) {
    require_once('dokuwiki/lib/helper.php');
    return buildNotExistingFileNameWithoutSpaces($path, $filename);
}

Since owncloud 6 please open <path-to-owncloud>/lib/private/helper.php and scroll down to line 635. Replace the content of function buildNotExistingFileName() that it looks like this:

public static function buildNotExistingFileName($path, $filename) {
   $view = \OC\Files\Filesystem::getView();
   require_once('dokuwiki/lib/helper.php');
   return buildNotExistingFileNameWithoutSpaces($path, $filename, $view);
}

Usage and how it works

You can include images and other files with the same syntax as before. E.g. you can write

{{favorites:image.png |My favorite image}}

But if the page is rendered and you have a look at the image URL, you will see something like …/lib/plugins/owncloud/exe?media=wiki:presentation:settings.pdf&fileid=81. The ownCloud plugin got the corresponding fileid from the ownCloud database. If you now rename or move this image, nothing will be changed in the article, because this fileid is unique and always points to this image.

If you save the wiki text and reopen it, you will see that the link has changed to

{{favorites:image.png?fileid=81 |My favorite image}}

You can rename or move the file, even if the cache is purged, the right image is shown.

If you use Create wikilink from the ownCloud webinterface, the fileid will be appended to the wiki link automatically, so you save some database queries.

Display directory content directly on the page

You can also use a folder name in a wikilink. Let's say, you have a directory work:presentation. If you want to display the content of this folder on the page, you can write:

{{work:presentation?direct}}

(note: you have to add ?direct) The result is shown in the image below. You can now navigate through sub folders or open and download files.
The shown content is always up to date, because jQuery and ajax is used.  Filelist

Use the extended detail page

In <path-to-dokuwiki>/lib/plugins/owncloud/tpl you will find a file named detail.php. If you use this file, you get some more information on the detail page of an image or file. The history is displayed directly and every version of a file is linked to the corresponding revision. There is also a section which lists the pages, where this file is used.

To use this detail page, just replace your template detail.php (in <path-to-dokuwiki>/lib/tpl/<template-name>/) with the detail.php from <path-to-dokuwiki>/lib/plugins/owncloud/tpl

Extended detail page

Uppercase filenames

If you use this hack to allow uppercase page and media filename, you must comment out two things in <path-to-ownCloud>/apps/dokuwiki/js/wiki.js

  1. line 89: name = name.toLowerCase(); to //name = name.toLowerCase();
  2. lines 50-53
    /*if(name.toLowerCase() != name){
        OC.Notification.show(t('dokuwiki', 'The file or folder name must be lowercase'));
        return false;
    }*/

Bugs / Feature Requests

Please report bugs or feature requests for this at the ownCloud plugin bug tracker.

There is a different bug tracker for the ownCloud app.

SQLite compatibility

Running Ubuntu 12.04 I was able to set up on my server. However when I make a changean and try to save the dokuwiki page, it hangs permanently.

Actually my owncloud is installed with SQLite because it's just for test. In the plugin in action.php, the following resquest is done :

$helper→dbQuery('INSERT IGNORE INTO *PREFIX*dokuwiki_media_use (fileid, wikipage,wikipage_hash,firstheading) VALUES (?,?,?,?)', array($fileid, $ID, md5($ID), $heading)); }

The problem is : SQLite doesn't use “INSERT IGNORE”, only “INSERT OR IGNORE”

My colleague suggest the following fix for helper.php :

Line 61 replace “public function dbQuery($sql, $params)” by the following

public function dbQuery($sql, $params){
    $dbtype = OC_Config::getValue('dbtype', 'sqlite');
    if($dbtype == 'sqlite' || $dbtype == 'sqlite3') $sql = str_replace('INSERT IGNORE', 'INSERT OR IGNORE', $sql);
    $db = OC_DB::prepare($sql);
    $this->lastQuery = $db->execute($params);
}

And now it works, thanks for this excellent plugin ! =)

Olivier

ChangeLog

This plugin

Associated ownCloud App

Discussion

1)
You can find many other tutorials on the web.
plugin/owncloud.txt · Last modified: 2015-02-13 23:05 by 213.60.165.1