Skip to content
This repository has been archived by the owner on Jun 18, 2018. It is now read-only.

Commit

Permalink
Merge pull request #74 from leekelleher/develop
Browse files Browse the repository at this point in the history
Preparing for v0.3.0 release
  • Loading branch information
leekelleher authored Jul 8, 2016
2 parents 8f6a98a + bdb8f5c commit 99ebbf7
Show file tree
Hide file tree
Showing 26 changed files with 423 additions and 180 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ _ReSharper.*
Thumbs.db
.DS_Store
*.log
.vs

artifacts/
src/packages/*/**
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Guidelines for bug reports:
2. **Check if the issue has been fixed** — try to reproduce it using the
latest `master` or development branch in the repository.

3. **Isolate the problem** — create a [reduced test
case](http://css-tricks.com/6263-reduced-test-cases/) and a live example.
3. **Isolate the problem** — create a reduced test
case and a live example.

A good bug report shouldn't leave others needing to chase you up for more
information. Please try to be as detailed as possible in your report. What is
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ To [install from NuGet](https://www.nuget.org/packages/Our.Umbraco.NestedContent

PM> Install-Package Our.Umbraco.NestedContent

We also have a [MyGet package repository](https://www.myget.org/gallery/umbraco-nested-content) - for bleeding-edge / development releases.
We also have a [MyGet package repository](https://www.myget.org/gallery/umbraco-packages) - for bleeding-edge / development releases.

#### Manual build

Expand Down Expand Up @@ -57,8 +57,12 @@ A PDF download is also available: [Nested Content - Developers Guide v1.0.pdf](d

Please be aware that not all property-editors will work within Nested Content. The following property-editors are known to have compatibility issues:

* Upload (default Umbraco core)
* Checkbox List (default Umbraco core)
* Image Cropper (default Umbraco core)
* Macro Container (default Umbraco core)
* Radiobutton List (default Umbraco core)
* Repeatable Textstring (default Umbraco core) - this works in the back-office, but due to a bug in the value-converter it will produce additional blank entries
* Upload (default Umbraco core)

---

Expand Down
21 changes: 17 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# version format
version: 0.2.0.{build}
version: 0.3.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
init:
- set UMBRACO_PACKAGE_PRERELEASE_SUFFIX=

cache:
- src\packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified

build_script:
- build-appveyor.cmd

Expand All @@ -14,7 +17,7 @@ artifacts:
- path: artifacts\*.zip

deploy:
# MyGet Deployment for builds & releases
# MyGet (Nested Content feed) Deployment for builds & releases
- provider: NuGet
server: https://www.myget.org/F/umbraco-nested-content/
symbol_server: https://nuget.symbolsource.org/MyGet/umbraco-nested-content
Expand All @@ -24,7 +27,17 @@ deploy:
on:
branch: develop

# GitHub Deployment for releases
# MyGet (Umbraco Community feed) Deployment for builds & releases
- provider: NuGet
server: https://www.myget.org/F/umbraco-packages/
symbol_server: https://nuget.symbolsource.org/MyGet/umbraco-packages
api_key:
secure: Q1/4K8VSwr7BjwmKDTef8y5lOc7S+jK9ELuWy67y6OVRpjxmnF9M3Gfs1kT+ir8x
artifact: /.*\.nupkg/
on:
branch: develop

# GitHub Deployment for releases
- provider: GitHub
auth_token:
secure: pEozEGTqJutQwOidJU6BTB+Ix0NV4vrUnomhfeqheVz4RNwfxjEYLoqR4XabhlPz
Expand All @@ -35,7 +48,7 @@ deploy:
branch: master
appveyor_repo_tag: true # deploy on tag push only

# NuGet Deployment for releases
# NuGet Deployment for releases
- provider: NuGet
server:
api_key:
Expand Down
19 changes: 19 additions & 0 deletions build/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
param($installPath, $toolsPath, $package, $project)

$appPluginsFolder = $project.ProjectItems | Where-Object { $_.Name -eq "App_Plugins" }
$nestedContentFolder = $appPluginsFolder.ProjectItems | Where-Object { $_.Name -eq "NestedContent" }

if (!$nestedContentFolder)
{
$newPackageFiles = "$installPath\Content\App_Plugins\NestedContent"

$projFile = Get-Item ($project.FullName)
$projDirectory = $projFile.DirectoryName
$projectPath = Join-Path $projDirectory -ChildPath "App_Plugins"
$projectPathExists = Test-Path $projectPath

if ($projectPathExists) {
Write-Host "Updating Nested Content App_Plugin files using PS as they have been excluded from the project"
Copy-Item $newPackageFiles $projectPath -Recurse -Force
}
}
2 changes: 2 additions & 0 deletions build/package.proj
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
<PluginFiles Include="$(CoreProjectDir)\Web\UI\**\*.*" />
<PackageFile Include="$(MSBuildProjectDirectory)\package.xml" />
<NuSpecFile Include="$(MSBuildProjectDirectory)\package.nuspec" />
<InstallPsFile Include="$(MSBuildProjectDirectory)\install.ps1" />
</ItemGroup>
<Copy SourceFiles="@(BinFiles)" DestinationFolder="$(BuildUmbDir)\bin" />
<Copy SourceFiles="@(PackageFile)" DestinationFolder="$(BuildUmbDir)" />
Expand All @@ -132,6 +133,7 @@
<Copy SourceFiles="@(PluginFiles)" DestinationFiles="@(PluginFiles->'$(BuildNuGetDir)\Content\%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy SourceFiles="@(SrcFiles)" DestinationFiles="@(SrcFiles->'$(BuildNuGetDir)\src\%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy SourceFiles="@(NuSpecFile)" DestinationFolder="$(BuildNuGetDir)" />
<Copy SourceFiles="@(InstallPsFile)" DestinationFolder="$(BuildNuGetDir)\tools" />
</Target>

<!-- MANIFEST UMBRACO -->
Expand Down
2 changes: 1 addition & 1 deletion build/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<version>0.0.0</version>
<license url=""></license>
<url></url>
<requirements>
<requirements type="strict">
<major>0</major>
<minor>0</minor>
<patch>0</patch>
Expand Down
Binary file modified docs/assets/img/screenshot-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions docs/code-snippets/NC_RENAME_DOCTYPE_OR_PROPERTY_ALIAS.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- # Nested Content SQL scripts

-- ## Renaming a DocType alias

UPDATE
cmsPropertyData
SET
dataNtext = CAST(REPLACE(CAST(dataNtext AS nvarchar(max)), '"ncContentTypeAlias":"OLD_ALIAS"', '"ncContentTypeAlias":"NEW_ALIAS"') AS ntext)
WHERE
dataNtext LIKE '%"ncContentTypeAlias":"OLD_ALIAS"%'
;

UPDATE
cmsDataTypePreValues
SET
[value] = CAST(REPLACE(CAST([value] AS nvarchar(max)), '"ncAlias": "OLD_ALIAS"', '"ncAlias": "NEW_ALIAS"') AS ntext)
WHERE
[value] LIKE '%"ncAlias": "OLD_ALIAS"%'
;

-- ## Renaming a property alias

UPDATE
cmsPropertyData
SET
dataNtext = CAST(REPLACE(CAST(dataNtext AS nvarchar(max)), ',"OLD_ALIAS":', ',"NEW_ALIAS":') AS ntext)
WHERE
dataNtext LIKE '%"ncContentTypeAlias":"CONTENT_TYPE_ALIAS"%'
;
1 change: 1 addition & 0 deletions src/Our.Umbraco.NestedContent.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Package", "Build Pack
..\appveyor.yml = ..\appveyor.yml
..\build-appveyor.cmd = ..\build-appveyor.cmd
..\build.cmd = ..\build.cmd
..\build\install.ps1 = ..\build\install.ps1
..\build\package.nuspec = ..\build\package.nuspec
..\build\package.proj = ..\build\package.proj
..\build\package.xml = ..\build\package.xml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,108 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Our.Umbraco.NestedContent.Extensions;
using Our.Umbraco.NestedContent.Helpers;
using Our.Umbraco.NestedContent.Models;
using Our.Umbraco.NestedContent.PropertyEditors;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PropertyEditors;
using Umbraco.Web;

namespace Our.Umbraco.NestedContent.Converters
{
[PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)]
[PropertyValueType(typeof(IEnumerable<IPublishedContent>))]
public class NestedContentValueConverter : PropertyValueConverterBase
{
private UmbracoHelper _umbraco;
internal UmbracoHelper Umbraco
{
get { return _umbraco ?? (_umbraco = new UmbracoHelper(UmbracoContext.Current)); }
}

public override bool IsConverter(PublishedPropertyType propertyType)
{
return propertyType.PropertyEditorAlias.InvariantEquals(NestedContentPropertyEditor.PropertyEditorAlias);
return propertyType.IsNestedContentProperty() && !propertyType.IsSingleNestedContentProperty();
}

public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
{
try
{
using (DisposableTimer.DebugDuration<NestedContentValueConverter>(string.Format("ConvertDataToSource ({0})", propertyType.DataTypeId)))
{
if (source != null && !source.ToString().IsNullOrWhiteSpace())
{
var rawValue = JsonConvert.DeserializeObject<List<object>>(source.ToString());
var processedValue = new List<IPublishedContent>();

var preValueCollection = NestedContentHelper.GetPreValuesCollectionByDataTypeId(propertyType.DataTypeId);
var preValueDictionary = preValueCollection.AsPreValueDictionary();

for (var i = 0; i < rawValue.Count; i++)
{
var item = (JObject)rawValue[i];

// Convert from old style (v.0.1.1) data format if necessary
// - Please note: This call has virtually no impact on rendering performance for new style (>v0.1.1).
// Even so, this should be removed eventually, when it's safe to assume that there is
// no longer any need for conversion.
NestedContentHelper.ConvertItemValueFromV011(item, propertyType.DataTypeId, ref preValueCollection);

var contentTypeAlias = NestedContentHelper.GetContentTypeAliasFromItem(item);
if (string.IsNullOrEmpty(contentTypeAlias))
{
continue;
}

var publishedContentType = PublishedContentType.Get(PublishedItemType.Content, contentTypeAlias);
if (publishedContentType == null)
{
continue;
}

var propValues = item.ToObject<Dictionary<string, object>>();
var properties = new List<IPublishedProperty>();

foreach (var jProp in propValues)
{
var propType = publishedContentType.GetPropertyType(jProp.Key);
if (propType != null)
{
properties.Add(new DetachedPublishedProperty(propType, jProp.Value));
}
}

// Parse out the name manually
object nameObj = null;
if (propValues.TryGetValue("name", out nameObj))
{
// Do nothing, we just want to parse out the name if we can
}

processedValue.Add(new DetachedPublishedContent(
nameObj == null ? null : nameObj.ToString(),
publishedContentType,
properties.ToArray(),
i));
}

// Detect min/max items == 1 and just return a single IPublishedContent
int minItems, maxItems;
if (preValueDictionary.ContainsKey("minItems") && int.TryParse(preValueDictionary["minItems"], out minItems) && minItems == 1
&& preValueDictionary.ContainsKey("maxItems") && int.TryParse(preValueDictionary["maxItems"], out maxItems) && maxItems == 1)
{
return processedValue.FirstOrDefault();
}

return processedValue;
}
}
return propertyType.ConvertPropertyToNestedContent(source);
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using Our.Umbraco.NestedContent.Extensions;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.PropertyEditors;

namespace Our.Umbraco.NestedContent.Converters
{
[PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)]
[PropertyValueType(typeof(IPublishedContent))]
public class SingleNestedContentValueConverter : PropertyValueConverterBase
{
public override bool IsConverter(PublishedPropertyType propertyType)
{
return propertyType.IsSingleNestedContentProperty();
}

public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
{
try
{
return propertyType.ConvertPropertyToNestedContent(source);
}
catch (Exception e)
{
LogHelper.Error<SingleNestedContentValueConverter>("Error converting value", e);
}

return null;
}
}
}
Loading

0 comments on commit 99ebbf7

Please sign in to comment.