<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Jay Harris is Cpt. LoadTest - JavaScript</title>
    <link>http://www.cptloadtest.com/</link>
    <description>a .net developers blog on improving user experience of humans and coders</description>
    <language>en-us</language>
    <copyright>Jason Harris</copyright>
    <lastBuildDate>Tue, 03 Dec 2013 05:34:25 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.12105.0</generator>
    <managingEditor>jharris@harrisdesigns.com</managingEditor>
    <webMaster>jharris@harrisdesigns.com</webMaster>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Azure Websites are a fantastic method of hosting your own web site. At Arana Software,
we use them often, particularly as test environments for our client projects. We can
quickly spin up a free site that is constantly up-to-date with the latest code using
continuous deployment from the project’s Git repository. Clients are able to see progress
on our development efforts without us having to worry about synchronizing codebases
or managing infrastructure. Since Windows Azure is a Microsoft offering, it is a natural
for handling .NET projects, but JavaScript-based nodejs is also a natural fit and
a first-class citizen on the Azure ecosystem.
</p>
        <h3>Incorporating Grunt
</h3>
        <p>
          <a href="http://gruntjs.com/">Grunt</a> is a JavaScript-based task runner for your
development projects to help you with those repetitive, menial, and mundane tasks
that are necessary for production readiness. This could be running unit tests, compiling
code, image processing, bundling and minification, and more. For our production deployments,
we commonly use Grunt to compile LESS into CSS, CoffeeScript into JavaScript, and
Jade into HTML, taking the code we write and preparing it for browser consumption.
We also use Grunt to optimize these various files for speed through bundling and minification.
The output of this work is done at deployment rather than development, with only the
source code committed into Git and never its optimized output.
</p>
        <h3>Git Deploy and Kudu
</h3>
        <p>
Continuous deployment will automatically update your site with the latest source code
whenever modifications are made to the source repository. This will also work with
Mercurial. There is plenty of existing documentation on <a href="http://www.windowsazure.com/en-us/develop/nodejs/common-tasks/publishing-with-git/">setting
up Git Deploy in Azure</a>, so consider that a prerequisite for this article. However,
Git Deploy, alone, will only take the files as they are in source, and directly deploy
them to the site. If you need to run additional tasks, such as compiling your .NET
source or running Grunt, that is where Kudu comes in.
</p>
        <p>
Kudu is the engine that drives Git deployments in Windows Azure. Untouched, it will
simply synchronize files from Git to your /wwwroot, but it can be easily reconfigured
to execute a deployment command, such as a Windows Command file, a Shell Script, or
a nodejs script. This is enabled through a standardized file named ".deployment".
For Grunt deployment, we are going to execute a Shell Script that will perform npm,
Bower, and Grunt commands in an effort to make our code production-ready. For other
options on .deployment, check out the <a href="https://github.com/projectkudu/kudu/wiki">Kudu
project wiki</a>.
</p>
        <p>
Kudu is also available locally for testing, and to help build out your deployment
scripts. The engine is available as a part of the cross-platform Windows Azure Command
Line Tools, available through npm.
</p>
        <h4>Installing the Azure CLI
</h4>
        <pre class="plain:nocontrols" name="code">npm install azure-cli –-global</pre>
        <p>
We can also use the Azure CLI to generate default Kudu scripts for our nodejs project.
Though we will need to make a few modifications to make the scripts work with Grunt,
it will give us a good start.
</p>
        <pre class="plain:nocontrols" name="code">azure site deploymentscript –-node</pre>
        <p>
This command will generate both our &lt;code&gt;.deployment&lt;/code&gt; and the default
&lt;code&gt;deploy.sh&lt;/code&gt;.
</p>
        <h4>Our .deployment file
</h4>
        <pre class="plain" name="code">[config]
command = bash ./deploy.sh</pre>
        <h3>Customizing deploy.sh for Grunt Deployment
</h3>
        <p>
From <code>.deployment</code>, Kudu will automatically execute our <code>deploy.sh</code> script.
Kudu’s default <code>deploy.sh</code> for a nodejs project will establish the environment
for node and npm as well as some supporting environment variables. It will also include
a "# Deployment" section containing all of the deployment steps. By default,
this will copy your repository contents to your /wwwroot, and then execute <code>npm
install --production</code> against wwwroot, as if installing the application's operating
dependencies. However, under Grunt, we want to execute tasks prior to <code>/wwwroot</code> deployment,
such as executing our Grunt tasks to compile LESS into CSS and CoffeeScript into JavaScript.
By replacing the entire Deployment section with the code below, we instruct Kudu to
perform the following tasks:
</p>
        <ol>
          <li>
Get the latest changes from Git (or Hg). This is done automatically before running
deploy.sh. 
</li>
          <li>
Run <code>npm install</code>, installing all dependencies, including those necessary
for development. 
</li>
          <li>
Optionally run <code>bower install</code>, if bower.json exists. This will update
our client-side JavaScript libraries. 
</li>
          <li>
Optionally run <code>grunt</code>, if Gruntfile.js exists. Below, I have grunt configured
to run the Clean, Common, and Dist tasks, which are LinemanJS's default tasks for
constructing a production-ready build. You can update the script to run whichever
tasks you need, or modify your Gruntfile to set these as the default tasks. 
</li>
          <li>
Finally, sync the contents of the prepared <code>/dist</code> directory to <code>/wwwroot</code>.
It is important to note that this is a KuduSync (similar to RSync), and not just a
copy. We only need to update the files that changed, which includes removing any obsolete
files. 
</li>
        </ol>
        <h4>Our deploy.sh file's Deployment Section
</h4>
        <pre class="plain:firstline[98]" name="code"># Deployment
# ----------

echo Handling node.js grunt deployment.

# 1. Select node version
selectNodeVersion

# 2. Install npm packages
if [ -e "$DEPLOYMENT_SOURCE/package.json" ]; then
  eval $NPM_CMD install
  exitWithMessageOnError "npm failed"
fi

# 3. Install bower packages
if [ -e "$DEPLOYMENT_SOURCE/bower.json" ]; then
  eval $NPM_CMD install bower
  exitWithMessageOnError "installing bower failed"
  ./node_modules/.bin/bower install
  exitWithMessageOnError "bower failed"
fi

# 4. Run grunt
if [ -e "$DEPLOYMENT_SOURCE/Gruntfile.js" ]; then
  eval $NPM_CMD install grunt-cli
  exitWithMessageOnError "installing grunt failed"
  ./node_modules/.bin/grunt --no-color clean common dist
  exitWithMessageOnError "grunt failed"
fi

# 5. KuduSync to Target
"$KUDU_SYNC_CMD" -v 500 -f "$DEPLOYMENT_SOURCE/dist" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg;.deployment;deploy.sh"
exitWithMessageOnError "Kudu Sync to Target failed"</pre>
        <p>
These commands will execute bower and Grunt from local npm installations, rather than
the global space, as Windows Azure does not allow easy access to global installations.
Because bower and Grunt are manually installed based on the existence of bower.json
or Gruntfile.js, they also are not required to be referenced in your own package.json.
Finally, be sure to leave the –no-color flag enabled for Grunt execution, as the Azure
Deployment Logs will stumble when processing the ANSI color codes that are common
on Grunt output.
</p>
        <p>
Assuming that Git Deployment has already been configured, committing these files in
to Git will complete the process. Because the latest changes from Git are pulled before
executing the deployment steps, these two new files (<code>.deployment</code> and <code>deploy.sh</code>)
will be available when Kudu is ready for them.
</p>
        <h3>Troubleshooting
</h3>
        <h4>Long Directory Paths and the 260-Character Path Limit
</h4>
        <p>
Though Azure does a fantastic job of hosting nodejs projects, at the end of the day
Azure is still hosted on the Windows platform, and brings with it Windows limitations.
One of the issues that you will quickly run into under node is the <a href="http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#maxpath">260-Character
Path Limitation</a>. Under nodejs, the dependency tree for a node modules can get
rather deep. And because each dependency module loads up its own dependency modules
under its child folder structure, the folder structure can get rather deep, too. For
example, Lineman requires Testem, which requires Winston, which requires Request;
in the end, the directory tree can lead to ~/node_modules/lineman/node_modules/testem/node_modules/winston/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream,
which combined with the root path structure, can far exceed the 260 limit.
</p>
        <p>
          <i>The Workaround</i>
        </p>
        <p>
To reduce this nesting, make some of these dependencies into first-level dependencies.
With the nodejs dependency model, if a module has already been brought in at a higher
level, it is not repeated in the chain. Thus, if Request is made as a direct dependency
and listed in your project's project.json, it will no longer be nested under Winston,
splitting this single dependency branch in two:
</p>
        <ol>
          <li>
~/node_modules/lineman/node_modules/testem/node_modules/winston 
</li>
          <li>
~/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream 
</li>
        </ol>
        <p>
This is not ideal, but it will solve is a workaround for the Windows file structure
limitations. The element that you must be careful of is with dependency versioning,
as you will need to make sure your <code>package.json</code> references the appropriate
version of your pseudo-dependency; in this case, make sure your <code>package.json</code> references
the same version of Request as is referenced by Winston.
</p>
        <p>
To help find those deep dependencies, use <code>npm list</code>. It will show you
the full graph on the command line, supplying a handy visual indicator.
</p>
        <h4>__dirname vs Process.cwd()
</h4>
        <p>
In the node ecosystem, <code>Process.cwd()</code> is the current working directory
for the node process. There is also a common variable named <code>__dirname</code> that
is created by node; its value is the directory that contained your node script. If
you executed node against a script in the current working directory, then these values
should be the same. Except when they aren't, like in Windows Azure.
</p>
        <p>
In Windows Azure, everything is executed on the system drive, C:. Node and npm live
here, and it appears as though your deployment space does as well. However, this deployment
space is really a mapped directory, coming in from a network share where your files
are persisted. In Azure's node ecosystem, this means that your <code>Process.cwd()</code> is
the C-rooted path, while <code>__dirname</code> is the \\10.whatever-rooted UNC path
to your persisted files. Some Grunt-based tools and plugins (including Lineman) will
fail because that it will reference <code>__dirname</code> files while Grunt's core
is attempting to run tasks with the scope of <code>Process.cwd()</code>; Grunt recognizes
that it's trying to take action on \\10.whatever-rooted files in a C-rooted scope,
and fails because the files are not in a child directory.
</p>
        <p>
          <i>The Workaround</i>
        </p>
        <p>
If you are encountering this issue, reconfigure Grunt to work in the \\10.whatever-rooted
scope. You can do this by setting it's base path to <code>__dirname</code>, overriding
the default <code>Process.cwd()</code>. Within your Gruntfile.js, set the base path
immediately within your module export:
</p>
        <pre class="jscript" name="code">module.exports = function (grunt) {
  grunt.file.setBase(__dirname);
  // Code omitted
}</pre>
        <h4>Unable to find environment variable LINEMAN_MAIN
</h4>
        <p>
