Apple Computer Hardware manual About XSL, JavaScript Example

Page 27

JavaScript Example

The following example JavaScript function adds a header link next to the magnifier button that points to www.apple.com, and changes the “Other Wikis” link to point to www.apple.com:

Event.observe(window, 'load', function() {

//add another header link (to apple.com) by manipulating the DOM

//using script.aculo.us Builder

//we'll just insert it before the search button

if ($('linkSearch')) { $('linkSearch').parentNode.insertBefore(Builder.node('li',

{id:'linkApple'}, [

Builder.node('a', {href:'http://www.apple.com'}, 'apple') ]), $('linkSearch'));

}

//change the Other Wikis link to something else if ($('groups_users_button')) {

$('groups_users_button').down('a').href = 'http://www.apple. com/';

}

});

To use this example JavaScript code, save it as a .js file in this folder: /Library/Application Support/Apple/WikiServer/Themes/theme_name/

About XSL

XSL defines XML document transformation and presentation. For information about XSL, see:

www.w3.org/Style/XSL/

The wiki server uses a set of XSL files located at: /usr/share/wikid/lib/apple_templates/

Because a software update can overwrite files in /usr/share/wikid/lib/ apple_templates/, edit the copies of these XSL files located in:

/Library/Application Support/Apple/WikiServer/Themes/theme_name/

XSL files in this location override XSL files in /usr/share/wikid/lib/apple_templates/.

If a software update overwrites the files in /usr/share/wikid/lib/apple_templates/, you’ll need to manually merge the changed contents of your customized XSL files with the updated XSL files. If you don’t merge the contents, the versions won’t match and an error will occur.

Chapter 1    Customizing How the Wiki Looks

27

Image 27
Contents Mac OS X Server 019-1252/2008-04-24 Contents Managing Wiki Content Preface Getting Additional InformationPreface About This Guide Theme File Structure Overview This chapter describes how to customize a wiki’s appearanceCustomizing How the Wiki Looks Variant Theme File Structure Overview File or Folder Name Purpose Wireframe Theme File Structure OverviewBorders, and positioning for comment entry Creating a Theme Terminal, enter the following commandsWebsite Editing CSS FilesAbout Property List Editor Editing Property List FilesAbout Dictionaries About Property List FilesAbout Property List Keys and Values About StringsHere is an example of an array with multiple strings About ErrorsHere is the sidebars array in a plain text editor Here is an example of an array with a single stringChanging General Theme Settings Key Default Value Possible ValuesDescription All sidebars require the following keys Creating SidebarsUnderstanding the Types of Sidebars Shared KeysStatic Unique Keys Each dictionary entry has the following keysKey Example Value Possible Values Optional or Required Search Unique Keys Calendar Unique Keys Sidebar Name Description Overview of the Example SidebarsTag Unique Keys Recent Activity Unique KeysUsing the Example Sidebars Terminal, enter the following commandTo comment out specific sidebars To this Adding JavaScript and XSL Files To add JavaScript files or XSL files to a themePut JavaScript .js files or XSL .xsl files in this folder About JavaScript Here are some published JavaScript guidesTopic JavaScript Example About XSLCreate a plain text file with the following content Viewing Dynamic XMLTo view context $ sudo serveradmin stop teams sudo serveradmin start teams Attributes Creating a Custom Whitelist About the Custom Whitelist’s Structure Allowing Specific URL ProtocolsAllowing Specific CSS Styles Allowing Specific Html Tags and Attributes To allow specific Html tags and attributesTag Attributes Protocol About the Built-in WhitelistProtocols Allowed in the Built-in Whitelist Built-in whitelist allows these protocolsBuilt-in whitelist allows these Html tags and attributes CSS Styles Allowed in the Built-in WhitelistHtml Tags and Attributes Allowed in the Built-in Whitelist Built-in whitelist allows these CSS stylesNode Pre Cite Span Strong Tbody Tfoot Colspan, rowspan Thead Backing Up the Wiki Server Migrating Wiki Content From Other WebsitesManaging Wiki Content Wiki File Structure Overview File or Folder Name Purpose Manually Editing Raw ContentViewing a Wiki’s Administration Settings To regenerate the index after editing raw wiki contentFor more information about AtomPub, see Key Example Value Description Metadata.plist file includes the following keysTo manually edit wiki administration settings Pageuid Viewing a Page’s MetainformationManaging Attachments