Skip to content

Instantly share code, notes, and snippets.

View KevinJump's full-sized avatar
🚴

Kevin Jump KevinJump

🚴
View GitHub Profile
@KevinJump
KevinJump / uSyncCacheRebuild.cs
Last active September 26, 2019 14:33
uSync 8.2 Cache rebuild
using System.Linq;
using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Services.Changes;
using Umbraco.Web.Cache;
using Umbraco.Web.PublishedCache;
using uSync8.BackOffice;
namespace uSync8.EventTriggers
@KevinJump
KevinJump / deleteprotect.cs
Created September 25, 2019 10:49
uSync Delete Protect - Save Media before it goes from the recycle bin.
using Jumoo.uSync.Core;
using Jumoo.uSync.Core.Interfaces;
using Newtonsoft.Json;
using System.IO;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.IO;
//
// Example: Hooking into TranslationManager (v8) Events
//
// Shows you how to register for the Events fired by Translation Manager
// these are the job events, each one gets the job object passed to it
// so you can extract info and workout what you might want to do.
//
//
// Packages (if not in web project)
<div>
<umb-load-indicator ng-if="model.loading"></umb-load-indicator>
<umb-box ng-if="!model.loading">
<umb-box-header title="Notifications"
description="Define who will get an email when key events occur (';' seperated lists)">
</umb-box-header>
<umb-box-content>
<umb-control-group label="Pending Notifications"
description="Email addresses to notify">
/// <summary>
/// Exmaple how to go into a Translation Node once it has been created and strip properties
/// based on the document type.
///
/// In this example we remove all but vorto properties - this is actually something TM will do
/// for you on loopback sets from version 2.2 - but the principles show you how to traverse
/// the translation node, go in find values and manipulate them.
/// </summary>
public class EventSetup : ApplicationEventHandler
{
@KevinJump
KevinJump / IDLinkMapper.cs
Created April 25, 2019 08:50
Translation Manager - Link Mapper
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Jumoo.TranslationManager.Core.Models;
using Umbraco.Core;
using Umbraco.Core.Services;
namespace Jumoo.TranslationManager.LinkUpdater.LinkMappers
@KevinJump
KevinJump / vorto-only.cs
Last active August 22, 2018 19:14
Umbraco Translation Manager - remove everything but vorto elements from a translation job, just before it is submitted (created)
/*
n.b this code isn't really tested - but in principle will work - it may need tweaking around
the edges.
At the moment there are no TranslationNode creation events - so you have to attach this to the
job submitting event which happens just before a job is created - in practice if you are
creating jobs directly from the send to translate dialog you won't notice the diffrence.
*/
//
@KevinJump
KevinJump / CustomGridJsonValueMapper.cshtml
Created January 4, 2018 11:36
Value Mapper for Custom JSON snippets inside Umbraco Grid Values - used by Translation Manager to import / export the text values
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Jumoo.TranslatePlus.Core.Models;
using Jumoo.TranslatePlus.Core.Providers;
using Jumoo.TranslatePlus.Core.ValueMappers;
using Newtonsoft.Json;
using Umbraco.Core;
@KevinJump
KevinJump / StackedContentMapper.cshtml
Last active September 13, 2018 11:05
Example of a Translation Manager Value Mapper (for stacked Content) - Show how to build a more complex mapper, and pass any inner values back into other mappers (this is now in translation manager core - and supports v2 of stacked content)
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Umbraco.Core;
using Jumoo.TranslatePlus.Core.Models;
namespace Jumoo.TranslatePlus.Core.ValueMappers
{
private void ContentTreeController_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
{
var translationMenu = e.Menu.Items.Where(x => x.Alias == "sendToTranslate").FirstOrDefault();
if (translationMenu != null)
e.Menu.Items.Remove(translationMenu);
if (sender.TreeAlias == "content")
{
var item = sender.ApplicationContext.Services.ContentService.GetById(int.Parse(e.NodeId));