Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #16 from umco/develop
Browse files Browse the repository at this point in the history
Preparing v1.1.0 release
  • Loading branch information
leekelleher authored Mar 5, 2018
2 parents cdac41c + fbc2479 commit 6e30f41
Show file tree
Hide file tree
Showing 33 changed files with 826 additions and 432 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The issue tracker is the preferred channel for [bug reports](#bugs),
requests](#pull-requests), but please respect the following restrictions:

* Please **do not** use the issue tracker for personal support requests (use
[Our Umbraco](https://our.umbraco.org/projects/backoffice-extensions/nested-content/nested-content-feedback) or Twitter).
Our Umbraco or Twitter).

* Please **do not** derail or troll issues. Keep the discussion on topic and
respect the opinions of others.
Expand Down
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ We also have a [MyGet package repository](https://www.myget.org/gallery/umbraco-

If you prefer, you can compile Inner Content yourself, you'll need:

* Visual Studio 2015 (or above)
* [Visual Studio 2017 (or above, including Community Editions)](https://www.visualstudio.com/downloads/)
* Microsoft Build Tools 2015 (aka [MSBuild 15](https://www.microsoft.com/en-us/download/details.aspx?id=48159))

To clone it locally click the "Clone in Windows" button above or run the following git commands.

Expand All @@ -38,30 +39,38 @@ To clone it locally click the "Clone in Windows" button above or run the followi

## Known Issues

* _[TBC]_
- _[TBC]_

---

## Implementations

Umbraco packages that use Inner Content as a dependency library.

- [Stacked Content](https://github.com/umco/umbraco-stacked-content)

---

## Contributing to this project

Anyone and everyone is welcome to contribute. Please take a moment to review the [guidelines for contributing](CONTRIBUTING.md).

* [Bug reports](CONTRIBUTING.md#bugs)
* [Feature requests](CONTRIBUTING.md#features)
* [Pull requests](CONTRIBUTING.md#pull-requests)
- [Bug reports](CONTRIBUTING.md#bugs)
- [Feature requests](CONTRIBUTING.md#features)
- [Pull requests](CONTRIBUTING.md#pull-requests)

---

## Contact

Have a question?

* [Raise an issue](https://github.com/umco/umbraco-inner-content/issues) on GitHub
- [Raise an issue](https://github.com/umco/umbraco-inner-content/issues) on GitHub

## Dev Team

* [Matt Brailsford](https://github.com/mattbrailsford)
* [Lee Kelleher](https://github.com/leekelleher)
- [Matt Brailsford](https://github.com/mattbrailsford)
- [Lee Kelleher](https://github.com/leekelleher)

## License

Expand Down
12 changes: 6 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
os: Visual Studio 2015
image: Visual Studio 2017

# version format
version: 1.0.3.{build}
version: 1.1.0.{build}

# UMBRACO_PACKAGE_PRERELEASE_SUFFIX if a rtm release build this should be blank, otherwise if empty will default to alpha
# example UMBRACO_PACKAGE_PRERELEASE_SUFFIX=beta
Expand All @@ -15,7 +15,7 @@ before_build:
- nuget restore src

build_script:
- build-appveyor.cmd
- build-appveyor.cmd

artifacts:
- path: artifacts\*.nupkg
Expand All @@ -24,8 +24,8 @@ artifacts:
deploy:
# MyGet Deployment for builds & releases
- provider: NuGet
server: https://www.myget.org/F/umbraco-packages/
symbol_server: https://nuget.symbolsource.org/MyGet/umbraco-packages
server: https://www.myget.org/F/umbraco-packages/api/v2/package
symbol_server: https://www.myget.org/F/umbraco-packages/symbols/api/v2/package
api_key:
secure: 36/Ax5O+e6wENlhoTwgvoEBZV3FG4XjF429SNTej2qsGTAL+cdfA1kT/tm1St8vx
artifact: /.*\.nupkg/
Expand All @@ -47,7 +47,7 @@ deploy:
- provider: NuGet
server:
api_key:
secure: eSLiOXbGVrxSG+X7PV6qTTUZ5VzS9EFj5+EufaWPfd+QXkF6gc8rZ4mGoHIVp/fL
secure: 0+oAleUTnr9UuJrhLW5rphRR+QGz00XX1Ui3k5kwyr2kUdEamiQ3F+gW0q8MJbDT
artifact: /.*\.nupkg/
on:
branch: master
Expand Down
3 changes: 2 additions & 1 deletion build-appveyor.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ ECHO APPVEYOR_BUILD_NUMBER : %APPVEYOR_BUILD_NUMBER%
ECHO APPVEYOR_BUILD_VERSION : %APPVEYOR_BUILD_VERSION%

CALL build\tools\NuGet\NuGet.exe restore src\Our.Umbraco.InnerContent.sln
CALL "%programfiles(x86)%\MSBuild\14.0\Bin\amd64\MsBuild.exe" build\package.proj
CALL "%programfiles(x86)%\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\amd64\MsBuild.exe" build\package.proj
REM CALL "%programfiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\MsBuild.exe" build\package.proj
2 changes: 1 addition & 1 deletion build/package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<language></language>
<tags></tags>
<dependencies>
<dependency id="Our.Umbraco.InnerContent.Core" version="0.0.0" />
<dependency id="Our.Umbraco.InnerContent.Core" version="0.0.0" />
</dependencies>
</metadata>
<files />
Expand Down
Binary file modified build/tools/NuGet/NuGet.exe
Binary file not shown.
29 changes: 27 additions & 2 deletions src/Our.Umbraco.InnerContent.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2008
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Our.Umbraco.InnerContent", "Our.Umbraco.InnerContent\Our.Umbraco.InnerContent.csproj", "{4B0C20EA-3B2B-4C56-A09A-C4F208D577EC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{ABCCCFCD-7ABB-4480-ACA6-E32A79B89990}"
ProjectSection(SolutionItems) = preProject
..\CONTRIBUTING.md = ..\CONTRIBUTING.md
..\LICENSE.md = ..\LICENSE.md
..\README.md = ..\README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Scripts", "Build Scripts", "{0EDC340A-DCE2-459A-9114-99B7334A1D2D}"
ProjectSection(SolutionItems) = preProject
..\appveyor.yml = ..\appveyor.yml
..\build-appveyor.cmd = ..\build-appveyor.cmd
..\build.cmd = ..\build.cmd
..\build\install.ps1 = ..\build\install.ps1
..\build\package.core.nuspec = ..\build\package.core.nuspec
..\build\package.nuspec = ..\build\package.nuspec
..\build\package.proj = ..\build\package.proj
..\build\package.xml = ..\build\package.xml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -19,4 +38,10 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0EDC340A-DCE2-459A-9114-99B7334A1D2D} = {ABCCCFCD-7ABB-4480-ACA6-E32A79B89990}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3DB20A45-23C8-4D1F-9007-7E6FAD1B4C06}
EndGlobalSection
EndGlobal
24 changes: 0 additions & 24 deletions src/Our.Umbraco.InnerContent/Boostrap.cs

This file was deleted.

56 changes: 56 additions & 0 deletions src/Our.Umbraco.InnerContent/Bootstrap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System.Linq;
using Newtonsoft.Json;
using Our.Umbraco.InnerContent.Helpers;
using Umbraco.Core;
using Umbraco.Core.Sync;
using Umbraco.Web.Cache;

namespace Our.Umbraco.InnerContent
{
public class Bootstrap : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
DataTypeCacheRefresher.CacheUpdated += (sender, e) =>
{
if (e.MessageType != MessageType.RefreshByJson)
return;
// NOTE: The properties for the JSON payload are available here: (Currently there isn't a public API to deserialize the payload)
// https://github.com/umbraco/Umbraco-CMS/blob/release-7.4.0/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs#L64-L68
var payload = JsonConvert.DeserializeAnonymousType((string)e.MessageObject, new[] { new { Id = default(int) } });
if (payload == null)
return;
foreach (var item in payload)
{
applicationContext.ApplicationCache.RuntimeCache.ClearCacheItem(string.Format(InnerContentConstants.PreValuesCacheKey, item.Id));
}
};

ContentTypeCacheRefresher.CacheUpdated += (sender, e) =>
{
if (e.MessageType != MessageType.RefreshByJson)
return;
// NOTE: The properties for the JSON payload are available here: (Currently there isn't a public API to deserialize the payload)
// https://github.com/umbraco/Umbraco-CMS/blob/release-7.4.0/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs#L93-L109
var payload = JsonConvert.DeserializeAnonymousType((string)e.MessageObject, new[] { new { Id = default(int), AliasChanged = default(bool) } });
if (payload == null)
return;
// Only update if the content-type alias has changed.
var ids = payload.Where(x => x.AliasChanged).Select(x => x.Id).ToArray();
if (ids.Length == 0)
return;
var contentTypes = applicationContext.Services.ContentTypeService.GetAllContentTypes(ids);
foreach (var contentType in contentTypes)
{
ContentTypeCacheHelper.TryRemove(contentType);
ContentTypeCacheHelper.TryAdd(contentType);
}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ protected IPublishedContent ConvertInnerContentDataToSource(
return InnerContentHelper.ConvertInnerContentToPublishedContent(item, parentNode, sortOrder, level, preview);
}
}
}
}

This file was deleted.

92 changes: 92 additions & 0 deletions src/Our.Umbraco.InnerContent/Helpers/ContentTypeCacheHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System;
using System.Collections.Concurrent;
using Umbraco.Core.Models;
using Umbraco.Core.Services;

namespace Our.Umbraco.InnerContent.Helpers
{
internal static class ContentTypeCacheHelper
{
private static readonly ConcurrentDictionary<Guid, string> Forward = new ConcurrentDictionary<Guid, string>();
private static readonly ConcurrentDictionary<string, Guid> Reverse = new ConcurrentDictionary<string, Guid>();

public static void ClearAll()
{
Forward.Clear();
Reverse.Clear();
}

public static void TryAdd(IContentType contentType)
{
TryAdd(contentType.Key, contentType.Alias);
}

public static void TryAdd(Guid guid, string alias)
{
Forward.TryAdd(guid, alias);
Reverse.TryAdd(alias, guid);
}

public static bool TryGetAlias(Guid key, out string alias, IContentTypeService contentTypeService = null)
{
if (Forward.TryGetValue(key, out alias))
return true;

// The alias isn't cached, we can attempt to get it via the content-type service, using the GUID.
if (contentTypeService != null)
{
var contentType = contentTypeService.GetContentType(key);
if (contentType != null)
{
TryAdd(contentType);
alias = contentType.Alias;
return true;
}
}

return false;
}

public static bool TryGetGuid(string alias, out Guid key, IContentTypeService contentTypeService = null)
{
if (Reverse.TryGetValue(alias, out key))
return true;

// The GUID isn't cached, we can attempt to get it via the content-type service, using the alias.
if (contentTypeService != null)
{
var contentType = contentTypeService.GetContentType(alias);
if (contentType != null)
{
TryAdd(contentType);
key = contentType.Key;
return true;
}
}

return false;
}

public static void TryRemove(IContentType contentType)
{
if (TryRemove(contentType.Alias) == false)
{
TryRemove(contentType.Key);
}
}

public static bool TryRemove(Guid guid)
{
return Forward.TryRemove(guid, out string alias)
? Reverse.TryRemove(alias, out guid)
: false;
}

public static bool TryRemove(string alias)
{
return Reverse.TryRemove(alias, out Guid guid)
? Forward.TryRemove(guid, out alias)
: false;
}
}
}
Loading

0 comments on commit 6e30f41

Please sign in to comment.