Skip to content

Instantly share code, notes, and snippets.

@nathanwoulfe
nathanwoulfe / nunpublish.js
Created June 5, 2018 10:19
Hide the unpublish button for members of the editor group
/* package.manifest...
*
* {
* "javascript" : ["~/App_Plugins/nunpublish/script.js"]
* }
*/
(function () {
function directive(authResource) {
@agrath
agrath / SmartPropertyType.cs
Last active March 26, 2018 10:49
An example of dynamically generated strong properties for Umbraco ModelsBuilder
//A PublishEventHandler catches the DataTypeService.Saved method as a developer workflow entry point;
//When the data type is saved this kicks off the generation and writes a model to our models folder
//This could be app_code if you don't use VS to build your solution, but we generate our ModelsBuilder models
//into a class which is then built as part of the solution
internal class PublishEventHandler : ApplicationEventHandler
{
public const string FileSuffix = ".smartpropertytype.cs";
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
@dawoe
dawoe / DefaultController.cs
Created November 7, 2017 08:20
Donut Cache examples from Umbraco UK Festival talk "The need for speed"
public class DefaultController : RenderMvcController
{
[UmbracoDonutOutputCache(CacheProfile = "LongPageCache",
Options = OutputCacheOptions.NoCacheLookupForPosts &
OutputCacheOptions.ReplaceDonutsInChildActions, Order = 100)]
public override ActionResult Index(RenderModel model)
{
return base.Index(model);
}
}
@mikkelhm
mikkelhm / CustomApplicationEventHandler.cs
Created June 1, 2017 12:01
Umbraco Bypass ascii encoding if all fails
using System.Globalization;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Strings;
namespace Custom
{
public class CustomApplicationEventHandler : ApplicationEventHandler
{
@spra85
spra85 / Rick Roll.js
Created February 10, 2017 10:52
RickRoll
var audio,music,musicParse;audio="",musicParse=function(f){return eval("for(var t=0,S='RIFF_oO_WAVEfmt "+atob("EAAAAAEAAQBAHwAAQB8AAAEACAA")+"data';++t<3e5;)S+=String.fromCharCode("+f+")")},(music=function(){var a;return a="(t<<3)*[8/9,1,9/8,6/5,4/3,3/2,0][[0xd2d2c8,0xce4088,0xca32c8,0x8e4009][t>>14&3]>>(0x3dbe4688>>((t>>10&15)>9?18:t>>10&15)*3&7)*3&7]&255",audio=new Audio("data:audio/wav;base64,"+btoa(musicParse(a))),audio.play()})();
@jamiepollock
jamiepollock / LocalizedEditorModelEventManagerEventHandler.cs
Created October 21, 2016 16:30
Working with EditorModelEventManager to localise an EditorContentModel powered by /config/lang/*.user.xml files
using System.Collections.Generic;
using System.Globalization;
using Umbraco.Core;
using Umbraco.Core.Services;
using Umbraco.Web;
using Umbraco.Web.Editors;
using Umbraco.Web.Models.ContentEditing;
namespace MyWebsite
{
@tompipe
tompipe / NestedContentEditorGroupHandler.cs
Created October 7, 2016 12:17
Nested Content Property Editor Grouping
public class NestedContentEditorGroupHandler : ApplicationEventHandler
{
protected override void OnApplicationStarted(object sender, EventArgs e)
{
base.OnApplicationStarted(sender, e);
var dtMap = Mapper.FindTypeMapFor<IDataTypeDefinition, DataTypeBasic>();
dtMap?.AddAfterMapAction((s, d) =>
{
var src = (IDataTypeDefinition) s;
using System;
using System.Collections.Generic;
using System.Linq;
using MyProj.Extensions;
using MyProj.Models;
using Umbraco.Core;
using Umbraco.Core.Persistence;
namespace MyProj.Helpers
{
@jbreuer
jbreuer / ContentExtensions.cs
Created May 18, 2016 14:59
An extension method to convert an IContent to an IPublishedContent.
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ContentExtensions.cs" company="Colours B.V.">
// © Colours B.V. 2015
// </copyright>
// <summary>
// The content extensions.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Project.Web.Core.Extensions
@ProNotion
ProNotion / Purge Long Folder Structures
Last active May 12, 2016 18:07
How to Delete Files which exceed 255 Characters on Windows e.g. long filenames
robocopy /PURGE <empty_dir> <directory_to_remove>