From 8e2f7e974a02d6d93f2c283862b175e836b83edf Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Tue, 12 Oct 2010 23:34:41 -0700 Subject: [PATCH] Changing the default theme to TheThemeMachine, adding some more content widgets @ startup (for lack of a better place ATM - distro or some filler content scheme) and some shape templates --HG-- branch : dev --- src/Orchard.Web/Core/Contents/Shapes.cs | 5 +- src/Orchard.Web/Core/Shapes/Views/Menu.cshtml | 16 ++--- .../Orchard.Setup/Services/SetupService.cs | 38 +++++++++--- .../Orchard.Widgets/Orchard.Widgets.csproj | 2 + .../Modules/Orchard.Widgets/Shapes.cs | 21 +++++++ .../Views/Items/Content-WidgetPage.cshtml | 10 +++ .../Orchard.Widgets/Views/Items_Widget.cshtml | 2 +- src/Orchard.Web/Orchard.Web.csproj | 8 +-- .../TheThemeMachine/Views/AsideThird.cshtml | 14 ----- .../Views/Items_Widget-Content.cshtml | 17 ++++++ .../Views/Items_Widget-HtmlWidget.cshtml | 11 ++++ .../TheThemeMachine/Views/Layout.cshtml | 61 +++++++------------ .../Themes/TheThemeMachine/Views/Menu.cshtml | 10 --- .../TheThemeMachine/Views/MenuItem.cshtml | 22 ------- .../TheThemeMachine/Views/_Document.cshtml | 21 ------- 15 files changed, 125 insertions(+), 133 deletions(-) create mode 100644 src/Orchard.Web/Modules/Orchard.Widgets/Shapes.cs create mode 100644 src/Orchard.Web/Modules/Orchard.Widgets/Views/Items/Content-WidgetPage.cshtml delete mode 100644 src/Orchard.Web/Themes/TheThemeMachine/Views/AsideThird.cshtml create mode 100644 src/Orchard.Web/Themes/TheThemeMachine/Views/Items_Widget-Content.cshtml create mode 100644 src/Orchard.Web/Themes/TheThemeMachine/Views/Items_Widget-HtmlWidget.cshtml delete mode 100644 src/Orchard.Web/Themes/TheThemeMachine/Views/Menu.cshtml delete mode 100644 src/Orchard.Web/Themes/TheThemeMachine/Views/MenuItem.cshtml delete mode 100644 src/Orchard.Web/Themes/TheThemeMachine/Views/_Document.cshtml diff --git a/src/Orchard.Web/Core/Contents/Shapes.cs b/src/Orchard.Web/Core/Contents/Shapes.cs index b492501ea..aeab8e953 100644 --- a/src/Orchard.Web/Core/Contents/Shapes.cs +++ b/src/Orchard.Web/Core/Contents/Shapes.cs @@ -1,8 +1,5 @@ -using System; -using Orchard.ContentManagement; +using Orchard.ContentManagement; using Orchard.DisplayManagement.Descriptors; -using Orchard.DisplayManagement.Implementation; -using Orchard.UI.Zones; namespace Orchard.Core.Contents { public class Shapes : IShapeTableProvider { diff --git a/src/Orchard.Web/Core/Shapes/Views/Menu.cshtml b/src/Orchard.Web/Core/Shapes/Views/Menu.cshtml index d3178883a..b483973cd 100644 --- a/src/Orchard.Web/Core/Shapes/Views/Menu.cshtml +++ b/src/Orchard.Web/Core/Shapes/Views/Menu.cshtml @@ -1,10 +1,10 @@ @{ - // these should move somewhere else - Model.Id = "menu-" + Model.MenuName.ToLower(); - Model.Classes.Add(Model.Id); - Model.Classes.Add("menu"); - var tag = Html.Resolve().Create(Model, "ul"); + // Model is Model.Menu from the layout (Layout.Menu) + var tag = Tag(Model, "ul"); } -@tag.StartElement -@DisplayChildren(Model) -@tag.EndElement + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs index d48162bbb..6cf4faaef 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs @@ -181,7 +181,7 @@ namespace Orchard.Setup.Services { // set site theme var themeService = environment.Resolve(); - themeService.SetSiteTheme("Classic"); + themeService.SetSiteTheme("TheThemeMachine"); // add default culture var cultureManager = environment.Resolve(); @@ -217,19 +217,41 @@ namespace Orchard.Setup.Services { // add a layer for the homepage - var layer = contentManager.Create("Layer"); - layer.As().Name = "TheHomepage"; - layer.As().LayerRule = "url \"~/\""; - contentManager.Publish(layer); - + var homepageLayer = contentManager.Create("Layer"); + homepageLayer.As().Name = "TheHomepage"; + homepageLayer.As().LayerRule = "url \"~/\""; + contentManager.Publish(homepageLayer); + // create an html widget with the homepage layer as its container var htmlWidget = contentManager.Create("HtmlWidget"); - htmlWidget.As().LayerPart = layer.As(); + htmlWidget.As().LayerPart = homepageLayer.As(); htmlWidget.As().Title = T("Welcome to Orchard!").Text; htmlWidget.As().Zone = "Content"; htmlWidget.As().Position = "5"; - htmlWidget.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

"; + htmlWidget.As().Text = "

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

"; contentManager.Publish(htmlWidget); + // and three more for the third aside...really need this elsewhere... + var asideHtmlWidget = contentManager.Create("HtmlWidget"); + asideHtmlWidget.As().LayerPart = homepageLayer.As(); + asideHtmlWidget.As().Title = T("First Leader Aside").Text; + asideHtmlWidget.As().Zone = "AsideThird"; + asideHtmlWidget.As().Position = "4"; + asideHtmlWidget.As().Text = "

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum. Aliquam vel sem nibh. Suspendisse vel condimentum tellus.

"; + contentManager.Publish(asideHtmlWidget); + var asideHtmlWidget1 = contentManager.Create("HtmlWidget"); + asideHtmlWidget1.As().LayerPart = homepageLayer.As(); + asideHtmlWidget1.As().Title = T("Second Leader Aside").Text; + asideHtmlWidget1.As().Zone = "AsideThird"; + asideHtmlWidget1.As().Position = "5"; + asideHtmlWidget1.As().Text = "

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum. Aliquam vel sem nibh. Suspendisse vel condimentum tellus.

"; + contentManager.Publish(asideHtmlWidget1); + var asideHtmlWidget2 = contentManager.Create("HtmlWidget"); + asideHtmlWidget2.As().LayerPart = homepageLayer.As(); + asideHtmlWidget2.As().Title = T("Third Leader Aside").Text; + asideHtmlWidget2.As().Zone = "AsideThird"; + asideHtmlWidget2.As().Position = "6"; + asideHtmlWidget2.As().Text = "

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum. Aliquam vel sem nibh. Suspendisse vel condimentum tellus.

"; + contentManager.Publish(asideHtmlWidget2); // create the home page as a WidgetPage var page = contentManager.Create("WidgetPage", VersionOptions.Draft); diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj b/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj index 7ee68d518..37ab03bb7 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Orchard.Widgets.csproj @@ -85,6 +85,7 @@ + @@ -118,6 +119,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Shapes.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Shapes.cs new file mode 100644 index 000000000..0a52c4f72 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Shapes.cs @@ -0,0 +1,21 @@ +using Orchard.ContentManagement; +using Orchard.DisplayManagement.Descriptors; +using Orchard.Widgets.Models; + +namespace Orchard.Widgets { + public class Shapes : IShapeTableProvider { + public void Discover(ShapeTableBuilder builder) { + builder.Describe("Items_Widget") + .OnDisplaying(displaying => { + ContentItem contentItem = displaying.Shape.ContentItem; + if (contentItem != null) { + var zoneName = contentItem.As().Zone; + displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + contentItem.ContentType); + displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + zoneName); + //...would like... + //displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + zoneName + "__" + contentItem.ContentType); + } + }); + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Views/Items/Content-WidgetPage.cshtml b/src/Orchard.Web/Modules/Orchard.Widgets/Views/Items/Content-WidgetPage.cshtml new file mode 100644 index 000000000..237d9471c --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Views/Items/Content-WidgetPage.cshtml @@ -0,0 +1,10 @@ +@if(Model.Content != null) { +
+ @if(Model.Header != null) { +
+ @Display(Model.Header) +
+ } + @Display(Model.Content) +
+} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Views/Items_Widget.cshtml b/src/Orchard.Web/Modules/Orchard.Widgets/Views/Items_Widget.cshtml index 5480ffce7..05001230b 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Views/Items_Widget.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Views/Items_Widget.cshtml @@ -1,2 +1,2 @@ @Display(Model.Header) -@Display(Model.Content) +@Display(Model.Content) \ No newline at end of file diff --git a/src/Orchard.Web/Orchard.Web.csproj b/src/Orchard.Web/Orchard.Web.csproj index 918590dc8..dd352827b 100644 --- a/src/Orchard.Web/Orchard.Web.csproj +++ b/src/Orchard.Web/Orchard.Web.csproj @@ -141,12 +141,10 @@ - - + Designer - @@ -317,10 +315,8 @@ + - - Designer - diff --git a/src/Orchard.Web/Themes/TheThemeMachine/Views/AsideThird.cshtml b/src/Orchard.Web/Themes/TheThemeMachine/Views/AsideThird.cshtml deleted file mode 100644 index 41d6d75d9..000000000 --- a/src/Orchard.Web/Themes/TheThemeMachine/Views/AsideThird.cshtml +++ /dev/null @@ -1,14 +0,0 @@ -
-

First Leader Aside

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum. Aliquam vel sem nibh. Suspendisse vel condimentum tellus.

-
- -
-

Second Leader Aside

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum. Aliquam vel sem nibh. Suspendisse vel condimentum tellus.

-
- -
-

Third Leader Aside

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum. Aliquam vel sem nibh. Suspendisse vel condimentum tellus.

-
diff --git a/src/Orchard.Web/Themes/TheThemeMachine/Views/Items_Widget-Content.cshtml b/src/Orchard.Web/Themes/TheThemeMachine/Views/Items_Widget-Content.cshtml new file mode 100644 index 000000000..052f312f7 --- /dev/null +++ b/src/Orchard.Web/Themes/TheThemeMachine/Views/Items_Widget-Content.cshtml @@ -0,0 +1,17 @@ +@using Orchard.ContentManagement; +@using Orchard.Widgets.Models; +@{ + var title = ((IContent)Model.ContentItem).As().Title; +} +
+
+

@title

+ @Display(Model.Header) +
+ @Display(Model.Content) + @if(Model.Footer != null) { +
+ @Display(Model.Footer) +
+ } +
\ No newline at end of file diff --git a/src/Orchard.Web/Themes/TheThemeMachine/Views/Items_Widget-HtmlWidget.cshtml b/src/Orchard.Web/Themes/TheThemeMachine/Views/Items_Widget-HtmlWidget.cshtml new file mode 100644 index 000000000..92878ff06 --- /dev/null +++ b/src/Orchard.Web/Themes/TheThemeMachine/Views/Items_Widget-HtmlWidget.cshtml @@ -0,0 +1,11 @@ +@using Orchard.ContentManagement; +@using Orchard.Widgets.Models; +@{ + var title = ((IContent)Model.ContentItem).As().Title; +} +
+

@title

+ @Display(Model.Header) + @Display(Model.Content) + @Display(Model.Footer) +
\ No newline at end of file diff --git a/src/Orchard.Web/Themes/TheThemeMachine/Views/Layout.cshtml b/src/Orchard.Web/Themes/TheThemeMachine/Views/Layout.cshtml index 57783dcc7..ffb08877d 100644 --- a/src/Orchard.Web/Themes/TheThemeMachine/Views/Layout.cshtml +++ b/src/Orchard.Web/Themes/TheThemeMachine/Views/Layout.cshtml @@ -43,71 +43,54 @@ @using(Capture(branding => WorkContext.Layout.Header.Add(branding) )) {

@WorkContext.CurrentSite.SiteName

} - -
- @if(Model.Header != null) { - - } -
- - - @if(Model.Navigation != null) { - - } - - +@if(Model.Header != null) { +
+ +
+} +@if(Model.Navigation != null) { + +}
@if(Model.Messages != null) {
@Zone(Model.Messages)
} - @if(Model.AsideSecond != null) { } - @* the model content for the page is in the Content zone @ the default position (nothing, zero, zilch) *@ @if(Model.Content != null) {
@Zone(Model.Content)
} - - @if(Model.AsideFirst != null) { - -@* Create a zone and only show it on the home page. *@ - -@if (Request.Path == "/OrchardLocal") { -WorkContext.Layout.AsideThird.Add(New.AsideThird()); - } + } @if(Model.AsideThird != null) { } -
- - @if(Model.Footer != null) { -
- @Zone(Model.Footer) -
- } - else { -
- Powered by Orchard © The Theme Machine 2010. @Display.User() -
+@* span -> p (?) *@ +@using(Capture(pbo => WorkContext.Layout.Footer.Add(pbo) )) { + Powered by Orchard © The Theme Machine 2010. +} +@if(Model.Footer != null) { +
+ @Zone(Model.Footer) + @Display.User() +
} - @tag.EndElement \ No newline at end of file diff --git a/src/Orchard.Web/Themes/TheThemeMachine/Views/Menu.cshtml b/src/Orchard.Web/Themes/TheThemeMachine/Views/Menu.cshtml deleted file mode 100644 index b483973cd..000000000 --- a/src/Orchard.Web/Themes/TheThemeMachine/Views/Menu.cshtml +++ /dev/null @@ -1,10 +0,0 @@ -@{ - // Model is Model.Menu from the layout (Layout.Menu) - var tag = Tag(Model, "ul"); -} - \ No newline at end of file diff --git a/src/Orchard.Web/Themes/TheThemeMachine/Views/MenuItem.cshtml b/src/Orchard.Web/Themes/TheThemeMachine/Views/MenuItem.cshtml deleted file mode 100644 index 7b96d871d..000000000 --- a/src/Orchard.Web/Themes/TheThemeMachine/Views/MenuItem.cshtml +++ /dev/null @@ -1,22 +0,0 @@ -@{ - // odd formatting in this file is to cause more attractive results in the output. - var items = (IEnumerable)Enumerable.Cast(Model); -} -@{ -if (!HasText(Model.Text)) { - @DisplayChildren(Model) -} else { - if (Model.Href.TrimEnd('/').ToUpperInvariant() == Request.Path.TrimEnd('/').ToUpperInvariant()) { - Model.Classes.Add("current"); - } - var tag = Tag(Model, "li"); - @tag.StartElement - @Model.Text - if (items.Any()) { -
    - @DisplayChildren(Model) -
- } - @tag.EndElement - } -} \ No newline at end of file diff --git a/src/Orchard.Web/Themes/TheThemeMachine/Views/_Document.cshtml b/src/Orchard.Web/Themes/TheThemeMachine/Views/_Document.cshtml deleted file mode 100644 index bbef65ac1..000000000 --- a/src/Orchard.Web/Themes/TheThemeMachine/Views/_Document.cshtml +++ /dev/null @@ -1,21 +0,0 @@ -@using Orchard.Mvc.Html; -@using Orchard.UI.Resources; -@{ - RegisterLink(new LinkEntry {Type = "image/x-icon", Rel = "shortcut icon", Href = Url.Content("~/modules/orchard.themes/Content/orchard.ico")}); - //todo: (heskew) get conditions (as in conditional comments) hooked up for script tags too - Script.Include("html5.js").AtLocation(ResourceLocation.Head); -} - - - - - @Model.Title - @Display(Model.Head) - - - -@* Layout (template) is in the Body zone @ the default position (nothing, zero, zilch) *@ -@Display(Model.Body) -@Display(Model.Tail) - - \ No newline at end of file