Skip to content

Instantly share code, notes, and snippets.

View herskinduk's full-sized avatar

Kern Herskind Nightingale herskinduk

View GitHub Profile
<#@ template hostspecific="true" language="C#" #>
<#@ output extension=".txt" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="VSLangProj" #>
<#@ import namespace="System" #>
<#@ import namespace="System.Reflection" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ assembly name="EnvDTE" #>
@herskinduk
herskinduk / ConfigureActionFilters.cs
Created February 24, 2017 00:32
ItemService database restrinction
using Headless.ItemService;
using Sitecore.Pipelines;
using System.Web.Http;
namespace Headless
{
public class ConfigureActionFilters
{
private HttpConfiguration configuration;
private RestrictDatabaseActionFilter actionFilter;
using Sitecore.Mvc.Helpers;
using Sitecore.Mvc.Pipelines;
using Sitecore.Mvc.Pipelines.Response.RenderRendering;
using Sitecore.Mvc.Presentation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
@herskinduk
herskinduk / ArticleViewRendering.cshtml
Last active April 29, 2016 08:34
Sitecore MVC inside-out layout
@using Sitecore.Mvc.Presentation
@using Sitecore.Mvc
@model RenderingModel
@{
Layout = null;
Sitecore.Context.Items["twitter:title"] = Model.Item["title"]
Sitecore.Context.Items["twitter:description"] = Model.Item["description"]
}
<h1>@Html.Sitecore().Field("title")</h1>
@Html.Sitecore().Field("text")
@herskinduk
herskinduk / Mvc1.cshtml
Last active April 25, 2016 22:12
Sitecore MVC Layout views
@using Sitecore.Mvc
@using Sitecore.Mvc.Analytics.Extensions
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>@Html.Sitecore().Field("title", new { DisableWebEdit = true })</title>
@Html.Sitecore().VisitorIdentification()
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map-canvas { height: 100% }
</style>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=...&sensor=false">
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sitecore.ContentSearch.ComputedFields;
using Sitecore.ContentSearch;
using Spatial4n.Core.Context;
using Lucene.Net.Spatial.Prefix.Tree;
using Lucene.Net.Spatial.Prefix;
@herskinduk
herskinduk / AreaControlllerRunner.cs
Created July 29, 2013 06:30
Experimental Sitecore ControllerRunner with childaction behaviour. Based on the AreaControllerRunner from the Sitecore.MVC.Contrib project.
using Sitecore.Mvc.Controllers;
using System.Web.Mvc;
using System.Web.Routing;
using Sitecore.Mvc.Presentation;
using Sitecore.Mvc.Common;
namespace Sitecore.Mvc.Contrib.Controllers
{
public class AreaControllerRunner : ControllerRunner, IControllerRunner
{
@herskinduk
herskinduk / ChildActionRenderer.cs
Last active December 20, 2015 07:19
Experimental Sitecore ChildActionRenderer - like ControllerRenderer, but using the HtmlHelper Action extension method for rendering. Standard MVC child action behaviour wrt TempData. Has dependencies on the Sitecore.MVC.Contrib project.
using Sitecore.Mvc.Common;
using Sitecore.Mvc.Presentation;
using Sitecore.Mvc.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Mvc.ExpressionUtil;
// Use the async execute
var asyncController = controller as IAsyncController;
Task.Factory.FromAsync(asyncController.BeginExecute, asyncController.EndExecute, PageContext.Current.RequestContext, null).Wait();
// The old way (sync)
//(controller as IController).Execute(PageContext.Current.RequestContext);