Blog Archives

The less obvious changes in TortoiseSVN 1.7

Haven’t heard much from people about their observations on what is a fairly major upgrade to the SVN shell for Windows.

Anyone who uses Tortoise and is considering the upgrade should check the changelog before proceeding.

The obvious/major changes are covered there including the new metadata format for working copies which requires your project working copies to be upgraded. Also the log dialog, revision graph, branch/tag and commit dialogs have all undergone a lot of interface improvements.

So far I’ve already noticed two other changes not documented in the changelog on tortoisesvn.net, they’re specific to functions that I know I use at least once a day so it’s worth highlighting them.

SVN Export

The ‘SVN Export’ function has always been one of Tortoise SVN’s most overlooked menu items. Export only runs on folders and when run, it copies the selected folder to another folder removing the .svn folders recursively so that you get a completely unversioned copy of the original folder and it’s children.

One of the problems with the function that was always counter-intuitive was that the destination folder could not be created, it was just created under the destination you selected. So exporting ‘Temp’ to C:\Temp would put the unversioned contents in C:\Temp\Temp.

In 1.7, this has been changed. When you export an SVN folder, the destination folder is where the contents of the folder you’re exporting will be placed. So now you have to create a new folder where your export will be copied to.

Hard to see why this wasn’t included in the changelog and something you only find out through trial-and-error, as welcome as the change is.

SVN Cleanup

I’m not sure how many people ever knew what ‘Cleanup’ did. Over the years I’ve seen developers run it on folders trying to fix conflicts, directory not found errors and every other SVN error a repo could return.

In 1.7, running an SVN Cleanup will now give you an options menu that allows you to choose what cleanup options to run. I know I’ve always used cleanup to refresh shell overlays (the SVN icons), but now the new menu shows you some other options. Nice.

 

Tortoise SVN Cleanup dialog in 1.7

Tortoise SVN: Release notes/changelog for 1.7

LinkedInDiggRedditTumblrGoogle GmailPrintFriendlyEmailShare

Obscure Sitecore Features, inspired by Julian’s Flight Simulator

To the untrained eye, this blog might look a little neglected when really it’s just been taking a hiatus from publishing blog posts. More regular updates are around the corner including a project I’ve wanted to finish for almost six months.

In the meantime, I wanted to highlight an excellent blog post by Julian over at Igloo.

I’ve worked with Julian twice before and now for an account at Reactive we’re working together to create an SVN masterpiece that will allow two separate development teams to compete directly to create code conflicts. You can follow Julian on Twitter.


Microsoft Flight Simulator 9/11

This is Julian's screen most days


Around June, Julian took a break from playing Microsoft Flight Simulator and wrote a blog post about some useful but obscure features of Sitecore. Only coming across it last night, I notice that it’s only be re-tweeted five times which is a shame because it’s really useful.

The Gloo: Top 5 Obscure Sitecore Features

Hopefully this blog post and my excessive use of WordPress SEO plugins will help generate some more views for this piece. A couple of the most interesting for me were: BulkUpdateContext; is a must-have for anyone who is doing content migration using Sitecore and the third (UrlString Class) is something I’ve used before, but like many parts of the Sitecore API, aren’t widely known.

