From 9fe274a7d45c070225c6e130d2433e1a186d118c Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Fri, 8 Oct 2010 13:53:27 -0700 Subject: [PATCH] Adding a new WidgetPage content type and WidgetsBagPart to support a widget only page and making *the* home page a WidgetPage to support the new default theme* - Current WidgetsBagPart only links to the widget management page so widget management isn't in more than one place (would be the case if Content zone widgets management were part of this part) *could be configured through the distribution instead when that's implemented --HG-- branch : dev --- .../Orchard.Setup/Services/SetupService.cs | 17 ++++++++++++----- .../Drivers/WidgetBagPartDriver.cs | 16 ++++++++++++++++ .../Modules/Orchard.Widgets/Migrations.cs | 19 +++++++++++++++++++ .../Orchard.Widgets/Models/WidgetBagPart.cs | 5 +++++ .../Orchard.Widgets/Orchard.Widgets.csproj | 5 +++++ .../Orchard.Widgets/ResourceManifest.cs | 10 ++++++++++ .../Modules/Orchard.Widgets/Styles/admin.css | 4 ++++ .../Parts/Widgets.WidgetBagPart.cshtml | 8 ++++++++ 8 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetBagPartDriver.cs create mode 100644 src/Orchard.Web/Modules/Orchard.Widgets/Models/WidgetBagPart.cs create mode 100644 src/Orchard.Web/Modules/Orchard.Widgets/ResourceManifest.cs create mode 100644 src/Orchard.Web/Modules/Orchard.Widgets/Styles/admin.css create mode 100644 src/Orchard.Web/Modules/Orchard.Widgets/Views/EditorTemplates/Parts/Widgets.WidgetBagPart.cshtml diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs index 63c5959a1..a444f745f 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs @@ -194,6 +194,7 @@ namespace Orchard.Setup.Services { //hackInstallationGenerator.GenerateInstallEvents(); var contentDefinitionManager = environment.Resolve(); + //todo: (heskew) pull these definitions (and initial content creation) out into more appropriate modules contentDefinitionManager.AlterTypeDefinition("BlogPost", cfg => cfg .WithPart("CommentsPart") .WithPart("TagsPart") @@ -214,12 +215,18 @@ namespace Orchard.Setup.Services { .WithSetting("BodyPartSettings.FlavorDefault", BodyPartSettings.FlavorDefaultDefault)); // create home page as a CMS page - var page = contentManager.Create("Page", VersionOptions.Draft); - page.As().Text = "

Welcome to Orchard!

Congratulations, you've successfully set-up your Orchard site.

This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click Edit to go into edit mode and replace this with whatever you want on your home page to make it your own.

One thing you could do (but you don't have to) is go into Manage Settings (follow the Admin link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.

You probably want to make the site your own. One of the ways you can do that is by clicking Manage Themes in the admin menu. A theme is a packaged look and feel that affects the whole site.

Next, you can start playing with the content types that we installed. For example, go ahead and click Add New Page in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to Manage Menu. You can also click Add New Blog and start posting by clicking \"Add New Post\".

Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to Manage Themes and clicking Install a new Theme. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please consider participating.

--The Orchard Crew

"; - page.As().Slug = "home"; - page.As().Path = "home"; + //var page = contentManager.Create("Page", VersionOptions.Draft); + //page.As().Text = "

Welcome to Orchard!

Congratulations, you've successfully set-up your Orchard site.

This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click Edit to go into edit mode and replace this with whatever you want on your home page to make it your own.

One thing you could do (but you don't have to) is go into Manage Settings (follow the Admin link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.

You probably want to make the site your own. One of the ways you can do that is by clicking Manage Themes in the admin menu. A theme is a packaged look and feel that affects the whole site.

Next, you can start playing with the content types that we installed. For example, go ahead and click Add New Page in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to Manage Menu. You can also click Add New Blog and start posting by clicking \"Add New Post\".

Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to Manage Themes and clicking Install a new Theme. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please consider participating.

--The Orchard Crew

"; + //page.As().Slug = "home"; + //page.As().Path = "home"; + //page.As().Title = T("Home").ToString(); + //page.As().Owner = user; + //contentManager.Publish(page); + //siteSettings.Record.HomePage = "RoutableHomePageProvider;" + page.Id; + //scratch that + //create the home page as a WidgetPage + var page = contentManager.Create("WidgetPage", VersionOptions.Draft); page.As().Title = T("Home").ToString(); - page.As().Owner = user; contentManager.Publish(page); siteSettings.Record.HomePage = "RoutableHomePageProvider;" + page.Id; diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetBagPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetBagPartDriver.cs new file mode 100644 index 000000000..763cd48b4 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetBagPartDriver.cs @@ -0,0 +1,16 @@ +using JetBrains.Annotations; +using Orchard.ContentManagement.Drivers; +using Orchard.Core.ContentsLocation.Models; +using Orchard.Widgets.Models; + +namespace Orchard.Widgets.Drivers { + [UsedImplicitly] + public class WidgetBagPartDriver : ContentPartDriver { + private const string TemplateName = "Parts/Widgets.WidgetBagPart"; + + protected override DriverResult Editor(WidgetBagPart part) { + var location = part.GetLocation("Editor"); + return ContentPartTemplate("", TemplateName, Prefix).Location(location); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Migrations.cs index 2b4005e82..1eade65e5 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Migrations.cs @@ -1,6 +1,9 @@ using System.Collections.Generic; using Orchard.ContentManagement; +using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.MetaData; +using Orchard.ContentManagement.MetaData.Builders; +using Orchard.Core.Contents.Extensions; using Orchard.Data.Migration; using Orchard.Environment.Configuration; using Orchard.Environment.Descriptor.Models; @@ -73,6 +76,22 @@ namespace Orchard.Widgets { return 1; } + public int UpdateFrom1() { + ContentDefinitionManager.AlterPartDefinition("WidgetBagPart", + cfg => cfg + .WithLocation(new Dictionary { + {"Editor", new ContentLocation {Zone = "primary", Position = "5"}} + }) + ); + ContentDefinitionManager.AlterTypeDefinition("WidgetPage", + cfg => cfg + .WithPart("RoutePart") + .WithPart("WidgetBagPart") + .Creatable() + ); + return 2; + } + private void CreateDefaultLayers() { _processingEngine.AddTask( _shellSettings, diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Models/WidgetBagPart.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Models/WidgetBagPart.cs new file mode 100644 index 000000000..4561d6014 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Models/WidgetBagPart.cs @@ -0,0 +1,5 @@ +using Orchard.ContentManagement; + +namespace Orchard.Widgets.Models { + public class WidgetBagPart : ContentPart {} +} diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj b/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj index f6f436d6f..8eb9891ed 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj @@ -59,11 +59,13 @@ + + @@ -71,12 +73,14 @@ + + @@ -93,6 +97,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/ResourceManifest.cs b/src/Orchard.Web/Modules/Orchard.Widgets/ResourceManifest.cs new file mode 100644 index 000000000..d7e09aa23 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Widgets/ResourceManifest.cs @@ -0,0 +1,10 @@ +using Orchard.UI.Resources; + +namespace Orchard.Widgets { + public class ResourceManifest : IResourceManifestProvider { + public void BuildManifests(ResourceManifestBuilder builder) { + var manifest = builder.Add(); + manifest.DefineStyle("WidgetsAdmin").SetUrl("admin.css"); + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Styles/admin.css b/src/Orchard.Web/Modules/Orchard.Widgets/Styles/admin.css new file mode 100644 index 000000000..2e263c949 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Styles/admin.css @@ -0,0 +1,4 @@ +.widgetsbag-editor h5 { + color:#4c4c4c; + font-weight:bold; +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Views/EditorTemplates/Parts/Widgets.WidgetBagPart.cshtml b/src/Orchard.Web/Modules/Orchard.Widgets/Views/EditorTemplates/Parts/Widgets.WidgetBagPart.cshtml new file mode 100644 index 000000000..9ef9756a2 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Views/EditorTemplates/Parts/Widgets.WidgetBagPart.cshtml @@ -0,0 +1,8 @@ +@{ + Style.Require("WidgetsAdmin"); +} +
+
@T("Widgets")
+ @* todo: (heskew) either embed some widget management here or link to a more specific widget management URL that's a little more specific to managing widgets for the Content zone for this item *@ +

@T("Manage content widgets with the {0}.", @Html.ActionLink(T("widget manager").Text, "Index", "Admin", new {area = "Orchard.Widgets"}, null))

+
\ No newline at end of file