Skip to content

Instantly share code, notes, and snippets.

@leekelleher
leekelleher / UmbracoFormsPickerValueConverter.cs
Created March 28, 2018 15:54
Umbraco Forms - Value Converter for the "Form Picker" property-editor, used to define the value type as a `Guid`
using System;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PropertyEditors;
namespace Our.Umbraco.Web.PropertyEditors
{
public class UmbracoFormsPickerValueConverter : PropertyValueConverterBase, IPropertyValueConverterMeta
{
public override bool IsConverter(PublishedPropertyType propertyType)
{
@leekelleher
leekelleher / ProviderCollectionExtensions.cs
Last active March 13, 2019 17:48
Umbraco Forms - Extension methods to remove specific providers, e.g. removing a FieldType, such as Recaptcha
using System;
using System.Collections.Generic;
using System.Reflection;
using Umbraco.Forms.Core.Common;
namespace Our.Umbraco.Web.Extensions
{
public static class ProviderCollectionExtensions
{
public static void RemoveProvider<T>(this ProviderCollection<T> collection, params string[] providerIds)
using System;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.Web;
using System.Web.Hosting;
using ImageProcessor.Web.Services;
namespace UmbrellaInc.Web.Services
{
@leekelleher
leekelleher / ToListAttribute.cs
Created November 21, 2017 13:41
Ditto `ToList` processor
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Our.Umbraco.Ditto
{
public class ToListAttribute : DittoProcessorAttribute
{
public override object ProcessValue()
@leekelleher
leekelleher / ContentFinderByAsciiUrl.cs
Last active November 13, 2018 09:29
Umbraco - an IContentFinder that attempts to find the content by it's ASCII URL. This is useful for if an existing website has switched from non-ASCII URLs.
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Web;
using Umbraco.Web.Routing;
namespace Our.Umbraco.Web.Routing.ContentFinders
{
public class ContentFinderByAsciiUrl : IContentFinder
@leekelleher
leekelleher / html5-canvas-png-tintcolor.html
Created May 12, 2017 16:06
Playing around with HTML Canvas to tint the colour of a white logo (on transparent background) PNG
<html>
<head>
<title>canvas</title>
</head>
<body bgcolor="white">
<h1>canvas</h1>
<canvas id="logo"></canvas>
<script>
var can = document.getElementById("logo");
@leekelleher
leekelleher / MarkdownPropertyDescriptions.cs
Last active February 5, 2020 06:52
Umbraco - Converts a property's description using markdown
using Umbraco.Core;
using Umbraco.Web.Editors;
namespace Our.Umbraco
{
public class MyBootstrapper : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
EditorModelEventManager.SendingContentModel += (sender, e) =>
@leekelleher
leekelleher / QueryStringAttribute.cs
Created October 18, 2016 11:05
A QueryString processor for Ditto
using System.Web;
using Umbraco.Core;
namespace Our.Umbraco.Ditto
{
public class QueryStringAttribute : DittoProcessorAttribute
{
public QueryStringAttribute(string key)
: this()
{
@leekelleher
leekelleher / SupersetPublishedContent.cs
Last active August 29, 2018 12:40
IPublishedContent superset - exploring an idea where a piece of content can become a superset of another piece of content (from elsewhere in the content-tree)
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
namespace Our.Umbraco.Web.Models
{
public class SupersetPublishedContent : IPublishedContent
@leekelleher
leekelleher / PolymorphicCollectionMappingTests.cs
Created May 3, 2016 22:53
Ditto - unit-test to explore how mapping polymorphic collections might work
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace Our.Umbraco.Ditto.Tests
{
[TestFixture]
public class PolymorphicCollectionMappingTests
{