Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Umbraco.Forms.Core.Enums;
using System.Net;
using System.Collections.Specialized;
using Umbraco.Core.Logging;
using Umbraco.Forms.Core.Providers.Models;
@Vrijdagonline
Vrijdagonline / flurl-example.cs
Created September 26, 2019 13:10 — forked from tmenier/flurl-example.cs
Flurl example - post URL-encoded, receive JSON
var result = await "http://localhost:8080/lzp/servRoot"
.PostUrlEncodedAsync(new {
className = "com.lzp.service.UserInfoService",
methodName = "login",
user_name = "123",
user_pwd = "123"
})
.ReceiveJson<TestResultModel>();
public IPublishedContent GetGlobalContentNode()
{
return (IPublishedContent)ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem("Application.BusinessLogic.Services.GetGlobalContentNode", () => {
var settingsNode = GetNonPageContentNode();
//Get the child folder node - Configuration Folder
var configFolder = settingsNode.Children.SingleOrDefault(x => x.DocumentTypeAlias == Constants.DocTypes.SiteConfigurationFolder);
if (configFolder == null) { return null; }
@Vrijdagonline
Vrijdagonline / web.config
Created February 4, 2019 20:34 — forked from dawoe/web.config
Redirect based on browser language
<rule name="RedirectToDutchHomepage" enabled="true" stopProcessing="true">
<match url="^$"></match>
<conditions>
<add input="{HTTP_ACCEPT_LANGUAGE}" pattern="^nl"></add>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/nl/"></action>
</rule>
<rule name="RedirectToFrenchHomepage" enabled="true" stopProcessing="true">
<match url="^$"></match>
<conditions>
@Vrijdagonline
Vrijdagonline / Rss.cshtml
Created November 9, 2018 13:21 — forked from nul800sebastiaan/Rss.cshtml
Simple altTemplate RSS feed - see comments for usage instructions.
@inherits UmbracoTemplatePage
@{
Response.ContentType = "text/xml";
// The variables in this code block are the only ones you might need to change a little to get it to work
var blogName = "Cultiv";
var currentUrl = string.Format("https://{0}", Request.Url.Host);
// Find first node under the root of document type BlogOverview
var blogNode = Model.Content.AncestorOrSelf(1).Descendants("BlogOverview").First();
@Vrijdagonline
Vrijdagonline / gist:ab13d09115429d1b332bf2e736081120
Created November 9, 2018 13:20 — forked from nul800sebastiaan/gist:1067257
Grouping in Razor (Umbraco 4.7.1)
@foreach(var group in Model.Children.InGroupsOf(2))
{
<div class="row-of-two">
@foreach(var item in group)
{
<span>@item.Name</span>
}
</div>
}
@Vrijdagonline
Vrijdagonline / Base.cshtml
Created November 5, 2018 07:37 — forked from wjonesy/Base.cshtml
A gist for using responsive images in Umbraco's grid editor
@model dynamic
@using Umbraco.Web.Templates
@functions {
public static string EditorView(dynamic contentItem)
{
string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString();
view = view.ToLower().Replace(".html", ".cshtml");
if (!view.Contains("/"))
@Vrijdagonline
Vrijdagonline / Preload CSS - Not blocking CSS.html
Created August 1, 2018 14:05 — forked from thedaviddias/Preload CSS - Not blocking CSS.html
Preload CSS and don't block the DOM with your CSS file request.
<link rel="preload" href="css/global.min.css" as="style" onload="this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="css/global.min.css"></noscript>
<script>
/*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
!function(a){"use strict";var b=function(b,c,d){function j(a){if(e.body)return a();setTimeout(function(){j(a)})}function l(){f.addEventListener&&f.removeEventListener("load",l),f.media=d||"all"}var g,e=a.document,f=e.createElement("link");if(c)g=c;else{var h=(e.body||e.getElementsByTagName("head")[0]).childNodes;g=h[h.length-1]}var i=e.styleSheets;f.rel="stylesheet",f.href=b,f.media="only x",j(function(){g.parentNode.insertBefore(f,c?g:g.nextSibling)});var k=function(a){for(var b=f.href,c=i.length;c--;)if(i[c].href===b)return a();setTimeout(function(){k(a)})};return f.addEventListener&&f.addEventListener("load",l),f.onloadcssdefined=k,k(l),f};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b}("undefined"!=typeof global?global:this);
/*! loadCSS rel=preload po
@Vrijdagonline
Vrijdagonline / MediaExportController.cs
Created February 1, 2018 14:56 — forked from dampee/MediaExportController.cs
export media library (umbraco v6 + umbraco v7)
using System;
using System.IO;
using System.Web.Hosting;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Web;
using Umbraco.Web.WebApi;
/// <summary>
@Vrijdagonline
Vrijdagonline / basic.html
Created May 20, 2017 08:51 — forked from jplhomer/basic.html
Example of loading fonts with loadCSS
<!-- Our font file is fonts.css -->
<script>
/*!
loadCSS: load a CSS file asynchronously.
[c]2014 @scottjehl, Filament Group, Inc.
Licensed MIT
*/
/* exported loadCSS */