Skip to content

Commit

Permalink
Adding Script modules and support in recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros committed Dec 17, 2016
1 parent 0270c34 commit e042c92
Show file tree
Hide file tree
Showing 48 changed files with 847 additions and 428 deletions.
28 changes: 28 additions & 0 deletions Orchard.sln
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Orchard.Alias", "src\Orchar
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TheBlogTheme", "src\Orchard.Cms.Web\Themes\TheBlogTheme\TheBlogTheme.xproj", "{9EB6EB7C-1C07-4DA3-9E91-AF1B1A92539D}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Orchard.Scripting.Abstractions", "src\Orchard.Scripting.Abstractions\Orchard.Scripting.Abstractions.xproj", "{9A7DBD64-6F4F-4685-953D-9ACD79ED34FF}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Orchard.Scripting.JavaScript", "src\Orchard.Scripting.JavaScript\Orchard.Scripting.JavaScript.xproj", "{64B42E50-21A3-4F42-8D9D-CAD30493ECA1}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Orchard.Scripting.Core", "src\Orchard.Scripting.Core\Orchard.Scripting.Core.xproj", "{ECB391BC-F0C7-4775-A585-2781A40ABF5E}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Orchard.Scripting", "src\Orchard.Cms.Web\Modules\Orchard.Scripting\Orchard.Scripting.xproj", "{0A43B150-748F-4595-AD2B-69CEF6B11ED0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -519,6 +527,22 @@ Global
{9EB6EB7C-1C07-4DA3-9E91-AF1B1A92539D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EB6EB7C-1C07-4DA3-9E91-AF1B1A92539D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EB6EB7C-1C07-4DA3-9E91-AF1B1A92539D}.Release|Any CPU.Build.0 = Release|Any CPU
{9A7DBD64-6F4F-4685-953D-9ACD79ED34FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A7DBD64-6F4F-4685-953D-9ACD79ED34FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A7DBD64-6F4F-4685-953D-9ACD79ED34FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A7DBD64-6F4F-4685-953D-9ACD79ED34FF}.Release|Any CPU.Build.0 = Release|Any CPU
{64B42E50-21A3-4F42-8D9D-CAD30493ECA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64B42E50-21A3-4F42-8D9D-CAD30493ECA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64B42E50-21A3-4F42-8D9D-CAD30493ECA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64B42E50-21A3-4F42-8D9D-CAD30493ECA1}.Release|Any CPU.Build.0 = Release|Any CPU
{ECB391BC-F0C7-4775-A585-2781A40ABF5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ECB391BC-F0C7-4775-A585-2781A40ABF5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ECB391BC-F0C7-4775-A585-2781A40ABF5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ECB391BC-F0C7-4775-A585-2781A40ABF5E}.Release|Any CPU.Build.0 = Release|Any CPU
{0A43B150-748F-4595-AD2B-69CEF6B11ED0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A43B150-748F-4595-AD2B-69CEF6B11ED0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A43B150-748F-4595-AD2B-69CEF6B11ED0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A43B150-748F-4595-AD2B-69CEF6B11ED0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -611,5 +635,9 @@ Global
{F67204C5-61EC-49DF-9122-4520D9076651} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{716AD330-36FE-42C9-A40A-E92D5C5D27AE} = {90030E85-0C4F-456F-B879-443E8A3F220D}
{9EB6EB7C-1C07-4DA3-9E91-AF1B1A92539D} = {AF3BADEA-CC93-4116-B3C1-F8D074EBEE4F}
{9A7DBD64-6F4F-4685-953D-9ACD79ED34FF} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{64B42E50-21A3-4F42-8D9D-CAD30493ECA1} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{ECB391BC-F0C7-4775-A585-2781A40ABF5E} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{0A43B150-748F-4595-AD2B-69CEF6B11ED0} = {A066395F-6F73-45DC-B5A6-B4E306110DCE}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ private void UpdateContentPart(ContentPartDefinition part, ContentPartDefinition
{
builder.WithField(field.Name, fieldBuilder =>
{
fieldBuilder.MergeSettings(part.Settings);
fieldBuilder.OfType(field.FieldName);
fieldBuilder.MergeSettings(field.Settings);
});
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using Orchard.Scripting;

namespace Orchard.ContentManagement
{
public class IdGeneratorMethod : IGlobalMethodProvider
{
private static GlobalMethod Uuid = new GlobalMethod
{
Name = "uuid",
Method = serviceProvider => (Func<object>) (() =>
{
var idGenerator = serviceProvider.GetRequiredService<IContentItemIdGenerator>();
return idGenerator.GenerateUniqueId(new ContentItem());
})
};

public IEnumerable<GlobalMethod> GetMethods()
{
yield return Uuid;
}
}
}
3 changes: 3 additions & 0 deletions src/Orchard.Cms.Web/Modules/Orchard.Contents/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Orchard.Environment.Navigation;
using Orchard.Indexing;
using Orchard.Recipes;
using Orchard.Scripting;
using Orchard.Security.Permissions;

namespace Orchard.Contents
Expand All @@ -34,6 +35,8 @@ public override void ConfigureServices(IServiceCollection services)

services.AddScoped<IContentItemIndexHandler, AspectsContentIndexHandler>();
services.AddScoped<IContentItemIndexHandler, DefaultContentIndexHandler>();

services.AddScoped<IGlobalMethodProvider, IdGeneratorMethod>();
}

public override void Configure(IApplicationBuilder builder, IRouteBuilder routes, IServiceProvider serviceProvider)
Expand Down
3 changes: 2 additions & 1 deletion src/Orchard.Cms.Web/Modules/Orchard.Contents/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"Orchard.ContentManagement.Display": "2.0.0-*",
"Orchard.Settings": "2.0.0-*",
"Orchard.Navigation": "2.0.0-*",
"Orchard.Indexing.Abstractions": "2.0.0-*"
"Orchard.Indexing.Abstractions": "2.0.0-*",
"Orchard.Scripting.Abstractions": "2.0.0-*"
},
"buildOptions": {
"debugType": "portable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public async Task<IActionResult> Import([FromBody] ArchiveContainer archive)

var executionId = Guid.NewGuid().ToString("n");
var fileProvider = new PhysicalFileProvider(tempArchiveFolder);
await _recipeExecutor.ExecuteAsync(executionId, new Recipes.Models.RecipeDescriptor { RecipeFileName = "Recipe.json", RecipeFileProvider = fileProvider });
await _recipeExecutor.ExecuteAsync(executionId, new Recipes.Models.RecipeDescriptor { RecipeFileInfo = fileProvider.GetFileInfo("Recipe.json") });
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion src/Orchard.Cms.Web/Modules/Orchard.Recipes/Module.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Version: 2.0.x
OrchardVersion: 2.0.x
Description: Provides Orchard Recipes.
FeatureDescription: Implementation of Orchard recipes.
Dependencies: Orchard.Modules
Dependencies: Orchard.Modules, Orchard.Scripting
Category: Infrastructure
3 changes: 0 additions & 3 deletions src/Orchard.Cms.Web/Modules/Orchard.Recipes/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public override void ConfigureServices(IServiceCollection services)

services.AddRecipeExecutionStep<CommandStep>();
services.AddRecipeExecutionStep<RecipesStep>();

services.AddRecipeOptions();
services.AddRecipeExtension<JsonRecipeParser>("*.recipe.json");
}
}
}
9 changes: 9 additions & 0 deletions src/Orchard.Cms.Web/Modules/Orchard.Scripting/Module.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Name: Scripting
AntiForgery: enabled
Author: The Orchard Team
Website: http://orchardproject.net
Version: 2.0.x
OrchardVersion: 2.0.x
Description: Adds scripting capabilities.
Dependencies:
Category: Infrastructure
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>0a43b150-748f-4595-ad2b-69cef6b11ed0</ProjectGuid>
<RootNamespace>Orchard.Admin</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Orchard.Admin")]
[assembly: AssemblyTrademark("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6d650f4a-cf99-4244-838d-af5010a8460a")]
15 changes: 15 additions & 0 deletions src/Orchard.Cms.Web/Modules/Orchard.Scripting/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Mvc.Modules;
using Microsoft.Extensions.DependencyInjection;
using Orchard.Scripting.JavaScript;

namespace Orchard.Scripting
{
public class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScripting();
services.AddJavaScriptEngine();
}
}
}
26 changes: 26 additions & 0 deletions src/Orchard.Cms.Web/Modules/Orchard.Scripting/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "2.0.0-*",
"dependencies": {
"Microsoft.AspNetCore.Mvc.Modules.Hosting": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.1.0",
"Orchard.Scripting.Core": "2.0.0-*",
"Orchard.Scripting.JavaScript": "2.0.0-*"
},
"buildOptions": {
"define": [ "TRACE" ],
"debugType": "portable",
"warningsAsErrors": true
},
"frameworks": {
"netstandard1.6": {
"imports": [
"dnxcore50",
"portable-net451+win8"
]
}
},
"packOptions": {
"type": "git",
"url": "https://github.com/OrchardCMS/Orchard2"
}
}
Loading

0 comments on commit e042c92

Please sign in to comment.