CAPTCHA Update

By
Dave
Project
Published
27 Aug 2013 19:04
Last Modified
27 Aug 2013 19:18

Even though I previously added a CAPTCHA, I've recently been getting a lot more comment spam.

While I'm tempted to turn off commenting altogether because of the nuisance caused by spammers, I thought I'd first try and tighten-up the implementation. Hopefully it will reduce the comment spam, and shouldn't make posting genuine comments any less inconvenient that it is now.

Blog Indexes

By
Dave
Project
Published
17 Jan 2013 13:31
Last Modified
17 Jan 2013 13:32

As the number of blog posts grow it becomes increasingly important to provide flexible ways to access individual entries. I've now added a basic index by both date and project, using the following URL structure:

  • http://{domain}/index/blog/{year}/{month}/{day}/ for posts, optionally by year, month, and day
  • http://{domain}/index/blog/category/{slug} for posts, optionally by category

Vanity URLs Part 2

By
Dave
Project
Published
22 Apr 2012 11:54
Last Modified
13 Jan 2013 18:14

I previously described an approach for supporting vanity URLs through the use of the MVC routing table. Since my hosting company now supports IIS7 Remote Administration, an alternative approach is to use IIS HTTP Redirection.

I simply add a folder to my web site, connect using IIS Manger and add an HTTP Refirect to the original URL. The advantage of this approach is that I can redirect URLs from the root web site (will not be parsed by the MVC routing table), such as:

http://{domain}/{slug}

Vanity URLs

By
Dave
Project
Published
15 Apr 2011 11:31
Last Modified
13 Jan 2013 18:15

The category controller currently uses the following URL structure:

http://{domain}/blog/category/{slug1}

It is often useful for URLs to be more concise, for example when adding a caption to a video. In such cases "vanity URLs" are often used. I've updated the blog categories to enable them to support a vanity URL, currently based on the category slug, as follows:

http://{domain}/blog/{slug}

The approach I took was to inject specific entries into the MVC routing table. Clearly this wouldn't be sensible for large numbers of entries, but the number of blog cetegories should be relatively small, and not every category has to have one. An added complication is that whenever I add, update, or delete a category I may need to regenerate the routing table to support adding/removing vanity URLs. I add the enries as follows:

foreach (Category category in new BlogService().ListCategories())
   if (category.VanityUrl)
      routes.MapRoute(category.Slug, category.Slug, new { controller = "Archive", action = "CategoryIndex", name = category.Slug });

Listing 1. Adding vanity URLs to MVC route table

1 A slug is a "friendly" URL (both from an SEO and human-perspective), using characters which do not require HTML-encoding (e.g. dashes instead of spaces)

Size Matters

By
Dave
Project
Published
24 Jan 2011 21:08
Last Modified
13 Jan 2013 18:15

There's plenty more features I'd like to add to this blog engine, but it's currently serving me well.

One of the things I found refreshing about this project is that I now have a reasonably-spec'd personal blog-engine in just a 75Kb download (the source code is 80Kb). OK, the downloads are .zip files, but they expand to 176Kb, and 225Kb respectively (including images).

Disk-space and bandwidh may be cheap, but such a small download to run a blog site appeals to me. Could this be one of the smallest .NET-based blog engines available? :)

Blog Engine v1.2 Released

By
Dave
Project
Published
5 Jan 2011 23:13
Last Modified
13 Jan 2013 18:17

I've made some improvements to my personal, lightweight blog engine from version 1.0 as follows:

  1. Added <meta name="keywords"> and <meta name="description"> tags to the post detail view and post model to help SEO.
  2. Corrected various HTML formatting issues, and provided new, more flexible CSS styles.
  3. Added a blog index showing posts by category.
  4. Added a simple CAPTCHA for comment submission.
  5. Added a gallery.
  6. Added support for site-pinning with Internet Explorer 9 Beta on Windows 7.

You can download version 1.2 using the following links:

  1. Dr Dave's Blog Engine v1.2 (binaries and ASP.NET pages) (zip'd), 75Kb. Files required to run Dr Dave's Blog Engine.
  2. Dr Dave's Blog Engine v1.2 (source code) (zip'd), 79Kb. Visual Studio 2010 project for Dr Dave's Blog Engine.

To install the blog engine using the binaries, follow these steps:

  1. Un-zip the archive and copy the files to your web site.
  2. Browse to your site and you should see the following:

    front page

    Figure 1. Front page after installation.

  3. Click "Sign In". The default username is "admin" with a password of "password". Click "Edit Account" in the Admin menu and change the password. A combination of upper-case letters, lower-case letters and numbers is recommended, with a length of at least six characters. You can also change the username if required.
  4. Click "Settings" on the Admin menu, and update the blog title, sub-title, and feed-title accordingly. Update the other settings if required.

If you decide to use this engine to run your blog, please keep the "Powered by" link, and I'd be grateful if you could inlcude an acknowledgement.

This project remains under active development as and when bugs are identified, or further features are required and I have the time. Note that I do not have time to support the installation or operation of this blog engine, however I will endeavour to answer questions in comments.

Time for the Gallery

