MacawSharePointSkinner 1.0.0.1 released
Welcome to the MacawSharePointSkinner. MacawSharePointSkinner is a tool designed to enable non-intrusive modifications to the visual and functional design of SharePoint. The tool can be used for both Windows SharePoint Services 2.0 and for Microsoft Office SharePoint Portal Server 2003. Actually, it can be used for any web site utilizing the ASP.NET technology. Download at http://www.gotdotnet.com/Workspaces/Workspace.aspx?id=3ed68681-ae28-4d33-8c36-403e6af7fa11
One of the major issues that we encounter in the implementation of SharePoint within organizations is that organizations want modifications to the visual and functional design that are almost impossible to implement without a major overhaul of the standard files and templates provided with SharePoint. SharePoint is constructed as a kind of standard product that is best used out of the box. Some design can be applied by specifying themes (for team sites) or by modifying CSS stylesheets (for the portal). The possibilities here are limited however, and changes to the actual HTML that is rendered results in changes to hundreds of the standard files.
When implementing customer requested visual modifications, one of the big problems that we encountered in making extensive modifications to the files and templates delivered with SharePoint was that the rendering of the same HTML is implemented differently by different pages. Some pages contain the actual HTML that is outputted and can be easily modified. Other pages contain server controls that do the rendering of the same HTML. These pages are almost impossible to modify. Another problem is that modifications must often be made to hundreds of pages.
The approach that MacawSharePointSkinner takes is two-fold:
Text Replacements – MacawSharePointSkinner lets SharePoint render the final HTML, and just before this HTML is sent to the browser MacawSharePointSkinner makes the needed modifications to this HTML. This is done in such a way that no modifications are needed to the internal files of SharePoint, so it is non-intrusive. Another advantage is that it will survive service packs (although the output HTML may change in a service pack!) and template modifications.
Url Redirections – MacawSharePointSkinner can translate requested url’s into other url’s. This allows you to redirect standard SharePoint url’s to your own url’s.
MacawSharePointSkinner is implemented as an HttpModule that provides functionality for url replacements and powerful replacements in the HTML output rendered by SharePoint.
I will not describe the inner workings of an HttpModule, for more information have a look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconhttpmodules.asp.
MacawSharePointSkinner is an HttpModule. HttpModules are configured in the web.config of your ASP.NET web site. SharePoint is an ASP.NET web site. The required DLL is installed in the Global Assembly Cache (GAC).
Follow the steps below for installation:
| Step | Action |
| 1 | Deploy the DLL Macaw.SharePoint.Skinner.dll from the Release directory to the GAC by dragging it to the directory c:\windows\assembly using Explorer. |
| 2 | Make a directory to contain the MacawSharePointSkinner configuration file, for example c:\MacawSharePointSkinnerConfig. Copy the files SkinConfig.xml and SharePointSkinner.xsd to this directory. |
| 3 | Open the web.config files of the portal for which you want to enable the MacawSharePointSkinner functionality, and the SharePoint /_layouts virtual directory in NotePad or another text editor. Those files can be found in the virtual directory of the portal (when SharePoint is configured on the default web site, this directory is c:\inetpub\wwwroot), and the directory C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\LAYOUTS\web.config. In step 3-10 the needed changes are described as the bold lines in the boxes. The other lines of the configuration file are there to give you the context where to find the place to do the modifications. |
| 4 | Enable support for an appSettings section: : <configSections> <section name="appSettings" type="System.Configuration.NameValueFileSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <sectionGroup name="SharePoint"> : |
| 5 | Add the appSettings section with the following keys: | MacawSharePointSkinner-ConfigFile | Path of the configuration file. Must be a directory path, not an URL. | | MacawSharePointSkinner-Logging | ‘on’ or ‘off’ to enable or disable debugging information in comments in the page | : </configSections> <appSettings> <!-- MACAW: configuration for MacawSharePointSkinner --> <add key="MacawSharePointSkinner-ConfigFile" value="c:\MacawSharePointSkinnerConfig\SkinConfig.xml"/> <add key="MacawSharePointSkinner-Logging" value="on"/> <!-- MACAW: end of configuration for MacawSharePointSkinner --> </appSettings> <SharePoint> : |
| 6 | Add the MacawSharePointSkinner HttpModule: : <httpModules> <clear /> <add name="OutputCache" type="System.Web.Caching.OutputCacheModule" /> <add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule" /> <!-- <add name="Session" type="System.Web.SessionState.SessionStateModule"/>--> <add name="MacawSharePointSkinner" type="Macaw.SharePoint.Skinner.Skin,Macaw.SharePoint.Skinner, Version=1.0.0.1, Culture=neutral, PublicKeyToken=efcf6ac388b9b555"/> </httpModules> : |
The final step is to modify the MacawSharePointSkinner configuration file SkinConfig.xml.
1.4 Alternative configurations
This section describes some alternative configuration possibilities for the HttpModule dll, and for the used configuration files.
1.4.1 HttpModule dll deployment
The procedure described above deploys the Macaw.SharePoint.Skinner.dll to the global assembly cache. This deployment has the advantage that you only need one step to deploy the assembly and it is available in all virtual directories. Disadvantage is that an IISRESET is needed to activate the DLL.
If you don’t want to deploy Macaw.SharePoint.Skinner.dll to the global assembly cache, you need to deploy it to the following bin directories:
- C:\inetpub\wwwroot\bin (the path to the SharePoint virtual directory)
- C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\ISAPI\BIN (to keep FrontPage working, and have skinning support on the help pages)
- C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\LAYOUTS\BIN (to have skinning enabled on all pages in the ‘/_layouts/’ directory)
1.4.2 Configuration files
It is possible to specify different configuration files for the different virtual directories in their corresponding web.config files. This allows for specific skinning configurations for the SharePoint virtual directory pages and the /_layouts virtual directory pages.
It is possible to specify a file pattern as a configuration file, instead of a single file. So for example if you specify c:\MacawSharePointSkinnerConfig\SkinnerSharePoint*.xml as configuration file in the web.config of the SharePoint virtual directory and c:\MacawSharePointSkinnerConfig\SkinnerLayout*.xml in the web.config of the /_layouts virtual directory, you can have multiple configuration files to define your skinning operations. This is used in large Share Point modification projects where each subproject has its own configuration files. Note however that the configuration files are read in undefined order, so make the configuration files as independent as possible of each other. Especially overlapping URL redirections can lead to unpredictable behavior.
If order of interpretation of configuration files is important, it is also possible to supply multiple configuration files separated by ‘;’ characters. For example: c:\MacawSharePointSkinnerConfig\mefirst.xml; c:\MacawSharePointSkinnerConfig\restoffiles*.xml
Configuration of the MacawSharePointSkinner is done in an XML file named SkinConfig.xml. This file can be found in a directory called c:\MacawSharePointSkinnerConfig or another directory as defined in step 2 of the installation procedure defined in section 2.2. This file can be edited in any text editor like notepad or in a special XML editor.
Within the configuration file regular expressions are used extensively to define match patterns.
The structure of the configuration file is unambiguously defined by the corresponding XSD schema SharePointSkinner.xsd.
In this chapter some configuration examples are given
This section describes the skinning elements that make up the skinning language. The elements are given, and their hierarchy. Between brackets the occurrence count is specified.
| (1) | exactly once |
| (0,1) | optional |
| (0,n) | zero or more times |
| (1,n) | one or more times |
skinner (1)
default-uri-matchtype (0,1)
cache-time (0,1)
parameters (0,1)
parameter (1, n)
urlredirections (0,1)
urlredirection (0,n)
rules (0,1)
rule(0,n)
uris (1)
uri (1,n)
match (0,1)
parameters (0,1)
parameter (1, n)
texts (0,1)
text (0,n)
match (0,1)
parameters (0,1)
parameter (1, n)
blocks (1)
block (1,n)
match (0,1)
replacements (1)
replacement (1,n)
find (1)
replace (1)
Below is a detailed description of the available elements.
| Element | Description |
| Skinner | Root element in the skinning configuration file. |
| default-uri-matchtype | Default way of matching for all match elements for uri. | Type | Name | Req. | Possible values / description | | Attribute | matchtype | No | RegExp|WildCard|Exact, not specifiedàRegExp | Currently only the type RegExp is supported. This is always the initial default value. |
| cache-time | Time to cache the configuration file in seconds. | Type | Name | Req. | Possible values / description | | Attribute | duration | Yes | 0, -1, n | Currently time expiration is not supported. Only the following values are supported: 0: the configuration is reread on every replacement (for testing purposes only) -1: the configuration is never reread. A new initialization happens on IISRESET |
| parameters | Group element for specifying parameters using the parameter element. |
| parameter | Parameter definition that can be used for replacements in other elements like match, find and replace. | Type | Name | Req. | Possible values / description | | Attribute | name | Yes | Name of the parameter | | Value | n.a. | Yes | Value of the parameter | Parameters are replaced in the text of elements when the text {{parametername}} occurs. |
| urlredirections | Group element for specifying url redirections using the urlredirection element. |
| urlredirection | Url redirection definition that specifies how to redirect a matching target url to a destination url. | Type | Name | Req. | Possible values / description | | Attribute | name | Yes | Name of the redirection rule | | Attribute | permanent | No | true|false. If true, redirections are done through an HTTP 301 response. This means an extra roundtrip to the server. Complete Url (http://servername/...) must be specified for the destination. I false, the redirection is done within the same application domain (same virtual directory) | | Attribute | enabled | No | true| false. If true this redirection is used, if not specified redirection is used | Parameters are replaced in the text of elements when the text {{parametername}} occurs. |
| Target | Specifies the expression to match the target uri. | Type | Name | Req. | Possible values / description | | Attribute | matchtype | No | RegExp|Exact, not specifiedàRegExp | | Value | n.a. | Yes | Expression to match. Regular expression match in CDATA section |
|
| destination | Replacement for the matched uri. May contain captures and parameters. | Type | Name | Req. | Possible values / description | | Value | n.a. | Yes | Replacement text. Regular expression replacement in CDATA section |
|
| rules | Group element for specifying rules using the rule element. |
| rule | Skinning is implemented by execution of rules. More than one rule can be defined. When a rule matches, skinning can stop at this rule or it can continue to match next rules. A rule contains two elements: - uris specify the match the requested page must make on uri, text or both
- blocks to specify the replacements to be executed on the page if matching
| Type | Name | Req. | Possible values / description | | Attribute | enabled | No | true| false. If true this rule is used, if not specified rule is used | | |