Not sure if I can come up with five of my own but here’s a couple, perhaps not-as-obscure features.

  1. Developer Center: XPath Builder: hardly obscure you might say but the number of certified developers I’ve come across who didn’t know it existed is surprising. In the CMS, open the menu and run Developer Center, when it loads click  Tools > XPath Builder from the menu.

    XPath Builder

    This tool allows a developer to test Sitecore XPath queries in the CMS against the database, these queries can then be used by the Sitecore.Data.Database methods: SelectItems, SelectItemsUsingXPath, SelectSingleItem and SelectSingleItemUsingXPath. The Sitecore Developer Network has an excellent reference on using Sitecore Query, you’ll need an SDN login to view it.

    Besides from testing query syntax, it’s also a useful way to compare query:/ vs fastquery:/ speeds.

    Here’s a basic rundown of the fields in XPath Builder:

    • Context Node: the node from which the query will be executed, this can help you test ancestor and descedant queries
    • Database selector: choose to run the query against core, master or web
    • XPath Expression: enter a Sitecore Query using query or XPath notation
    • Result: returns the results of the query (or any error messsages). The number of items returned is limited by web.config setting Query.MaxItems
  2. Utility classes in the root Sitecore namespace: they can be easy to miss if you’ve never looked in the Sitecore namespace or the documented API before, here’s a rundown of a few that I’ve found useful in the past:
    • Sitecore.Constants: system-wide constants, far too many to describe here but I’ve no doubt many places/developers have coded their own ways to get these values
    • Sitecore.DateUtil: Sitecore stores all datetimes in ISO format “yyyyMMddTHHmmss”, this class contains methods to convert this string to and from .Net’s DateTime type
    • Sitecore.DaysOfWeek enum: pretty straight-forward
    • Sitecore.FieldIDs: a static class for holding well-known GUIDs relating to template fields, useful for API work on Templates
    • Sitecore.ItemIDs: a static class for holding assorted well-known GUIDs, for example the ID of the Layouts root folder or the Templates root folder
    • Sitecore.MainUtil: far too broad to describe in detail but here’s a few functions included you may have coded yourself in previous Sitecore projects: ColorToString, CombineArrays, DecodeName, EncodeName, SendMail (uses SMTP settings from the web.config).
    • Sitecore.StringUtil: utility functions for string manipulation
    • Sitecore.TemplateIDs: (really, really useful) a static class for holding well-known GUIDs relating to core Sitecore templates, i.e. Command, Folder, Image, MediaFolder and many more.

    Details of all these classes and more are available through SDN, especially useful in Windows Help format for the entire API as part of the documentation package.

Finally, just to continue the private jokes with Igloo, Julian has been kind enough to wait for us to do something on the shared server “when you’re finished playing Microsoft Flight Simulator”, and I’ve told him repeatedly that it’s actually The Sims we’re all hooked on. The pool trick I told Julian about last week, well I found the page where I learnt about it as a kid in my late teens (with no friends). On Sammys Kill your Sim tutorial (possibly the greatest title in SEO history) the example you see below has not been photoshopped.

 

Nice ass Jules

This is what will happen if Igloo commit code that breaks the build

LinkedInDiggRedditTumblrGoogle GmailPrintFriendlyEmailShare

October 2010, an update!

So a year on from starting at IE, what’s news? Besides spring and the joy of hayfever again, I thought I’d give a run down on what’s been keeping me busy.

Hoyts.com.au and hoyts.co.nz; the website for the cinema chain that operates here and in NZ is both a business and technical challenge on many levels. Dealing with external vendors, multiple stakeholders and a codebase that was far from Sitecore best practice has been a learning experience. In the year since we’ve managed to put live a home page redesign, regular maintenance updates and bug fixes, and most importantly; the new rewards program which is going strong.

Hoyts Corporate Australia and New Zealand; architecturally what should have been a fairly straight-forward exercise to create a ‘microsite’ running off a main site presented it’s own challenges when working around some publishing booby traps left by the previous developers. Also learnt some lessons about working with a multi-site Sitecore installation.

Hoyts Mobile Australia and New Zealand; a couple of brand new Hoyts websites, no Sitecore integration. Designed to replace an older WAP mobile site, the new mobile website incorporates some of the latest HTML5 and CSS3 techniques to streamline front-end development. Server side, it was awesome to work with MVC2, not having done any MVC development for a while, it took a while to get used to again.

Other stuff about mobile development and this site:

Maxxia NZ; just to make sure Sitecore isn’t the only CMS I work on, I did Level 1 and 2 Umbraco certification. Just in time to build the Maxxia NZ website. Nothing notable about the site itself, from the point of view of CMS’s though, it’s refreshing to work with a different CMS and one that really is bare-bones compared to Sitecore. Highly recommended for small/mid-level organisations looking for a .Net CMS, or for anyone not looking to pay for Sitecore’s full feature set.

IE Website; much to the amusement of the other .Net developers, I also put my hand up to play with WordPress. I’m not sure I’d call myself a WordPress guru, but I did get to play with a couple of cool new features of WordPress; custom post types and taxonomies.

Along the way, I’ve also learnt a hell of a lot more about front-end development than I expected. I’d even say I know my way around Photoshop and creating non-table layouts in CSS… it’s only taken me a few years to catch up to everyone else on this.

Finally, I couldn’t finish this post without giving a shout out to all the peeps at IE. They’re pretty sweet ;)

Special kudos to the .Net team there, the dorks… and Mig’s mum. She’s super sweet. ;)

