Skip to content

Instantly share code, notes, and snippets.

View glcheetham's full-sized avatar

glcheetham glcheetham

View GitHub Profile
@glcheetham
glcheetham / Web.debug.config
Created August 8, 2016 14:40
Web.debug.config if you already have Umbraco set up
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
Set your connection string in the XML snippet below
-->
<connectionStrings>
<add name="umbracoDbDSN"
@glcheetham
glcheetham / TXTFile.cshtml
Created October 2, 2016 13:00
Text File Umbraco Template
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = null;
umbraco.library.ChangeContentType("text/plain");
}
@(Model.Content.GetPropertyValue<string>("fileContent"))
@glcheetham
glcheetham / UrlRewriting.xml
Created October 2, 2016 13:25
Line to add in UrlRewriting.config to rewrite your robots.txt URL
<add name="robots-rewrite"
virtualUrl="^~/robots.txt"
destinationUrl="~/robotstxt"
/>
@glcheetham
glcheetham / XMLSitemap.cshtml
Last active October 12, 2016 16:35
Example dynamic Umbraco sitemap.xml template
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = null;
umbraco.library.ChangeContentType("text/xml");
}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
@foreach (var root in Umbraco.TypedContentAtRoot())
{
@glcheetham
glcheetham / ResourceService.cs
Created January 29, 2017 11:30
Loosely-Coupled Class Which uses APIs from UmbracoHelper
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MyProject.Models;
using Umbraco.Web;
using Our.Umbraco.Ditto;
namespace MyProject.Services
{
@glcheetham
glcheetham / Startup.cs
Created January 29, 2017 11:33
Using Inversion of Control with UmbracoHelper
builder.RegisterInstance(umbracoHelper.ContentQuery).As<ITypedPublishedContentQuery>();
builder.RegisterType<ResourceService>().As<IResourceService>();
@glcheetham
glcheetham / Example.cs
Created January 29, 2017 11:39
Example instantiation of loosely-coupled class which depends on UmbracoHelper
var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
// Or from any other environment that comes with UmbracoHelper already available https://our.umbraco.org/documentation/reference/querying/umbracohelper/
// UmbracoHelper.ContentQuery implements the ITypedContentQuery interface
var resourceService = new ResourceService(umbracoHelper.ContentQuery);
@glcheetham
glcheetham / react-state-strategy-pattern.js
Created May 20, 2016 19:19
React state with strategy pattern
// Example of a React state. Manage this with Flux, Redux, black magic, etc...
import AccountFields from '../Components/AccountFields'
import SurveyFields from '../Components/SurveyFields'
import Confirmation from '../Components/Confirmation'
let pages = [
{"Title": "Account Fields", "ActiveComponent": React.createFactory(AccountFields) },
{"Title": "Survey Fields", "ActiveComponent": React.createFactory(SurveyFields) },
{"Title": "Confirmation", "ActiveComponent": React.createFactory(Confirmation) }
]
@glcheetham
glcheetham / UmbracoApplication.cs
Created May 27, 2016 21:41
Umbraco IOC Implementation that works properly
using Autofac;
using Autofac.Integration.Mvc;
using Autofac.Integration.WebApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Optimization;
using MyApp.Services;
using MyApp.Services.Interfaces;
@glcheetham
glcheetham / App.jsx
Created October 7, 2017 11:51
JSX Bootstrap 3 Kitchen Sink
const KitchenSink = () => (<div classNameName="App">
<div className="navbar navbar-default navbar-static-top">
<div className="container">
<div className="navbar-header">
<button type="button" className="navbar-toggle" data-toggle="collapse" data-target=".header-collapse">
<span className="sr-only">Toggle navigation</span> <span className="icon-bar"></span> <span className="icon-bar"></span> <span className="icon-bar"></span>
</button>
<a className="navbar-brand" href="#">Kitchen Sink</a>
</div>