DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:dokubookmark

dokubookmark Plugin

Compatible with DokuWiki

>= 2008-05-05

plugin bookmarklet to submit content to DokuWiki

Last updated on
2011-12-21
Provides
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 blog, bookmark, create, tags

Download dokubookmark.zip
Version 0.6.0
GIT repository http://gareus.org/gitweb/?p=dokubookmark.git

News

  • 0.6.0
    • Use standard editor (instead previously built-in text entry); increases compatibility and interoperability.
    • Removed tagbox functionality; tagentry can provide this functionality.
    • Base support for blogtng: push default tag (currently non-configurable) to blogtng tags field

Usage

dokubookmark offers an easy way to submit new pages to DokuWiki: Simply add the Bookmarklet below to your browser bookmarks.

  1. visit any website (that you may want to bookmark or write about)
  2. [optionally] select some text. (select a single-word: title, select multiple words: description)
  3. activate the “Bookmarklet” → Popup browser window.
  4. [optionally] add a custom description, article, tags or notes.
  5. preview, fill in CAPTCHA (or log-in) and save

This plugin was inspired by the tips section's weblog_bookmarklet article - thanks to Riny.

Setup

Just install the plugin, the default settings will do, but you may want to tweak them to your preferences.

Config

They're documented - use DokuWiki's Configuration panel.

config-key default-value description
default namespace wiki:weblog:@D@ where to save new pages
Namespace Presets Private=weblog:@D@;Public=wik..1) flexible version of the above. allows to specify multiple namespaces and custom templates
Date-time format Y:m_d_His how to format timestamps
Note: timestamps (@D@) can be used for wiki-page names; a colon separates namespaces.
tagbox 1 on/off - show available tags - requires the tag plugin
tabboxtable 1 on/off - if showing tags, put them in a HTML table
wikitemplate 2) the fallback page-template that is used if no other templates have been specified/found

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. Identical to@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.

Notes: Tags are optional (requires the DokuWiki tag plugin). Presets come in handy to quickly change the namespace or apply templates.

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

Bookmarklet

Bookmarklets are smart bookmarks. They usually allow one to perform complex task via a single click (web-browser bookmark-toolbar).

Add a new bookmark in your browser with the Location text below. Adjust the hostname and protocol to match your DokuWiki server's host-name.

javascript:Q=document.selection?document.selection.createRange().text:document.getSelection();void(window.open('http://MY-HOST-NAME/doku.php?do=dokubookmark&te='+escape(Q)+'&ur='+escape(location.href)+'&ti='+escape(document.title),'dokuwikiadd','scrollbars=yes,resizable=yes,toolbars=yes,width=680,height=520,left=210,top=150,status=yes'));

To prevent 'encoding-hell' (hello Russians encodings!) use encodeURI() instead escape(). It guaranteed provide result as UTF-8 string. So, bookmarklet should look like:

javascript:Q=document.selection?document.selection.createRange().text:document.getSelection();void(window.open('http://MY-HOST-NAME/doku.php?do=dokubookmark&te='+encodeURI(Q)+'&ur='+encodeURI(location.href)+'&ti='+encodeURI(document.title),'dokuwikiadd','scrollbars=yes,resizable=yes,toolbars=yes,width=680,height=520,left=210,top=150,status=yes'));

Discussion

Any help to improve this plugin is welcome. Feel free to discuss here or drop us a line, contact info comes with the source.

Background information (JavaScript POSTing to DokuWiki) and a development version can be found here and here. A deployed dokubookmark is online at apps.linuxaudio.org.

–robin & Riny

tip: From version 0.3.7 (to be released) you can include the username in the path, which if combined with the Arctic template and the pagelist plugin, to give every user his own weblog-entry sidebar.

suggestion for future release Option to disable “show up in 'recent changes'” to prevent clutter up. Could be done by marking as “Minor edit” and skip minor edits in “recent changes”

robin suggests to leave the changelog alone and use a customized page-list plugin.

what do you need? “a global changelog without the bookmarks” may translate into a namespace-white/blacklisted changelog or index. Maybe there's an existing solution available, the most close I could find quickly was userhistory, recent and editor.

BTW. I use a patched version of the dir plugin to show ~~META:url=<URL>~~ of each page in a namespace-list (and use ~~META:url=@U@~~ in the bookmark-template). I'm currently pondering how to best integrate this with other modules. The include plugin and friends may also be an option.

The plugin doesn't handle international utf8 characters in title,selection.Change escape() to encodeURI() in bookmarklet ,use utf8_unhtml around line 129 action.php,add (,ENT_COMPAT,'UTF-8') in htmlentities calls @ printForm @ helper.php

psofa email:psofa <dot> <part before dot again> at gmail

Its me again :) The plugin seemed to depend on pages being created for each tag ( i suppose the tag plugin behaved like this at some point ) in order to create the tag table. If you have the cloud plugin you can replace the _gettags() function with

 function _gettags() {
    $tag = plugin_load('helper', 'tag');
    $cloudpl = plugin_load('syntax','cloud');
    $cloud = $cloudpl->_getTagCloud(50, $min, $max, $tag);
    $taglist=array();
    foreach ($cloud as $word => $size) {$taglist[]=$word;};
    return($taglist);
  }

psofa email:psofa <dot> <part before dot again> at gmail

Hi, I'm not a coder so this might seems overkill, but I wrapped the bookmarklet in a firefox custom button with a short-cut key. Following instructions on https://developer.mozilla.org/en/custom_toolbar_button

CustomButton = { 
 
1: function () { 
 
myDoc = window._content.document
mySel = myDoc.selection?myDoc.selection.createRange().text:myDoc.getSelection(); 
myContent = encodeURIComponent(mySel);
myloc = encodeURIComponent(myDoc.location.href);
mytitle=encodeURIComponent(myDoc.title);
 
myparam='scrollbars=yes,resizable=yes,toolbars=yes,width=680,height=520,left=210,top=150,status=yes';
 
myUri = "http://localhost:8800/doku.php?do=dokubookmark&te=" + myContent + '&ur=' + myloc + '&ti=' + mytitle;
 
window.open(myUri,'dokuwikiadd', myparam);
  }, 
 
}

Is there a possibility to add the bookmarked page title in the page name (after the date (@D@))? I tried with @T@ but it includes the url and creates namespaces.

– bandit8876 at gmail

This is great, but I have a hard time to get it working with my own templates; it does load the _template.txt from the default namespace, but switching presets does not load the _template.txt from that particular namespace. Any pointers are welcome.

– Hans Peter Willems

1) , 2)
too long to post here
plugin/dokubookmark.txt · Last modified: 2015-08-28 19:41 by Aleksandr