By
Dave
Project
Published
30 Dec 2010 23:10
Last Modified
13 Jan 2013 18:18

While reminiscing about watching Take Hart, I decided that I needed a gallery. This would serve as an area to store images such as screenshots of the projects I am working on.

I opted for the following URL structure:

  1. http://{domain}/blog/gallery for all galleries
  2. http://{domain}/blog/gallery/{name} for all images in a given gallery
  3. http://{domain}/blog/gallery/{name}/{index} for a particular image in a given gallery

I added a new gallery controller to the blog engine, and added an index view for the galleries, as shown below in Figure 1. Each gallery has a thumbnail image, a title and a description. Image counts are shown for each gallery.

Galleries

Figure 1. Example galleries.

The gallery index view links to an index action of an image controller, and the view for a particular gallery is shown below in Figure 2. Each image is shown as a thumbnail (created manually), along with a title. I opted for a square thumbnail to avoid issues with different aspect ratios, and paging is enabled.

Galleries

Figure 2. An example gallery.

The image index view links to the detail action, and the view for a particular image is shown below in Figure 3. The image is shown along with a description. 'Previous' and 'Next' links are included.

Gallery Image

Figure 3. An example image in a gallery.

In order to add images, I transfer them to them to the web server (e.g. using ftp), then "add" images to a particualr gallery by specifying the location of the thumbnail and image itself, along with the title and description in an edit view. This metadata is stored using a similar repository to the posts (currently XML) though this could be easily changed.

IE9 Customisation

By
Dave
Project
Published
13 Oct 2010 23:06
Last Modified
13 Jan 2013 18:18

Internet Explorer 9 Beta enables some specific integration features for Windows 7, such as "site pinning" to the Taskbar, Start Menu, and desktop (effectively Site Specific Browsers), customising the navigation button colours, and providing Jump Lists. I'll discuss how I've supported each of these features for my Blog Engine.

Icons

A site can be "pinned" to the Windows 7 Taskbar, Start Menu, and Desktop, for example by dragging the IE9 tab or the address bar icon to the relevant target. The icons used for pinning are defined in the favicon.ico file in the root of the web site. This file contains a number of images at different resolutions which are used for the address bar, tab, browser "Home" button, Taskbar, Start Menu, and pinning the site by dragging the address bar icon.

The icon file is specified in the site.master View using the following tags:

<link rel="shortcut icon" type="image/x-icon" href="/blog/favicon.ico" />
<link rel="icon" type="image/ico" href="/blog/favicon.ico" />
IE9 Beta Taskbar Site Pinning

Figure 1. IE9 Beta Taskbar Site Pinning

Navigation Buttons

I set the colour of the back and forward navigation buttons (see Figure 2) to match the color of my current site header with the following tag:

<meta name="msapplication-navbutton-color" content="#303030" />
IE9 Beta Header

Figure 2. IE9 Beta header

Jump Lists

I was already passing a ViewModel containing the categories and item counts to the master page, so adding links to each category in a Jump List (see Figure 3) using the following tag structure was trivial.

<meta name="msapplication-task" content="name=Category name (item count);action-uri=/blog/archive/category/Random-Stuff;icon-uri=/blog/favicon.ico" />
IE9 Beta Jump List

Figure 3. IE9 Beta Jump List

Pinning the site to the Start Menu also gives access to the Jump List, as shown below in Figure 4.

IE9 Beta Star Menu Site Pinning with Jump List

Figure 4. IE9 Beta Start Menu Site Pinning with Jump List

CAPTCHA Time

By
Dave
Project
Published
22 Jul 2010 23:10
Last Modified
13 Jan 2013 18:20

It's taken a few weeks for the spam-bots to notice my blog engine, but they're now starting to become more active. There are many options in the toolbox for dealing with spam comments, one of which is to add a CAPTCHA. This is a test in which a computer generates a challenge, and then attempts to verify that the response is generated by a human.

There are many CAPTCHA implementations available (reCAPTCHA is a good example), however I though it would be instructive to generate my own. The System.Drawing.Drawing2D namespace got me started, as shown below in Figure 1.

CAPTCHA image

Figure1. Initial CAPTCHA image (enlarged)

The image is generated by a controller action, returning a FileResult object with the appropriate content type. A new image is generated after a configurable interval. There are numerous ways to implement the CAPTCHA check when the comment form is submitted, the simplest of which is to have stored the CAPTCHA data in ASP.NET session state. Given this project is intended as a lightweight, personal blogging engine and that I wouldn't envisage scaling out across multiple servers, this doesn't seem a bad approach for the time-being.

Of course, it's rather sad that I have to use a CAPTCHA, and I apologise for inconveniencing anyone submitting a valid comment.

SEO Results

By
Dave
Project
Published
19 Jul 2010 16:16
Last Modified
3 Jan 2011 01:54

Shortly after implementing the changes to my blog engine as described in the post on Search Engine Optimation, my blog came up as the top result in a Bing search for "Dr Dave", as shown below in Figure 1. Possibly coincidence, but a good outcome nonetheless.

Bing search for Dr Dave

Figure 1. Top search result in Bing!

Still got some way to with Google however, as the same search came 8th overall...

Page