mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
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
This commit is contained in:
@@ -194,6 +194,7 @@ namespace Orchard.Setup.Services {
|
||||
//hackInstallationGenerator.GenerateInstallEvents();
|
||||
|
||||
var contentDefinitionManager = environment.Resolve<IContentDefinitionManager>();
|
||||
//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<BodyPart>().Text = "<p>Welcome to Orchard!</p><p>Congratulations, you've successfully set-up your Orchard site.</p><p>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 <a href=\"Admin/Pages/Edit/3\">Edit</a> to go into edit mode and replace this with whatever you want on your home page to make it your own.</p><p>One thing you could do (but you don't have to) is go into <a href=\"Admin/Settings\">Manage Settings</a> (follow the <a href=\"Admin\">Admin</a> link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.</p><p>You probably want to make the site your own. One of the ways you can do that is by clicking <a href=\"Admin/Themes\">Manage Themes</a> in the admin menu. A theme is a packaged look and feel that affects the whole site.</p><p>Next, you can start playing with the content types that we installed. For example, go ahead and click <a href=\"Admin/Pages/Create\">Add New Page</a> in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to <a href=\"Admin/Navigation\">Manage Menu</a>. You can also click <a href=\"Admin/Blogs/Create\">Add New Blog</a> and start posting by clicking \"Add New Post\".</p><p>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 <a href=\"Admin/Themes\">Manage Themes</a> and clicking <a href=\"Admin/Themes/Install\">Install a new Theme</a>. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please <a href=\"http://www.orchardproject.net/\">consider participating</a>.</p><p>--The Orchard Crew</p>";
|
||||
page.As<RoutePart>().Slug = "home";
|
||||
page.As<RoutePart>().Path = "home";
|
||||
//var page = contentManager.Create("Page", VersionOptions.Draft);
|
||||
//page.As<BodyPart>().Text = "<p>Welcome to Orchard!</p><p>Congratulations, you've successfully set-up your Orchard site.</p><p>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 <a href=\"Admin/Pages/Edit/3\">Edit</a> to go into edit mode and replace this with whatever you want on your home page to make it your own.</p><p>One thing you could do (but you don't have to) is go into <a href=\"Admin/Settings\">Manage Settings</a> (follow the <a href=\"Admin\">Admin</a> link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.</p><p>You probably want to make the site your own. One of the ways you can do that is by clicking <a href=\"Admin/Themes\">Manage Themes</a> in the admin menu. A theme is a packaged look and feel that affects the whole site.</p><p>Next, you can start playing with the content types that we installed. For example, go ahead and click <a href=\"Admin/Pages/Create\">Add New Page</a> in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to <a href=\"Admin/Navigation\">Manage Menu</a>. You can also click <a href=\"Admin/Blogs/Create\">Add New Blog</a> and start posting by clicking \"Add New Post\".</p><p>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 <a href=\"Admin/Themes\">Manage Themes</a> and clicking <a href=\"Admin/Themes/Install\">Install a new Theme</a>. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please <a href=\"http://www.orchardproject.net/\">consider participating</a>.</p><p>--The Orchard Crew</p>";
|
||||
//page.As<RoutePart>().Slug = "home";
|
||||
//page.As<RoutePart>().Path = "home";
|
||||
//page.As<RoutePart>().Title = T("Home").ToString();
|
||||
//page.As<CommonPart>().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<RoutePart>().Title = T("Home").ToString();
|
||||
page.As<CommonPart>().Owner = user;
|
||||
contentManager.Publish(page);
|
||||
siteSettings.Record.HomePage = "RoutableHomePageProvider;" + page.Id;
|
||||
|
||||
|
@@ -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<WidgetBagPart> {
|
||||
private const string TemplateName = "Parts/Widgets.WidgetBagPart";
|
||||
|
||||
protected override DriverResult Editor(WidgetBagPart part) {
|
||||
var location = part.GetLocation("Editor");
|
||||
return ContentPartTemplate("", TemplateName, Prefix).Location(location);
|
||||
}
|
||||
}
|
||||
}
|
@@ -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<string, ContentLocation> {
|
||||
{"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,
|
||||
|
@@ -0,0 +1,5 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Widgets.Models {
|
||||
public class WidgetBagPart : ContentPart {}
|
||||
}
|
@@ -59,11 +59,13 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Drivers\WidgetBagPartDriver.cs" />
|
||||
<Compile Include="Drivers\LayerPartDriver.cs" />
|
||||
<Compile Include="Drivers\WidgetPartDriver.cs" />
|
||||
<Compile Include="Migrations.cs" />
|
||||
<Compile Include="Handlers\LayerPartHandler.cs" />
|
||||
<Compile Include="Handlers\WidgetPartHandler.cs" />
|
||||
<Compile Include="Models\WidgetBagPart.cs" />
|
||||
<Compile Include="Models\LayerPart.cs" />
|
||||
<Compile Include="Models\LayerPartRecord.cs" />
|
||||
<Compile Include="Models\WidgetPart.cs" />
|
||||
@@ -71,12 +73,14 @@
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Filters\WidgetFilter.cs" />
|
||||
<Compile Include="ResourceManifest.cs" />
|
||||
<Compile Include="RuleEngine\AuthenticatedRuleProvider.cs" />
|
||||
<Compile Include="RuleEngine\RuleManager.cs" />
|
||||
<Compile Include="RuleEngine\UrlRuleProvider.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Module.txt" />
|
||||
<Content Include="Styles\admin.css" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
@@ -93,6 +97,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Views\Admin\Index.cshtml" />
|
||||
<None Include="Views\EditorTemplates\Parts\Widgets.WidgetBagPart.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
10
src/Orchard.Web/Modules/Orchard.Widgets/ResourceManifest.cs
Normal file
10
src/Orchard.Web/Modules/Orchard.Widgets/ResourceManifest.cs
Normal file
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
4
src/Orchard.Web/Modules/Orchard.Widgets/Styles/admin.css
Normal file
4
src/Orchard.Web/Modules/Orchard.Widgets/Styles/admin.css
Normal file
@@ -0,0 +1,4 @@
|
||||
.widgetsbag-editor h5 {
|
||||
color:#4c4c4c;
|
||||
font-weight:bold;
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
@{
|
||||
Style.Require("WidgetsAdmin");
|
||||
}
|
||||
<div class="widgetsbag-editor">
|
||||
<h5>@T("Widgets")</h5>
|
||||
@* 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 *@
|
||||
<p>@T("Manage content widgets with the {0}.", @Html.ActionLink(T("widget manager").Text, "Index", "Admin", new {area = "Orchard.Widgets"}, null))</p>
|
||||
</div>
|
Reference in New Issue
Block a user