Skip to content

Instantly share code, notes, and snippets.

View smdooley's full-sized avatar

Sean Dooley smdooley

View GitHub Profile
@joeriks
joeriks / Comment.cshtml
Created March 19, 2011 16:51
Basic Umbraco Razor commentary form
@using umbraco.cms.businesslogic.web
@* A Razor script to add a basic comment function to Umbraco pages
You need a document type called Comment with a textstring property
called commentName and a textbox multiple property called commentMessage
You also need to allow the Comment document type as child document type
to your textpage document type.
Create this script with a macro and add it below the bodyText in your
template(s) *@
@leekelleher
leekelleher / NavigationAToZ.xslt
Created November 24, 2011 11:22
XSLT snippet for generating an A to Z list for Umbraco content nodes.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp "&#x00A0;">
]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library">
@jayhjkwon
jayhjkwon / BookController.cs
Last active September 10, 2020 09:32
WebAPI2 Unit Testing with IHttpActionResult
// GET api/books
public IHttpActionResult Get()
{
return Ok(_repository.GetBooks().AsEnumerable());
}
// GET api/books/1
public IHttpActionResult Get(int id)
{
var book = _repository.GetBook(id);
@francoishill
francoishill / gist:6483997
Created September 8, 2013 11:27
Media queries for mobile devices - Requires at least requires the meta viewport tag with content 'width=device-width'
/*http://i-skool.co.uk/mobile-development/web-design-for-mobiles-and-tablets-viewport-sizes/*/
/*At least requires the meta viewport tag with content 'width=device-width'*/
@media only screen and (max-width: 1080px) and (orientation : portrait) {
/* PORTRAIT:
Windows Surface Pro*/
}
@media only screen and (max-width: 800px) and (orientation : portrait) {
/* PORTRAIT:
Acer Iconia Tab A100
@greenygh0st
greenygh0st / LinkParser.cs
Created December 13, 2015 06:12
C# helper method for parsing out links and video (Vimeo & YouTube) content
using System;
using System.Text.RegularExpressions;
namespace DalesLab.Helpers
{
public static class Parser
{
public static readonly Regex VimeoVideoRegex = new Regex(@"vimeo\.com/(?:.*#|.*/videos/)?([0-9]+)", RegexOptions.IgnoreCase | RegexOptions.Multiline);
public static readonly Regex YoutubeVideoRegex = new Regex(@"youtu(?:\.be|be\.com)/(?:(.*)v(/|=)|(.*/)?)([a-zA-Z0-9-_]+)", RegexOptions.IgnoreCase);
public static readonly Regex HyperlinkRegex = new Regex("http(s)?://([\\w+?\\.\\w+])+([a-zA-Z0-9\\~\\!\\@\\#\\$\\%\\^\\&amp;\\*\\(\\)_\\-\\=\\+\\\\\\/\\?\\.\\:\\;\\'\\,]*)?", RegexOptions.IgnoreCase); //http://weblogs.asp.net/farazshahkhan/regex-to-find-url-within-text-and-make-them-as-link
@deMD
deMD / CommonServices
Created September 8, 2016 07:13
Code used to enable Ninject in Umbraco
using Ninject;
using Umbraco.IocTest.BLL.Providers;
using Umbraco.IocTest.Core.Interfaces;
namespace Umbraco.IocTest.BLL
{
/// <summary>
/// The CommonServices are services that are a 1:1 pair with an implemnting class.
/// For example: A single provider interface can only have one implmentation,
/// thus this is registered in the common services.
@barryokane
barryokane / PatternLibRazorViewEngine.cs
Created March 11, 2017 04:56
Inspired by Heather Floyd's article (http://24days.in/umbraco-cms/2016/unique-sites-using-theming), however our use case is slightly different: we want to share a library of partials between multiple Umbraco sites with custom overrides on specific sites
using System.Linq;
using Umbraco.Web.Mvc;
namespace Endzone.Umbraco.PatternLib
{
public class PatternLibRazorViewEngine : RenderViewEngine
{
public PatternLibRazorViewEngine() : base()
{
/*
@mattbrailsford
mattbrailsford / PriceBreakOrderLineCalculator.cs
Last active May 3, 2022 13:02
Example order line calculator that support price breaks
using System;
using System.Collections.Generic;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web;
using Vendr.Core.Calculators;
using Vendr.Core.Models;
using Vendr.Core.Services;
using Vendr.Web.Models;
namespace Vendr.DemoStore.Web.Calculators
@diazvictor
diazvictor / InventoryGame.js
Last active November 14, 2023 23:24
Small Example Of A Game Inventory With Javascript
/* jshint esversion: 8 */
// This example is a port of: https://gist.github.com/diazvictor/6fe3372bce79587a3c21123a19881cb1
// I create the Inventory class
class Inventory {
// What to do when the class is initialized
constructor() {
this.items = [];
}
@AndyButland
AndyButland / AjaxFormPage.cshtml
Last active June 7, 2024 09:40
Umbraco Forms API usage with vanilla JavaScript
@*
Demonstration of using the Umbraco Forms 13 API for retrieving the definition of a form, rendering it and posting an entry.
It's based off an Umbraco content item with a property with alias "Form", of type "Form Picker".
*@
@using Microsoft.AspNetCore.Antiforgery
@using Microsoft.Extensions.Options;
@using Umbraco.Cms.Web.Common.PublishedModels;
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.AJaxformPage>
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;