Skip to content
Open

Ethos #210

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
258 changes: 118 additions & 140 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<ProjectReference Include="..\StatCan.OrchardCore.Security\StatCan.OrchardCore.Security.csproj" PrivateAssets="none" />

<!-- Modules -->
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.DisplayHelpers\StatCan.OrchardCore.DisplayHelpers.csproj" PrivateAssets="none" />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove duplicate entry

<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.CommonTypes\StatCan.OrchardCore.CommonTypes.csproj" PrivateAssets="none" />
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.Configuration\StatCan.OrchardCore.Configuration.csproj" PrivateAssets="none" />
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.ContentFields\StatCan.OrchardCore.ContentFields.csproj" PrivateAssets="none" />
Expand Down
7 changes: 7 additions & 0 deletions src/Modules/StatCan.OrchardCore.Ethos/FeatureIds.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace StatCan.OrchardCore.Persona
{
public static class FeatureIds
{
public const string Persona = "StatCan.OrchardCore.Persona";
}
}
21 changes: 21 additions & 0 deletions src/Modules/StatCan.OrchardCore.Ethos/Manifest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using OrchardCore.Modules.Manifest;
using static StatCan.OrchardCore.Persona.FeatureIds;

[assembly: Module(
Name = "StatCan Persona",
Author = "Digital Innovation Team",
Website = "https://digital.statcan.gc.ca",
Version = "1.0.0"
)]

[assembly: Feature(
Id = Persona,
Name = "StatCan.Persona - Widgets",
Category = "Content",
Description = "Adds a widget used to create a Persona",
Dependencies = new[]
{
"OrchardCore.Widgets",

}
)]
74 changes: 74 additions & 0 deletions src/Modules/StatCan.OrchardCore.Ethos/Migrations.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using OrchardCore.ContentFields.Settings;
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.ContentManagement.Metadata.Settings;
using OrchardCore.Data.Migration;
using OrchardCore.Title.Models;
using StatCan.OrchardCore.Extensions;
using OrchardCore.Media.Settings;

namespace StatCan.OrchardCore.Persona
{
public class Migrations : DataMigration
{
private readonly IContentDefinitionManager _contentDefinitionManager;
public Migrations(IContentDefinitionManager contentDefinitionManager)
{
_contentDefinitionManager = contentDefinitionManager;
}

public int Create()
{
CreatePersona();
return 1;
}

private void CreatePersona() {
_contentDefinitionManager.AlterTypeDefinition("Persona", type => type
.DisplayedAs("Persona")
.Stereotype("Widget")
.WithPart("Persona", part => part
.WithPosition("0")
)
);

_contentDefinitionManager.AlterPartDefinition("Persona", part => part
.WithField("Data", field => field
.OfType("TextField")
.WithDisplayName("Data")
.WithEditor("CodeMirror")
.WithPosition("0")
.WithSettings(new TextFieldSettings
{
Hint = "Enter JSON for Persona here.",
Required = true,
})
)
.WithField("PhotoPicker", field => field
.OfType("MediaField")
.WithDisplayName("PhotoPicker")
.WithPosition("2")
.WithSettings(new MediaFieldSettings
{
Hint = "Select the photo to use for the persona.",
Required = false,
Multiple = false,
AllowMediaText = false,
AllowAnchors = true,
})
)
.WithField("Colour", field => field
.OfType("TextField")
.WithDisplayName("Colour")
.WithEditor("Color")
.WithPosition("1")
.WithSettings(new TextFieldSettings
{
Hint = "Choose the colour that matches the site's theme.",
Required = true,
})
)
);

}
}
}
95 changes: 95 additions & 0 deletions src/Modules/StatCan.OrchardCore.Ethos/Recipes/Persona.recipe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"name": "Persona",
"displayName": "Persona",
"description": "Creates a Persona tool.",
"author": "StatCan Digital Innovation",
"website": "digital.statcan.gc.ca",
"version": "1.0.0",
"issetuprecipe": false,
"categories": [],
"tags": [],
"steps": [
{
"name": "ContentDefinition",
"ContentTypes": [
{
"Name": "Persona",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is required since you are creating the types with the code Migration

"DisplayName": "Persona",
"Settings": {
"ContentTypeSettings": {
"Creatable": true,
"Listable": true,
"Stereotype": "Widget"
},
"FullTextAspectSettings": {}
},
"ContentTypePartDefinitionRecords": [
{
"PartName": "Persona",
"Name": "Persona",
"Settings": {
"ContentTypePartSettings": {
"Position": "0"
}
}
}
]
}
],
"ContentParts": [
{
"Name": "Persona",
"Settings": {},
"ContentPartFieldDefinitionRecords": [
{
"FieldName": "TextField",
"Name": "Data",
"Settings": {
"ContentPartFieldSettings": {
"DisplayName": "Data",
"Editor": "CodeMirror",
"Position": "0"
},
"TextFieldSettings": {
"Hint": "Enter JSON for Persona here.",
"Required": true
}
}
},
{
"FieldName": "MediaField",
"Name": "PhotoPicker",
"Settings": {
"ContentPartFieldSettings": {
"DisplayName": "PhotoPicker",
"Position": "2"
},
"MediaFieldSettings": {
"Hint": "Select the photo to use for the persona.",
"Multiple": false,
"AllowMediaText": false,
"AllowAnchors": true
}
}
},
{
"FieldName": "TextField",
"Name": "Colour",
"Settings": {
"ContentPartFieldSettings": {
"DisplayName": "Colour",
"Editor": "Color",
"Position": "1"
},
"TextFieldSettings": {
"Hint": "Choose the colour that matches the site's theme.",
"Required": true
}
}
}
]
}
]
}
]
}
13 changes: 13 additions & 0 deletions src/Modules/StatCan.OrchardCore.Ethos/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;
using OrchardCore.Data.Migration;

namespace StatCan.OrchardCore.Persona
{
[Feature(FeatureIds.Persona)]
public class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection serviceCollection) => serviceCollection.AddScoped<IDataMigration, Migrations>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>$(AspNetCoreTargetFramework)</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*;node_modules\**</DefaultItemExcludes>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.ContentManagement" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.Contents" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.ResourceManagement" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.ContentFields" Version="$(OrchardCoreVersion)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="OrchardCore.Title" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.Contents" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.Autoroute" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.Media" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.Flows" Version="$(OrchardCoreVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Lib\StatCan.OrchardCore.Extensions\StatCan.OrchardCore.Extensions.csproj" />
</ItemGroup>

</Project>
Loading