LinkedInDiggRedditTumblrGoogle GmailPrintFriendlyEmailShare

Using Sitecore.NVelocity library to create email templates

If you find yourself sending emails from a Sitecore application and you don’t want to generate the emails in code-behind, an easy way to create basic email templates is by using the NVelocity library built into Sitecore API.

What is NVelocity?

NVelocity is a .Net port of the popular template engine Velocity written in Java. The .Net port is mostly recently maintained by the guys at Castle Project.

Sitecore’s NVelocity library

This is probably a bit older but still works fine for basic email templates.

One problem I repeatedly ran into, with both the Sitecore NVelocity library and the Castle Project NVelocity implementation was loading template files from the file system. After wasting a couple of hours on this (repeatedly the template file could not be found, no matter what I tried) I gave up and loaded the templates into memory using a TextReader and then applied the template using VelocityHelper.Evaluate.

Unfortunately there is nowhere near enough documentation online about NVelocity issues with reading template files, or the Sitecore NVelocity library to get much help with this problem. Basically any call to load a template file (using GetTemplate) would result in a ResourceNotFoundException.

Example of a NVelocity email template

Thank you for your registration

Your username was: $username

The delivery details you gave were:

Address: $address
City: $city
State: $state

Thank you

The file above should be saved somewhere as a .vm file, for example template1.vm. This is a basic email template for NVelocity, you use the dollar sign followed by a variable name to define somewhere that content is replaced, so in the example ‘username’, ‘address’, ‘city’ and ‘state’ are template data values.

Replacing content

This is the implementation that worked for me.

private void SendEmail()
{
 System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
 System.Text.StringBuilder sb = new System.Text.StringBuilder();
 string filePath = HttpContext.Current.Server.MapPath("/common/templates/template1.vm");
 string template;

 if (!System.IO.File.Exists(filePath))
 throw new ApplicationException("Could not find email template file: " + filePath);

 System.IO.TextReader reader = new System.IO.StreamReader(filePath);
 template = reader.ReadToEnd();

 NVelocity.VelocityContext context = new NVelocity.VelocityContext();

 context.Put("username", "hansolo");
 context.Put("address", "1337 Isme Street");
 context.Put("city", "Built On Rock N' Roll");
 context.Put("state", "VIC");

 message.From = new MailAddress("web@testsender.com");
 message.To.Add("recipient@test.com");
 message.Subject = "Test of NVelocity as email templating engine";
 message.IsBodyHtml = false;

 NVelocity.App.Velocity.Init();
 message.Body = Sitecore.Text.NVelocity.VelocityHelper.Evaluate(context, template, "example-template-replace");

 MainUtil.SendMail(message);            
}

What this does is takes the contents of the template1.vm file and replace all the values found inside using the values defined in the context.Put statements. Note these values don’t need to include the dollar sign.

Calling VelocityHelper.Evaluate and passing in a NVelocity VelocityContext, in-memory template (read from file system using System.IO) and log name will return the contents of the template with specified values replaced from the context passed in.

Output Email body

From the example above this is the body of the email sent.

Thank you for your registration

Your username was: wonaldng

The delivery details you gave were:

Address: 1337 Isme Street
City: Built On Rock N' Roll
State: VIC

Thank you

Useful links

Castle Project: Using NVelocity – the most referenced tutorial for this library.

Velocity @ Apache.org – Java version reference documentation.

Velocity is, on it’s own, a very strong template engine. In an advanced situation it can do a lot more than just replacing variables in a template, including things like program-control and conditional statements.

Hope this saves you some time if you ever have to go down this path.

LinkedInDiggRedditTumblrGoogle GmailPrintFriendlyEmailShare

Firefox overtakes Internet Explorer in Germany

Das Spiegel Online

Good news!

LinkedInDiggRedditTumblrGoogle GmailPrintFriendlyEmailShare

OCAU Hacked! Whirlpool Hacked(?)

Another day, yet another vBulletin break-in. Making off with potentially thousands of passwords… this time it’s Overclockers Australia forum.

Possible Security Issue (ya think?)

Just got this via email…

We’re still investigating what happened.  However, it is very likely that your OCAU password has been compromised.  Therefore please change your OCAU password as soon as possible.

Also, if you use the same password elsewhere, you should probably change those as well.  However, please be aware that using the same password on multiple services is a bad idea.

