Skip to content

Instantly share code, notes, and snippets.

@deanebarker
deanebarker / WebhookController.cs
Created December 27, 2016 22:47
Contentful Database Synchronization Controller
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Net;
using System.Web.Http;
// Note: for this to work, you need to insert this line in the Application_Start event of your global.asax
@deanebarker
deanebarker / WyamBuilder.cs
Last active January 17, 2017 20:08
An example of configuing Wyam to build from an HttpHandler.
using System;
using System.Configuration;
using System.Diagnostics;
using System.Web;
using Wyam.Core.Execution;
using Wyam.Core.Modules.Contents;
using Wyam.Core.Modules.Control;
using Wyam.Core.Modules.IO;
using Wyam.Core.Modules.Metadata;
using Wyam.Markdown;
@deanebarker
deanebarker / CommentForm.html
Last active September 12, 2017 19:46
The simplest comment implementation I could come up with using Episerver Social with the "Alloy" demo site
<form method="post" action="/social/comments/add" id="commentForm">
<input type="hidden" name="pageId" value="@Model.CurrentPage.ContentGuid"/>
<input type="text" name="author" placeholder="Your name..."/>
<textarea name="body" id="commentBody" placeholder="Your comment..."></textarea>
<br/>
<input type="submit" id="commentSubmitButton" disabled="disabled" style="opacity: 0.5;" value="Submit" />
</form>
<div id="commentList">
Loading comments...
@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;
@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 / 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 / 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 / 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 / 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 / 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.