Merge branch '1.9.x' into dev

This commit is contained in:
Sebastien Ros
2015-09-23 17:19:28 -07:00
3 changed files with 36 additions and 26 deletions

View File

@@ -1,9 +1,9 @@
using System.Linq;
using System;
using System.Linq;
using Markdown.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.Localization;
namespace Markdown.Handlers {
@@ -18,24 +18,6 @@ namespace Markdown.Handlers {
part.UseMarkdownForBlogs = false;
});
OnUpdated<MarkdownSiteSettingsPart>((context, part) => {
var blogPost = _contentDefinitionManager.GetTypeDefinition("BlogPost");
if (blogPost == null) {
return;
}
var bodyPart = blogPost.Parts.FirstOrDefault(x => x.PartDefinition.Name == "BodyPart");
if (bodyPart == null) {
return;
}
_contentDefinitionManager.AlterTypeDefinition("BlogPost", build => build
.WithPart("BodyPart", cfg => cfg
.WithSetting("BodyTypePartSettings.Flavor", part.UseMarkdownForBlogs ? "markdown" : "html")
)
);
});
T = NullLocalizer.Instance;
}
@@ -46,5 +28,33 @@ namespace Markdown.Handlers {
base.GetItemMetadata(context);
context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Markdown")));
}
protected override void UpdateEditorShape(UpdateEditorContext context) {
if (!string.Equals("markdown", context.GroupId, StringComparison.OrdinalIgnoreCase))
return;
var part = context.ContentItem.As<MarkdownSiteSettingsPart>();
if (part == null) {
return;
}
base.UpdateEditorShape(context);
var blogPost = _contentDefinitionManager.GetTypeDefinition("BlogPost");
if (blogPost == null) {
return;
}
var bodyPart = blogPost.Parts.FirstOrDefault(x => x.PartDefinition.Name == "BodyPart");
if (bodyPart == null) {
return;
}
_contentDefinitionManager.AlterTypeDefinition("BlogPost", build => build
.WithPart("BodyPart", cfg => cfg
.WithSetting("BodyTypePartSettings.Flavor", part.UseMarkdownForBlogs ? "markdown" : "html")
)
);
}
}
}

View File

@@ -7,11 +7,11 @@ namespace Orchard.Caching {
}
public static class CacheManagerExtensions {
public static TResult Get<TKey, TResult>(this ICacheManager cacheManager, TKey key, bool lazy, Func<AcquireContext<TKey>, TResult> acquire) {
// Wrap the call in a Lazy initializer to prevent multiple processes from
// executing the same lambda in parallel.
if (lazy) {
return cacheManager.Get<TKey, Lazy<TResult>>(key, k => new Lazy<TResult>(() => acquire(k))).Value;
public static TResult Get<TKey, TResult>(this ICacheManager cacheManager, TKey key, bool preventConcurrentCalls, Func<AcquireContext<TKey>, TResult> acquire) {
if (preventConcurrentCalls) {
lock(key) {
return cacheManager.Get(key, acquire);
}
}
else {
return cacheManager.Get(key, acquire);

View File

@@ -213,7 +213,7 @@ namespace Orchard.Environment {
// This is a "fake" cache entry to allow the extension loader coordinator
// notify us (by resetting _current to "null") when an extension has changed
// on disk, and we need to reload new/updated extensions.
_cacheManager.Get("OrchardHost_Extensions",
_cacheManager.Get("OrchardHost_Extensions", true,
ctx => {
_extensionMonitoringCoordinator.MonitorExtensions(ctx.Monitor);
_hostLocalRestart.Monitor(ctx.Monitor);