Skip to content

Instantly share code, notes, and snippets.

View abjerner's full-sized avatar

Anders Bjerner abjerner

View GitHub Profile
using System;
using System.Collections.Generic;
using Skybrud.Essentials.Security;
using Skybrud.Umbraco.GridData.Models;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core;
namespace code.Features.BlockList.Models {
/// <summary>
using System;
using System.IO;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace MyWebsite {
public partial class Utils {
@abjerner
abjerner / LinkedInOAuth2.cshtml
Created February 24, 2017 20:33
Example on how to handle authenticating with LinkedIn using OAuth 2.0, and how to obtain the name and email address of the authenticated user.
@using Skybrud.Social.LinkedIn
@using Skybrud.Social.LinkedIn.ExtensionMethods
@using Skybrud.Social.LinkedIn.OAuth2
@using Skybrud.Social.LinkedIn.Responses.Users
@{
<h2>LinkedIn: OAuth</h2>
string baseUrl = "http://social-legacy.abjerner/linkedin/oauth2/";
@abjerner
abjerner / ExaminePublishedContent.cs
Created October 11, 2016 21:17
Convert SearchResult into IPublishedContent
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Examine;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
namespace Skybrud.ExamineDevStuff {
@abjerner
abjerner / ContentPickerDemo.html
Created August 26, 2016 19:33
Example on an Umbraco property editor with a content picker (both single and multi)
<div ng-controller="ContentPickerDemo.Controller">
<div>
<a href="#" prevent-default ng-click="addSingle()" class="btn btn-default">Add single</a>
<a href="#" prevent-default ng-click="addMultiple()" class="btn btn-default">Add multiple</a>
</div>
<div ng-show="model.value.items.length > 0" style="margin-top: 10px;">
<div ng-repeat="item in model.value.items">
<i class="icon {{item.icon}}"></i> {{item.name}}
using System;
using System.Web;
public class StringWrapper {
public string Value { get; set; }
public HtmlString ValueAsHtml {
get { return new HtmlString(Value ?? ""); }
}
@abjerner
abjerner / WcagHelpers.cs
Last active February 7, 2016 16:46
Calculates the WCAG 2.0 contrast ratio between two colors
using System;
using System.Drawing;
public class WcagHelpers {
/// <summary>
/// Calculates the relative luminance of a given <code>color</code> as specified by the WCAG 2.0 specification.
/// </summary>
/// <param name="color">The color.</param>
/// <returns>Returns the relative luminance.</returns>

When logging in to Umbraco, you will be greated by the dashboard of the Content section. Similarly, if you browse to another section, you will see the dashboard of that section.

Which tabs and panels that are shown in a given dashboard is controlled by the /config/Dashboard.config file. If you want to add or remove a tab (or just configure the various dashboards in general), you can do so here.

Eg. if you wish to replace the default Get started tab in the dashboard of the Content section, you can search the config file for something like (based on Umbraco 7.4-beta - the XML may differ a little from version to version):

  <section alias="StartupDashboardSection">
    <access>
      <deny>translator</deny>
@abjerner
abjerner / Examine.cshtml
Created December 15, 2015 08:38
Index a single content node in Examine
@using System.Xml.Linq
@using umbraco.cms.businesslogic.web
@using UmbracoExamine
@inherits UmbracoViewPage
@{
// Generate an instance of XElement to be indexed
XElement node = new Document(Model.Id).ToXDocument(false).Root;
@abjerner
abjerner / dependencies.md
Created September 7, 2015 07:01
Umbraco 6.1.5 NuGet dependencies

Installing Umbraco 6.1.5 directly via NuGet will cause some issues since some of the dependencies are downloaded in newer versions. Installing each dependency in the order as listed below will make sure that the dependencies are installed in the correct version.

Install-Package Newtonsoft.Json -Version 6.0.4
Install-Package Microsoft.Web.Infrastructure
Install-Package Microsoft.AspNet.Razor -Version 2.0.30506
Install-Package Microsoft.AspNet.WebPages -Version 2.0.30506
Install-Package Microsoft.AspNet.Mvc -Version 4.0.30506
Install-Package Microsoft.AspNet.Mvc.FixedDisplayModes -Version 1.0.1
Install-Package Microsoft.AspNet.WebApi.Client -Version 4.0.30506