Monday, 30 November 2009

Umbraco Developer 's Christmas Office :)

This weekend my colleague and I decided it was a good idea to decorate our office for Christmas, it's quite difficult to actually photograph it to it's full effect, but you'll have to take our word for it, it looks pretty Christmasy :)

We have a 7' Tree covered in lights and decorations, lights around our PC's, tinsel everywhere we could fit it, and even large snow flakes hanging from the ceiling..

You'd think we have no work on, but if fact it's the opposite we're manically busy! But hey, it's a bit of fun and it seems to be cheering everyone up in this otherwise rather Dull Regus Serviced Office ;-)

We can definitely recommend doing something a bit different, as it's got us noticed and we've already won enough extra work from companies in the building to pay for our office for a year, not bad :)

So here's a photo of our office, has anyone else decorated their office? I'd be happy to update this post with any good Christmas office photos that you send me!

Happy Christmas all!

Chris

Thursday, 19 November 2009

Add Intellisense when using the URL rewritingnet config file

I often use the URL re-writing engine that comes with Umbraco which is from urlrewriting.net and I have always found it very fiddly to edit the configuration file, I wish I have know it was possible to add Intellisense to Visual Studio, and I guessed that most people would also not realise this, after all, who reads the manual right?!

So, if you are someone who edits the urlrewriting.config without Intellisense, but would like to use it, this is how you do it :)

1) Download the URL rewriting source code files from urlrewriting.net
2) Unzip the source files and find the urlwritingnet.xsd file, put this file into your web project, or the directory where your urlredirect.config lives.
3) Open up the web project and then open your config file, and hey presto! You should find you now have intellisense!

So, the next question is, are there XSD files for the rest of the Umbraco config files, and more importantly for the Umbraco.xml file? If not, does anyone fancy creating them? I am sure intellisense for all these files would be very helpful :)

Sunday, 15 November 2009

Twitter Feeds in Umbraco using XSLT

There are currently two packages tagged on the Umbraco forum that can be used to add a twitter feed to your website. I was playing around with "Twitter for Umbraco" by Warren Buckley and noticed a bug in the way it converted twitter @names to links, so I thought I would try and solve this using XSLT.

It may also be useful for those of you using Darren Ferguson's "Feed Cache" package as the demo on Darren's site does not add links to the tweets.

To use this XSLT you simple call the XSLT Template passing in your Twitter message:

<xsl:call-template name="formaturl">
<xsl:with-param name="url" select="text"/>
</xsl:call-template>

Then add the XSLT template to your XSLT macro (outside of the main template)

<xsl:template name="formaturl">
<xsl:param name="twitterfeed"/>
<xsl:variable name="transform-http" select="Exslt.ExsltRegularExpressions:replace($twitterfeed, '(http\:\/\/\S+)',ig,'<a href="$1">$1</a>')"/>
<xsl:variable name="transform-https" select="Exslt.ExsltRegularExpressions:replace($transform-http, '(HTTps\:\/\/\S+)',ig,'<a href="$1">$1</a>')"/>
<xsl:variable name="transform-AT" select="Exslt.ExsltRegularExpressions:replace($transform-https, '(^|\s)@(\w+)',ig,' <a href="http://www.twitter.com/$2">@$2</a>')"/>
<xsl:variable name="transform-HASH" select="Exslt.ExsltRegularExpressions:replace($transform-AT, '(^|\s)#(\w+)',ig,' <a href="http://www.twitter.com/search?q=$2">#$2</a>')"/>
<xsl:value-of select="$transform-HASH" disable-output-escaping="yes"/>
</xsl:template>

You should find that this now replaces all the @names, #names and URL's with links!

Sunday, 1 November 2009

Survey about Umbraco Repositories

I am currently thinking about developing a hosted repository service for Umbraco Packages, this will allow free, private and commercial repositories to be available within the Umbraco interface for immediate installation.

I would be really interested to hear your views and opinions on this sort of service:

Please answer this survey!

Everyone who answers the survey and leaves their email address will be sent an invitation to beta test the service when it launches in the near future :)

Tuesday, 20 October 2009

Umbraco Permissions Script - Secure Version

Back in May I blogged about how to set Permissions for Umbraco using SetACL to set the appropriate directory permissions based on the installation recommendations.

Recently I have been working on a site for a client who wanted every security item to be locked down as tightly as possible. And so I modified the script based on the Umbraco security best practices, I thought I'd share it with everyone, if I have missed anything, or if anyone has any suggestions on how to improve this, please let me know :)

Please refer to my previous post regarding the SetAcl command line application that you will need.

I suggest you save the following into a batch file called: umbPermSecure.bat

echo off
REM Script to setup the Security Permissions for an Umbraco site
REM This script will give your machine Network Service the minimum rights required
REM for Umbraco to work

REM I suggest you update this script to also remove any users who do not need
REM access to the web folders

REM **** Pre-requisites ****
REM You will need to download -> http://setacl.sourceforge.net/
REM It is assumed that you have stored SetACL in a directory called, C:\SetACL if
REM not, you will need to modify the script.

