Skip to content

Instantly share code, notes, and snippets.

View jamiepollock's full-sized avatar

Jamie Pollock jamiepollock

View GitHub Profile
@jamiepollock
jamiepollock / ProtectedContentNotifyEventHandler.cs
Last active June 27, 2016 13:04
ProtectedContentNotifyEventHandler an Umbraco event which will look for any members who have access to the current content node being saved then send an email to them
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
namespace DemoApp
{
public class ProtectedContentNotifyEventHandler : ApplicationEventHandler
@jamiepollock
jamiepollock / MyContentSmellerEventHandler.cs
Created June 7, 2016 15:02
Untested example of checking what's changed between revisions of a IContent save event handler in Umbraco.
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
namespace My.App.Events
{
public class MyContentSmellerEventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
@jamiepollock
jamiepollock / ArchetypeLabelHelper.js
Created April 7, 2016 16:48
A JS Helper for making Umbraco Archetype template labels beautiful :)
var ArchetypeLabelHelper = (function () {
//private helpers
if (!String.prototype.format) {
String.prototype.format = function () {
var args = arguments;
return this.replace(/{(\d+)}/g, function (match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
@jamiepollock
jamiepollock / CreateOnlyDictionaryHandler.cs
Last active July 29, 2020 08:24
A uSync custom DictionaryHandler which only imports items if they're missing. It will not overwrite any existing authored translations.
using Jumoo.uSync.BackOffice;
using Jumoo.uSync.BackOffice.Handlers;
using Jumoo.uSync.BackOffice.Helpers;
using Jumoo.uSync.Core;
using Jumoo.uSync.Core.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
@jamiepollock
jamiepollock / MyDirective.js
Created January 11, 2016 10:22
Simple reusable rte editor - wrapping umb-editor rte with a reusable config for use in a custom Umbraco backoffice ui
angular.module("umbraco.directives").directive('simplerichtexteditor', function (assetsService) {
return {
restrict: 'E',
scope: {
field: '='
},
controller: function ($scope, $element) {
$scope.model = {
alias: 'simpleRichtextEditor',
view: 'rte',
@jamiepollock
jamiepollock / DirectiveController.js
Created January 11, 2016 09:16
simpledatepicker - basic angularjs datetime picker for custom Umbraco backoffces. It's a little hacky :/
angular.module("umbraco.directives")
.directive('simpledatepicker', function ($parse, $filter, assetsService) {
return {
restrict: 'E',
scope: {
field: '='
},
controller: function ($scope, $element) {
assetsService.loadCss('/umbraco/lib/datetimepicker/bootstrap-datetimepicker.min.css').then(function () {
var filesToLoad = ["/umbraco/lib/moment/moment-with-locales.js",
@jamiepollock
jamiepollock / MultipleIPublishedTypeConverterBase.cs
Last active September 22, 2015 07:59
Ditto TypeConverter - Multiple IEnumerable<IPublishedContent> & Single IPublishedContent
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using Umbraco.Core;
using Umbraco.Core.Models;
namespace My.Website.ComponentModel.TypeConverters
{
public abstract class MultipleIPublishedContentTypeConverterBase<T> : TypeConverter
@jamiepollock
jamiepollock / CustomDittoValueResolver.cs
Created September 21, 2015 14:58
Custom Ditto ValueResolver - Single IPublishedContent from IEnumerable<IPublishedContent
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Our.Umbraco.Ditto;
using Umbraco.Core.Models;
namespace My.Website.ComponentModel
{
public class SinglePublishedContentUmbracoPropertyAttribute : UmbracoPropertyAttribute
@jamiepollock
jamiepollock / RebuildMediaCacheTool.ascx
Created June 18, 2015 16:08
Tool for automatically resaving media nodes in Umbraco v6. Add to your dashboard.config to gain easy access to this tool.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RebuildMediaCacheTool.ascx.cs" Inherits="My.Website.Dashboard.RebuildMediaCacheTool" %>
<div class="dashboardWrapper">
<h2>Rebuild Media Cache</h2>
<img src="/umbraco_client/Dashboards/ExamineManagementIco.png" alt="" class="dashboardIcon" />
<asp:MultiView ID="MainView" runat="server">
<asp:View ID="InitialView" runat="server">
<asp:Button ID="RebuildButton" Text="Rebuild Media Cache" runat="server"/>
</asp:View>
<asp:View ID="CompleteView" runat="server">
<p>Rebuild complete!</p>
@jamiepollock
jamiepollock / HomeViewModel.cs
Created June 15, 2015 15:35
The following is an implementation of the GridResolver. The attribute takes two properties; propertyAlias and framework. Framework is used to determine the grid framework. In this case it is fanoe (based on the v7.2.x+ starter kit.
using System.Web.Mvc;
using Our.Umbraco.Ditto.Resolvers.Grid.Attributes;
namespace My.Website.ViewModels {
public class HomeViewModel {
[GridResolver(framework: "fanoe")]
public MvcHtmlString Content { get; set; }
}
}