Skip to content

Instantly share code, notes, and snippets.

Avatar

Darren Ferguson darrenferguson

View GitHub Profile
View Example.cs
public ActionResult GetFileStreamResult(UrlInformation urlInformation, HttpContext context)
{
string url = urlInformation.Path;
string connection = ConfigurationManager.AppSettings["AzureBlobFileSystem.ConnectionString:media"];
string containerName = ConfigurationManager.AppSettings["AzureBlobFileSystem.ContainerName:media"];
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(connection);
var client = cloudStorageAccount.CreateCloudBlobClient();
var container = client.GetContainerReference(containerName);
View UmbracoBooter.cs
using log4net;
using Moriyama.Core.Routing.ContentFinders;
using Moriyama.Core.Routing.UrlProviders;
using System.Reflection;
using Umbraco.Core;
using Umbraco.Web.Routing;
namespace Moriyama.Core.Events
{
public class UmbracoBooter : IApplicationEventHandler
View UmbracoHiddenFolderContentFinder.cs
using System.Web.Configuration;
using Umbraco.Core;
using Umbraco.Web.Routing;
namespace Moriyama.Core.Routing.ContentFinders
{
public class UmbracoHiddenFolderContentFinder : ContentFinderByNiceUrl
{
public override bool TryFindContent(PublishedContentRequest contentRequest)
{
View UmbracoHiddenFolderChildrenContentFinder.cs
using System.Linq;
using System.Web.Configuration;
using Umbraco.Web.Routing;
namespace Moriyama.Core.Routing.ContentFinders
{
/// <summary>
/// A content finder which looks for content items which are children of an Umbraco Hidden Folder.
/// </summary>
public class UmbracoHiddenFolderChildrenContentFinder : ContentFinderByNiceUrl
View UmbracoHiddenFolderUrlProvider.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Models;
using Umbraco.Web;
using Umbraco.Web.Routing;
namespace Moriyama.Core.Routing.UrlProviders
View gist:f5c39a986435a64373fa38c3126a0262
### Keybase proof
I hereby claim:
* I am darrenferguson on github.
* I am darrenferguson (https://keybase.io/darrenferguson) on keybase.
* I have a public key whose fingerprint is 138F 786D 6C5D 3EE4 5429 94B1 3E81 F7EC F93D 9E48
To claim this, I am signing this object:
View MyPublishedContent.cs
public class MyPublishedContent : PublishedContentBase
{
public MyPublishedContent(string xml)
{
var doc = new XmlDocument();
doc.LoadXml(xml);
_xmlNode = doc.DocumentElement;
}
private readonly XmlNode _xmlNode;
View ArchiveContentFinder.cs
public class ArchiveContentFinder : IContentFinder
{
public bool TryFindContent(PublishedContentRequest contentRequest)
{
var path = contentRequest.Uri.GetAbsolutePathDecoded();
var db = ApplicationContext.Current.DatabaseContext.Database;
var archived = db.SingleOrDefault<Archive>("select * from archive where Url = @0 or Url = @1", path, path + "/");
View Archive.cs
public class Archive
{
public int Id { get; set; }
public string Url { get; set; }
public string Xml { get; set; }
}
public static class PublishedContentExtensions
{
public static void Archive(this IContent content)
View gist:6be53533f6b4d614702b2f0bcfa04737
public static void Archive(this IContent content)
{
var h = new UmbracoHelper(UmbracoContext.Current);
var c = h.TypedContent(content.Id);
if (c != null)
{
var u = c.Url;
var xml = content.ToXml();