REM **** Usage ****
REM You need to pass in the path for the root of your Umbraco directory
REM E.g. umbPermSecure.bat C:\inetpub\umbracoroot

@echo umbPermSecure.bat - Script to set Umbraco File and Directory Permissions
@echo based on the Umbraco Security Best Practices Document (13th March 2009)
@echo Published by Chris Houston - 19th October 2009
@echo http://blog.vizioz.com

@echo Adding READ only access

SetACL.exe -on "%1" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:read"
-actn clear -clr "dacl,sacl" -log "c:\setacl\log.txt"
SetACL.exe -on "%1\web.config" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:read"
-actn clear -clr "dacl,sacl" -log "c:\setacl\log.txt"
SetACL.exe -on "%1\bin" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:read"
-actn clear -clr "dacl,sacl" -log "c:\setacl\log.txt"
SetACL.exe -on "%1\umbraco" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:read"
-actn clear -clr "dacl,sacl" -log "c:\setacl\log.txt"

@echo Adding READ and EXECUTE access

SetACL.exe -on "%1\app_code" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:read_ex"
-actn clear -clr "dacl,sacl" -log "c:\setacl\log.txt"
SetACL.exe -on "%1\usercontrols" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:read_ex"
-actn clear -clr "dacl,sacl" -log "c:\setacl\log.txt"

@echo Adding READ, WRITE and MODIFY access

SetACL.exe -on "%1\config" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:read"
-ace "n:%computername%\NETWORK SERVICE;p:change" -actn clear -clr "dacl,sacl" -log "c:\setacl\log.txt"
SetACL.exe -on "%1\css" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:read"
-ace "n:%computername%\NETWORK SERVICE;p:change" -actn clear -clr "dacl,sacl" -log "c:\setacl\log.txt"
SetACL.exe -on "%1\data" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:read"
-ace "n:%computername%\NETWORK SERVICE;p:change" -actn clear -clr "dacl,sacl" -log "c:\setacl\log.txt"
SetACL.exe -on "%1\masterpages" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:read"
-ace "n:%computername%\NETWORK SERVICE;p:change" -actn clear -clr "dacl,sacl" -log "c:\setacl\log.txt"
SetACL.exe -on "%1\media" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:read"
-ace "n:%computername%\NETWORK SERVICE;p:change" -actn clear -clr "dacl,sacl" -log "c:\setacl\log.txt"
SetACL.exe -on "%1\python" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:read"
-ace "n:%computername%\NETWORK SERVICE;p:change" -actn clear -clr "dacl,sacl" -log "c:\setacl\log.txt"
SetACL.exe -on "%1\scripts" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:read"
-ace "n:%computername%\NETWORK SERVICE;p:change" -actn clear -clr "dacl,sacl" -log "c:\setacl\log.txt"
SetACL.exe -on "%1\xslt" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:read"
-ace "n:%computername%\NETWORK SERVICE;p:change" -actn clear -clr "dacl,sacl" -log "c:\setacl\log.txt"

Saturday, 22 August 2009

Umbraco Certified Developer - Level 2 - Chris Houston

I just thought I'd create a quick blog post to say that I have now been on the Umbraco Level 2 course (which I would recommend!) and although it turned out that I pretty much new 95% of what was taught, the extra 5% and a chance to have a trip to Copenhagen made it worth it :)

I am now officially Umbraco level 2 certified :)

Hopefully over the next month I will have some time to start adding a few more useful blog posts to my blog. I know I've been a little slack on the posting in the last month, it's just been a busy time for me!

Thursday, 9 July 2009

How to add items to the Document Types context menu.

I am currently working on an extension to Umbraco that needed an extra menu item on the Document Types menu in the Settings section, my first thought was to use the BeforeNodeRender event to add the menu item, but this event only fires on the Content and Media menu trees.

See: Codeplex Issue 21623

The "temporary" solution has been to extend the "loadNodeTypes" class, I say temporary because I assume that the core team may well extend the event functionality to the entire menu tree in the future which would be much better and would prevent you from having to complete override the menu items.

This was suggested by Slace on my "is it possible to add an item to the context menu in tree's other than media content" post on the our.umbraco.org site.

There are three things you need to do:

1) Override the loadNodeTypes

using System.Collections.Generic;
using umbraco.interfaces;
using umbraco.BusinessLogic.Actions;

namespace Vizioz.xMind2Umbraco
{
// Note: Remember these menu's might change in future versions of Umbraco

public class loadNodeTypesMenu : umbraco.loadNodeTypes
{
public loadNodeTypesMenu(string application) : base(application) { }

protected override void CreateRootNodeActions(ref List<IAction> actions)
{
actions.Clear();
actions.Add(ActionNew.Instance);
actions.Add(xMindImportAction.Instance);
actions.Add(ContextMenuSeperator.Instance);
actions.Add(ActionImport.Instance);
actions.Add(ContextMenuSeperator.Instance);
actions.Add(ActionRefresh.Instance);
}
protected override void CreateAllowedActions(ref List<IAction> actions)
{
actions.Clear();
actions.Add(ActionCopy.Instance);
actions.Add(xMindImportAction.Instance);
actions.Add(ContextMenuSeperator.Instance);
actions.Add(ActionExport.Instance);
actions.Add(ContextMenuSeperator.Instance);
actions.Add(ActionDelete.Instance);
}
}
}


