AddLinkBookmarklet

Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.


Goal

The goal is to easily mantain a list of URL links (bookmarks) on a wiki page. The problem is normally you have to copy the URL, open the wiki page, "Edit Page" and then paste the URL.

Solution

  • Include Attach:addlink.php.txt to you config.php.
  • Insert the markup [[addlink]] into your page.
  • Save the page. The markup has change into a link Add to Group.Page.
    Note: The markup has changed into +=<Group>.<Page> /chr
  • Bookmark this link
  • Go and surf the web, when you find an interesting page, use the Bookmark
  • Tada... A new window opens, containing the page with the [[addlink]] on it, in editing mode. And the first line is the URL of your interesting page.
chr In Opera, the same window is used, which is fine since you can just make the changes, save and then press back twice.

Discussion

The [[addlink]] command creates a [(approve links) edit diff].That is a link to a javascript program that you can add to your bookmarks. The creation take two steps to avoid further URL substitution: In $DoubleBrackets, [[addlink]] is substituted by addlink:Group.Page, then in $LinkPatterns, this is substituted by the bookmarklet. As a side effect, you can also use addlink:Group.Page to create the bookmarklet for a specific page.

Have a look at the created script. It's pretty easy. It contains the URL of the wikipage and opens it with action=addlink and url=xxx where xxx is the URL of the page that you're surfing on.

The action=addlink is added in addlink.php as well. It calls HandleAddLink, which is basically a copy of HandleEdit except that the url is added in front.

To try it out, see: http://www.knappi.org/index.php/Main/GaesteSeite

chr: I added the section below for easy reference when explaining this plugin to new users. It assumes that someone (the wiki administrator) has already installed this plugin, and also added [[addlink]] to a page, e.g. Misc.Links. A user can now simply follow these instructions, which are supposed to be placed together with [[addlink] on the relevant page.

Easy instructions

This page has a user friendly way to easily add links to it. To install it, add the link below to your bookmarks:

In the future, when you come across a web page you wish to link to from this page, just click the link you bookmarked above. This will automatically insert the address of the web page you were visiting into the edit view of this page. You can then add additional comments if you like and save the results.

See Also

History

22.3.2004Changed bookmarklet-text to +=Group/Page. Changed default behavior to pop up a new window
3.3.2004First version

Comments & Bugs

  • For those with popup killers an alternative way:
    • This is included as default behavior now. Thus I removed it here.
  • chr: I'd like this plugin to add the link either just before or just after the location of the actual [[addlink]]. If that is not possible, I'd like the option of having the link text added last. The reason is that I'd like to have instructions and a title at the top of the page...
    • I'd like to do the same. Is there already a solution? Otherwise I'll try to hack the script a little...
  • thom: I changed the JavaScript a little to also add the page title to a bookmark entry. Additionally I changed the Wiki code which gets generate to use definitions instead of unordered lists (Attach:addlink-thom.php.txt). But I can't figure out how to add an entry at the bottom or a predefined place (e.g. through a $asdf? token) of the page...
    • KAL: should be possible by changing the statement:
      $Text = ':'. $_REQUEST['url'] . " : " . $_REQUEST['name'] . "\n\n".$text;
      using the str_replace() function e.g.
    $Text = str_replace('[[$asdf]]',':'. $_REQUEST['url'] . " : " . $_REQUEST['name'] . "\n\n",$text);
    or using preg_replace()
    and to place it on the buttom the following should do this
    $Text = $text."\n\n:". $_REQUEST['url'] . " : " . $_REQUEST['name'];

Contributors

Copyright

GPL pmwiki-2.3.38 -- Last modified by {{KAL}}

from IP: 85.171.160.186 ip should be disabled by default for security reasons