Skip to content

Instantly share code, notes, and snippets.

View warrenbuckley's full-sized avatar

Warren Buckley warrenbuckley

View GitHub Profile
warrenbuckley / Setup.ps1
Created June 3, 2024 13:01
An Umbraco V14+ script to help scaffold files for an Umbraco Package Development
## Setup of an Umbraco V14+ project with Vite, TypeScript & Lit
## Author: Warren Buckley
## if project name is not provided, ask for it
if (-not $ProjectName) {
$ProjectName = Read-Host "Enter a project name"
## Variables
warrenbuckley / UpdateAllMembersWithNewMemberGroup.sql
Created April 24, 2024 15:53
Umbraco: Add a NEW member group to all members who do not have the group already assigned
-- Variables --
DECLARE @memberGroupIntId INT
-- Get the INT ID of the member group that is called 'Portal Member' --
SELECT @memberGroupIntId = [id]
FROM [dbo].[umbracoNode]
WHERE nodeObjectType = '366E63B9-880F-4E13-A61C-98069B029728' -- This GUID is for member groups --
warrenbuckley / AuthorContentIndexer.cs
Created May 24, 2023 12:18
Umbraco V12: Extending Content Delivery API
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.DeliveryApi;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Web;
namespace ExampleProject.ContentDeliveryApi
public class AuthorContentIndexer : IContentIndexHandler
private readonly IUmbracoContextFactory _umbracoContextFactory;
warrenbuckley / appsettings.development.json
Created November 7, 2022 12:22
Example V9+ Umbraco CMS Serilog Configuration to write to additional File location
"$schema" : "./appsettings-schema.json",
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Examine.Lucene.Providers.LuceneIndex": "Debug",
"Examine.BaseIndexProvider": "Debug",
"Examine.Lucene.LoggingReplicationClient": "Debug",
"Examine.Lucene.ExamineReplicator": "Debug"
warrenbuckley / StaticAssetsHeaders.cs
Created September 22, 2022 11:13
Showing how to use ASP.NET Static Assets options to set custom headers on files with Umbraco
using Microsoft.Net.Http.Headers;
using Umbraco.Cms.Core.Composing;
namespace StaticAssets
public class StaticAssetsHeaders : IComposer
public void Compose(IUmbracoBuilder builder)
builder.Services.Configure<StaticFileOptions>(options =>
warrenbuckley / appsettings.json
Created May 3, 2022 14:47
Umbraco 9+ appsettings.json configuration to remove init HTML P tags in TinyMCE RTE
"$schema": "./umbraco/config/appsettings-schema.json",
"Umbraco": {
// NOTE: Other settings removed in this example for clarity
"CMS": {
"RichTextEditor": {
"CustomConfig": {
"forced_root_block": ""
warrenbuckley / MyCustomIdentityErrorDescriber.cs
Last active July 27, 2021 15:13
.NET Core Identity PasswordValidators with Umbraco CMS BackOffice Users
using Microsoft.AspNetCore.Identity;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Services;
using Umbraco.Extensions;
namespace Umbraco.Cms.Web.UI.NetCore
public class MyCustomIdentityErrorDescriber : BackOfficeErrorDescriber
private ILocalizedTextService _textService;
warrenbuckley / BlogPost.cshtml
Created July 2, 2021 11:02
Automatically Generate Open Graph Social Images in Umbraco V9
@using Umbraco.Cms.Web.Common.PublishedModels;
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.BlogPost>
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
Layout = null;
<meta property="og:title" content="@Model.Header" />
warrenbuckley / DontShout.cs
Created May 5, 2021 10:49
Umbraco V9 Event to Notification Handler Example
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Infrastructure.Services.Notifications;
namespace TestingEvents
public class DontShout : INotificationHandler<ContentPublishingNotification>
public void Handle(ContentPublishingNotification notification)
foreach (var node in notification.PublishedEntities)
warrenbuckley / ActiveGithubSponsor.cs
Last active August 12, 2020 09:31
This is an example of using the C# Octokit.GraphQL wrapper library to query if the logged in user is an active sponsor of 'warrenbuckley'
using Octokit.GraphQL;
using Octokit.GraphQL.Model;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace Octokit
class Program