This is to solve the annoyance of having to click twice to edit an wikipage from another page: Once on the wikipage's link to get to it, and then again by clicking "edit".

I made a bookmarklet that works with Opera to make it so you can just right-click a link to a page in the wiki, and choose "Edit JSPWiki page", which takes you straight to the edit page. It is so sweet. The best part is that it works with any install of JSPWiki that you are working with, including the mothership here at JSPWiki.org.

First of all, my apologies-- this is only for the Opera web-browser. I'm using v7.2. Similar modifications may be possible in other flexible browsers (probably firefix, probably not IE)-- please list here if you figure out how.


How to implement one-click editing of JSPWiki pages in Opera.#

In the directory Opera7\defaults\menu create a file called something like "my_menu.ini". In this file, you can override Opera's default menus with your own customised ones. It should have the following header:

; Menu specification file for Opera 7.0

[Version]
File Version=2

[Info]
Name=My menu modifs
Description=Personal Opera menu setup
Comments=This file contains only modified items...
Author=YourNameHere
Version=1

Open the file Opera7\default\standard_menu.ini and copy the section entitled "[Link Popup Menu]". This should look something like

[Link Popup Menu]

Item, 67389		= Open link
Item, 53018		= Open link in new page
Item, 53019		= Open link in background page
--------------------1
Item, 54020		= Open link in new window
Item, 67633		= Open link in background window
--------------------2
Item, 50418		= Add link to bookmarks
Item, 50216		= Copy link
Item, 50761		= Save link
Item, 67350		= Download url
--------------------4
Submenu, 22235,		Document Popup Menu

Paste it into the bottom of your my_menu.ini file.

Add the following somewhere in the menu.

Item, "Edit JSPWiki page" = Copy link & Go to page, "javascript: 
	lnk='%c'; 
	indx=lnk.indexOf('Wiki.jsp?page='); 
	if(indx!=-1){ 
		new_lnk=lnk.substring(0,indx)+'Edit.jsp'+lnk.substring(indx+8); 
		document.location.href=new_lnk; 
	} else { 
		indx=lnk.indexOf('wiki/'); 
		if(indx!=-1){ 
			new_lnk=lnk.substring(0,indx)+'Edit.jsp?page='+lnk.substring(indx+5); 
			document.location.href=new_lnk; 
		} else { 
			alert('Can\'t edit this!  It is not a JSPWiki page.'); 
		} 
	} 
"

(NOTE: This all needs to be on ONE LINE! I've chopped it up here only because it was making this wiki page difficult to read.)

Basically, it copies the link (to your system clipboard), which Opera then makes available through '%c'. Then it's just a matter of replacing "Wiki.jsp" (or "wiki/" in the new URL format) with "Edit.jsp".

In mine, I've added it twice, once at the top, and once at the bottom (which has to have a different name) for extreme ease of use. :-) My my_menu.ini file now looks like this:

; Menu specification file for Opera 7.0

[Version]
File Version=2

[Info]
Name=Dan's menu modifs
Description=Personal Opera menu setup
Comments=This file contains only modified items...
Author=Dan
Version=1

[Link Popup Menu]

Item, "Edit JSPWiki page" = Copy link & Go to page, "javascript: 
	lnk='%c'; 
	indx=lnk.indexOf('Wiki.jsp?page='); 
	if(indx!=-1){ 
		new_lnk=lnk.substring(0,indx)+'Edit.jsp'+lnk.substring(indx+8); 
		document.location.href=new_lnk; 
	} else { 
		indx=lnk.indexOf('wiki/'); 
		if(indx!=-1){ 
			new_lnk=lnk.substring(0,indx)+'Edit.jsp?page='+lnk.substring(indx+5); 
			document.location.href=new_lnk; 
		} else { 
			alert('Can\'t edit this!  It is not a JSPWiki page.'); 
		} 
	} 
"
--------------------1
Item, 50418		= Add link to bookmarks
Item, 50216		= Copy link
Item, 50761		= Save link
Item, 67350		= Download url
Item, "Open in IE"	= Copy link & Execute program, "iexplore","%c" 
--------------------2
Item, 67389		= Open link
Item, 53018		= Open link in new page
Item, 53019		= Open link in background page
--------------------3
Item, 54020		= Open link in new window
Item, 67633		= Open link in background window
--------------------4
Submenu, 22235, Document Popup Menu
Item, "Edit JSPWiki page 2" = Copy link & Go to page, "javascript: 
	lnk='%c'; 
	indx=lnk.indexOf('Wiki.jsp?page='); 
	if(indx!=-1){ 
		new_lnk=lnk.substring(0,indx)+'Edit.jsp'+lnk.substring(indx+8); 
		document.location.href=new_lnk; 
	} else { 
		indx=lnk.indexOf('wiki/'); 
		if(indx!=-1){ 
			new_lnk=lnk.substring(0,indx)+'Edit.jsp?page='+lnk.substring(indx+5); 
			document.location.href=new_lnk; 
		} else { 
			alert('Can\'t edit this!  It is not a JSPWiki page.'); 
		} 
	} 
"

Again, the added items need to be ALL ON ONE LINE. I've chopped them up here only because it was making this wiki page difficult to read.)

To enable it, first restart Opera. Then, go to Preferences... Toolbars & Menus. Under "Menu setup" there should be two items. "Opera Standard", and the one you just added. Pick the new one and click Apply. (Note that the Opera Standard is still in effect-- only your new file is used like a patch overtop of it.)

That should be it! Now right-click any wiki-link in JSP wiki, and choose "Edit JSPWiki page".

Voila!

You can also assign nearly the same javascript code to a hot-key (also using the Opera web-browser). I use "e ctrl" (aka ctrl-e), which edits the page you are currently viewing. The only differences are:

  • delete the "Copy link &" part of "Copy link & Go to page,", and
  • replace "lnk='%c';" with "lnk=location.href;".
You won't believe how much easier it is to edit a page with this keyboard-shortcut in place.

-- DanHoward -- feb 24, 2004.


Categorie#

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-15) was last changed on 28-Nov-2005 17:58 by DanHoward