Skip to content

Instantly share code, notes, and snippets.

View carlwoodhouse's full-sized avatar

Carl Woodhouse carlwoodhouse

View GitHub Profile
using System;
using System.Threading.Tasks;
using GraphQL.Language.AST;
using GraphQL.Validation;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Localization;
using OrchardCore.Apis.GraphQL;
namespace Some.Nsamespace.ValidationRules
{
<script>
(function () {
var ip, newNode, referenceNode;
// helper function to execute once we have the IP address
function useIP (ip) {
if (ip.indexOf("194.176.105.") === 0) {
var el = document.getElementsByTagName('body')[0];
el.setAttribute('data-n3', 'true');
}
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using Orchard.Alias;
using Orchard.ContentManagement;
namespace SomeNamespace.Alias {
public class AliasContentAccessor : IAliasContentAccessor {
ConcurrentDictionary<string, int?> _lookups;
using Orchard.Themes;
namespace Something.Themes {
public class CustomThemeSelector : IThemeSelector {
public ThemeSelectorResult GetTheme(RequestContext context) {
if (someCondition) {
return new ThemeSelectorResult {
Priority = 10,
using Orchard.ContentManagement;
using Orchard.DisplayManagement.Descriptors;
using Patient.Framework.DisplayManagement;
namespace Patient.ContentTypes.Clinical.Providers {
public class HubPlacementParseStrategyMatchProvider : IPlacementParseStategyMatchProvider {
public string Key { get { return "Hub"; } }
public bool IsMatch(ShapePlacementContext context, string expression) {
var contentItem = context.Content.ContentItem;
<div class="topic" id="readspeaker-content">
<header class="slat hubHeader hubHeader--action hubHeader--image" style="background-image: url('/assets/img/tmp/hub-hero-2.jpg')">
<div class="container hubHeader__tools">
@Display(Model.ContentMenu)
</div>
<div class="container hubHeader__content">
<a class="button button--transparent hubHeader__action"
href="#"
data-modal="#hub-header-video">
@carlwoodhouse
carlwoodhouse / button markup
Last active August 10, 2017 15:13
rs instructions
// raw markup
<li class="page-options_item rs-button">
<div id="readspeaker_button" class="rs_skip rsbtn_colorskin rs_preserve">
<a id="rs_link" class="rsbtn_play page-options_link" accesskey="L" title="Listen with ReadSpeaker" href="//app-eu.readspeaker.com/cgi-bin/rsent?customerid=5816&amp;lang=en_uk&amp;readid=readspeaker-content&amp;url=@(encodedUrl)" data-name="Listen" data-rsevent-id="rs_357211" role="button">
<span class="icon icon-listen"></span> Listen
</a>
<a href="#" id="rs_placeholder" class="page-options_link" style="display: none;">
<div class="pt-1">
<img class="pr-1" src="@Html.PatientCdnUrl("gfx/translate-loading.gif")" alt="Please wait..." /> Listen
using System.ComponentModel.DataAnnotations;
using System.Web;
using Orchard;
using Patient.Framework.AntiSpam.Services;
namespace Patient.Framework.AntiSpam.Attributes {
public class RecaptchaAttribute : ValidationAttribute {
using System.IO;
using Orchard;
using Orchard.DisplayManagement;
using Orchard.DisplayManagement.Descriptors;
using Orchard.Environment;
namespace Some.Namespace {
public class MyShapes : IShapeTableProvider {
private Work<IShapeFactory> _shapefactory;
private readonly Work<IShapeDisplay> _shapeDisplay;
@carlwoodhouse
carlwoodhouse / SomeController.cs
Created June 22, 2017 22:30
controller returning a shape
[Themed]
public class MyController : Controller {
public ActionResult Index() {
var shape = _orchardServices.New.MyShape(SomeProperty: "woowooo");
return new ShapeResult(this, shape);
}
}