While there probably isn’t anything lower you can do than to hack a community forum, hopefully the fact that vBulletin now store passwords MD5′d and Hashed will add a level of security to prevent a stolen User table being brute-forced easily.

Still, it’s a timely reminder to only give out access to those you trust, and if possible, lock down database access to only a handful of site engineers & developers.

UPDATE:

Holy shit! Looks like Whirlpool was hit too.

*craps pants*

*cries*

LinkedInDiggRedditTumblrGoogle GmailPrintFriendlyEmailShare

Scripting data in SQL 2008 Enterprise Manager

Did you know this incredibly useful feature now comes with SQL 2008′s Enterprise Manager? I haven’t tested it with multiple tables that have complex relationships, but if you want to script data with more complexity, you should consider Red Gate’s SQL Data Compare.

Script Data in MS SQL Server 2008 Database Tables using Generate SQL Server Script Wizard

If neither is feasible, one of the most popular, creative and often-overlooked options is to use Microsoft Excel and write a formula to generate INSERT statements. Drag the cell corner to copy this formula for multiple rows. There are also many other code generation possibilities from this technique if you think creatively.

SQL Queries from Excel

Scripting SQL data is easy to do, make it part of your build process! Stick it in SVN and you bring version control to your database development.

LinkedInDiggRedditTumblrGoogle GmailPrintFriendlyEmailShare

Bored of Lorem Ipsum?

Check out BlindTextGenerator, a site that will generate dummy text for you with a number of exciting options.

I’m sure designers will get excited about this… boring people that they are. :p

LinkedInDiggRedditTumblrGoogle GmailPrintFriendlyEmailShare

ADO.Net performance: ExecuteReader vs ExecuteNonQuery vs ExecuteScalar

Just re-linking a two year old blog post with performance advice that every developer using ADO.Net should read.

ExecuteReader, ExecuteNonQuery, ExecuteScalar … When to use What ?

Further notes:

  • Here is a good example (post #3) of how to implement OUTPUT parameters in a stored procedure using ExecuteNonQuery(), ignore post #2, he doesn’t know what he’s talking about.
  • Another example with just the ADO.Net side from MSDN: Executing a Command and Accessing Output Parameters.
  • The ExecuteNonQuery method returns the number of rows affected by the query (typically for Insert, Update, or Delete operations). From the MSDN page above.
LinkedInDiggRedditTumblrGoogle GmailPrintFriendlyEmailShare

Who is responsible for WordPress maintenance?

This post is a response to a blog post by Jeff Chandler at Weblog Tools Collection titled:

Are You Responsible Enough To Run WordPress?

As Jeff mentions, the advent of such a powerful blogging framework lowers the bar of entry significantly for web publishing, but to blame the end users for a failure on their part to update their WP installations is unfair. While I don’t think WordPress themselves are in any way to blame, I don’t agree with the implications of expecting content authors to also be website administrators.

I think WP publishers are no different to end users of the Windows operating system. What WordPress and the massive developer community around it has achieved is unprecedented in the history of the web, but to ask end users of this product to see themselves as having some measure of technical responsibility for their site will require a significant paradigm shift.

You can’t just upload WordPress, perform a bunch of customizations, install 50 plugins, 50 themes, and think everything will be fine from that day forward.

Yet this is exactly what WP users are doing and nothing in the installation process really makes someone pay attention to the community around WP development or stay informed with product development. Anyone who buys hosting space and sets up WordPress immediately falls into “end user” mode. It’s like expecting your average Excel user to keep updated with Microsoft Office security bulletins.

Yes, WordPress is incredibly easy-to-use, easy-to-install and a walk in the park to customise, but there’s still plenty of room for improvement. I believe the developers of an application have a responsibility to make sure the users are being properly educated on their obligations, so why aren’t people installing WordPress told more about security, why aren’t people installing plug-ins or themes being told (perhaps they need to be told more forcefully) about how these installations can impede their upgrade options and the security ramifications that can result?

You don’t have to be a fan of Microsoft or Apple to recognise that they got rich by buffering end-users from the technical details underlying the technology we use every day.

The sentiment from some sections of this community; that people without the technical knowledge to manage Apache configuration, understand PHP code or perform an SVN merge have no business running a website is something that needs to die (in a fire).

LinkedInDiggRedditTumblrGoogle GmailPrintFriendlyEmailShare

Switch to our mobile site