mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge branch '1.9.x' into dev
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using Markdown.Models;
|
using Markdown.Models;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Handlers;
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.ContentManagement.MetaData;
|
using Orchard.ContentManagement.MetaData;
|
||||||
using Orchard.ContentManagement.MetaData.Builders;
|
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
|
|
||||||
namespace Markdown.Handlers {
|
namespace Markdown.Handlers {
|
||||||
@@ -18,24 +18,6 @@ namespace Markdown.Handlers {
|
|||||||
part.UseMarkdownForBlogs = false;
|
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;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,5 +28,33 @@ namespace Markdown.Handlers {
|
|||||||
base.GetItemMetadata(context);
|
base.GetItemMetadata(context);
|
||||||
context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Markdown")));
|
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")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -7,11 +7,11 @@ namespace Orchard.Caching {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class CacheManagerExtensions {
|
public static class CacheManagerExtensions {
|
||||||
public static TResult Get<TKey, TResult>(this ICacheManager cacheManager, TKey key, bool lazy, Func<AcquireContext<TKey>, TResult> acquire) {
|
public static TResult Get<TKey, TResult>(this ICacheManager cacheManager, TKey key, bool preventConcurrentCalls, Func<AcquireContext<TKey>, TResult> acquire) {
|
||||||
// Wrap the call in a Lazy initializer to prevent multiple processes from
|
if (preventConcurrentCalls) {
|
||||||
// executing the same lambda in parallel.
|
lock(key) {
|
||||||
if (lazy) {
|
return cacheManager.Get(key, acquire);
|
||||||
return cacheManager.Get<TKey, Lazy<TResult>>(key, k => new Lazy<TResult>(() => acquire(k))).Value;
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return cacheManager.Get(key, acquire);
|
return cacheManager.Get(key, acquire);
|
||||||
|
@@ -213,7 +213,7 @@ namespace Orchard.Environment {
|
|||||||
// This is a "fake" cache entry to allow the extension loader coordinator
|
// This is a "fake" cache entry to allow the extension loader coordinator
|
||||||
// notify us (by resetting _current to "null") when an extension has changed
|
// notify us (by resetting _current to "null") when an extension has changed
|
||||||
// on disk, and we need to reload new/updated extensions.
|
// on disk, and we need to reload new/updated extensions.
|
||||||
_cacheManager.Get("OrchardHost_Extensions",
|
_cacheManager.Get("OrchardHost_Extensions", true,
|
||||||
ctx => {
|
ctx => {
|
||||||
_extensionMonitoringCoordinator.MonitorExtensions(ctx.Monitor);
|
_extensionMonitoringCoordinator.MonitorExtensions(ctx.Monitor);
|
||||||
_hostLocalRestart.Monitor(ctx.Monitor);
|
_hostLocalRestart.Monitor(ctx.Monitor);
|
||||||
|
Reference in New Issue
Block a user