If like me, you are using Lineman to build your applications, you will encounter this
issue. Lineman manages Grunt and its configuration, so it prefers that all Grunt tasks
are executed via the Lineman CLI rather than directly executed via the Grunt CLI.
Lineman's Gruntfile.js includes a reference to an environment variable LINEMAN_MAIN,
set by the Lineman CLI, so that Grunt will run under the context of the proper Lineman
installation, which is what causes the failure if Grunt is executed directly.
</p>
        <p>
          <i>The Fix (Because this isn't a hack)</i>
        </p>
        <p>
Your development cycle has been configured to use lineman, so your deployment cycle
should use it, too! Update your <code>deploy.sh</code> Grunt execution to run Lineman
instead of Grunt. Also, since Lineman is referenced in your package.json, we don't
need to install it; it is already there.
</p>
        <p>
Option 1: deploy.sh
</p>
        <pre class="plain:firstline[120]" name="code"># 4. Run grunt
if [ -e "$DEPLOYMENT_SOURCE/Gruntfile.js" ]; then
  ./node_modules/.bin/lineman --no-color grunt clean common dist
  exitWithMessageOnError "lineman failed"
fi</pre>
        <p>
Recommendation: Since Lineman is wrapping Grunt for all of its tasks, consider simplifying <code>lineman
grunt clean common dist</code> into <code>lineman clean build</code>. You will still
need the <code>--no-color</code> flag, so that Grunt will not use ANSI color codes. 
</p>
        <p>
          <i>The Alternate Workaround</i>
        </p>
        <p>
If you don't want to change your <code>deploy.sh</code>—perhaps because you want to
maintain the generic file to handle all things Grunt—then as an alternative you can
update your <code>Gruntfile.js</code> to specify a default value for the missing <code>LINEMAN_MAIN</code> environment
variable. This environment variable is just a string value passed in to node's require
function, so that the right Lineman module can be loaded. Since Lineman is already
included in your <code>package.json</code>, it will already be available in the local <code>/node_modules</code> folder
because of the earlier <code>npm install</code> (deploy.sh, Step #2), and we can pass
'lineman' into <code>require( )</code> to have Grunt load the local Lineman installation.
Lineman will then supply its configuration into Grunt, and the system will proceed
as if you executed Lineman directly.
</p>
        <p>
Option 2: Gruntfile.js
</p>
        <pre class="jscript" name="code">module.exports = function(grunt) {
  grunt.file.setBase(__dirname);
  if (process.env['LINEMAN_MAIN'] === null || process.env['LINEMAN_MAIN'] === undefined) {
    process.env['LINEMAN_MAIN'] = 'lineman';
  }
  require(process.env['LINEMAN_MAIN']).config.grunt.run(grunt);
};</pre>
        <h3>Credits
</h3>
        <p>
Thank you to <a href="http://www.twitter.com/davidebbo">@davidebbo</a>, <a href="http://www.twitter.com/guayan">@guayan</a>, <a href="http://www.twitter.com/amitapl">@amitapl</a>,
and <a href="http://www.twitter.com/dburton">@dburton</a> for helping troubleshoot
Kudu and Grunt Deploy, making this all possible.
</p>
        <h3>Changelog
</h3>
        <p>
2013-12-03: Updated LINEMAN_MAIN Troubleshooting to improve resolution. Rather than
editing deploy.sh to set the environment variable, edit the file to execute Lineman.
This is the proper (and more elegant) solution. [Credit: <a href="http://www.twitter.com/searls">@searls</a>]
</p>
        <div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:9b0ba700-7d7e-41fe-8c1b-8c35f6d0d010" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px">Technorati
Tags: <a href="http://technorati.com/tags/Grunt" rel="tag">Grunt</a>,<a href="http://technorati.com/tags/Lineman" rel="tag">Lineman</a>,<a href="http://technorati.com/tags/Node" rel="tag">Node</a>,<a href="http://technorati.com/tags/Azure" rel="tag">Azure</a>,<a href="http://technorati.com/tags/Git" rel="tag">Git</a></div>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d" />
      </body>
      <title>Git and Grunt Deploy to Windows Azure</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d.aspx</guid>
      <link>http://www.cptloadtest.com/2013/12/03/Git-And-Grunt-Deploy-To-Windows-Azure.aspx</link>
      <pubDate>Tue, 03 Dec 2013 05:34:25 GMT</pubDate>
      <description>&lt;p&gt;
Azure Websites are a fantastic method of hosting your own web site. At Arana Software,
we use them often, particularly as test environments for our client projects. We can
quickly spin up a free site that is constantly up-to-date with the latest code using
continuous deployment from the project’s Git repository. Clients are able to see progress
on our development efforts without us having to worry about synchronizing codebases
or managing infrastructure. Since Windows Azure is a Microsoft offering, it is a natural
for handling .NET projects, but JavaScript-based nodejs is also a natural fit and
a first-class citizen on the Azure ecosystem.
&lt;/p&gt;
&lt;h3&gt;Incorporating Grunt
&lt;/h3&gt;
&lt;p&gt;
&lt;a href="http://gruntjs.com/"&gt;Grunt&lt;/a&gt; is a JavaScript-based task runner for your
development projects to help you with those repetitive, menial, and mundane tasks
that are necessary for production readiness. This could be running unit tests, compiling
code, image processing, bundling and minification, and more. For our production deployments,
we commonly use Grunt to compile LESS into CSS, CoffeeScript into JavaScript, and
Jade into HTML, taking the code we write and preparing it for browser consumption.
We also use Grunt to optimize these various files for speed through bundling and minification.
The output of this work is done at deployment rather than development, with only the
source code committed into Git and never its optimized output.
&lt;/p&gt;
&lt;h3&gt;Git Deploy and Kudu
&lt;/h3&gt;
&lt;p&gt;
Continuous deployment will automatically update your site with the latest source code
whenever modifications are made to the source repository. This will also work with
Mercurial. There is plenty of existing documentation on &lt;a href="http://www.windowsazure.com/en-us/develop/nodejs/common-tasks/publishing-with-git/"&gt;setting
up Git Deploy in Azure&lt;/a&gt;, so consider that a prerequisite for this article. However,
Git Deploy, alone, will only take the files as they are in source, and directly deploy
them to the site. If you need to run additional tasks, such as compiling your .NET
source or running Grunt, that is where Kudu comes in.
&lt;/p&gt;
&lt;p&gt;
Kudu is the engine that drives Git deployments in Windows Azure. Untouched, it will
simply synchronize files from Git to your /wwwroot, but it can be easily reconfigured
to execute a deployment command, such as a Windows Command file, a Shell Script, or
a nodejs script. This is enabled through a standardized file named &amp;quot;.deployment&amp;quot;.
For Grunt deployment, we are going to execute a Shell Script that will perform npm,
Bower, and Grunt commands in an effort to make our code production-ready. For other
options on .deployment, check out the &lt;a href="https://github.com/projectkudu/kudu/wiki"&gt;Kudu
project wiki&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Kudu is also available locally for testing, and to help build out your deployment
scripts. The engine is available as a part of the cross-platform Windows Azure Command
Line Tools, available through npm.
&lt;/p&gt;
&lt;h4&gt;Installing the Azure CLI
&lt;/h4&gt;
&lt;pre class="plain:nocontrols" name="code"&gt;npm install azure-cli –-global&lt;/pre&gt;
&lt;p&gt;
We can also use the Azure CLI to generate default Kudu scripts for our nodejs project.
Though we will need to make a few modifications to make the scripts work with Grunt,
it will give us a good start.
&lt;/p&gt;
&lt;pre class="plain:nocontrols" name="code"&gt;azure site deploymentscript –-node&lt;/pre&gt;
&lt;p&gt;
This command will generate both our &amp;lt;code&amp;gt;.deployment&amp;lt;/code&amp;gt; and the default
&amp;lt;code&amp;gt;deploy.sh&amp;lt;/code&amp;gt;.
&lt;/p&gt;
&lt;h4&gt;Our .deployment file
&lt;/h4&gt;
&lt;pre class="plain" name="code"&gt;[config]
command = bash ./deploy.sh&lt;/pre&gt;
&lt;h3&gt;Customizing deploy.sh for Grunt Deployment
&lt;/h3&gt;
&lt;p&gt;
From &lt;code&gt;.deployment&lt;/code&gt;, Kudu will automatically execute our &lt;code&gt;deploy.sh&lt;/code&gt; script.
Kudu’s default &lt;code&gt;deploy.sh&lt;/code&gt; for a nodejs project will establish the environment
for node and npm as well as some supporting environment variables. It will also include
a &amp;quot;# Deployment&amp;quot; section containing all of the deployment steps. By default,
this will copy your repository contents to your /wwwroot, and then execute &lt;code&gt;npm
install --production&lt;/code&gt; against wwwroot, as if installing the application's operating
dependencies. However, under Grunt, we want to execute tasks prior to &lt;code&gt;/wwwroot&lt;/code&gt; deployment,
such as executing our Grunt tasks to compile LESS into CSS and CoffeeScript into JavaScript.
By replacing the entire Deployment section with the code below, we instruct Kudu to
perform the following tasks:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Get the latest changes from Git (or Hg). This is done automatically before running
deploy.sh. 
&lt;/li&gt;
&lt;li&gt;
Run &lt;code&gt;npm install&lt;/code&gt;, installing all dependencies, including those necessary
for development. 
&lt;/li&gt;
&lt;li&gt;
Optionally run &lt;code&gt;bower install&lt;/code&gt;, if bower.json exists. This will update
our client-side JavaScript libraries. 
&lt;/li&gt;
&lt;li&gt;
Optionally run &lt;code&gt;grunt&lt;/code&gt;, if Gruntfile.js exists. Below, I have grunt configured
to run the Clean, Common, and Dist tasks, which are LinemanJS's default tasks for
constructing a production-ready build. You can update the script to run whichever
tasks you need, or modify your Gruntfile to set these as the default tasks. 
&lt;/li&gt;
&lt;li&gt;
Finally, sync the contents of the prepared &lt;code&gt;/dist&lt;/code&gt; directory to &lt;code&gt;/wwwroot&lt;/code&gt;.
It is important to note that this is a KuduSync (similar to RSync), and not just a
copy. We only need to update the files that changed, which includes removing any obsolete
files. 
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Our deploy.sh file's Deployment Section
&lt;/h4&gt;
&lt;pre class="plain:firstline[98]" name="code"&gt;# Deployment
# ----------

echo Handling node.js grunt deployment.

# 1. Select node version
selectNodeVersion

# 2. Install npm packages
if [ -e &amp;quot;$DEPLOYMENT_SOURCE/package.json&amp;quot; ]; then
  eval $NPM_CMD install
  exitWithMessageOnError &amp;quot;npm failed&amp;quot;
fi

# 3. Install bower packages
if [ -e &amp;quot;$DEPLOYMENT_SOURCE/bower.json&amp;quot; ]; then
  eval $NPM_CMD install bower
  exitWithMessageOnError &amp;quot;installing bower failed&amp;quot;
  ./node_modules/.bin/bower install
  exitWithMessageOnError &amp;quot;bower failed&amp;quot;
fi

# 4. Run grunt
if [ -e &amp;quot;$DEPLOYMENT_SOURCE/Gruntfile.js&amp;quot; ]; then
  eval $NPM_CMD install grunt-cli
  exitWithMessageOnError &amp;quot;installing grunt failed&amp;quot;
  ./node_modules/.bin/grunt --no-color clean common dist
  exitWithMessageOnError &amp;quot;grunt failed&amp;quot;
fi

# 5. KuduSync to Target
&amp;quot;$KUDU_SYNC_CMD&amp;quot; -v 500 -f &amp;quot;$DEPLOYMENT_SOURCE/dist&amp;quot; -t &amp;quot;$DEPLOYMENT_TARGET&amp;quot; -n &amp;quot;$NEXT_MANIFEST_PATH&amp;quot; -p &amp;quot;$PREVIOUS_MANIFEST_PATH&amp;quot; -i &amp;quot;.git;.hg;.deployment;deploy.sh&amp;quot;
exitWithMessageOnError &amp;quot;Kudu Sync to Target failed&amp;quot;&lt;/pre&gt;
&lt;p&gt;
These commands will execute bower and Grunt from local npm installations, rather than
the global space, as Windows Azure does not allow easy access to global installations.
Because bower and Grunt are manually installed based on the existence of bower.json
or Gruntfile.js, they also are not required to be referenced in your own package.json.
Finally, be sure to leave the –no-color flag enabled for Grunt execution, as the Azure
Deployment Logs will stumble when processing the ANSI color codes that are common
on Grunt output.
&lt;/p&gt;
&lt;p&gt;
Assuming that Git Deployment has already been configured, committing these files in
to Git will complete the process. Because the latest changes from Git are pulled before
executing the deployment steps, these two new files (&lt;code&gt;.deployment&lt;/code&gt; and &lt;code&gt;deploy.sh&lt;/code&gt;)
will be available when Kudu is ready for them.
&lt;/p&gt;
&lt;h3&gt;Troubleshooting
&lt;/h3&gt;
&lt;h4&gt;Long Directory Paths and the 260-Character Path Limit
&lt;/h4&gt;
&lt;p&gt;
Though Azure does a fantastic job of hosting nodejs projects, at the end of the day
Azure is still hosted on the Windows platform, and brings with it Windows limitations.
One of the issues that you will quickly run into under node is the &lt;a href="http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#maxpath"&gt;260-Character
Path Limitation&lt;/a&gt;. Under nodejs, the dependency tree for a node modules can get
rather deep. And because each dependency module loads up its own dependency modules
under its child folder structure, the folder structure can get rather deep, too. For
example, Lineman requires Testem, which requires Winston, which requires Request;
in the end, the directory tree can lead to ~/node_modules/lineman/node_modules/testem/node_modules/winston/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream,
which combined with the root path structure, can far exceed the 260 limit.
&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;The Workaround&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
To reduce this nesting, make some of these dependencies into first-level dependencies.
With the nodejs dependency model, if a module has already been brought in at a higher
level, it is not repeated in the chain. Thus, if Request is made as a direct dependency
and listed in your project's project.json, it will no longer be nested under Winston,
splitting this single dependency branch in two:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
~/node_modules/lineman/node_modules/testem/node_modules/winston 
&lt;/li&gt;
&lt;li&gt;
~/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream 
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
This is not ideal, but it will solve is a workaround for the Windows file structure
limitations. The element that you must be careful of is with dependency versioning,
as you will need to make sure your &lt;code&gt;package.json&lt;/code&gt; references the appropriate
version of your pseudo-dependency; in this case, make sure your &lt;code&gt;package.json&lt;/code&gt; references
the same version of Request as is referenced by Winston.
&lt;/p&gt;
&lt;p&gt;
To help find those deep dependencies, use &lt;code&gt;npm list&lt;/code&gt;. It will show you
the full graph on the command line, supplying a handy visual indicator.
&lt;/p&gt;
&lt;h4&gt;__dirname vs Process.cwd()
&lt;/h4&gt;
&lt;p&gt;
In the node ecosystem, &lt;code&gt;Process.cwd()&lt;/code&gt; is the current working directory
for the node process. There is also a common variable named &lt;code&gt;__dirname&lt;/code&gt; that
is created by node; its value is the directory that contained your node script. If
you executed node against a script in the current working directory, then these values
should be the same. Except when they aren't, like in Windows Azure.
&lt;/p&gt;
&lt;p&gt;
In Windows Azure, everything is executed on the system drive, C:. Node and npm live
here, and it appears as though your deployment space does as well. However, this deployment
space is really a mapped directory, coming in from a network share where your files
are persisted. In Azure's node ecosystem, this means that your &lt;code&gt;Process.cwd()&lt;/code&gt; is
the C-rooted path, while &lt;code&gt;__dirname&lt;/code&gt; is the \\10.whatever-rooted UNC path
to your persisted files. Some Grunt-based tools and plugins (including Lineman) will
fail because that it will reference &lt;code&gt;__dirname&lt;/code&gt; files while Grunt's core
is attempting to run tasks with the scope of &lt;code&gt;Process.cwd()&lt;/code&gt;; Grunt recognizes
that it's trying to take action on \\10.whatever-rooted files in a C-rooted scope,
and fails because the files are not in a child directory.
&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;The Workaround&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
If you are encountering this issue, reconfigure Grunt to work in the \\10.whatever-rooted
scope. You can do this by setting it's base path to &lt;code&gt;__dirname&lt;/code&gt;, overriding
the default &lt;code&gt;Process.cwd()&lt;/code&gt;. Within your Gruntfile.js, set the base path
immediately within your module export:
&lt;/p&gt;
&lt;pre class="jscript" name="code"&gt;module.exports = function (grunt) {
  grunt.file.setBase(__dirname);
  // Code omitted
}&lt;/pre&gt;
&lt;h4&gt;Unable to find environment variable LINEMAN_MAIN
&lt;/h4&gt;
&lt;p&gt;
If like me, you are using Lineman to build your applications, you will encounter this
issue. Lineman manages Grunt and its configuration, so it prefers that all Grunt tasks
are executed via the Lineman CLI rather than directly executed via the Grunt CLI.
Lineman's Gruntfile.js includes a reference to an environment variable LINEMAN_MAIN,
set by the Lineman CLI, so that Grunt will run under the context of the proper Lineman
installation, which is what causes the failure if Grunt is executed directly.
&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;The Fix (Because this isn't a hack)&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
Your development cycle has been configured to use lineman, so your deployment cycle
should use it, too! Update your &lt;code&gt;deploy.sh&lt;/code&gt; Grunt execution to run Lineman
instead of Grunt. Also, since Lineman is referenced in your package.json, we don't
need to install it; it is already there.
&lt;/p&gt;
&lt;p&gt;
Option 1: deploy.sh
&lt;/p&gt;
&lt;pre class="plain:firstline[120]" name="code"&gt;# 4. Run grunt
if [ -e &amp;quot;$DEPLOYMENT_SOURCE/Gruntfile.js&amp;quot; ]; then
  ./node_modules/.bin/lineman --no-color grunt clean common dist
  exitWithMessageOnError &amp;quot;lineman failed&amp;quot;
fi&lt;/pre&gt;
&lt;p&gt;
Recommendation: Since Lineman is wrapping Grunt for all of its tasks, consider simplifying &lt;code&gt;lineman
grunt clean common dist&lt;/code&gt; into &lt;code&gt;lineman clean build&lt;/code&gt;. You will still
need the &lt;code&gt;--no-color&lt;/code&gt; flag, so that Grunt will not use ANSI color codes. 
&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;The Alternate Workaround&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
If you don't want to change your &lt;code&gt;deploy.sh&lt;/code&gt;—perhaps because you want to
maintain the generic file to handle all things Grunt—then as an alternative you can
update your &lt;code&gt;Gruntfile.js&lt;/code&gt; to specify a default value for the missing &lt;code&gt;LINEMAN_MAIN&lt;/code&gt; environment
variable. This environment variable is just a string value passed in to node's require
function, so that the right Lineman module can be loaded. Since Lineman is already
included in your &lt;code&gt;package.json&lt;/code&gt;, it will already be available in the local &lt;code&gt;/node_modules&lt;/code&gt; folder
because of the earlier &lt;code&gt;npm install&lt;/code&gt; (deploy.sh, Step #2), and we can pass
'lineman' into &lt;code&gt;require( )&lt;/code&gt; to have Grunt load the local Lineman installation.
Lineman will then supply its configuration into Grunt, and the system will proceed
as if you executed Lineman directly.
&lt;/p&gt;
&lt;p&gt;
Option 2: Gruntfile.js
&lt;/p&gt;
&lt;pre class="jscript" name="code"&gt;module.exports = function(grunt) {
  grunt.file.setBase(__dirname);
  if (process.env['LINEMAN_MAIN'] === null || process.env['LINEMAN_MAIN'] === undefined) {
    process.env['LINEMAN_MAIN'] = 'lineman';
  }
  require(process.env['LINEMAN_MAIN']).config.grunt.run(grunt);
};&lt;/pre&gt;
&lt;h3&gt;Credits
&lt;/h3&gt;
&lt;p&gt;
Thank you to &lt;a href="http://www.twitter.com/davidebbo"&gt;@davidebbo&lt;/a&gt;, &lt;a href="http://www.twitter.com/guayan"&gt;@guayan&lt;/a&gt;, &lt;a href="http://www.twitter.com/amitapl"&gt;@amitapl&lt;/a&gt;,
and &lt;a href="http://www.twitter.com/dburton"&gt;@dburton&lt;/a&gt; for helping troubleshoot
Kudu and Grunt Deploy, making this all possible.
&lt;/p&gt;
&lt;h3&gt;Changelog
&lt;/h3&gt;
&lt;p&gt;
2013-12-03: Updated LINEMAN_MAIN Troubleshooting to improve resolution. Rather than
editing deploy.sh to set the environment variable, edit the file to execute Lineman.
This is the proper (and more elegant) solution. [Credit: &lt;a href="http://www.twitter.com/searls"&gt;@searls&lt;/a&gt;]
&lt;/p&gt;
&lt;div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:9b0ba700-7d7e-41fe-8c1b-8c35f6d0d010" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"&gt;Technorati
Tags: &lt;a href="http://technorati.com/tags/Grunt" rel="tag"&gt;Grunt&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Lineman" rel="tag"&gt;Lineman&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Node" rel="tag"&gt;Node&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Azure" rel="tag"&gt;Azure&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Git" rel="tag"&gt;Git&lt;/a&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d.aspx</comments>
      <category>Azure</category>
      <category>Continuous Integration</category>
      <category>JavaScript</category>
      <category>Programming</category>
      <category>Task Automation</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=fa601dad-9032-43a8-ba67-195baa859d88</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,fa601dad-9032-43a8-ba67-195baa859d88.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,fa601dad-9032-43a8-ba67-195baa859d88.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=fa601dad-9032-43a8-ba67-195baa859d88</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you have read my post on <a title="Blog Post: Misconceptions on JavaScript Plugins and SEO" href="http://www.cptloadtest.com/2009/08/31/Misconceptions-On-JavaScript-Plugins-And-SEO.aspx" target="_blank">Misconceptions
on JavaScript Plugins and SEO</a>, you know that search engines don't do JavaScript.
Though these plugins and libraries (such as one for pulling your latest Twitter Updates)
are nice for adding dynamic content for your users, they are just end-user flare and
add nothing to your SEO rankings. They also put an unnecessary tax on your users,
as each client browser is responsible for independently retrieving the external content;
the time for your page to render is extended by a few seconds as the client must first
download the JS library then make the JSON/AJAX request for your content.
</p>
        <p>
In response to this, I have created <a title="dasControls on CodePlex" href="http://dascontrols.codeplex.com/" target="_blank">dasControls</a>,
a library of custom macros for dasBlog (the blogging engine that powers <a href="http://www.cptloadtest.com">www.cptloadtest.com</a>).
I have started with content that is driven by custom JavaScript libraries and convert
the content and data retrieval into server-side controls. For now, dasControls contains
only a Twitter Status macro, but I intend to add more controls in the coming months.
</p>
        <p>
dasControls [Build 1.0.0.0] : <a title="Download dasControls v1.0" href="http://dascontrols.codeplex.com/Release/ProjectReleases.aspx" target="_blank">Download</a> | <a title="dasControls on CodePlex" href="http://dascontrols.codeplex.com/" target="_blank">Project
Page</a></p>
        <h3>dasControls TwitterStatus Macro
</h3>
        <p>
The TwitterStatus macro uses server-side retrieval of your Twitter data, eliminating
all client-side JavaScript calls for your tweets. By placing the Twitter request on
the server, the data is also available to any search engines that index your page.
Additionally, data is cached on the server, and new updates are retrieved based on
the polling interval you specify. When using real-time client-side JavaScript calls,
there is a 2-5 second delay for your end-users while the data is retrieved from Twitter;
by caching the data on the local server, this delay is eliminated, and the content
for each user is delivered from the local cache, lightening the load for the end-user
while avoiding an undue burden for high-traffic sites.
</p>
        <p>
          <strong>Macro Name:</strong> TwitterStatus 
<br /><strong>Macro Syntax:</strong> &lt;% TwitterStatus("user name"[, number
of tweets[, polling interval]])|dasControls %&gt;
</p>
        <ul>
          <li>
            <strong>User Name</strong> : String. Your Twitter handle. 
</li>
          <li>
            <strong>Number of Tweets</strong> : Integer. The number of tweets to retrieve and
display. [default: 10] 
</li>
          <li>
            <strong>Polling Interval </strong>: Integer. The number of minutes between each Twitter
retrieval. [default: 5] 
</li>
        </ul>
        <p>
          <strong>Relevant CSS:</strong>
        </p>
        <ul>
          <li>
            <strong>TwitterStatusItem</strong> : CSS class given to each Tweet, rendered as a
DIV. 
</li>
          <li>
            <strong>TwitterStatusTimestamp</strong> : CSS class given to each Tweet's timestamp
("32 minutes ago"), rendered as an inline SPAN within each Tweet element. 
</li>
        </ul>
        <h4>Using the Macro within a dasBlog Template
</h4>
        <p>
This macro is for use in the dasBlog HomeTemplate. The macro works just like any out-of-the
box macro, except that you must also include the alias specified within dasControls
entry the web.config (the value of the "macro" attribute). Your twitter
handle is required, though you can also optionally include the number of Tweets to
pull from Twitter (default: 10) and the number of minutes between each Twitter data
request (default: 5). Because everything happens on the server, there is no need to
include any of the Twitter JSON JavaScript libraries or HTML markup.
</p>
        <pre>&lt;% TwitterStatus("jayharris", 6, 5)|dasControls %&gt;</pre>
        <h3>Installation and Setup of dasControls
</h3>
        <p>
Download dasControls, extract the assembly into your dasBlog 'bin' directory.
</p>
        <p>
dasControls [Build 1.0.0.0] : <a title="Download dasControls v1.0" href="http://dascontrols.codeplex.com/Release/ProjectReleases.aspx" target="_blank">Download</a> | <a title="dasControls on CodePlex" href="http://dascontrols.codeplex.com/" target="_blank">Project
Page</a></p>
        <p>
Enable Custom Macros within your dasBlog installation, and add the Twitter macro to
your list of Custom Macros. 
<br />
First, ensure that the &lt;newtelligence.DasBlog.Macros&gt; section exists within
your web.config:
</p>
        <pre class="xml:nocontrols" name="code">&lt;newtelligence.DasBlog.Macros&gt;
  &lt;!-- Other Macro Libraries --&gt;
&lt;/newtelligence.DasBlog.Macros&gt;</pre>
        <p>
Second, ensure that the Macros Configuration Section is defined in to your web.config
&lt;configSections&gt;:
</p>
        <pre class="xml:nocontrols" name="code">&lt;configSections&gt;
  &lt;!—Other Configuration Sections --&gt;
  &lt;section requirePermission="false" name="newtelligence.DasBlog.Macros"
    type="newtelligence.DasBlog.Web.Core.MacroSectionHandler,
      newtelligence.DasBlog.Web.Core" /&gt;
&lt;/configSections&gt;</pre>
        <p>
Third, add the dasControls library entry to the dasBlog Macros section:
</p>
        <pre class="xml:nocontrols" name="code">&lt;newtelligence.DasBlog.Macros&gt;
  &lt;add macro="dasControls"
    type="HarrisDesigns.Controls.dasBlogControls.Macros,
      HarrisDesigns.Controls.dasBlogControls"/&gt;
&lt;/newtelligence.DasBlog.Macros&gt;</pre>
        <h4>
        </h4>
        <h3>Roadmap for dasControls
</h3>
        <p>
In the upcoming weeks and months, I plan on adding additional macros to the dasControls
library, including Delicious, Google Reader's Shared Items, and Facebook. If you're
interested in any others, or have any ideas, please let me know.
</p>
        <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:238d54f0-5dde-4a71-b7ed-b73b8f647b47" class="wlWriterEditableSmartContent">Technorati
Tags: <a href="http://technorati.com/tags/dasBlog" rel="tag">dasBlog</a>,<a href="http://technorati.com/tags/dasControls" rel="tag">dasControls</a>,<a href="http://technorati.com/tags/Open+Source" rel="tag">Open
Source</a>,<a href="http://technorati.com/tags/CodePlex" rel="tag">CodePlex</a>,<a href="http://technorati.com/tags/SEO" rel="tag">SEO</a>,<a href="http://technorati.com/tags/Twitter" rel="tag">Twitter</a></div>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=fa601dad-9032-43a8-ba67-195baa859d88" />
      </body>
      <title>dasControls v1.0, a Twitter Status Macro for dasBlog</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,fa601dad-9032-43a8-ba67-195baa859d88.aspx</guid>
      <link>http://www.cptloadtest.com/2009/10/01/dasControls-V10-A-Twitter-Status-Macro-For-DasBlog.aspx</link>
      <pubDate>Thu, 01 Oct 2009 02:33:55 GMT</pubDate>
      <description>&lt;p&gt;
If you have read my post on &lt;a title="Blog Post: Misconceptions on JavaScript Plugins and SEO" href="http://www.cptloadtest.com/2009/08/31/Misconceptions-On-JavaScript-Plugins-And-SEO.aspx" target="_blank"&gt;Misconceptions
on JavaScript Plugins and SEO&lt;/a&gt;, you know that search engines don't do JavaScript.
Though these plugins and libraries (such as one for pulling your latest Twitter Updates)
are nice for adding dynamic content for your users, they are just end-user flare and
add nothing to your SEO rankings. They also put an unnecessary tax on your users,
as each client browser is responsible for independently retrieving the external content;
the time for your page to render is extended by a few seconds as the client must first
download the JS library then make the JSON/AJAX request for your content.
&lt;/p&gt;
&lt;p&gt;
In response to this, I have created &lt;a title="dasControls on CodePlex" href="http://dascontrols.codeplex.com/" target="_blank"&gt;dasControls&lt;/a&gt;,
a library of custom macros for dasBlog (the blogging engine that powers &lt;a href="http://www.cptloadtest.com"&gt;www.cptloadtest.com&lt;/a&gt;).
I have started with content that is driven by custom JavaScript libraries and convert
the content and data retrieval into server-side controls. For now, dasControls contains
only a Twitter Status macro, but I intend to add more controls in the coming months.
&lt;/p&gt;
&lt;p&gt;
dasControls [Build 1.0.0.0] : &lt;a title="Download dasControls v1.0" href="http://dascontrols.codeplex.com/Release/ProjectReleases.aspx" target="_blank"&gt;Download&lt;/a&gt; | &lt;a title="dasControls on CodePlex" href="http://dascontrols.codeplex.com/" target="_blank"&gt;Project
Page&lt;/a&gt;
&lt;/p&gt;
&lt;h3&gt;dasControls TwitterStatus Macro
&lt;/h3&gt;
&lt;p&gt;
The TwitterStatus macro uses server-side retrieval of your Twitter data, eliminating
all client-side JavaScript calls for your tweets. By placing the Twitter request on
the server, the data is also available to any search engines that index your page.
Additionally, data is cached on the server, and new updates are retrieved based on
the polling interval you specify. When using real-time client-side JavaScript calls,
there is a 2-5 second delay for your end-users while the data is retrieved from Twitter;
by caching the data on the local server, this delay is eliminated, and the content
for each user is delivered from the local cache, lightening the load for the end-user
while avoiding an undue burden for high-traffic sites.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Macro Name:&lt;/strong&gt; TwitterStatus 
&lt;br /&gt;
&lt;strong&gt;Macro Syntax:&lt;/strong&gt; &amp;lt;% TwitterStatus(&amp;quot;user name&amp;quot;[, number
of tweets[, polling interval]])|dasControls %&amp;gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;User Name&lt;/strong&gt; : String. Your Twitter handle. 
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Number of Tweets&lt;/strong&gt; : Integer. The number of tweets to retrieve and
display. [default: 10] 
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Polling Interval &lt;/strong&gt;: Integer. The number of minutes between each Twitter
retrieval. [default: 5] 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;strong&gt;Relevant CSS:&lt;/strong&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TwitterStatusItem&lt;/strong&gt; : CSS class given to each Tweet, rendered as a
DIV. 
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TwitterStatusTimestamp&lt;/strong&gt; : CSS class given to each Tweet's timestamp
(&amp;quot;32 minutes ago&amp;quot;), rendered as an inline SPAN within each Tweet element. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Using the Macro within a dasBlog Template
&lt;/h4&gt;
&lt;p&gt;
This macro is for use in the dasBlog HomeTemplate. The macro works just like any out-of-the
box macro, except that you must also include the alias specified within dasControls
entry the web.config (the value of the &amp;quot;macro&amp;quot; attribute). Your twitter
handle is required, though you can also optionally include the number of Tweets to
pull from Twitter (default: 10) and the number of minutes between each Twitter data
request (default: 5). Because everything happens on the server, there is no need to
include any of the Twitter JSON JavaScript libraries or HTML markup.
&lt;/p&gt;
&lt;pre&gt;&amp;lt;% TwitterStatus(&amp;quot;jayharris&amp;quot;, 6, 5)|dasControls %&amp;gt;&lt;/pre&gt;
&lt;h3&gt;Installation and Setup of dasControls
&lt;/h3&gt;
&lt;p&gt;
Download dasControls, extract the assembly into your dasBlog 'bin' directory.
&lt;/p&gt;
&lt;p&gt;
dasControls [Build 1.0.0.0] : &lt;a title="Download dasControls v1.0" href="http://dascontrols.codeplex.com/Release/ProjectReleases.aspx" target="_blank"&gt;Download&lt;/a&gt; | &lt;a title="dasControls on CodePlex" href="http://dascontrols.codeplex.com/" target="_blank"&gt;Project
Page&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Enable Custom Macros within your dasBlog installation, and add the Twitter macro to
your list of Custom Macros. 
&lt;br /&gt;
First, ensure that the &amp;lt;newtelligence.DasBlog.Macros&amp;gt; section exists within
your web.config:
&lt;/p&gt;
&lt;pre class="xml:nocontrols" name="code"&gt;&amp;lt;newtelligence.DasBlog.Macros&amp;gt;
  &amp;lt;!-- Other Macro Libraries --&amp;gt;
&amp;lt;/newtelligence.DasBlog.Macros&amp;gt;&lt;/pre&gt;
&lt;p&gt;
Second, ensure that the Macros Configuration Section is defined in to your web.config
&amp;lt;configSections&amp;gt;:
&lt;/p&gt;
&lt;pre class="xml:nocontrols" name="code"&gt;&amp;lt;configSections&amp;gt;
  &amp;lt;!—Other Configuration Sections --&amp;gt;
  &amp;lt;section requirePermission=&amp;quot;false&amp;quot; name=&amp;quot;newtelligence.DasBlog.Macros&amp;quot;
    type=&amp;quot;newtelligence.DasBlog.Web.Core.MacroSectionHandler,
      newtelligence.DasBlog.Web.Core&amp;quot; /&amp;gt;
&amp;lt;/configSections&amp;gt;&lt;/pre&gt;
&lt;p&gt;
Third, add the dasControls library entry to the dasBlog Macros section:
&lt;/p&gt;
&lt;pre class="xml:nocontrols" name="code"&gt;&amp;lt;newtelligence.DasBlog.Macros&amp;gt;
  &amp;lt;add macro=&amp;quot;dasControls&amp;quot;
    type=&amp;quot;HarrisDesigns.Controls.dasBlogControls.Macros,
      HarrisDesigns.Controls.dasBlogControls&amp;quot;/&amp;gt;
&amp;lt;/newtelligence.DasBlog.Macros&amp;gt;&lt;/pre&gt;
&lt;h4&gt;
&lt;/h4&gt;
&lt;h3&gt;Roadmap for dasControls
&lt;/h3&gt;
&lt;p&gt;
In the upcoming weeks and months, I plan on adding additional macros to the dasControls
library, including Delicious, Google Reader's Shared Items, and Facebook. If you're
interested in any others, or have any ideas, please let me know.
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:238d54f0-5dde-4a71-b7ed-b73b8f647b47" class="wlWriterEditableSmartContent"&gt;Technorati
Tags: &lt;a href="http://technorati.com/tags/dasBlog" rel="tag"&gt;dasBlog&lt;/a&gt;,&lt;a href="http://technorati.com/tags/dasControls" rel="tag"&gt;dasControls&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Open+Source" rel="tag"&gt;Open
Source&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CodePlex" rel="tag"&gt;CodePlex&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SEO" rel="tag"&gt;SEO&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Twitter" rel="tag"&gt;Twitter&lt;/a&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=fa601dad-9032-43a8-ba67-195baa859d88" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,fa601dad-9032-43a8-ba67-195baa859d88.aspx</comments>
      <category>Blogging</category>
      <category>dasControls</category>
      <category>JavaScript</category>
      <category>SEO</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=88fb8162-b06b-4df8-91ef-c2aefe0e1b8f</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,88fb8162-b06b-4df8-91ef-c2aefe0e1b8f.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,88fb8162-b06b-4df8-91ef-c2aefe0e1b8f.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=88fb8162-b06b-4df8-91ef-c2aefe0e1b8f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Search Engine Optimization is high on the radar, right now. Whether it be the quest
for the first Coupon site in Bing, the highest Cosmetics site on Google, or the top-ranked
"Jay Harris" on every search engine, the war is waged daily throughout the
internet. For companies, it's the next sale. For people, it's the next job. Dollars
are on the line in a never-ending battle for supremacy.
</p>
        <p>
One of the contributing factors in your Search Engine Ranking is Content. Fresh, new
content brings more search engine crawls. More crawls contributes to higher rankings.
Search engines like sites that are constantly providing new content; it lets the engine
know that the site is not dead or abandoned. And though this new content idea works
out well for the New York Times and CNN, not everyone has a team of staff writers
who are paid to constantly produce new content. So we shortcut. We don't so much have
to have new content as long as we make Google think we have new content. There are
hundreds if not thousands of JavaScript plugins out there to provide fresh content
to our readers, ranging from Picasa photos, to Twitter updates, to AdWords, to Microsoft
Gamercard tags. But I have to let you in on a little secret:
</p>
        <p>
JavaScript Plugins do nothing for SEO. 
<br />
Nothing. 
<br />
Search engine spiders don't do JavaScript.
</p>
        <p>
"This must be a lie. When I look at my site, I see my new photos, or my new tweets,
or my new Achievement Points; why don't the spiders see it, too?" Well, it's
true. Google Spiders, and most other Search Engine Spiders, <a title="Google Webmaster Guidelines: Search Engine spiders do not execute JavaScript" href="http://www.google.com/support/webmasters/bin/answer.py?hl=en&amp;answer=35769#2" target="_blank">don't
do JavaScript</a>, which is why JS provides no SEO contribution; spiders do not index
what they do not see. A look through your traffic monitor, like Google Analytics,
will often show a disparity between logged traffic and what is actually accounted
for in Web Server logs. Analytics, a JavaScript-based traffic monitor, only logs about
40% of the total traffic to this site (excluding traffic to the RSS feed), which means
that the other 60% of my visitors have JavaScript disabled. A JavaScript Disabled
on 60% of all browsers seems like a ridiculously high percentage unless you consider
that Spiders and Bots do not execute JavaScript.
</p>
        <p>
Just like Google doesn't see the pretty layout from your stylesheet, Google also doesn't
see the dynamic content from your JavaScript. Pulling down HTML, (since it is all
just text, anyway) is easy; there's not even a lot of overhead associated with parsing
that HTML. But add in some JavaScript, and suddenly there's a lot more effort involved
in crawling your page, especially since there is a lot of bad JavaScript out there.
So search engines just check what has been written into your HTML. They read the the
URL, the keywords and META description, but only the content as rendered by the server.
JavaScript is not touched, and JavaScript-based content is not indexed.
</p>
        <p>
So how do you get around this? How do you get this SEO boost, since JavaScript isn't
an available option?
</p>
        <p>
Use plug-ins and utilities that pull your dynamic data server-side, rather than client-side.
Create a custom WebControl that will download and parse your latest Twitter updates.
Create a dasBlog macro to create your Microsoft Gamertag. By putting this responsibility
on the server, not only will you make life easier on your end user (one less JavaScript
library to download), but you also make this new content available to indexing engines,
which can only help your Google Juice.
</p>
        <h4>Update:
</h4>
        <p>
I've been working on a set of macros for dasBlog to start pulling my dynamic content
retrievals to the server. Keep an eye out over the next couple of days for the release
of my first macro, a Twitter Status dasBlog macro that will replace the need for the
Twitter JS libraries on your site.
</p>
        <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:aac5652b-95d9-407d-8780-9361eae9b5de" class="wlWriterEditableSmartContent">Technorati
Tags: <a href="http://technorati.com/tags/JavaScript" rel="tag">JavaScript</a>,<a href="http://technorati.com/tags/SEO" rel="tag">SEO</a>,<a href="http://technorati.com/tags/Twitter" rel="tag">Twitter</a></div>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=88fb8162-b06b-4df8-91ef-c2aefe0e1b8f" />
      </body>
      <title>Misconceptions on JavaScript Plugins and SEO</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,88fb8162-b06b-4df8-91ef-c2aefe0e1b8f.aspx</guid>
      <link>http://www.cptloadtest.com/2009/08/31/Misconceptions-On-JavaScript-Plugins-And-SEO.aspx</link>
      <pubDate>Mon, 31 Aug 2009 12:47:29 GMT</pubDate>
      <description>&lt;p&gt;
Search Engine Optimization is high on the radar, right now. Whether it be the quest
for the first Coupon site in Bing, the highest Cosmetics site on Google, or the top-ranked
&amp;quot;Jay Harris&amp;quot; on every search engine, the war is waged daily throughout the
internet. For companies, it's the next sale. For people, it's the next job. Dollars
are on the line in a never-ending battle for supremacy.
&lt;/p&gt;
&lt;p&gt;
One of the contributing factors in your Search Engine Ranking is Content. Fresh, new
content brings more search engine crawls. More crawls contributes to higher rankings.
Search engines like sites that are constantly providing new content; it lets the engine
know that the site is not dead or abandoned. And though this new content idea works
out well for the New York Times and CNN, not everyone has a team of staff writers
who are paid to constantly produce new content. So we shortcut. We don't so much have
to have new content as long as we make Google think we have new content. There are
hundreds if not thousands of JavaScript plugins out there to provide fresh content
to our readers, ranging from Picasa photos, to Twitter updates, to AdWords, to Microsoft
Gamercard tags. But I have to let you in on a little secret:
&lt;/p&gt;
&lt;p&gt;
JavaScript Plugins do nothing for SEO. 
&lt;br /&gt;
Nothing. 
&lt;br /&gt;
Search engine spiders don't do JavaScript.
&lt;/p&gt;
&lt;p&gt;
&amp;quot;This must be a lie. When I look at my site, I see my new photos, or my new tweets,
or my new Achievement Points; why don't the spiders see it, too?&amp;quot; Well, it's
true. Google Spiders, and most other Search Engine Spiders, &lt;a title="Google Webmaster Guidelines: Search Engine spiders do not execute JavaScript" href="http://www.google.com/support/webmasters/bin/answer.py?hl=en&amp;amp;answer=35769#2" target="_blank"&gt;don't
do JavaScript&lt;/a&gt;, which is why JS provides no SEO contribution; spiders do not index
what they do not see. A look through your traffic monitor, like Google Analytics,
will often show a disparity between logged traffic and what is actually accounted
for in Web Server logs. Analytics, a JavaScript-based traffic monitor, only logs about
40% of the total traffic to this site (excluding traffic to the RSS feed), which means
that the other 60% of my visitors have JavaScript disabled. A JavaScript Disabled
on 60% of all browsers seems like a ridiculously high percentage unless you consider
that Spiders and Bots do not execute JavaScript.
&lt;/p&gt;
&lt;p&gt;
Just like Google doesn't see the pretty layout from your stylesheet, Google also doesn't
see the dynamic content from your JavaScript. Pulling down HTML, (since it is all
just text, anyway) is easy; there's not even a lot of overhead associated with parsing
that HTML. But add in some JavaScript, and suddenly there's a lot more effort involved
in crawling your page, especially since there is a lot of bad JavaScript out there.
So search engines just check what has been written into your HTML. They read the the
URL, the keywords and META description, but only the content as rendered by the server.
JavaScript is not touched, and JavaScript-based content is not indexed.
&lt;/p&gt;
&lt;p&gt;
So how do you get around this? How do you get this SEO boost, since JavaScript isn't
an available option?
&lt;/p&gt;
&lt;p&gt;
Use plug-ins and utilities that pull your dynamic data server-side, rather than client-side.
Create a custom WebControl that will download and parse your latest Twitter updates.
Create a dasBlog macro to create your Microsoft Gamertag. By putting this responsibility
on the server, not only will you make life easier on your end user (one less JavaScript
library to download), but you also make this new content available to indexing engines,
which can only help your Google Juice.
&lt;/p&gt;
&lt;h4&gt;Update:
&lt;/h4&gt;
&lt;p&gt;
I've been working on a set of macros for dasBlog to start pulling my dynamic content
retrievals to the server. Keep an eye out over the next couple of days for the release
of my first macro, a Twitter Status dasBlog macro that will replace the need for the
Twitter JS libraries on your site.
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:aac5652b-95d9-407d-8780-9361eae9b5de" class="wlWriterEditableSmartContent"&gt;Technorati
Tags: &lt;a href="http://technorati.com/tags/JavaScript" rel="tag"&gt;JavaScript&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SEO" rel="tag"&gt;SEO&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Twitter" rel="tag"&gt;Twitter&lt;/a&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=88fb8162-b06b-4df8-91ef-c2aefe0e1b8f" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,88fb8162-b06b-4df8-91ef-c2aefe0e1b8f.aspx</comments>
      <category>Blogging</category>
      <category>JavaScript</category>
      <category>SEO</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=e54fb1b0-d25c-4f0b-a4cd-eefa8c3715e9</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,e54fb1b0-d25c-4f0b-a4cd-eefa8c3715e9.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,e54fb1b0-d25c-4f0b-a4cd-eefa8c3715e9.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=e54fb1b0-d25c-4f0b-a4cd-eefa8c3715e9</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
As I discussed in an earlier post (<a title="Jay Harris, Blog Post: Blog your code using Google Syntax Highlighter" href="http://www.cptloadtest.com/2008/11/24/BlogYourCodeUsingGoogleSyntaxHighlighter.aspx">Blog
your code using Google Syntax Highlighter</a>), Google Syntax Highlighter is a simple
tool that allows bloggers to easily display code in a format that is familiar end
users. The tool renders the code in a very consumable fashion that includes colored
syntax highlighting, line highlighting, and line numbers. Out of the box it supports
most of the common languages of today, and a few from yesterday, but some common languages
are unsupported. Perl, ColdFusion, and Flash's ActionScript all are unloved by Google
Syntax Highlighter, as are many others that you may want to post to your blog. For
these languages, the solution is a custom brush.
</p>
        <h3>Syntax Highlighting Brushes
</h3>
        <p>
For Google Syntax Highlighter, brushes are JavaScript files that govern the syntax
highlighting process, with names following the format of shBrushLanguage.js, such
as shBrushXml.js. Brushes contain information about the keywords, functions, and operators
of a language, as well as the syntax for comments, strings, and other syntax characteristics.
Keyword-level syntax is applied to any specific word in the language, including keywords,
functions, and any word operators, such as <em>and</em>, <em>or</em>, and <em>not</em>.
Regular expressions apply character-level syntax to code, and identifies items such
as character operators, the remainder of an inline comment, or the entire contents
of a comment block. Finally, aliases are defined for the brush; these are the language
aliases that are used within the <em>class</em> attribute of the Google Syntax Highlighter
&lt;PRE&gt; tag. With this information, the brush applies the syntax highlighting
styles according to the CSS defined for each component of the language. 
</p>
        <h3>Breaking Down Brushes
</h3>
        <h4>Decomposing the SQL Brush
</h4>
        <p>
In JavaScript, everything is an object that can be assigned to a variable, whether
its a number, string, function, or class. Brushes are each a delegate function. The
variable name of the brush must match <em>dp.sh.Brushes.SomeLanguage</em>.
</p>
        <pre class="js:nocontrols:firstline[1]" name="code">dp.sh.Brushes.Sql = function() {</pre>
        <p>
Next, define the list of keywords for applying syntax highlighting. Each list is not
an array, but rather a single-space delimited string of keywords that will be highlighted.
Also, multiple keyword lists can exist, such as one list for function names, another
for keywords, and perhaps another for types, and unique styling can be applied to
each grouping (we'll get to styling a little later). 
</p>
        <pre class="js:nocontrols:firstline[2]" name="code">  var funcs = 'abs avg case cast coalesce convert count current_timestamp ' +
    'current_user day isnull left lower month nullif replace right ' +
    'session_user space substring sum system_user upper user year';

  var keywords = 'absolute action add after alter as asc at authorization ' +
    'begin bigint binary bit by cascade char character check checkpoint ' +
    'close collate column commit committed connect connection constraint ' +
    'contains continue create cube current current_date current_time ' +
    'cursor database date deallocate dec decimal declare default delete ' +
    'desc distinct double drop dynamic else end end-exec escape except ' +
    'exec execute false fetch first float for force foreign forward free ' +
    'from full function global goto grant group grouping having hour ' +
    'ignore index inner insensitive insert instead int integer intersect ' +
    'into is isolation key last level load local max min minute modify ' +
    'move name national nchar next no numeric of off on only open option ' +
    'order out output partial password precision prepare primary prior ' +
    'privileges procedure public read real references relative repeatable ' +
    'restrict return returns revoke rollback rollup rows rule schema ' +
    'scroll second section select sequence serializable set size smallint ' +
    'static statistics table temp temporary then time timestamp to top ' +
    'transaction translation trigger true truncate uncommitted union ' +
    'unique update values varchar varying view when where with work';

  var operators = 'all and any between cross in join like not null or ' +
    'outer some';</pre>
        <p>
Following the keyword definitions is the Regular Expression pattern and Style definition
object list. The list, <em>this.regexList</em>, is an array of pattern/style objects: <em>{regex:
regexPattern, css: classString}</em>. The <em>regexPattern</em> is a JavaScript <em>RegExp</em> object,
and defines the pattern to match in the source code; this pattern can be created using
one of three options within Google Syntax Highlighter. 
</p>
        <dl>
          <dt>Predefined Patterns </dt>
          <dd>Within Google Syntax Highlighter, <em>dp.sh.RegexLib</em> contains five predefined
regular expression patterns. <em>MultiLineCComments</em> is used for any language
that uses C-style multi-line comment blocks: <em>/* my comment block */</em>. <em>SingleLineCComments</em> is
used for any language that uses C-style single line or inline comments: <em>// my
comment</em>. <em>SingleLinePerlComments</em> applies for Perl-style single line comments: <em>#
my comment</em>. <em>DoubleQuotedString</em> identifies any string wrapped in double-quotes
and <em>SingleQuotedString</em> identifies strings wrapped in single-quotes. These
options are used in place of creating a new instance of the <em>RegExp</em> object. 
</dd>
          <dt>Keyword Patterns </dt>
          <dd>Google Syntax Highlighter has a <em>GetKeywords(string)</em> function which will
build a pattern string based on one of the brush's defined keyword strings. However,
this is only the pattern string, and not the <em>RegExp</em> object. Pass this value
into the <em>RegExp</em> constructor: <em>new RegExp(this.GetKeyword(keywords), 'gmi')</em></dd>
          <dt>Custom Pattern Definition </dt>
          <dd>Create a new <em>RegExp</em> object using a custom pattern. For example, use <em>new
RegExp('--(.*)$', 'gm')</em> to match all Sql comments, such as <em>--my comment</em>.</dd>
        </dl>
        <p>
For these pattern/style objects, the regular expression pattern is followed by the
name of the CSS class to apply to any regular expression matches. The style sheet
packaged with Google Syntax Highlighter, SyntaxHighlighter.css, already defines the
many CSS classes used by GSH; place the additional styles for your custom brushes
within this file, in a new file, in your HTML, or defined them within the brush using
JavaScript.
</p>
        <pre class="js:nocontrols:firstline[27]" name="code">  this.regexList = [
    {regex: new RegExp('--(.*)$', 'gm'), css: 'comment'},
    {regex: dp.sh.RegexLib.DoubleQuotedString, css: 'string'},
    {regex: dp.sh.RegexLib.SingleQuotedString, css: 'string'},
    {regex: new RegExp(this.GetKeywords(funcs), 'gmi'), css: 'func'},
    {regex: new RegExp(this.GetKeywords(operators), 'gmi'), css: 'op'},
    {regex: new RegExp(this.GetKeywords(keywords), 'gmi'), css: 'keyword'}
  ];</pre>
        <p>
The delegate definition ends with any style specifications. Apply a style sheet to
the entire code block using <em>this.CssClass</em>. Also, as mentioned above, the
brush can define custom CSS using this.Style as an alternative to placing the CSS
in HTML or a CSS file. When finished, close the delegate.
</p>
        <pre class="js:nocontrols:firstline[36]" name="code">  this.CssClass = 'dp-sql';
  this.Style = '.dp-sql .func { color: #ff1493; }' +
    '.dp-sql .op { color: #808080; }'; }
</pre>
        <p>
The final component of a Brush, set outside of your delegate, contains the prototype
declaration and any aliases to apply to the Brush. Aliases consist of a string array
(a real array this time, not a space-delimited string) of language aliases to use,
such as ['c#','c-sharp','csharp']. Alias values must be unique across all defined
brushes that you have included into your site.
</p>
        <pre class="js:nocontrols:firstline[40]" name="code">dp.sh.Brushes.Sql.prototype = new dp.sh.Highlighter();
dp.sh.Brushes.Sql.Aliases = ['sql'];</pre>
        <h3>Making a Custom Brush (for ActionScript) 
</h3>
        <p>
I like rich media applications, such as those developed in Flash or Silverlight. I
was surprised when I found that Google Syntax Highlighter does not ship with an ActionScript
brush, and more surprised when I found out that no one has written one, yet. So, using
the methods from above, I created one. This isn't meant to be an exhaustive brush,
but more like <a href="http://en.wikipedia.org/wiki/Stone_soup">Stone Soup</a>. It's
a start. Please feel free to add to it.
</p>
        <pre class="js" name="code">dp.sh.Brushes.ActionScript = function() {

  var keywords = 'and break case catch class continue default do dynamic else ' +
    'extends false finally for if implements import in interface NaN new not ' +
    'null or private public return static super switch this throw true try ' +
    'undefined var void while with';

  this.regexList = [{regex: dp.sh.RegexLib.SingleLineCComments, css: 'comment'},
    {regex: dp.sh.RegexLib.MultiLineCComments, css: 'comment'},
    {regex: dp.sh.RegexLib.DoubleQuotedString, css: 'string'},
    {regex: dp.sh.RegexLib.SingleQuotedString, css: 'string'},
    {regex: new RegExp(this.GetKeywords(keywords), 'gm'), css: 'keyword'}];

    this.CssClass = 'dp-as';
}

dp.sh.Brushes.ActionScript.prototype = new dp.sh.Highlighter();
dp.sh.Brushes.ActionScript.Aliases = ['actionscript', 'as'];</pre>
        <div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:51b61cce-ee33-4c5c-9de4-a3c6cf350c46" style="margin: 0px; padding: 0px; display: inline;">Technorati
Tags: <a href="http://technorati.com/tags/Syntax%20Highlighter" rel="tag">Syntax Highlighter</a>,<a href="http://technorati.com/tags/SyntaxHighlighter" rel="tag">SyntaxHighlighter</a>,<a href="http://technorati.com/tags/Google%20Code" rel="tag">Google
Code</a>,<a href="http://technorati.com/tags/ActionScript" rel="tag">ActionScript</a></div>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=e54fb1b0-d25c-4f0b-a4cd-eefa8c3715e9" />
      </body>
      <title>Extending Language Support in Google Syntax Highlighter</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,e54fb1b0-d25c-4f0b-a4cd-eefa8c3715e9.aspx</guid>
      <link>http://www.cptloadtest.com/2008/12/10/Extending-Language-Support-In-Google-Syntax-Highlighter.aspx</link>
      <pubDate>Wed, 10 Dec 2008 21:47:27 GMT</pubDate>
      <description>&lt;p&gt;
As I discussed in an earlier post (&lt;a title="Jay Harris, Blog Post: Blog your code using Google Syntax Highlighter" href="http://www.cptloadtest.com/2008/11/24/BlogYourCodeUsingGoogleSyntaxHighlighter.aspx"&gt;Blog
your code using Google Syntax Highlighter&lt;/a&gt;), Google Syntax Highlighter is a simple
tool that allows bloggers to easily display code in a format that is familiar end
users. The tool renders the code in a very consumable fashion that includes colored
syntax highlighting, line highlighting, and line numbers. Out of the box it supports
most of the common languages of today, and a few from yesterday, but some common languages
are unsupported. Perl, ColdFusion, and Flash's ActionScript all are unloved by Google
Syntax Highlighter, as are many others that you may want to post to your blog. For
these languages, the solution is a custom brush.
&lt;/p&gt;
&lt;h3&gt;Syntax Highlighting Brushes
&lt;/h3&gt;
&lt;p&gt;
For Google Syntax Highlighter, brushes are JavaScript files that govern the syntax
highlighting process, with names following the format of shBrushLanguage.js, such
as shBrushXml.js. Brushes contain information about the keywords, functions, and operators
of a language, as well as the syntax for comments, strings, and other syntax characteristics.
Keyword-level syntax is applied to any specific word in the language, including keywords,
functions, and any word operators, such as &lt;em&gt;and&lt;/em&gt;, &lt;em&gt;or&lt;/em&gt;, and &lt;em&gt;not&lt;/em&gt;.
Regular expressions apply character-level syntax to code, and identifies items such
as character operators, the remainder of an inline comment, or the entire contents
of a comment block. Finally, aliases are defined for the brush; these are the language
aliases that are used within the &lt;em&gt;class&lt;/em&gt; attribute of the Google Syntax Highlighter
&amp;lt;PRE&amp;gt; tag. With this information, the brush applies the syntax highlighting
styles according to the CSS defined for each component of the language. 
&lt;/p&gt;
&lt;h3&gt;Breaking Down Brushes
&lt;/h3&gt;
&lt;h4&gt;Decomposing the SQL Brush
&lt;/h4&gt;
&lt;p&gt;
In JavaScript, everything is an object that can be assigned to a variable, whether
its a number, string, function, or class. Brushes are each a delegate function. The
variable name of the brush must match &lt;em&gt;dp.sh.Brushes.SomeLanguage&lt;/em&gt;.
&lt;/p&gt;
&lt;pre class="js:nocontrols:firstline[1]" name="code"&gt;dp.sh.Brushes.Sql = function() {&lt;/pre&gt;
&lt;p&gt;
Next, define the list of keywords for applying syntax highlighting. Each list is not
an array, but rather a single-space delimited string of keywords that will be highlighted.
Also, multiple keyword lists can exist, such as one list for function names, another
for keywords, and perhaps another for types, and unique styling can be applied to
each grouping (we'll get to styling a little later). 
&lt;/p&gt;
&lt;pre class="js:nocontrols:firstline[2]" name="code"&gt;  var funcs = 'abs avg case cast coalesce convert count current_timestamp ' +
    'current_user day isnull left lower month nullif replace right ' +
    'session_user space substring sum system_user upper user year';

  var keywords = 'absolute action add after alter as asc at authorization ' +
    'begin bigint binary bit by cascade char character check checkpoint ' +
    'close collate column commit committed connect connection constraint ' +
    'contains continue create cube current current_date current_time ' +
    'cursor database date deallocate dec decimal declare default delete ' +
    'desc distinct double drop dynamic else end end-exec escape except ' +
    'exec execute false fetch first float for force foreign forward free ' +
    'from full function global goto grant group grouping having hour ' +
    'ignore index inner insensitive insert instead int integer intersect ' +
    'into is isolation key last level load local max min minute modify ' +
    'move name national nchar next no numeric of off on only open option ' +
    'order out output partial password precision prepare primary prior ' +
    'privileges procedure public read real references relative repeatable ' +
    'restrict return returns revoke rollback rollup rows rule schema ' +
    'scroll second section select sequence serializable set size smallint ' +
    'static statistics table temp temporary then time timestamp to top ' +
    'transaction translation trigger true truncate uncommitted union ' +
    'unique update values varchar varying view when where with work';

  var operators = 'all and any between cross in join like not null or ' +
    'outer some';&lt;/pre&gt;
&lt;p&gt;
Following the keyword definitions is the Regular Expression pattern and Style definition
object list. The list, &lt;em&gt;this.regexList&lt;/em&gt;, is an array of pattern/style objects: &lt;em&gt;{regex:
regexPattern, css: classString}&lt;/em&gt;. The &lt;em&gt;regexPattern&lt;/em&gt; is a JavaScript &lt;em&gt;RegExp&lt;/em&gt; object,
and defines the pattern to match in the source code; this pattern can be created using
one of three options within Google Syntax Highlighter. 
&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;Predefined Patterns &lt;/dt&gt;
&lt;dd&gt;Within Google Syntax Highlighter, &lt;em&gt;dp.sh.RegexLib&lt;/em&gt; contains five predefined
regular expression patterns. &lt;em&gt;MultiLineCComments&lt;/em&gt; is used for any language
that uses C-style multi-line comment blocks: &lt;em&gt;/* my comment block */&lt;/em&gt;. &lt;em&gt;SingleLineCComments&lt;/em&gt; is
used for any language that uses C-style single line or inline comments: &lt;em&gt;// my
comment&lt;/em&gt;. &lt;em&gt;SingleLinePerlComments&lt;/em&gt; applies for Perl-style single line comments: &lt;em&gt;#
my comment&lt;/em&gt;. &lt;em&gt;DoubleQuotedString&lt;/em&gt; identifies any string wrapped in double-quotes
and &lt;em&gt;SingleQuotedString&lt;/em&gt; identifies strings wrapped in single-quotes. These
options are used in place of creating a new instance of the &lt;em&gt;RegExp&lt;/em&gt; object. 
&lt;/dd&gt;
&lt;dt&gt;Keyword Patterns &lt;/dt&gt;
&lt;dd&gt;Google Syntax Highlighter has a &lt;em&gt;GetKeywords(string)&lt;/em&gt; function which will
build a pattern string based on one of the brush's defined keyword strings. However,
this is only the pattern string, and not the &lt;em&gt;RegExp&lt;/em&gt; object. Pass this value
into the &lt;em&gt;RegExp&lt;/em&gt; constructor: &lt;em&gt;new RegExp(this.GetKeyword(keywords), 'gmi')&lt;/em&gt; 
&lt;/dd&gt;
&lt;dt&gt;Custom Pattern Definition &lt;/dt&gt;
&lt;dd&gt;Create a new &lt;em&gt;RegExp&lt;/em&gt; object using a custom pattern. For example, use &lt;em&gt;new
RegExp('--(.*)$', 'gm')&lt;/em&gt; to match all Sql comments, such as &lt;em&gt;--my comment&lt;/em&gt;.&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;
For these pattern/style objects, the regular expression pattern is followed by the
name of the CSS class to apply to any regular expression matches. The style sheet
packaged with Google Syntax Highlighter, SyntaxHighlighter.css, already defines the
many CSS classes used by GSH; place the additional styles for your custom brushes
within this file, in a new file, in your HTML, or defined them within the brush using
JavaScript.
&lt;/p&gt;
&lt;pre class="js:nocontrols:firstline[27]" name="code"&gt;  this.regexList = [
    {regex: new RegExp('--(.*)$', 'gm'), css: 'comment'},
    {regex: dp.sh.RegexLib.DoubleQuotedString, css: 'string'},
    {regex: dp.sh.RegexLib.SingleQuotedString, css: 'string'},
    {regex: new RegExp(this.GetKeywords(funcs), 'gmi'), css: 'func'},
    {regex: new RegExp(this.GetKeywords(operators), 'gmi'), css: 'op'},
    {regex: new RegExp(this.GetKeywords(keywords), 'gmi'), css: 'keyword'}
  ];&lt;/pre&gt;
&lt;p&gt;
The delegate definition ends with any style specifications. Apply a style sheet to
the entire code block using &lt;em&gt;this.CssClass&lt;/em&gt;. Also, as mentioned above, the
brush can define custom CSS using this.Style as an alternative to placing the CSS
in HTML or a CSS file. When finished, close the delegate.
&lt;/p&gt;
&lt;pre class="js:nocontrols:firstline[36]" name="code"&gt;  this.CssClass = 'dp-sql';
  this.Style = '.dp-sql .func { color: #ff1493; }' +
    '.dp-sql .op { color: #808080; }'; }
&lt;/pre&gt;
&lt;p&gt;
The final component of a Brush, set outside of your delegate, contains the prototype
declaration and any aliases to apply to the Brush. Aliases consist of a string array
(a real array this time, not a space-delimited string) of language aliases to use,
such as ['c#','c-sharp','csharp']. Alias values must be unique across all defined
brushes that you have included into your site.
&lt;/p&gt;
&lt;pre class="js:nocontrols:firstline[40]" name="code"&gt;dp.sh.Brushes.Sql.prototype = new dp.sh.Highlighter();
dp.sh.Brushes.Sql.Aliases = ['sql'];&lt;/pre&gt;
&lt;h3&gt;Making a Custom Brush (for ActionScript) 
&lt;/h3&gt;
&lt;p&gt;
I like rich media applications, such as those developed in Flash or Silverlight. I
was surprised when I found that Google Syntax Highlighter does not ship with an ActionScript
brush, and more surprised when I found out that no one has written one, yet. So, using
the methods from above, I created one. This isn't meant to be an exhaustive brush,
but more like &lt;a href="http://en.wikipedia.org/wiki/Stone_soup"&gt;Stone Soup&lt;/a&gt;. It's
a start. Please feel free to add to it.
&lt;/p&gt;
&lt;pre class="js" name="code"&gt;dp.sh.Brushes.ActionScript = function() {

  var keywords = 'and break case catch class continue default do dynamic else ' +
    'extends false finally for if implements import in interface NaN new not ' +
    'null or private public return static super switch this throw true try ' +
    'undefined var void while with';

  this.regexList = [{regex: dp.sh.RegexLib.SingleLineCComments, css: 'comment'},
    {regex: dp.sh.RegexLib.MultiLineCComments, css: 'comment'},
    {regex: dp.sh.RegexLib.DoubleQuotedString, css: 'string'},
    {regex: dp.sh.RegexLib.SingleQuotedString, css: 'string'},
    {regex: new RegExp(this.GetKeywords(keywords), 'gm'), css: 'keyword'}];

    this.CssClass = 'dp-as';
}

dp.sh.Brushes.ActionScript.prototype = new dp.sh.Highlighter();
dp.sh.Brushes.ActionScript.Aliases = ['actionscript', 'as'];&lt;/pre&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:51b61cce-ee33-4c5c-9de4-a3c6cf350c46" style="margin: 0px; padding: 0px; display: inline;"&gt;Technorati
Tags: &lt;a href="http://technorati.com/tags/Syntax%20Highlighter" rel="tag"&gt;Syntax Highlighter&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SyntaxHighlighter" rel="tag"&gt;SyntaxHighlighter&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Google%20Code" rel="tag"&gt;Google
Code&lt;/a&gt;,&lt;a href="http://technorati.com/tags/ActionScript" rel="tag"&gt;ActionScript&lt;/a&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=e54fb1b0-d25c-4f0b-a4cd-eefa8c3715e9" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,e54fb1b0-d25c-4f0b-a4cd-eefa8c3715e9.aspx</comments>
      <category>Blogging</category>
      <category>Flash</category>
      <category>JavaScript</category>
      <category>Programming</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=417c2df3-d32c-436c-8c5c-46e1fe4b2808</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,417c2df3-d32c-436c-8c5c-46e1fe4b2808.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,417c2df3-d32c-436c-8c5c-46e1fe4b2808.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=417c2df3-d32c-436c-8c5c-46e1fe4b2808</wfw:commentRss>
      <slash:comments>9</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://code.google.com/p/syntaxhighlighter/">Google Syntax Highlighter</a> is
a simple tool that allows bloggers to easily display code in a format that is familiar
end users. The tool renders the code in a very consumable fashion that includes colored
syntax highlighting, line highlighting, and line numbers.
</p>
        <pre class="csharp:nocontrols" name="code">/*
This is an example of how Google
Syntax Highlighter can highlight and display syntax
to you, the end user
*/
public void HelloWorld()
{
  // I have some comments
  Console.WriteLine("Hello, World!");
}</pre>
        <p>
It is purely a client-side tool, as all of the processing is done strictly within
the browser through JavaScript. There is no server-side processing. Since it is all
JavaScript, you don't need special Copy/Paste plugins and macros installed to your
favorite IDE or your blog authoring tool. (I am leery of random plugins and installing
them into the software that I use to feed my family.) To including code in your blog
post, copy your code from Visual Studio, Notepad, Flash, Firebug, or any tool that
displays text, and paste it in to your post. As of v1.5.1, Google Syntax Highlighter
supports C, C++, C#, CSS, Delphi, HTML, Java, JavaScript, PHP, Pascal, Python, Ruby,
SQL, VB, VB.NET, XML, XSLT, and all of this is just what comes out of the box.
</p>
        <h3>Setting Up Syntax Highlighter
</h3>
        <p>
To get Syntax Highlighter running on your blog, <a href="http://code.google.com/p/syntaxhighlighter/downloads/list">download</a> the
latest version of the RAR archive and extract the code. The archive contains a parent
folder, <em>dp.SyntaxHighlighter</em>, with three child folders:
</p>
        <blockquote>
          <pre>dp.SyntaxHighlighter
  \Scripts         //Production-ready (Compressed) scripts
  \Styles          //CSS
  \Uncompressed    //Human-readable (Uncompressed/Debug) scripts</pre>
        </blockquote>
        <p>
Once the archive is extracted, upload <em>dp.SyntaxHighlighter</em> to your blog.
Feel free to rename the folder if you like, though I did not. It is not necessary
to upload the <em>Uncompressed</em> folder and its files; they are best used for debugging
or for viewing the code, as the files in the <em>Scripts</em> folder have been compressed
to reduce bandwidth by having most of their whitespace removed.
</p>
        <p>
After you have uploaded the files, you will need to add script and style references
to your site's HTML. This is code is not for your posts, but rather for your blog
template. In DasBlog, I place this code in the &lt;HEAD&gt; block of my <em>homeTemplate.blogtemplate</em> file.
Remember to change the file paths to match the path to where you uploaded the code.
</p>
        <pre class="html:nocontrols:nogutter" name="code">&lt;link type="text/css" rel="stylesheet"
  href="dp.SyntaxHighlighter/Styles/SyntaxHighlighter.css"&gt;&lt;/link&gt;
&lt;script language="javascript" src="dp.SyntaxHighlighter/Scripts/shCore.js"&gt;&lt;/script&gt;
&lt;script language="javascript" src="dp.SyntaxHighlighter/Scripts/shBrushCSharp.js"&gt;&lt;/script&gt;
&lt;script language="javascript" src="dp.SyntaxHighlighter/Scripts/shBrushXml.js"&gt;&lt;/script&gt;
&lt;script language="javascript"&gt;
window.onload = function () {
  dp.SyntaxHighlighter.ClipboardSwf = 'dp.SyntaxHighlighter/Scripts/clipboard.swf';
  dp.SyntaxHighlighter.HighlightAll('code');
}
&lt;/script&gt;</pre>
        <p>
To make the tool most efficient, including minimizing the code download by the client
browser, highlighting is only enabled for the languages that you specify. The highlighting
rules for each language is available through a file referred to as a Brush. The code
sample above enables only C# and XML/HTML by including the core file, <em>shCore.js</em>,
the C# brush, <em>shBrushCSharp.js</em> and the XML/HTML brush, <em>shBrushXml.js</em>.
A unique brush file is available for each of the supported languages, and only the
core file is required. These brushes are located in your <em>Scripts</em> directory
(the human-readable version is in the <em>Uncompressed</em> folder). Include only
the brushes that you like; if you forgot a language brush, the code will still display
on your page, but as unformatted text.
</p>
        <pre>&lt;!-- Unformatted HTML Code / No Brush --&gt;
&lt;p id="greeting"&gt;Hi, mom &amp; dad!&lt;/p&gt;</pre>
        <pre class="html:nogutter:nocontrols" name="code">&lt;!-- Formatted HTML Code --&gt;
&lt;p id="greeting"&gt;Hi, mom &amp; dad!&lt;/p&gt;</pre>
        <h3>Making Syntax Highlighter Go
</h3>
        <p>
Now that the application is deployed to the site, how does it get applied to a post?
Paste the code into the HTML view of your post, inside of a &lt;PRE&gt; tag. Create
a <em>name</em> attribute on your tag with a value of <em>code</em>, and a <em>class</em> attribute
set to the language and options you are using.
</p>
        <pre class="html:nocontrols:nogutter" name="code">&lt;pre name="code" class="c-sharp"&gt;
  public void HelloWorld()
  {
    Console.WriteLine("Hello, World!");
  }
&lt;/pre&gt;</pre>
        <p>
One catch is the code must be first made HTML-safe. All angle-brackets, <em>&lt;tag&gt;</em>,
must be converted to their HTML equivalent, <em>&amp;lt;tag&amp;gt;</em>, as well
as ampersands, <em>&amp;</em> to <em>&amp;amp;</em>. I also find it helpful if your
code-indentation uses two-spaces, rather than tabs.
</p>
        <pre class="html:nocontrols" name="code">&lt;!-- Pre-converted code --&gt;
&lt;p&gt;Hi, mom &amp; dad!&lt;/p&gt;</pre>
        <pre class="html:nocontrols" name="code">&lt;!-- Converted code --&gt;
&lt;pre name="code" class="html"&gt;
  &amp;lt;p&amp;gt;Hi, mom &amp;amp; dad!&amp;lt;/p&amp;gt;
&lt;/pre&gt;</pre>
        <p>
The <em>class</em> attribute is made up of both language and option aliases. These
aliases consist of one language followed by your desired options, all in a colon delimited
list.
</p>
        <p>
class="language[:option[:option[:option]]]"
</p>
        <p>
The value of language is any of Syntax Highlighter's defined language aliases, such
as <em>c#</em>, <em>csharp</em>, or <em>c-sharp</em> for C#, or <em>rb</em>, <em>ruby</em>, <em>rails</em>,
or <em>ror</em> for Ruby. See: <a href="http://code.google.com/p/syntaxhighlighter/wiki/Languages">full
list</a> of available languages.
</p>
        <p>
Options allow for such things as turning off the plain text / copy / about controls
(<em>nocontrols</em>), turning off the line number gutter (<em>nogutter</em>), or
specifying the number of the first line (<em>firstline[n]</em>). A JavaScript code
block with no controls header, and starting the line numbering at 34 would have a <em>class</em> attribute
value of <em>class="js:nocontrols:linenumber[34]"</em>. See: <a href="http://code.google.com/p/syntaxhighlighter/wiki/Configuration">full
list</a> of available options.
</p>
        <h3>Extending Syntax Highlighter
</h3>
        <p>
Because Google Syntax Highlighter is entirely in JavaScript, you have access to all
of the code. Edit it however you like to suit your needs. Additionally, brushes are
very easy to create, and include little more than a list of a highlighted language's
keywords in a string and an array of language aliases. Creating a brush for ActionScript
or QBasic would not take much time. Language brushes exist in the wild for <a href="http://nevstokes.com/includes/syntax/scripts/shBrushPerl.js">Perl</a>, <a href="http://pcnorb.blogspot.com/2008/10/shbrushbatch-for-google.html">DOS
Batch</a>, and <a href="http://blog.tech-cats.com/2007/10/syntax-highlighting-for-coldfusion.html">ColdFusion</a>.
</p>
        <p>
In a future post I plan on discussing Brush Creation in depth through creating a brush
for ActionScript.
</p>
        <h3>Comparing Syntax Highlighter to Others
</h3>
        <p>
I am a fan of this tool, though that should be obvious considering it is what I use
on this blog. I like how readable the code is, how extendable it is, and how easy
it is to use. I don't like its compatibility--or lack thereof--with RSS; since all
of the work is done in JavaScript, and RSS doesn't do JavaScript, there is no syntax
highlighting, numbers, or options within a feed, though the code formatting is still
maintained. Other tools, like the <em><a href="http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/">CopySourceAsHtml</a></em> plugin
for Visual Studio or <em><a href="http://lvildosola.blogspot.com/2007/02/code-snippet-plugin-for-windows-live.html">Insert
Code Snippet</a></em> for Windows Live Writer convert your code into formatted HTML,
where all of the syntax highlighting is applied through HTML attributes and embedded
CSS. Their methods are much easier than Syntax Highlighter, since there are no stylesheets
or JavaScript files to include in your HTML, and you don't have to worry about making
your code HTML-safe. Also, their method works in RSS feeds. However, there isn't the
same level of control. Through Syntax Highlighter's extendibility, I can theme my
code views, such as if I wanted them to look like my personal Visual Studio theme.
Through Syntax Highlighter, I can also make changes at a later time, and those changes
will immediately reflected in all past posts, whereas making modifications to the
HTML/embedded CSS pattern is much more difficult.
</p>
        <h3>Final Thoughts
</h3>
        <p>
I like CopySourceAsHtml in Visual Studio. I used it for years on this blog. But I
code in more languages than VB.Net or C#, and the plugin isn't available within the
Flash or LoadRunner IDE. I was also frustrated with pasting my code in, only to find
that it was too wide for my blog theme's margins, and would have to go back to Visual
Studio, change my line endings, and repeat the process. I'm sticking with Google Syntax
Highlighter. It works for all of my languages (as soon as I finish writing my ActionScript
brush), and when my line endings are too long, I simply change my HTML. And in my
HTML, my code still looks like code, rather than a mess of embedded style. I have
to sacrifice RSS formatting, but as a presentation developer that is very particular
about his HTML, I am glad for the customization and control.
</p>
        <div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:5e03f5f4-120c-4ce0-96ea-32867691f7e7" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati
Tags: <a href="http://technorati.com/tags/SyntaxHighlighter" rel="tag">SyntaxHighlighter</a>,<a href="http://technorati.com/tags/Syntax%20Highlighter" rel="tag">Syntax
Highlighter</a>,<a href="http://technorati.com/tags/Google%20Code" rel="tag">Google
Code</a></div>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=417c2df3-d32c-436c-8c5c-46e1fe4b2808" />
      </body>
      <title>Blog your code using Google Syntax Highlighter</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,417c2df3-d32c-436c-8c5c-46e1fe4b2808.aspx</guid>
      <link>http://www.cptloadtest.com/2008/11/24/Blog-Your-Code-Using-Google-Syntax-Highlighter.aspx</link>
      <pubDate>Mon, 24 Nov 2008 15:41:50 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://code.google.com/p/syntaxhighlighter/"&gt;Google Syntax Highlighter&lt;/a&gt; is
a simple tool that allows bloggers to easily display code in a format that is familiar
end users. The tool renders the code in a very consumable fashion that includes colored
syntax highlighting, line highlighting, and line numbers.
&lt;/p&gt;
&lt;pre class="csharp:nocontrols" name="code"&gt;/*
This is an example of how Google
Syntax Highlighter can highlight and display syntax
to you, the end user
*/
public void HelloWorld()
{
  // I have some comments
  Console.WriteLine("Hello, World!");
}&lt;/pre&gt;
&lt;p&gt;
It is purely a client-side tool, as all of the processing is done strictly within
the browser through JavaScript. There is no server-side processing. Since it is all
JavaScript, you don't need special Copy/Paste plugins and macros installed to your
favorite IDE or your blog authoring tool. (I am leery of random plugins and installing
them into the software that I use to feed my family.) To including code in your blog
post, copy your code from Visual Studio, Notepad, Flash, Firebug, or any tool that
displays text, and paste it in to your post. As of v1.5.1, Google Syntax Highlighter
supports C, C++, C#, CSS, Delphi, HTML, Java, JavaScript, PHP, Pascal, Python, Ruby,
SQL, VB, VB.NET, XML, XSLT, and all of this is just what comes out of the box.
&lt;/p&gt;
&lt;h3&gt;Setting Up Syntax Highlighter
&lt;/h3&gt;
&lt;p&gt;
To get Syntax Highlighter running on your blog, &lt;a href="http://code.google.com/p/syntaxhighlighter/downloads/list"&gt;download&lt;/a&gt; the
latest version of the RAR archive and extract the code. The archive contains a parent
folder, &lt;em&gt;dp.SyntaxHighlighter&lt;/em&gt;, with three child folders:
&lt;/p&gt;
&lt;blockquote&gt;&lt;pre&gt;dp.SyntaxHighlighter
  \Scripts         //Production-ready (Compressed) scripts
  \Styles          //CSS
  \Uncompressed    //Human-readable (Uncompressed/Debug) scripts&lt;/pre&gt;&lt;/blockquote&gt; 
&lt;p&gt;
Once the archive is extracted, upload &lt;em&gt;dp.SyntaxHighlighter&lt;/em&gt; to your blog.
Feel free to rename the folder if you like, though I did not. It is not necessary
to upload the &lt;em&gt;Uncompressed&lt;/em&gt; folder and its files; they are best used for debugging
or for viewing the code, as the files in the &lt;em&gt;Scripts&lt;/em&gt; folder have been compressed
to reduce bandwidth by having most of their whitespace removed.
&lt;/p&gt;
&lt;p&gt;
After you have uploaded the files, you will need to add script and style references
to your site's HTML. This is code is not for your posts, but rather for your blog
template. In DasBlog, I place this code in the &amp;lt;HEAD&amp;gt; block of my &lt;em&gt;homeTemplate.blogtemplate&lt;/em&gt; file.
Remember to change the file paths to match the path to where you uploaded the code.
&lt;/p&gt;
&lt;pre class="html:nocontrols:nogutter" name="code"&gt;&amp;lt;link type="text/css" rel="stylesheet"
  href="dp.SyntaxHighlighter/Styles/SyntaxHighlighter.css"&amp;gt;&amp;lt;/link&amp;gt;
&amp;lt;script language="javascript" src="dp.SyntaxHighlighter/Scripts/shCore.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script language="javascript" src="dp.SyntaxHighlighter/Scripts/shBrushCSharp.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script language="javascript" src="dp.SyntaxHighlighter/Scripts/shBrushXml.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script language="javascript"&amp;gt;
window.onload = function () {
  dp.SyntaxHighlighter.ClipboardSwf = 'dp.SyntaxHighlighter/Scripts/clipboard.swf';
  dp.SyntaxHighlighter.HighlightAll('code');
}
&amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;p&gt;
To make the tool most efficient, including minimizing the code download by the client
browser, highlighting is only enabled for the languages that you specify. The highlighting
rules for each language is available through a file referred to as a Brush. The code
sample above enables only C# and XML/HTML by including the core file, &lt;em&gt;shCore.js&lt;/em&gt;,
the C# brush, &lt;em&gt;shBrushCSharp.js&lt;/em&gt; and the XML/HTML brush, &lt;em&gt;shBrushXml.js&lt;/em&gt;.
A unique brush file is available for each of the supported languages, and only the
core file is required. These brushes are located in your &lt;em&gt;Scripts&lt;/em&gt; directory
(the human-readable version is in the &lt;em&gt;Uncompressed&lt;/em&gt; folder). Include only
the brushes that you like; if you forgot a language brush, the code will still display
on your page, but as unformatted text.
&lt;/p&gt;
&lt;pre&gt;&amp;lt;!-- Unformatted HTML Code / No Brush --&amp;gt;
&amp;lt;p id="greeting"&amp;gt;Hi, mom &amp;amp; dad!&amp;lt;/p&amp;gt;&lt;/pre&gt;&lt;pre class="html:nogutter:nocontrols" name="code"&gt;&amp;lt;!-- Formatted HTML Code --&amp;gt;
&amp;lt;p id="greeting"&amp;gt;Hi, mom &amp;amp; dad!&amp;lt;/p&amp;gt;&lt;/pre&gt;
&lt;h3&gt;Making Syntax Highlighter Go
&lt;/h3&gt;
&lt;p&gt;
Now that the application is deployed to the site, how does it get applied to a post?
Paste the code into the HTML view of your post, inside of a &amp;lt;PRE&amp;gt; tag. Create
a &lt;em&gt;name&lt;/em&gt; attribute on your tag with a value of &lt;em&gt;code&lt;/em&gt;, and a &lt;em&gt;class&lt;/em&gt; attribute
set to the language and options you are using.
&lt;/p&gt;
&lt;pre class="html:nocontrols:nogutter" name="code"&gt;&amp;lt;pre name="code" class="c-sharp"&amp;gt;
  public void HelloWorld()
  {
    Console.WriteLine("Hello, World!");
  }
&amp;lt;/pre&amp;gt;&lt;/pre&gt;
&lt;p&gt;
One catch is the code must be first made HTML-safe. All angle-brackets, &lt;em&gt;&amp;lt;tag&amp;gt;&lt;/em&gt;,
must be converted to their HTML equivalent, &lt;em&gt;&amp;amp;lt;tag&amp;amp;gt;&lt;/em&gt;, as well
as ampersands, &lt;em&gt;&amp;amp;&lt;/em&gt; to &lt;em&gt;&amp;amp;amp;&lt;/em&gt;. I also find it helpful if your
code-indentation uses two-spaces, rather than tabs.
&lt;/p&gt;
&lt;pre class="html:nocontrols" name="code"&gt;&amp;lt;!-- Pre-converted code --&amp;gt;
&amp;lt;p&amp;gt;Hi, mom &amp;amp; dad!&amp;lt;/p&amp;gt;&lt;/pre&gt;&lt;pre class="html:nocontrols" name="code"&gt;&amp;lt;!-- Converted code --&amp;gt;
&amp;lt;pre name="code" class="html"&amp;gt;
  &amp;amp;lt;p&amp;amp;gt;Hi, mom &amp;amp;amp; dad!&amp;amp;lt;/p&amp;amp;gt;
&amp;lt;/pre&amp;gt;&lt;/pre&gt;
&lt;p&gt;
The &lt;em&gt;class&lt;/em&gt; attribute is made up of both language and option aliases. These
aliases consist of one language followed by your desired options, all in a colon delimited
list.
&lt;/p&gt;
&lt;p&gt;
class="language[:option[:option[:option]]]"
&lt;/p&gt;
&lt;p&gt;
The value of language is any of Syntax Highlighter's defined language aliases, such
as &lt;em&gt;c#&lt;/em&gt;, &lt;em&gt;csharp&lt;/em&gt;, or &lt;em&gt;c-sharp&lt;/em&gt; for C#, or &lt;em&gt;rb&lt;/em&gt;, &lt;em&gt;ruby&lt;/em&gt;, &lt;em&gt;rails&lt;/em&gt;,
or &lt;em&gt;ror&lt;/em&gt; for Ruby. See: &lt;a href="http://code.google.com/p/syntaxhighlighter/wiki/Languages"&gt;full
list&lt;/a&gt; of available languages.
&lt;/p&gt;
&lt;p&gt;
Options allow for such things as turning off the plain text / copy / about controls
(&lt;em&gt;nocontrols&lt;/em&gt;), turning off the line number gutter (&lt;em&gt;nogutter&lt;/em&gt;), or
specifying the number of the first line (&lt;em&gt;firstline[n]&lt;/em&gt;). A JavaScript code
block with no controls header, and starting the line numbering at 34 would have a &lt;em&gt;class&lt;/em&gt; attribute
value of &lt;em&gt;class="js:nocontrols:linenumber[34]"&lt;/em&gt;. See: &lt;a href="http://code.google.com/p/syntaxhighlighter/wiki/Configuration"&gt;full
list&lt;/a&gt; of available options.
&lt;/p&gt;
&lt;h3&gt;Extending Syntax Highlighter
&lt;/h3&gt;
&lt;p&gt;
Because Google Syntax Highlighter is entirely in JavaScript, you have access to all
of the code. Edit it however you like to suit your needs. Additionally, brushes are
very easy to create, and include little more than a list of a highlighted language's
keywords in a string and an array of language aliases. Creating a brush for ActionScript
or QBasic would not take much time. Language brushes exist in the wild for &lt;a href="http://nevstokes.com/includes/syntax/scripts/shBrushPerl.js"&gt;Perl&lt;/a&gt;, &lt;a href="http://pcnorb.blogspot.com/2008/10/shbrushbatch-for-google.html"&gt;DOS
Batch&lt;/a&gt;, and &lt;a href="http://blog.tech-cats.com/2007/10/syntax-highlighting-for-coldfusion.html"&gt;ColdFusion&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
In a future post I plan on discussing Brush Creation in depth through creating a brush
for ActionScript.
&lt;/p&gt;
&lt;h3&gt;Comparing Syntax Highlighter to Others
&lt;/h3&gt;
&lt;p&gt;
I am a fan of this tool, though that should be obvious considering it is what I use
on this blog. I like how readable the code is, how extendable it is, and how easy
it is to use. I don't like its compatibility--or lack thereof--with RSS; since all
of the work is done in JavaScript, and RSS doesn't do JavaScript, there is no syntax
highlighting, numbers, or options within a feed, though the code formatting is still
maintained. Other tools, like the &lt;em&gt;&lt;a href="http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/"&gt;CopySourceAsHtml&lt;/a&gt;&lt;/em&gt; plugin
for Visual Studio or &lt;em&gt;&lt;a href="http://lvildosola.blogspot.com/2007/02/code-snippet-plugin-for-windows-live.html"&gt;Insert
Code Snippet&lt;/a&gt;&lt;/em&gt; for Windows Live Writer convert your code into formatted HTML,
where all of the syntax highlighting is applied through HTML attributes and embedded
CSS. Their methods are much easier than Syntax Highlighter, since there are no stylesheets
or JavaScript files to include in your HTML, and you don't have to worry about making
your code HTML-safe. Also, their method works in RSS feeds. However, there isn't the
same level of control. Through Syntax Highlighter's extendibility, I can theme my
code views, such as if I wanted them to look like my personal Visual Studio theme.
Through Syntax Highlighter, I can also make changes at a later time, and those changes
will immediately reflected in all past posts, whereas making modifications to the
HTML/embedded CSS pattern is much more difficult.
&lt;/p&gt;
&lt;h3&gt;Final Thoughts
&lt;/h3&gt;
&lt;p&gt;
I like CopySourceAsHtml in Visual Studio. I used it for years on this blog. But I
code in more languages than VB.Net or C#, and the plugin isn't available within the
Flash or LoadRunner IDE. I was also frustrated with pasting my code in, only to find
that it was too wide for my blog theme's margins, and would have to go back to Visual
Studio, change my line endings, and repeat the process. I'm sticking with Google Syntax
Highlighter. It works for all of my languages (as soon as I finish writing my ActionScript
brush), and when my line endings are too long, I simply change my HTML. And in my
HTML, my code still looks like code, rather than a mess of embedded style. I have
to sacrifice RSS formatting, but as a presentation developer that is very particular
about his HTML, I am glad for the customization and control.
&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:5e03f5f4-120c-4ce0-96ea-32867691f7e7" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati
Tags: &lt;a href="http://technorati.com/tags/SyntaxHighlighter" rel="tag"&gt;SyntaxHighlighter&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Syntax%20Highlighter" rel="tag"&gt;Syntax
Highlighter&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Google%20Code" rel="tag"&gt;Google
Code&lt;/a&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=417c2df3-d32c-436c-8c5c-46e1fe4b2808" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,417c2df3-d32c-436c-8c5c-46e1fe4b2808.aspx</comments>
      <category>Blogging</category>
      <category>JavaScript</category>
      <category>Programming</category>
      <category>Reviews</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=8edeeedc-5cb5-494c-bf06-231c52933fd6</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,8edeeedc-5cb5-494c-bf06-231c52933fd6.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,8edeeedc-5cb5-494c-bf06-231c52933fd6.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=8edeeedc-5cb5-494c-bf06-231c52933fd6</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently, here at the ranch, we have been experiencing a few issues with Internet
Explorer’s javascript functionality. It’s not that IE is doing anything wrong, but
rather that it performs unexpectedly. When opening a new window in javascript [window.open()],
the height and width dimensions are relative to the size of the canvas / stage / content
area (depending on what discipline you are from), all commonly referred to as innerHeight
and innerWidth. However, when you execute a resize function in javascript [window.resizeTo()],
the height and width dimensions are relative to the size of the entire window, including
any chrome, commonly referred to as outerHeight and outerWidth.
</p>
        <p>
Thus, if you create a window (500px x 300px), then resize it to (505px x 305px), the
window will actually get <em>smaller</em>, since the chrome adds more than 5 pixels
to height and width.
</p>
        <p>
The problem: SCOs (Courseware) can be of any size, depending on the specifications,
requirements, and whims of the original clients and developers. To keep courses in
their most visual-appealing state, we need to size the content window to precise innerHeight
and innerWidth pixel dimensions. Due to our site’s design, the link that launches
the Course Shell window has no idea what the size of the SCO is. The Course Shell
(LMS) knows how big the SCO is, but it is loaded into the Course Shell window, which
is obviously done <i>after</i> the window is created and initially sized. We need
a way to size the window to content-dimensions after the window is created.
</p>
        <p>
The catch: Internet Explorer has no native support for innerHeight and innerWidth,
let alone a way to resize to those dimensions. Furthermore, the difference between
the inner- and outer-dimensions due to window chrome can change from OS to OS and
from theme to theme. For example, in Windows XP’s default “bubbly” themes, the title
and status bars are much taller than in Windows “Classic” themes. Internet Explorer
has no native way to identify the difference in inner- and outer-dimensions, making
it difficult to resize to an inner size using an outer size command.
</p>
        <p>
I hacked together some (perhaps mediocre, but still effective) javascript to resize
a window to its inner dimensions rather than the outer dimensions, regardless of the
amount of chrome that the OS adds.
</p>
        <p>
          <strong>HTML</strong>
        </p>
        <pre name="code" class="html">&lt;div id="resizeReference"
    style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; z-index: -1;"&gt;
    &amp;nbsp;
&lt;/div&gt;</pre>
        <p>
          <strong>Javascript</strong>
        </p>
        <pre name="code" class="js">function resizeWindow(iWidth, iHeight){
    var resizeRef = document.getElementById('resizeReference');
    var iOuterWidth = iWidth + 10;
    var iOuterHeight = iHeight + 29;
 
    if (resizeRef) {
        var iPreWidth = resizeRef.offsetWidth;
        var iPreHeight = resizeRef.offsetHeight;
        window.resizeTo(iPreWidth,iPreHeight);
        var iPostWidth = resizeRef.offsetWidth;
        var iPostHeight = resizeRef.offsetHeight;
        iOuterWidth = iWidth + (iPreWidth-iPostWidth);
        iOuterHeight = iHeight + (iPreHeight-iPostHeight);
    }
    window.resizeTo(iOuterWidth, iOuterHeight);
}</pre>
        <p>
The HTML tag creates a hidden DIV whose height and width match the window. This provides
innerHeight and innerWidth. The JS takes the dimensions of that DIV and resizes the
window to those measured dimensions. Since this transfers the inner-dimensions to
the outer-dimensions, this provides the exact size of the window chrome. We can now
resize to the input parameter height and width, plus the height and width of window
chrome, to give us a resize to inner-dimensions.
</p>
        <p>
Execute resizeWindow no sooner than below the closing Body tag, so that the DIV is
rendered.
</p>
        <p>
It is a bit of a hack, but it works for now.
</p>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=8edeeedc-5cb5-494c-bf06-231c52933fd6" />
      </body>
      <title>Resizing IE to innerHeight and innerWidth</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,8edeeedc-5cb5-494c-bf06-231c52933fd6.aspx</guid>
      <link>http://www.cptloadtest.com/2006/05/02/Resizing-IE-To-InnerHeight-And-InnerWidth.aspx</link>
      <pubDate>Tue, 02 May 2006 14:23:23 GMT</pubDate>
      <description>&lt;p&gt;
Recently, here at the ranch, we have been experiencing a few issues with Internet
Explorer’s javascript functionality. It’s not that IE is doing anything wrong, but
rather that it performs unexpectedly. When opening a new window in javascript [window.open()],
the height and width dimensions are relative to the size of the canvas / stage / content
area (depending on what discipline you are from), all commonly referred to as innerHeight
and innerWidth. However, when you execute a resize function in javascript [window.resizeTo()],
the height and width dimensions are relative to the size of the entire window, including
any chrome, commonly referred to as outerHeight and outerWidth.
&lt;/p&gt;
&lt;p&gt;
Thus, if you create a window (500px x 300px), then resize it to (505px x 305px), the
window will actually get &lt;em&gt;smaller&lt;/em&gt;, since the chrome adds more than 5 pixels
to height and width.
&lt;/p&gt;
&lt;p&gt;
The problem: SCOs (Courseware) can be of any size, depending on the specifications,
requirements, and whims of the original clients and developers. To keep courses in
their most visual-appealing state, we need to size the content window to precise innerHeight
and innerWidth pixel dimensions. Due to our site’s design, the link that launches
the Course Shell window has no idea what the size of the SCO is. The Course Shell
(LMS) knows how big the SCO is, but it is loaded into the Course Shell window, which
is obviously done &lt;i&gt;after&lt;/i&gt; the window is created and initially sized. We need
a way to size the window to content-dimensions after the window is created.
&lt;/p&gt;
&lt;p&gt;
The catch: Internet Explorer has no native support for innerHeight and innerWidth,
let alone a way to resize to those dimensions. Furthermore, the difference between
the inner- and outer-dimensions due to window chrome can change from OS to OS and
from theme to theme. For example, in Windows XP’s default “bubbly” themes, the title
and status bars are much taller than in Windows “Classic” themes. Internet Explorer
has no native way to identify the difference in inner- and outer-dimensions, making
it difficult to resize to an inner size using an outer size command.
&lt;/p&gt;
&lt;p&gt;
I hacked together some (perhaps mediocre, but still effective) javascript to resize
a window to its inner dimensions rather than the outer dimensions, regardless of the
amount of chrome that the OS adds.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;HTML&lt;/strong&gt;
&lt;/p&gt;
&lt;pre name="code" class="html"&gt;&amp;lt;div id="resizeReference"
    style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; z-index: -1;"&amp;gt;
    &amp;amp;nbsp;
&amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;p&gt;
&lt;strong&gt;Javascript&lt;/strong&gt;
&lt;/p&gt;
&lt;pre name="code" class="js"&gt;function resizeWindow(iWidth, iHeight){
    var resizeRef = document.getElementById('resizeReference');
    var iOuterWidth = iWidth + 10;
    var iOuterHeight = iHeight + 29;
 
    if (resizeRef) {
        var iPreWidth = resizeRef.offsetWidth;
        var iPreHeight = resizeRef.offsetHeight;
        window.resizeTo(iPreWidth,iPreHeight);
        var iPostWidth = resizeRef.offsetWidth;
        var iPostHeight = resizeRef.offsetHeight;
        iOuterWidth = iWidth + (iPreWidth-iPostWidth);
        iOuterHeight = iHeight + (iPreHeight-iPostHeight);
    }
    window.resizeTo(iOuterWidth, iOuterHeight);
}&lt;/pre&gt;
&lt;p&gt;
The HTML tag creates a hidden DIV whose height and width match the window. This provides
innerHeight and innerWidth. The JS takes the dimensions of that DIV and resizes the
window to those measured dimensions. Since this transfers the inner-dimensions to
the outer-dimensions, this provides the exact size of the window chrome. We can now
resize to the input parameter height and width, plus the height and width of window
chrome, to give us a resize to inner-dimensions.
&lt;/p&gt;
&lt;p&gt;
Execute resizeWindow no sooner than below the closing Body tag, so that the DIV is
rendered.
&lt;/p&gt;
&lt;p&gt;
It is a bit of a hack, but it works for now.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=8edeeedc-5cb5-494c-bf06-231c52933fd6" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,8edeeedc-5cb5-494c-bf06-231c52933fd6.aspx</comments>
      <category>JavaScript</category>
      <category>Programming</category>
    </item>
  </channel>
</rss>