CSS Content To The Rescue

Looking to get a bit of extra visibility for pages on my hiking websites I implemented support for Google’s Rich Snippets.  This feature allows for the markup of pages so that extra bits of information such as user ratings or photos can be included in Google search results.  On a page with a long list of results, the eye catching additions could lead to greater click through rates.

Google supports a couple of different microformats that webpage owners can mark up their pages so that the Google search engine can determine what should be added to their results.  My sites catalog outdoor activities such as hiking trails and allows users to rate their enjoyability.  Marking up the average rating allows Google to show this rating with graphic stars.  The HTML markup such as:

<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"> 
 <span class="rating">
    <span itemprop="average">4.33</span>

is part of the markup that results in a Google search listing that looks like:

Google search result

That’s great!  So what’s the problem?  The problem is that Google does not just rely on markup to try and extract some meta data from the page in order to present them in the search results.  They also do some parsing on their own.  If you view one of the pages that I was trying to support you’ll note that I have an Amazon recommended item at the bottom of the page.  The writeup for this item includes the author(s)’ name preceded by the phrase “by “.  Even with no markup, to Google this is significant and they fetch the name as the author of the page!  Of course they are not the author of the page, but instead only of the item listed.  What to do?

I tried playing with some different text with varying degrees of success until I stumbled upon a solution via CSS, in particular through the content property.  I wanted the user visiting the page to see the author indicated by text similar to “by Robert Barron” but I didn’t want Google to see that.  The solution using CSS involves displaying the author’s name only with a CSS class designation:

<span class="AmazonAuth">Robert Barron</span>

The CSS markup indicates that it should be preceded by the value of content property:

    content: "by ";

The CSS above indicates that before an element of the class AmazonAuth the content should be inserted.  When Google parses web pages for indexing it does not take the CSS markup into account, so the “by ” prefix does not exist as far as it’s concerned and does not cause it to falsely guess the page author’s name.

Posted in Programming | Tagged | Leave a comment

Beware Of Visual Studio Proxy Migrations

I recently moved a C# code project from Visual Studio 2010 on Windows 7 to Visual Studio 2012 on Windows 8.  Theoretically, this should have resulted in no problems and code that just works from the start.  But that’s not the way it turned out.

The project in question was a Web project that included proxy code used to interface with Amazon’s Product API.  Visual Studio 2012 started reporting the following error, “Cannot implicitly convert type ‘Exploricity.Amazon.ECS.ImageSet[][]’ to ‘Exploricity.Amazon.ECS.ImageSet[]’.”

Since I have the source code under version control I was able to determine what files Visual Studio modified and what those changes were.  I found that the Reference.cs file in the Amazon.ECS folder contained a ton of changes.  Most were innocuous generated code changes that reflect the version of various system assemblies:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17929")]

But there was also this change:

public ImageSet[][] ImageSets

Visual Studio attempted to regenerate the proxy code and did so in such a way that broke it by making ImageSets a two dimensional array instead of keeping it as the single dimensional array it was before.

One of the takeaways from this is the importance of version control, even for small personal projects like this one was for me.  It made finding out what the problem was and resolving it a much easier task.

Posted in Programming | Tagged | Leave a comment

WordPress 3.5 on Windows Temp Directory Problem

I installed WordPress on a couple of different hosting accounts that I have on hand to try and see where I should place the final result.  On one of those accounts I was not able to update one of the plugins that was not up-to-date.  I also could not download any themes.

Some forum discussions that I’d come across indicated that this issue was primarily suffered by users who were hosting their site on a Windows machine.  This of course caused many helpful individuals to rail against Windows and recommend upgrading to a Unix hosting account without actually addressing the particular problem directly.  The fact that this issue started with version 3.5 only didn’t detract from their suggestion.

I finally found a useful post that pointed out the true cause of the issue and a simple workaround.  Version 3.5 changed the algorithm used to determine which directory to use for storing temp files as WordPress updates or download modules.  To restore the old behavior without having to approach one’s hosting provider for configuration changes one need only add or update the following line in the wp-config.php file:

define('WP_TEMP_DIR', ABSPATH . 'wp-content/');

Voila!  Everything works fine, even on my more restrictive hosting provider.

Posted in Programming | Tagged | Leave a comment

Welcome to My New Site

You might have noticed that my old personal website had gotten quite stale and needed to be updated.  Though I started the site to learn a bit about web programming, other projects have popped up since then that have drawn my attention and time.

So I thought it best to revisit the design decision here to minimize the amount of time it would take to create a nice looking site that still maintained some of the same information that was here previously.  This new site is designed to do that and add a few extra wrinkles.

There may be an emphasis here on programming topics but there will also be some personal stuff thrown in as well from time to time.  Each post will have a category and possibly multiple tags that should make it easier for you to see the types of posts that might be of interest to you.

Posted in Uncategorized | Leave a comment