[Home]WikiPatches/LinkJavaScript

UseModWiki | WikiPatches | RecentChanges | Preferences

The 1.0 release includes a configuration variable $UserHeader which can contain JavaScript and/or META tags. The contents of $UserHeader are added to the HTML header of every wiki page. --CliffordAdams
Patch to include JavaScript source file on every Wiki page.

Patch

In the wiki.pl section
 # Configuration/constant variables:
add the variable $JavaScript
 $FS $FS1 $FS2 $FS3 $CookieName $SiteBase $StyleSheet $JavaScript $NotFoundPg 
In the section
 # == Configuration =====================================================
initialise the variable $JavaScript. If you have a separate ConfigFile? you need to add it there too (see below)
  $JavaScript  = "";              # URL for Javascript source (like "/wiki.js") ##TAB
In routine
 sub GetHtmlHeader {
add the following code, note the next line is not actually part of this patch - but since you are in the area you might as well add the TYPE to the stylesheet link
    $html .= qq(<LINK REL="stylesheet" HREF="$StyleSheet" TYPE="text/css">\n); ##TAB
  if ($JavaScript ne '') { ##TAB
    $html .= qq(<SCRIPT LANGUAGE="JavaScript" SRC="$JavaScript" TYPE="text/javascript">); ##TAB
    $html .= qq(</SCRIPT>\n); ##TAB
  } ##TAB
After the last new line above you can add the following line, to ensure your wiki pages are not cached.
  $html .= qq (<META HTTP-EQUIV="Pragma" CONTENT="no-cache">\n); ##TAB

In your config file - if you use one, add the line (adjusting the URL to suit)

 $JavaScript  = "/wlink/wiki_script.js";              # URL for JavaScript source (like "/wiki.js") #TAB

Comments

Tried this script to implement frames by means of using javascript (at: http://www.koehl.nu/framing.js - DeadLink) but had compilation errors. Should the line with stylesheet be closed (}) or not before the Javascript opens? Dan Koehl


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited September 14, 2009 9:22 pm by JuanmaMP (diff)
Search: