Skip to content

Instantly share code, notes, and snippets.

Avatar

Kern Herskind Nightingale herskinduk

View GitHub Profile
@herskinduk
herskinduk / ConfigureActionFilters.cs
Created Feb 24, 2017
ItemService database restrinction
View ConfigureActionFilters.cs
using Headless.ItemService;
using Sitecore.Pipelines;
using System.Web.Http;
namespace Headless
{
public class ConfigureActionFilters
{
private HttpConfiguration configuration;
private RestrictDatabaseActionFilter actionFilter;
View SitecoreHelperExtension.cs
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;
View gist:b2e78cbb93c75b78c4b5
// 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);
View gist:0d4dc5bf1d7c05189ccc
app.SetDefaultSignInAsAuthenticationType(WsFederationAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(
new CookieAuthenticationOptions
{
AuthenticationType =
WsFederationAuthenticationDefaults.AuthenticationType
});
app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
{
MetadataAddress = ...,
View gist:d39b23e24843ba66e5eb
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
//use OpenId
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = ...,
Authority = ...,
@herskinduk
herskinduk / ItemServiceConsoler.cs
Last active Aug 29, 2015
SSC Item Service server-to-server example
View ItemServiceConsoler.cs
using System;
using System.Net;
using System.Net.Http;
using System.Text;
namespace ItemServiceConsoler
{
class Program
{
static void Main(string[] args)
View gist:89a99902e6e797134635
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<indexConfigurations>
<!-- Un-comment out the config for Lucene or SOLR for your project -->
<defaultLuceneIndexConfiguration>
<indexDocumentPropertyMapper>
@herskinduk
herskinduk / gist:c718a70852e7bc3dcb25
Created Oct 30, 2014
msbuild target for generating T4 assembly directives based on project references
View gist:c718a70852e7bc3dcb25
<Target Name="Write_AssemblyRefs_TT" BeforeTargets="TransformOnBuild">
<!-- A message for all to enjoy! -->
<WriteLinesToFile File="@(MyTextFile)"
Lines="&lt;# /* AUTOGENERATED BY MSBUILD and Kern Herskind Nightingale */ #&gt;"
Overwrite="true"
Encoding="Unicode" />
<!-- Output all assembly references with a HintPath -->
<WriteLinesToFile File="@(MyTextFile)"
Lines="&lt;#@ assembly name=&quot;$(ProjectDir)%(Reference.HintPath)&quot; #&gt;"
Overwrite="false"
@herskinduk
herskinduk / LuceneDocumentTypeMapper.cs
Created Oct 24, 2014
Fix for fortis lucene content search
View LuceneDocumentTypeMapper.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Fortis;
using Fortis.Model;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.Linq.Methods;
using Sitecore.ContentSearch.Security;
using Sitecore.Data;
@herskinduk
herskinduk / ArticleViewRendering.cshtml
Last active Apr 29, 2016
Sitecore MVC inside-out layout
View ArticleViewRendering.cshtml
@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")