Skip to content

Instantly share code, notes, and snippets.

View nathanwoulfe's full-sized avatar

Nathan Woulfe nathanwoulfe

View GitHub Profile
@nathanwoulfe
nathanwoulfe / azure-pipelines.yml
Created June 8, 2019 00:32
DevOps pipeline config for Umbraco package CI
trigger:
- master
- refs/tags/v*
pool:
vmImage: 'windows-latest'
variables:
solution: '**/Plumber8.sln'
buildPlatform: 'Any CPU'
@nathanwoulfe
nathanwoulfe / Appveyor.yml
Created June 8, 2019 00:31
Appveyor config for Umbraco CI
# version format
version: 1.0.0.{build}
image: Visual Studio 2017
cache:
- packages -> **\packages.config
- c:\projects\plumber8\plumber.web\node_modules -> **\packages.json
# UMBRACO_PACKAGE_PRERELEASE_SUFFIX will only be used for Release builds
@nathanwoulfe
nathanwoulfe / RunTests.ps1
Created June 8, 2019 00:24
Powershell script to run VS tests and output coverage reports
"install tools:"
&dotnet tool install dotnet-reportgenerator-globaltool --tool-path . --version 4.0.12
&dotnet tool install coverlet.console --tool-path . --version 1.4.1
"`nmake reports dir:"
md .\reports -Force
"`nrun tests:"
$unitTestFile = gci -Recurse | ?{ $_.FullName -like "*bin\*Plumber.Testing.dll" }
Write-Host "`$unitTestFile value: $unitTestFile"
2019-02-06 19:45:14,333 [P18512/D2/T11] ERROR Umbraco.Web.Editors.ContentController - Unhandled controller exception occurred for request 'http://localhost:62128/umbraco/backoffice/UmbracoApi/Content/PostSave'
System.ArgumentNullException: Value cannot be null.
Parameter name: user
at Umbraco.Core.Security.ContentPermissionsHelper.CheckPermissions(IContent content, IUser user, IUserService userService, IEntityService entityService, Char[] permissionsToCheck)
at Umbraco.Web.Editors.Filters.ContentSaveValidationAttribute.ValidateUserAccess(ContentItemSave contentItem, HttpActionContext actionContext)
at Umbraco.Web.Editors.Filters.ContentSaveValidationAttribute.OnActionExecuting(HttpActionContext actionContext)
at System.Web.Http.Filters.ActionFilterAttribute.OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
@nathanwoulfe
nathanwoulfe / installer.cs
Created February 4, 2019 09:43
Bang some tables into a fresh v8 install. Is this the right way to do it? It smells smelly.
// namespaces and usings omitted for brevity
//
public class WorkflowInstallMigration : Upgrader
{
private readonly MigrationPlan _plan;
private readonly IScopeProvider _scopeProvider;
private readonly IMigrationBuilder _migrationBuilder;
private readonly IKeyValueService _keyValueService;
@nathanwoulfe
nathanwoulfe / MapHttpAttributeRoutes.cs
Created February 4, 2019 09:29
MapHttpAttributeRoutes
// v7 version
using System.Web.Http;
using Umbraco.Core;
namespace MyNamespace
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)

In case you missed it, Umbraco 8 dropped almost by surprise in the last week of February.

Along with a massive refactoring of lots of code of which I have absolutely no understanding, v8 introduces something I do understand - Content Apps.

Since you're reading Skrift, I'm hoping you're up to speed with the latest and greatest from Umbraco HQ, and content apps (or the term, at least), aren't an entirely new concept. If you're reading this and thinking 'Content Whats?', duck over to the Umbraco documentation and read up on the shiny new feature.

Content apps are beautifully described in that documentation as 'companion read-only information relating to the current content item in the Umbraco backoffice'.

Note the emphasis on companion and read-only. Content apps are not an interface for updating a node, but for supplying additional information for making our editors' jobs more pleasant.

@nathanwoulfe
nathanwoulfe / plugin.min.js
Created June 16, 2018 05:22
Restore anchors in TinyMce
/* this has been heavily edited for brevity */
tinymce.PluginManager.add('link', function (editor) {
/* ... */
function showDialog(linkList) {
/* ... */
var selectedElm = selection.getNode();
@nathanwoulfe
nathanwoulfe / events.cs
Created June 7, 2018 03:13
Events from an interface
// interface
public interface IService
{
// other stuff, but nothing related to events
}
// inheriting class
public class Service : IService
{
public static event EventHandler<MyEventArgs> SomethingHappened;
@nathanwoulfe
nathanwoulfe / nunpublish.js
Created June 5, 2018 10:19
Hide the unpublish button for members of the editor group
/* package.manifest...
*
* {
* "javascript" : ["~/App_Plugins/nunpublish/script.js"]
* }
*/
(function () {
function directive(authResource) {