Skip to content

Instantly share code, notes, and snippets.

@skttl
skttl / MigrateVendrToCommerce.cs
Last active February 15, 2024 09:19
Migrate Vendr database to Umbraco Commerce
using System;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Migrations;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Migrations;
using Umbraco.Cms.Infrastructure.Migrations.Upgrade;
namespace Umbraco.Community.Migrations;
using Umbraco.Cms.Web.Website.Controllers;
namespace Ecreo.Essentials.Helpers;
public static class UrlHelperExtensions
{
public static string? Action<T>(this IUrlHelper Url, string name) where T : SurfaceController
{
return Url.Action<T>(name, null, null, null, null);
}
@skttl
skttl / UmbracoViewComponent.cs
Created June 1, 2023 11:00
Umbraco enabled viewcomponent
using Microsoft.AspNetCore.Mvc.ViewComponents;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Logging;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Web.Common.Routing;
namespace Ecreo.Essentials.ViewComponents;
@skttl
skttl / ReferencesController.cs
Created November 19, 2021 09:45
Force Umbraco to update media tracking references
using System;
using System.Text;
using System.Web.Http;
using Umbraco.Core.Models;
using Umbraco.Web.WebApi;
namespace My.Controllers
{
public class ReferencesController : UmbracoApiController
{
@skttl
skttl / rowview.html
Created September 15, 2020 08:25
Rowview for Umbraco Block list
<div class="rowview">
<div style="margin:0 0 10px;border:1px dashed #ccc;">
<div style="margin:0 -5px;padding:10px;display:flex;">
<div
ng-repeat="property in block.content.variants[0].tabs[0].properties"
ng-if="property.editor == 'Umbraco.BlockList'"
style="flex-grow:1;padding:0 5px;">
<umb-property property="property">
<umb-property-editor model="property"></umb-property-editor>
</umb-property>
@skttl
skttl / ResizerController.cs
Last active August 20, 2020 07:36
Resize all media in Umbraco 7
using ImageProcessor;
using ImageProcessor.Imaging;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Web.Http;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
@skttl
skttl / rule.config
Created June 24, 2020 08:45
Redirect all topdomain traffic (without subdomains) to www.
<rule name="Redirect all topdomain traffic (without subdomains) to www." stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^[^\.]*\.([^\.]+)$" />
<!--
https://regex101.com/r/6be5ka/1/
^ asserts position at start of a line
Match a single character not present in the list below [^\.]*
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
@skttl
skttl / slide.js
Last active February 24, 2023 07:47
Vanilla JS slideup slidedown slidetoggle
let fadeOut = (target, duration=500) => {
target.style.transitionProperty = 'opacity';
target.style.transitionDuration = duration + 'ms';
target.style.opacity = 0;
window.setTimeout( () => {
target.style.display = 'none';
target.style.removeProperty('opacity');
target.style.removeProperty('transition-duration');
target.style.removeProperty('transition-property');
@skttl
skttl / MyClass.cs
Created December 6, 2019 06:51
Inject UmbracoHelper in custom class v8
public interface IMyService {}
public class MyClass : IMyService {
UmbracoHelper umbracoHelper;
public MyClass(UmbracoHelper umbracoHelper)
{
this.umbracoHelper = umbracoHelper;
}
}
public class MyClassComposer : IUserComposer
{
@skttl
skttl / listview.css
Created September 20, 2019 08:20
Umbraco Cloud listview
.projects .project-inner {
display: grid;
grid-template-columns: 32px 1fr 15px 130px;
grid-template-rows: 1fr 1fr;
height: auto;
column-gap: 1em;
row-gap: 0;
padding: 1em;
}
.projects .project {