diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Templates/Migrations.cs index 4f75a0da3..4b68c649d 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Migrations.cs @@ -14,8 +14,7 @@ namespace Orchard.Templates { .WithPart("CommonPart") .WithPart("IdentityPart") .WithPart("TitlePart") - .WithPart("ShapePart", p => p - .WithSetting("ShapePartSettings.Processor", "Razor")) + .WithPart("ShapePart") .Draftable()); return 1; } diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Module.txt b/src/Orchard.Web/Modules/Orchard.Templates/Module.txt index f4515b3a5..60176b8fd 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Module.txt +++ b/src/Orchard.Web/Modules/Orchard.Templates/Module.txt @@ -4,10 +4,15 @@ Author: The Orchard Team Website: http://orchardproject.net Version: 1.8.1 OrchardVersion: 1.8 -Description: Provides a Template type that can be used to store Razor code and used as a shape. +Description: Provides a Template type that can be used to store template code and used as a shape. Features: Orchard.Templates: Name: Templates - Description: Provides a Template type that represents a Razor template, stored as a content item. + Description: Provides a Template type that represents a shape template, stored as a content item. Category: Content - Dependencies: Contents, Orchard.Tokens \ No newline at end of file + Dependencies: Contents, Orchard.Tokens + Orchard.Templates.Razor: + Name: Razor Templates + Description: Extends Templates with Razor templates. + Category: Content + Dependencies: Orchard.Templates \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Orchard.Templates.csproj b/src/Orchard.Web/Modules/Orchard.Templates/Orchard.Templates.csproj index 8b3b3c022..c5c39e305 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Orchard.Templates.csproj +++ b/src/Orchard.Web/Modules/Orchard.Templates/Orchard.Templates.csproj @@ -167,8 +167,10 @@ + + diff --git a/src/Orchard.Web/Modules/Orchard.Templates/RazorMigrations.cs b/src/Orchard.Web/Modules/Orchard.Templates/RazorMigrations.cs new file mode 100644 index 000000000..212701966 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Templates/RazorMigrations.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Orchard.Data.Migration; +using Orchard.ContentManagement.MetaData; +using Orchard.Environment.Extensions; + +namespace Orchard.Templates { + [OrchardFeature("Orchard.Templates.Razor")] + public class RazorMigrations : DataMigrationImpl { + public int Create() { + ContentDefinitionManager.AlterTypeDefinition("Template", type => type + .WithPart("ShapePart", p => p + .WithSetting("ShapePartSettings.Processor", "Razor"))); + return 1; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Services/NoTemplateProcessorBanner.cs b/src/Orchard.Web/Modules/Orchard.Templates/Services/NoTemplateProcessorBanner.cs new file mode 100644 index 000000000..4ca686166 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Templates/Services/NoTemplateProcessorBanner.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Orchard.Localization; +using Orchard.UI.Admin.Notification; +using Orchard.UI.Notify; + +namespace Orchard.Templates.Services { + public class NoTemplateProcessorBanner : INotificationProvider { + private readonly IEnumerable _processors; + + public NoTemplateProcessorBanner(IEnumerable processors) { + _processors = processors; + + T = NullLocalizer.Instance; + } + + public Localizer T { get; set; } + + public IEnumerable GetNotifications() { + if (!_processors.Any()) { + yield return new NotifyEntry { Message = T("To be able to use Templates enable a template processor like Razor Templates."), Type = NotifyType.Warning }; + } + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/IRazorCompiler.cs b/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/IRazorCompiler.cs index 9480061ec..869864581 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/IRazorCompiler.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/IRazorCompiler.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; namespace Orchard.Templates.Compilation.Razor { - public interface IRazorCompiler : IDependency { + public interface IRazorCompiler : IDependency { IRazorTemplateBase CompileRazor(string code, string name, IDictionary parameters); IRazorTemplateBase CompileRazor(string code, string name, IDictionary parameters); } diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorCompiler.cs b/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorCompiler.cs index 3e0b80400..615ddcb7c 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorCompiler.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Services/Razor/RazorCompiler.cs @@ -10,10 +10,12 @@ using System.Text; using System.Web.Razor; using Microsoft.CSharp; using Orchard.Caching; +using Orchard.Environment.Extensions; using Orchard.Logging; using Orchard.Utility.Extensions; namespace Orchard.Templates.Compilation.Razor { + [OrchardFeature("Orchard.Templates.Razor")] public class RazorCompiler : IRazorCompiler { private readonly ICacheManager _cache; private readonly ISignals _signals; diff --git a/src/Orchard.Web/Modules/Orchard.Templates/Services/RazorTemplateProcessor.cs b/src/Orchard.Web/Modules/Orchard.Templates/Services/RazorTemplateProcessor.cs index 2d51eb51c..88735f926 100644 --- a/src/Orchard.Web/Modules/Orchard.Templates/Services/RazorTemplateProcessor.cs +++ b/src/Orchard.Web/Modules/Orchard.Templates/Services/RazorTemplateProcessor.cs @@ -7,9 +7,12 @@ using System.Web.Mvc; using System.Web.UI; using System.Web.WebPages; using Orchard.DisplayManagement.Implementation; +using Orchard.Environment.Extensions; using Orchard.Logging; using Orchard.Templates.Compilation.Razor; + namespace Orchard.Templates.Services { + [OrchardFeature("Orchard.Templates.Razor")] public class RazorTemplateProcessor : TemplateProcessorImpl { private readonly IRazorCompiler _compiler; private readonly HttpContextBase _httpContextBase;