Skip to content

Instantly share code, notes, and snippets.

View tidyui's full-sized avatar

Håkan Edling tidyui

View GitHub Profile
@tidyui
tidyui / DistributedJsonCache.cs
Created April 15, 2020 13:25
Distributed Cache for Piranha that relies on Newtonsoft.Json for serialization
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Piranha;
using Piranha.Cache;
@tidyui
tidyui / PostCacheFix.cs
Created May 2, 2019 07:49
PostCacheFix for Piranha 6.1.0
using System;
using Microsoft.AspNetCore.Builder;
using Piranha.Models;
namespace Piranha.Fixes
{
public static class PostCacheFix
{
private static ICache _cache;
@tidyui
tidyui / AbsoluteUrlExtension.cs
Created April 1, 2019 19:07
Generate absolute URL in multisite setup
using System.Threading.Tasks;
using Piranha;
using Piranha.Models;
public static class AbsoluteUrlExtension
{
public static async Task<string> AbsoluteUrl(this PageBase page, IApi api, string scheme = "http")
{
// Get the site. If cache is enabled the site
// will be fetched from cache
@tidyui
tidyui / BooleanField.cs
Created June 15, 2017 08:47
Custom BooleanField for Piranha.Core
using Piranha.Extend.Fields;
namespace MyApp.Fields
{
public class BooleanField : SimpleField<bool> {}
}