Skip to content

Instantly share code, notes, and snippets.

View uniquelau's full-sized avatar

Laurence Gillian uniquelau

View GitHub Profile
@uniquelau
uniquelau / _Article.xslt
Created February 28, 2013 16:34
XSLT Document Property templating with Fallback.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:umb="urn:umbraco.library"
exclude-result-prefixes="umb"
>
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
@uniquelau
uniquelau / picturefill.ultralight.js
Created March 7, 2013 17:27
Very simple reduction of PictureFill.js - not suitable for production
// var retina = window.devicePixelRatio > 1;
var retina = window.devicePixelRatio > 1;
if (retina) {
// the user has a retina display
// tbh - lets just drop a cookie, and handle this stuff server-side
// document.cookie='HTTP_IS_RETINA=1;path=/'
$(function () {
@uniquelau
uniquelau / _Media.xslt
Last active December 14, 2015 16:49
1. Detect devicePixelRatio 2. Set Cookie 3. Render correct image for dPR - adjust jpeg quality based on dPR.
<!-- Fetch devicePixelRatio -->
<xsl:variable name="devicePixelRatio" select="normalize-space(umb:RequestCookies('dPR'))" />
<!-- Template for a Media Image -->
<xsl:template match="Image" name="GenericImage">
<xsl:param name="class"/>
<xsl:param name="crop"/>
<xsl:param name="id"/>
<xsl:param name="size"/>
<xsl:param name="retinafy"/>
@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]

@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">
/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 / 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;
}
<?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
/// 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");