2) Create a new Action to be used on the menu
using umbraco.interfaces;

namespace Vizioz.xMind2Umbraco
{
public class xMindImportAction : IAction
{
#region Implementation of IAction

public static xMindImportAction Instance
{
get { return umbraco.Singleton<xMindImportAction>.Instance; }
}

public char Letter
{
get { return 'p'; }
}

public bool ShowInNotifier
{
get { return true; }
}

public bool CanBePermissionAssigned
{
get { return true; }
}

public string Icon
{
get { return "editor/OPEN.gif"; }
}

public string Alias
{
get { return "Import from xMind"; }
}

public string JsFunctionName
{
get
{
return "openModal('dialogs/xMindImport.aspx?id=' + nodeID,
'Publish Management', 550, 480);";
}
}

public string JsSource
{
get { return string.Empty; }
}

#endregion
}
}


3) Update the UmbracoAppTree table, my case I changed the following:

TreeHandlerType
From: loadNodeTypes
To: loadNodeTypesMenu

TreeHandlerAssembly
From: umbraco
To: Vizioz.xMind2Umbraco

And the result is:

Tuesday, 9 June 2009

Regular expression in Umbraco for number validation.

This evening I was looking for a way to validate an Umbraco node that could be either text or a numeric value, in my case a salary that could be either an hourly amount, an annual figure or a comment.

In the case where the node contained a value I wanted the XSLT to output a pound sign (£) and for any that contained text it would just output the text, as this could be something like "Contact Us" or "Negotiable"

I thought someone else might find this useful so here is the XSLT and the regular expression.

First if you are using Umbraco, don't forget to include the reference to the EXSLT Regular expression library at the top of your XSLT.

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltRegularExpressions">

Then the code I used was:
<xsl:if test="Exslt.ExsltRegularExpressions:match($currentPage/data [@alias='Salary'],
'^[0-9]*\,?[0-9]*\.?[0-9]+$') != ''">
<xsl:text>£</xsl:text>
</xsl:if>

This regular expression allows any number of digits, an optional comma, more digits, an optional decimal point and finally more digits, so all the following are valid:

12,000
14.43
334,342.03

Friday, 29 May 2009

Umbraco directory permissions | umbPermissions Script

It has bugged me since I first used Umbraco that if I was doing a manual installation I had to set the directory permissions

I just downloaded a backup of one of my clients Umbraco sites and I was setting up a copy locally and of course I had to set the directory permissions, so I thought there must be a better way!

I did a bit of Googling and had a look on the Umbraco forum but I could not find a script to perform this task, then I came across Set ACL on Source Forge and I set about writing my own little script.

Save the following script as umbpermissions.bat and save it in the same directory as Set ACL

echo off
REM Script to setup the Security Permissions for an Umbraco site
REM This script will give your machine Network Service full rights to the appropriate directories

REM **** Pre-requisites ****
REM You will need to download -> http://setacl.sourceforge.net/

REM **** Usage ****
REM You need to pass in the path for the root of your Umbraco directory
REM E.g. umbPermissions.bat C:\inetpub\umbracoroot

@echo umbPermissions.bat - Script to set Umbraco File and Directory Permissions
@echo Published by Chris Houston - 29th May 2009
@echo http://blog.vizioz.com

SetACL.exe -on "%1\web.config" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:full"
SetACL.exe -on "%1\bin" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:full"
SetACL.exe -on "%1\config" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:full"
SetACL.exe -on "%1\css" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:full"
SetACL.exe -on "%1\data" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:full"
SetACL.exe -on "%1\masterpages" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:full"
SetACL.exe -on "%1\scripts" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:full"
SetACL.exe -on "%1\umbraco" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:full"
SetACL.exe -on "%1\umbraco_client" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:full"
SetACL.exe -on "%1\usercontrols" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:full"
SetACL.exe -on "%1\xslt" -ot file -actn ace -ace "n:%computername%\NETWORK SERVICE;p:full"


Feel free to comment if I missed anything!

Wednesday, 27 May 2009

Vizioz is back on the web

I founded Vizioz in 1996 as a website development business. Since then Vizioz has come in and out of focus, it is time to start building Vizioz into a website development consultancy. Over the following two months we will be launching our new website where we will be promoting our ASP.NET, C#, XHTML, CSS, XSLT, SQL, Umbraco Development, Wordpress Development and Graphic Design services, and of course our website will be powered by the open source content management system called Umbraco CMS which we have used for 10+ client sites in the last twelve months.

I will be using this new blog to talk about client projects we are currently working on and any Umbraco development related bits of code that we feel would be good to release back to the Umbraco community.

Top 5 most popular posts