A little dominoWiki enhancement: enforcing supported characters in page titles.....

Another minor dominoWiki alteration. If you wanted to enforce the current set of supported characters in a new dominoWiki page you could try making the following alterations.    Bear in mind the original function contains a line which uses a computed text formula and you need to keep that.  So be careful how you make the changes.  Of course you'd back up your old files and test in your development environment first wouldn't you :-;

I've passed the changes onto Ben just in case he isn't already doing this in his 1.2 development!

Add or modify the following in the en-gb-language.js file

var LANG_JS_NEW_PG_PROMPT = "Please provide a title for your new page\nValid characters are abcdefghijklmnopqrstuvwxyz0123456789-_.~ and space." ;

var LANG_JS_INVALID_CHARS_PROMPT = "Your title included some invalid characters.\nValid characters are abcdefghijklmnopqrstuvwxyz0123456789-_.~ and space.";



Replace the createBlankPage() Function in Wiki.js with this one:

/**

* createBlankPage()

*

* Triggered from link in site navigation. Prompts user for

* a page title & then creates blank page in edit mode with

* that title.

*

* Changes:

* Julian Ward 26-Oct-2006: change to accommodate spaces

* Jason Hook 27th September 2007 enforcing the valid characters for a wiki page

*/

function createBlankPage()

{

var choice = prompt(LANG_JS_NEW_PG_PROMPT, "");

// var rgExp = /([^\sabcdefghijklmnopqrstuvwxyz0123456789_.~-])/; // abcdefghijklmnopqrstuvwxyz0123456789-_.~ (this is redundant but it is an alternative regexp)

var rgExp = /([^\s\w.~-])/; // abcdefghijklmnopqrstuvwxyz0123456789-_.~

if (rgExp.test(trim(choice)))

{

 alert(LANG_JS_INVALID_CHARS_PROMPT);
 createBlankPage();

} else

{

if((choice=="") || (choice==null))

{

return;

}

else

{

var pg = trim(choice);

 

if((pg=="") || (pg==null))

{

return;

}

else

{

pg = pg.replace(/ /g, "_"); // Julian's change

document.location = "/<this line contains a computed text formula you need to keep>?openform&page=" + pg;

}

}

}

}

 
Trackbacks
  • Trackbacks are closed for this post.
Comments
  • No comments exist for this post.
Leave a comment

Comments are closed.