Posts for August 2010

There are several guides on the web covering the addition of Google based search to FlatPress sites.

This plugin takes a slightly different approach by extending the existing SearchBox plugin to also support Google searches and hence the possibility of generating income (if you are lucky) via Google AdSense.

First download the GoogleSearchBox plugin and copy into your fp-plugins folder.

Now go to Google and sign in to you Google account. Select the Custom Search product and generate a search engine for your site. For the look and feel of your custom search engine choose Iframe and then get the code.

When generating the code for you custom Google search engine it is necessary to provide the url for the static page on your FlatPress site where search results will be displayed, for example

On your FlatPress site generate a static page for the Google search results to be displayed on giving it the same name you used previously, e.g. GoogleSearchResults. Into this page paste the search results code provided by Google, for example:

<div id="cse-search-results"></div>
<script type="text/javascript">
  var googleSearchIframeName = "cse-search-results";
  var googleSearchFormName = "cse-search-box";
  var googleSearchFrameWidth = 400;
  var googleSearchDomain = "";
  var googleSearchPath = "/cse";
<script type="text/javascript" src=""></script>

Now go the Plugins page of you FlatPress site. First disable SearchBox. Then enable GoogleSearchBox and go to the configuration page for GoogleSearchBox.

Decide on how you want the search box to be displayed. In its concise form a text box and search button are displayed. The full search box allows the user to decide what form of search to perform - titles only, full or via Google.

In the Target field place the name of your static page where Google search results will appear, e.g. GoogleSearchResults.

In cx enter the unique Id of your search engine. This can be found in the Search box code provided by Google.

The cof field controls where adverts are displayed by Google in the search results. As you change the position you want advertising to be placed in the Google control panel this value will change in the Search box code window. Currently the values appear to be

  • FORID:9 to display adverts to the right
  • FORID:10 to display adverts on the top and to the right
  • FORID:11 to display adverts and the top and bottom

The ie field is the encoding for your Google search results and again can be found in the Search box code generated by Google.

Finally, go the the Widgets control panel on you FlatPress site and place the GoogleSearchBox widget into the appropriate bar.

Note, if a visitor has javascript disabled then they will not be able to issue a search against Google. Instead the search will revert back to using the built in facilities provided by FlatPress.

    A recent project has required a C# based web service to update a directory server with changes it receives.

    For testing the directory server chosen was OpenLDAP as shipped with Ubuntu 10.04 (Lucid Lynx).

    A great little tool found for manipulating this directory was LDAP Admin.

      One of the projects I have been working on uses the nunit.mocks assembly.

      Previously this project used release 2.4.7 of NUnit. On upgrading to 2.4.8 some tests started to fail.

      It appears that the behaviour of the Expect method has subtly changed. Previously the number of times a mocked method was called was irrelevant. With 2.4.8 it now appears Expect needs to be called for each invocation.

      The following code under 2.4.7 would allow LogInformation on ILogger to be called any number of times, but under 2.4.8 would only allow it to be called once.

      internal static ILogger GetMockLogger() { DynamicMock mockLogger = new DynamicMock(typeof(ILogger)); ILogger logger = (ILogger)mockLogger.MockInstance; mockLogger.Expect("LogInformation"); return logger; }

      To allow log Information to be called twice the following code would be used:

      internal static ILogger GetMockLogger() { DynamicMock mockLogger = new DynamicMock(typeof(ILogger)); ILogger logger = (ILogger)mockLogger.MockInstance; mockLogger.Expect("LogInformation"); mockLogger.Expect("LogInformation"); return logger; }