Skip to content

Instantly share code, notes, and snippets.

@leekelleher
leekelleher / MntpModelBinder.cs
Created October 2, 2012 10:43
uComponents: Temporary ModelBinder proxy/stub for Umbraco core's MultiNodeTreePicker
namespace Our.Umbraco
{
using uComponents.Core.DataTypes.MultiNodeTreePicker; // for v4.x
// using uComponents.DataTypes.MultiNodeTreePicker; // for v5.x
using umbraco.editorControls;
using umbraco.MacroEngines;
[RazorDataTypeModel(DataTypeGuids.MultiNodeTreePickerId)]
public class MntpModelBinder : MultiNodeTreePickerModelBinder
{
@leekelleher
leekelleher / CheckImageGenModule.cs
Created October 10, 2012 09:39
ImageGenFetch - when taking a copy of an Umbraco site from a production server, the /media directory can be a huge download. So if using ImageGen you can auto-download the /media images on-demand.
using System;
using System.IO;
using System.Net;
using System.Net.Mime;
using System.Text;
using System.Web;
namespace Umbrella.ImageGenFetch
{
public class CheckImageGenModule : IHttpModule
@leekelleher
leekelleher / RegisterResource.cs
Created October 10, 2012 13:23
Example of hooking into an Umbraco back-office page using UmbracoClientDependencyLoader.TryCreate
using System;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using ClientDependency.Core;
using umbraco.BusinessLogic;
using umbraco.IO;
using umbraco.presentation.masterpages;
using umbraco.uicontrols;
@leekelleher
leekelleher / gist:4045132
Created November 9, 2012 10:56
SpaceOutCamelCase - Method to space out a string on capitals or numbers.
/// <summary>
/// Spaces out a string on capitals or numbers.
/// </summary>
/// <param name="input">The input string.</param>
/// <returns>
/// The string with spaces before each capital letter or number
/// </returns>
public static string SpaceOutCamelCase(string input)
{
var space = ' ';
@leekelleher
leekelleher / 1-umbraco-scripting.md
Last active December 10, 2015 12:38
Umbraco console/scripting concept

Umbraco scripting, with console/CLI

Enabling a scripting mechanism for Umbraco, using a console (command line interface) to execute the scripts/queries.

So far, the examples are using C#, however a suitable scripting language should be used. Currently JavaScript is the favourite, followed by Lua and Python.

@leekelleher
leekelleher / remove-wp-meta.php
Created January 22, 2013 10:30
WordPress plugin to remove the auto-generated meta tags.
<?php
/*
Plugin Name: Remove WP Meta
Plugin URI: http://leekelleher.com/
Description: This plugin removes the auto-generated WP meta tags from each webpage.
Author: Lee Kelleher
Version: 0.1.0
Author URI: http://leekelleher.com/
*/
@leekelleher
leekelleher / RazorDataTypeModelBindingPropertyEditorValueConverter.cs
Created January 31, 2013 11:48
Umbraco: A bridge between RazorDataTypeModelBinding and PropertyEditorValueConverter.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using umbraco.MacroEngines;
using Umbraco.Core;
using Umbraco.Core.PropertyEditors;
namespace Our.Umbraco
{
@leekelleher
leekelleher / umbraco-find-nodes-by-property-value.sql
Last active October 3, 2017 14:10
Umbraco - Find nodes with specific property value
DECLARE @propertyAlias NVARCHAR(50);
DECLARE @search NVARCHAR(50);
SET @propertyAlias = 'bodyText';
SET @search = 'whatever';
SELECT
n.id,
n.path,
n.text
@leekelleher
leekelleher / fetch-msbuild-tasks.cmd
Last active December 16, 2015 00:39
Fetches associated MSBuild Tasks packages (via NuGet), then copies the assemblies and targets to a /tools directory. To be used with https://github.com/leekelleher/umbraco-package-boilerplate
IF NOT EXIST tools\MSBuildTasks\NUL (GOTO FETCH) ELSE GOTO EXIST
:EXIST
ECHO MSBuildTasks already exist
:FETCH
ECHO Fetching MSBuildTasks via NuGet
:: Set the working directory
CD tools
@leekelleher
leekelleher / example.cs
Last active December 16, 2015 13:39
Example of using uQuery.IGetProperty with uTwit property-editor.
var node = uQuery.GetNode(1234);
var twitter = node.GetProperty<Our.Umbraco.Models.uTwit>("twitter");
// use the uTwit model...
// twitter.ConsumerKey
// twitter.ConsumerSecret
// twitter.OAuthToken
// twitter.OAuthTokenSecret
// twitter.ScreenName