Skip to content

Instantly share code, notes, and snippets.

View deanebarker's full-sized avatar

Deane Barker deanebarker

View GitHub Profile
@deanebarker
deanebarker / FluidParserExtensions.cs
Last active October 9, 2021 13:55
Allows retrieval of the initial Fluid template using the declared IFileProvider
// var parser = new FluidParser();
// parser.ParseFromFile("deane");
namespace DeaneBarker.Fluid
{
public static class FluidParserExtensions
{
public static IFluidTemplate ParseFromFile(this FluidParser parser, string path)
{
if(TemplateOptions.Default.FileProvider == null)
@deanebarker
deanebarker / Managing Non-Web Content in Episerver
Last active August 7, 2020 13:53
A demo of using Episerver to manage "pure" (non-web) content.
This file exists just to name the gist...
@deanebarker
deanebarker / RenderScriban.cs
Last active June 30, 2019 11:36
A Scriban module for Wyam
using Scriban;
using Scriban.Parsing;
using Scriban.Runtime;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wyam.Common.Configuration;
@deanebarker
deanebarker / XmlNode.cs
Last active February 12, 2018 10:26
XmlNode Drop to output an XML document in DotLiquid
public class XmlNode : Drop
{
private const string attributeMethodName = "attr";
private const string xpathQueryMethodName = "xpath";
private const string listQueryMethodName = "list";
private const char shorthandDelimiter = '-';
private XmlElement doc;
public XmlNode(XmlDocument xml)
@deanebarker
deanebarker / StringMatcher.cs
Last active October 20, 2017 16:03
A class to match strings based on a specified method and options.
// If you think it's brilliant, then this is completely intentional.
// If you think it's dumb, then this is intended ironically because I'm just _that_ smart.
StringMatcher.IsMatch("Deane Barker", "deane ", StringMatchMethod.Starts, StringMatchOptions.IgnoreCase | StringMatchOptions.Trim); // True
StringMatcher.IsMatch("Deane Barker", "Barker", StringMatchMethod.Ends); // True
StringMatcher.IsMatch("Deane Barker", "ARK", StringMatchMethod.Contains, StringMatchOptions.IgnoreCase); // True
// etc.
// In reality, this is intended for use with a particular CMS, so that the editing interface can be dynamically generated
// based on the code. A dropdown will generate for the values in StringMatchMethod, and checkboxes will generate for the
@deanebarker
deanebarker / Editor.js
Created October 12, 2017 19:32
The simplest possible Dojo widget-based editing component for Episerver.
define(
["dojo/_base/declare", "dojo/ready", "dijit/_Widget", "dijit/_TemplatedMixin", "epi/epi"],
function (declare, ready, _Widget, _TemplatedMixin, epi) {
return declare(
[_Widget, _TemplatedMixin],
{
templateString: '<textarea data-dojo-attach-event="onchange:_onChange"></textarea>',
constructor: function () {
ready(this, function () {
@deanebarker
deanebarker / EpiserverMirroringEventLogging.cs
Created October 9, 2017 17:34
A library for master logging of Episerver mirroring events
using EPiServer.Enterprise;
using EPiServer.Enterprise.Mirroring;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.MirroringService;
using EPiServer.MirroringService.Common;
using EPiServer.MirroringService.MirroringMonitoring;
using EPiServer.MirroringService.MirroringTransferProtocol.Common;
using System;
using System.Linq;
@deanebarker
deanebarker / PoorMansCodeEditor.html
Last active February 26, 2018 01:17
Poor man's code editor in pure JavaScript.
<!--
This is a textarea that:
(1) Is styled(-ish) like a code editor
(2) Catches tabs and converts them to four (4) spaces
(3) Duplicates leading spaces from the last line
(4) Auto-expands to input
Pure inline HTML and JavaScript. No external dependencies. Has issues pre-IE-8, but should be otherwise okay.
@deanebarker
deanebarker / CustomRoutingResolver.cs
Created September 27, 2017 14:43
Episerver CMS: Route requests to alternate controllers and actions based on page properties.
using EPiServer.Core;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.ServiceLocation;
using EPiServer.Web;
using System.Linq;
using System.Web;
namespace BlendInteractive.Business
{
@deanebarker
deanebarker / contentful-reverse-lookup.html
Created September 20, 2017 17:54
An extension to show content items that are linked to the current item.
<html>
<head>
<link href="https://contentful.github.io/ui-extensions-sdk/cf-extension.css" rel="stylesheet">
<script src="https://contentful.github.io/ui-extensions-sdk/cf-extension-api.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.2.1/mustache.min.js"></script>
<style>
body {
margin: 0;
color: #8091a5 !important;
overflow: hidden;