Skip to content

Instantly share code, notes, and snippets.

View uniquelau's full-sized avatar

Laurence Gillian uniquelau

View GitHub Profile
IEnumerable<Node> nodes = uQuery.GetNodesByXPath("$ancestorOrSelf/*[normalize-space(pub)][1]");
if (nodes != null)
{
ltlFancyAPint.Text = nodes.First().GetProperty("pub").ToString();
}
@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNodeContext
@if (@Parameter.Url !=null)
{
string url = @Parameter.Url;
string query = Request.ServerVariables["QUERY_STRING"];
Response.Status = "301 Moved Permanently";
Response.Redirect(url + query);
@uniquelau
uniquelau / no6.markdown
Last active December 16, 2015 14:49
I am not a number, I am a free man!

Razor Error

Data stored inside a 'Simple Text Editor'

Errors

A

<script></script>

B

/// Lets give it a go.
/// Why could this fail? API offline, API outputing invalid XML, XSLT file missing/invalid.
try
{
/// <summary>
/// Passes the parameters into a XSL file, that is run against in memory XML
/// </summary>
string xsltFilePath = Server.MapPath("~/XSLT/getProduct.xsl");
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
This task will minify CSS and JS files.
By default it was process 'all' files inside the specified directories
Depends on the YUI Compressor DLL, located in the Tools folder (http://yuicompressor.codeplex.com/documentation)
VISUAL STUDIO : update your projects .ProjectName.Targets file to Import the project
@uniquelau
uniquelau / cssHelper.cs
Created March 28, 2013 16:37
Adjustment to CSS Helper to supper @media and @font
using Yahoo.Yui.Compressor;
public static string MinifyCss(string body)
{
var cssCompresser = new CssCompressor();
var minifiedCss = cssCompresser.Compress(body);
return minifiedCss;
}
/Build/Readme
==============
This project aims to make building, publishing and deploying Umbraco web applications easier.
It also enables team members who do not have Visual Studio to create and edit content without Visual Studio.
It encourages a seperation between the Visual Studio .csproj file and a user generated .targets which in my view makes MSBuild easier to grasp.
It automates the following:
- Including the Umbraco Application
- Including files created within Umbraco (e.g. a new stylesheet)
- Ensures required files are avalible for the build (e.g. installedPackages.config)
@uniquelau
uniquelau / GetTemplate.xslt
Last active December 15, 2015 11:58
Snippet of GetTemplate, that loads Umbraco content into an XML based template.
<!-- Process <content /> -->
<xsl:template match="content">
<!-- Process the $currentPage and load it's RTE, etc -->
<xsl:apply-templates select="$currentPage[current()/@position = 1]" mode="content">
<xsl:with-param name="position" select="@position" />
</xsl:apply-templates>
<!-- When the template has more than 1 content block, look inside the /Callouts folder-->
<xsl:if test="@position &gt; 1">
<!-- Handle sub content blocks, these could be RTE's, Link Groups, Widgets, Video's -->
<xsl:apply-templates select="$currentPage/Callouts/* [@isDoc][position() = current()/@position - 1]" mode="content">
@uniquelau
uniquelau / version-control.md
Last active December 14, 2015 23:59
Version Control 101

Version Control

Concept

Version Control does what it says on the tin. It allows you to travel back in time. As with most computer software it comes in different flavours (SVN, Hg, Git, etc) but the core concepts remain the same. A person creates or edits a file and these changes are 'commited' against time. Everytime a commit happens, a marker is created - a snapshot. This contains some meta data/information:

[timeline diagram]