Dokubookmark - Website Tagger

This bookmarklet takes the URL and title of the current page in your web-browser, plus any selected text on that page and sends it to DokuWiki to make a new wiki-page about it, using the current date/time as page-name.

The dokubookmark plugin as been released on the DokuWiki website.

News

2011/Dec/20: hatred has jumped aboard and updated the plugin to be compatible with latest dokuwiki. The plugin now uses the standard edit-form and the previously included tagentry plugin is now standalone.

Plugin usage

DokuWiki bookmarklet in action on http://apps.linuxaudio.org

Use this symlink to the latest version: dokubookmark.zip with the Plugin-manager. Development is kept in a git repository: download a snapshot from dokubookmark-devel.tgz.

To install the bookmarklet: drag this link to your bookmarks and edit the hostname afterwards.

Usage:

  • visit any website.
  • [optionally] select some text.
    • select a single-word: it's used as title.
    • select multiple words: page-title is used as title, selection is used as description.
  • click on the Bookmarklet

The browser opens a popup-window connecting to DokuWiki..

  1. [optionally] choose a Preset or simply edit the page-id/name by hand
  2. edit/adjust the wiki-page text
  3. save/preview

Notes: Presets come in handy to quickly change the namespace or apply templates.

Direct-saving needs to be enabled in the configuration, it is identical to DokuWiki save (it even checks sectok) yet it is intended to close the popup-window after a successful save and redirect to edit/preview/draft-merge if some concurrency or permission error occurs.

Plugin Configuration Options

see the DokuWiki built-in help in the configuration panel:

  • default namespace
  • Namespace Presets
  • default, preset and per namespace page templates
  • Date-time format (can be used as wiki-page name)
  • Tagging

Placeholders (replaced in wiki-page-name and wiki-page-template:

  • @T@ - title of the bookmarked page (as shown in browser title bar)
  • @U@ - the URL of the page to bookmark
  • @D@ - timestamp, now
  • @S@ - text that was selected.
  • @F@ - foo - the user who is making the change or 'anonymous'
  • @N@ - title/page-name. Same as @S if it is a single word, otherwise @T@. In both cases the value is stripped of non-alphanumerical characters and space is replaced with underscore.

If a _template.txt exists in the namespace of the page, the default DokuWiki placeholders (@PAGE@, etc ) are also available for those wiki-pages.

Bookmarklet

Add a new bookmark in your browser with the text below. Edit it to match the hostname and protocol to match your DokuWiki server.

This bookmarklet will work with methods (2), (3) and (4) mentioned below.

javascript:Q=document.selection?document.selection.createRange().text:document.getSelection();void(window.open('https://your.hostname/doku.php?do=bookmarklet&te='+encodeURIComponent(Q)+'&ur='+encodeURIComponent(location.href)+'&ti='+encodeURIComponent(document.title),'dokuwikiadd','scrollbars=yes,resizable=yes,toolbars=yes,width=600,height=300,left=200,top=200,status=yes'));

TODO

  • on permission denied - remember session during logon.
    • check permission of default- and preset-namespaces ahead.
    • catch permission denied on direct-save
    • remember+redirect on DokuWiki-preview page (→ standalone plugin/dw-action-hook?)
  • update/improve tagging user-interaction
  • CSS style
  • eventually make a 2nd pluging from lingering/unused code - a DokuWiki generated javascript directly POSTS to preview/edit/save. - use AJAX to choose pagename/preset..

devel background information

There are a few options to semi-automatically interact with DokuWiki using a Bookmarklet.

Calling the bookmark could do either of

  1. directly POST to DokuWiki
  2. have a server generate javascript that makes your browser POST to DokuWiki
  3. load an intermediate page that will submit a POST to DokuWiki with your browser.
  4. interact with a 3rd party server that will submit a POST to DokuWiki from it's server.

Each of those variants has it's merits.

All the examples here are based on Dokuwiki-Weblog, which implements method (4) and thus offers no possibility of authentication (unless provided by a 3rd party)

see bookmarklet for a method that does not require additional PHP code. it's a rather lengthy bookmarklet to directly http-post (1). - The DokuWiki hostname, namespace and wiki-template are all hardcoded in the bookmarklet.

(2) is a workaround for IE, which limits the maximum length of a bookmark. basically it just loads and execute method (1). - however some tasks (fi. filling in date+time and wiki-page-template) can be done by the server when generating the JavaScript.

(3) is an interesting solution because it is very flexible: interact with a bookmark-properties webpage which submits to DokuWiki (either as “fire and forget” save or followed by preview/edit) using the standard DokuWiki authentication mechanism.

 
wiki/dokubookmark.txt · Last modified: 22.10.2012 18:22 by rgareus