mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
More template work and getting the Blogs module's display in pretty good shape
--HG-- branch : dev
This commit is contained in:
@@ -1,23 +1,13 @@
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Core.Common.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Mvc.Html;
|
||||
|
||||
namespace Orchard.Core.Common.Extensions {
|
||||
public static class HtmlHelperExtensions {
|
||||
public static LocalizedString PublishedStateForModel(this HtmlHelper<CommonMetadataViewModel> htmlHelper, Localizer T) {
|
||||
return htmlHelper.PublishedState(htmlHelper.ViewData.Model, T);
|
||||
public static LocalizedString PublishedState(this HtmlHelper htmlHelper, DateTime? versionPublishedUtc, Localizer T) {
|
||||
return htmlHelper.DateTime(versionPublishedUtc, T("Draft"));
|
||||
}
|
||||
|
||||
public static LocalizedString PublishedState(this HtmlHelper htmlHelper, CommonMetadataViewModel metadata, Localizer T) {
|
||||
return htmlHelper.DateTime(metadata.VersionPublishedUtc, T("Draft"));
|
||||
}
|
||||
|
||||
public static LocalizedString PublishedWhenForModel(this HtmlHelper<CommonMetadataViewModel> htmlHelper, Localizer T) {
|
||||
return htmlHelper.PublishedWhen(htmlHelper.ViewData.Model.VersionPublishedUtc, T);
|
||||
}
|
||||
|
||||
public static LocalizedString PublishedWhen(this HtmlHelper htmlHelper, DateTime? versionPublishedUtc, Localizer T) {
|
||||
return htmlHelper.DateTimeRelative(versionPublishedUtc, T("as a Draft"), T);
|
||||
}
|
||||
|
@@ -1,8 +1,14 @@
|
||||
<Placement>
|
||||
<Place Parts_Common_Metadata="-"/>
|
||||
<Place Parts_Common_Metadata_Summary="-"/>
|
||||
<Place Parts_Common_Metadata_SummaryAdmin="-"/>
|
||||
<!-- available display shapes -->
|
||||
<!--
|
||||
Parts_Common_Metadata
|
||||
Parts_Common_Metadata_Summary
|
||||
Parts_Common_Metadata_SummaryAdmin
|
||||
-->
|
||||
<!-- edit shape just get default placement -->
|
||||
<!-- edit "shape" -->
|
||||
<Place Parts_Common_Body_Edit="Primary:2"/>
|
||||
<!-- default positioning -->
|
||||
<!-- show summary for all DisplayType by default -->
|
||||
<Place Parts_Common_Body_Summary="Content:5"/>
|
||||
<Match DisplayType="Detail">
|
||||
@@ -10,6 +16,9 @@
|
||||
<Place Parts_Common_Body_Summary="-"
|
||||
Parts_Common_Body="Content:5" />
|
||||
</Match>
|
||||
<Match DisplayType="Summary">
|
||||
<Place Parts_Common_Metadata_Summary="Meta:2"/>
|
||||
</Match>
|
||||
<Match DisplayType="SummaryAdmin">
|
||||
<Place Parts_Common_Body_Summary="-"
|
||||
Parts_Common_Metadata_SummaryAdmin="Meta:5"/>
|
||||
|
@@ -0,0 +1,2 @@
|
||||
@using Orchard.Core.Common.Extensions;
|
||||
<div class="published">@Html.PublishedState((DateTime?)Model.ContentPart.VersionPublishedUtc, T)</div>
|
@@ -1,6 +1,2 @@
|
||||
@model Orchard.Core.Common.ViewModels.CommonMetadataViewModel
|
||||
@using Orchard.Core.Common.Extensions;
|
||||
@if (Model.Creator != null) {
|
||||
<div class="metadata">
|
||||
<div class="posted">@T("Published by {0} {1}", Model.Creator.UserName, Html.PublishedWhen(Model, T))</div>
|
||||
</div>}
|
||||
@using Orchard.Core.Common.Extensions;
|
||||
<div class="published">@Html.PublishedState((DateTime?)Model.ContentPart.VersionPublishedUtc, T)</div>
|
@@ -5,7 +5,7 @@
|
||||
<div class="secondary">
|
||||
@Display(Model.Secondary)
|
||||
<fieldset>
|
||||
<input class="button primaryAction" type="submit" name="submit.Save" value="@T("Save")"/>
|
||||
<button class="primaryAction" type="submit" name="submit.Save">@T("Save")</button>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
@@ -1,11 +0,0 @@
|
||||
<div class="sections">
|
||||
<div class="primary">
|
||||
@Display(Model.Primary)
|
||||
</div>
|
||||
<div class="secondary">
|
||||
@Display(Model.Secondary)
|
||||
<fieldset>
|
||||
<input class="button primaryAction" type="submit" name="submit.Save" value="@T("Save")"/>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
@@ -1,3 +0,0 @@
|
||||
content item -> @Model.ContentItem.ContentType
|
||||
|
||||
@Display(Model.Primary)
|
@@ -1,8 +1,21 @@
|
||||
<article>
|
||||
@using Orchard.Utility.Extensions;
|
||||
@{
|
||||
Layout.Title = Model.Title;
|
||||
var contentTypeClassName = ((string)Model.ContentItem.ContentType).HtmlClassify();
|
||||
}
|
||||
<article class="content-item @contentTypeClassName">
|
||||
<header>
|
||||
@Display(Model.Header)
|
||||
@Display(Model.Header)
|
||||
@if (Model.Meta != null) {
|
||||
<div class="metadata">
|
||||
@Display(Model.Meta)
|
||||
</div>
|
||||
}
|
||||
</header>
|
||||
<section>
|
||||
@Display(Model.Content)
|
||||
</section>
|
||||
@Display(Model.Content)
|
||||
@if(Model.Footer != null) {
|
||||
<footer>
|
||||
@Display(Model.Footer)
|
||||
</footer>
|
||||
}
|
||||
</article>
|
@@ -377,8 +377,6 @@
|
||||
<Content Include="ContentsLocation\Views\Web.config" />
|
||||
<Content Include="Messaging\Views\Web.config" />
|
||||
<Content Include="Contents\Views\Items\Content.cshtml" />
|
||||
<Content Include="Contents\Views\Items\Content.Edit.cshtml" />
|
||||
<Content Include="Contents\Views\Items\Content.Summary.cshtml" />
|
||||
<Content Include="Contents\Views\Items\Content.SummaryAdmin.cshtml" />
|
||||
<Content Include="Shapes\Views\Document.cshtml" />
|
||||
<Content Include="Shapes\Views\User.cshtml" />
|
||||
@@ -389,11 +387,13 @@
|
||||
<Content Include="Shapes\Views\Web.config" />
|
||||
<Content Include="Dashboard\Views\Helper\Index.cshtml" />
|
||||
<None Include="Common\Placement.info" />
|
||||
<Content Include="Common\Views\Parts\Common.Metadata.Summary.cshtml" />
|
||||
<None Include="Contents\Placement.info" />
|
||||
<Content Include="Contents\Views\Content.ControlWrapper.cshtml" />
|
||||
<None Include="Localization\Placement.info" />
|
||||
<None Include="PublishLater\Placement.info" />
|
||||
<Content Include="Routable\Views\Parts\RoutableTitle.cshtml" />
|
||||
<None Include="PublishLater\Views\Parts\PublishLater.Metadata.Summary.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
@@ -1,14 +1,14 @@
|
||||
<Placement>
|
||||
<Place Parts_PublishLater_Metadata="-"/>
|
||||
<Place Parts_PublishLater_Metadata_Summary="-"/>
|
||||
<Place Parts_PublishLater_Metadata_SummaryAdmin="-"/>
|
||||
<!-- available display shapes -->
|
||||
<!--
|
||||
Parts_PublishLater_Metadata
|
||||
Parts_PublishLater_Metadata_Summary
|
||||
Parts_PublishLater_Metadata_SummaryAdmin
|
||||
-->
|
||||
<!-- edit shape just get default placement -->
|
||||
<!-- edit "shape" -->
|
||||
<Place Parts_PublishLater_Edit="Secondary:1"/>
|
||||
<Match DisplayType="Detail">
|
||||
<Place Parts_PublishLater_Metadata="Meta:1"/>
|
||||
</Match>
|
||||
<Match DisplayType="Summary">
|
||||
<Place Parts_PublishLater_Metadata_Summary="Meta:1"/>
|
||||
</Match>
|
||||
<!-- default positioning -->
|
||||
<Match DisplayType="SummaryAdmin">
|
||||
<Place Parts_PublishLater_Metadata_SummaryAdmin="Meta:1"/>
|
||||
</Match>
|
||||
|
@@ -45,7 +45,7 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Display(RoutePart part, string displayType, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_RoutableTitle", "Header:5", () => shapeHelper.Parts_RoutableTitle(ContentPart: part, Title: part.Title));
|
||||
return ContentShape("Parts_RoutableTitle", "Header:5", () => shapeHelper.Parts_RoutableTitle(ContentPart: part, Title: part.Title, Path: part.Path));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(RoutePart part, dynamic shapeHelper) {
|
||||
|
@@ -1 +1 @@
|
||||
<h1>@Model.Title</h1>
|
||||
<h1><a href="@Model.Path">@Model.Title</a></h1>
|
@@ -76,10 +76,9 @@ namespace Orchard.Blogs.Controllers {
|
||||
var list = Shape.List();
|
||||
list.AddRange(blogPosts);
|
||||
|
||||
blog.ContentItem = blogPart;
|
||||
blog.Content.Add(Shape.Parts_Blogs_BlogPost_List(ContentItems: list), "5");
|
||||
|
||||
return View("Display", blog);
|
||||
return View(blog);
|
||||
}
|
||||
|
||||
public ActionResult LiveWriterManifest(string blogSlug) {
|
||||
|
@@ -2,7 +2,6 @@
|
||||
using Orchard.Blogs.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.ContentsLocation.Models;
|
||||
|
||||
namespace Orchard.Blogs.Drivers {
|
||||
public class BlogArchivesPartDriver : ContentPartDriver<BlogArchivesPart> {
|
||||
@@ -24,13 +23,13 @@ namespace Orchard.Blogs.Drivers {
|
||||
if (blog == null)
|
||||
return null;
|
||||
|
||||
return shapeHelper.Parts_Blogs_BlogArchives(ContentItem: part, Blog: blog, Archives: _blogPostService.GetArchives(blog));
|
||||
return shapeHelper.Parts_Blogs_BlogArchives(ContentItem: part.ContentItem, Blog: blog, Archives: _blogPostService.GetArchives(blog));
|
||||
}).Location("Content");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BlogArchivesPart part, dynamic shapeHelper) {
|
||||
var location = part.GetLocation("Editor", "Primary", "5");
|
||||
return ContentPartTemplate(part, "Parts/Blogs.BlogArchives").Location(location);
|
||||
return ContentShape("Parts_Blogs_BlogArchives_Editor",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts/Blogs.BlogArchives", Model: part, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(BlogArchivesPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
|
@@ -6,7 +6,6 @@ using Orchard.Blogs.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Feeds;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Localization;
|
||||
|
||||
namespace Orchard.Blogs.Drivers {
|
||||
@@ -41,6 +40,8 @@ namespace Orchard.Blogs.Drivers {
|
||||
() => shapeHelper.Parts_Blogs_Blog_Manage(ContentPart: part)),
|
||||
ContentShape("Parts_Blogs_Blog_Description",
|
||||
() => shapeHelper.Parts_Blogs_Blog_Description(ContentPart: part, Description: part.Description)),
|
||||
ContentShape("Parts_Blogs_Blog_BlogPostCount",
|
||||
() => shapeHelper.Parts_Blogs_Blog_BlogPostCount(ContentPart: part, PostCount: part.PostCount)),
|
||||
// todo: (heskew) implement a paging solution that doesn't require blog posts to be tied to the blog within the controller
|
||||
ContentShape("Parts_Blogs_BlogPost_List",
|
||||
() => {
|
||||
|
@@ -5,7 +5,6 @@ using Orchard.Blogs.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.ContentsLocation.Models;
|
||||
|
||||
namespace Orchard.Blogs.Drivers {
|
||||
public class RecentBlogPostsPartDriver : ContentPartDriver<RecentBlogPostsPart> {
|
||||
@@ -44,12 +43,12 @@ namespace Orchard.Blogs.Drivers {
|
||||
|
||||
var blogPostList = shapeHelper.Parts_Blogs_BlogPost_List(ContentPart: part, ContentItems: list);
|
||||
|
||||
return ContentShape(shapeHelper.Parts_Blogs_RecentBlogPosts(ContentItem: part, ContentItems: blogPostList));
|
||||
return ContentShape(shapeHelper.Parts_Blogs_RecentBlogPosts(ContentItem: part.ContentItem, ContentItems: blogPostList));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(RecentBlogPostsPart part, dynamic shapeHelper) {
|
||||
var location = part.GetLocation("Editor", "Primary", "5");
|
||||
return ContentPartTemplate(part, "Parts/Blogs.RecentBlogPosts").Location(location);
|
||||
return ContentShape("Parts_Blogs_RecentBlogPosts_Editor",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts/Blogs.RecentBlogPosts", Model: part, Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(RecentBlogPostsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
|
@@ -137,10 +137,6 @@
|
||||
<Content Include="Views\Parts\Blogs.BlogPost.List.Admin.cshtml">
|
||||
<SubType>Code</SubType>
|
||||
</Content>
|
||||
<Content Include="Views\Items\Content-Blog.cshtml" />
|
||||
<Content Include="Views\Items\Content-BlogPost.cshtml" />
|
||||
<Content Include="Views\Items\Content-Blog.Summary.cshtml" />
|
||||
<Content Include="Views\Items\Content-BlogPost.Summary.cshtml" />
|
||||
<Content Include="Views\Items\Content-Blog.SummaryAdmin.cshtml" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Views\Web.config" />
|
||||
@@ -165,12 +161,13 @@
|
||||
<Content Include="Views\EditorTemplates\Parts\Blogs.RecentBlogPosts.cshtml" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Blogs.BlogArchives.cshtml" />
|
||||
<Content Include="Views\Items\Content-Blog.DetailAdmin.cshtml" />
|
||||
<Content Include="Views\Items\Content-Blog.Editor.cshtml" />
|
||||
<Content Include="Views\Items\Content-Blog.Edit.cshtml" />
|
||||
<Content Include="Views\Items\Content-BlogPost.Editor.cshtml" />
|
||||
<Content Include="Views\Items\Content-BlogPost.SummaryAdmin.cshtml" />
|
||||
<Content Include="Views\Parts\Blogs.BlogPost.List.cshtml" />
|
||||
<Content Include="Views\Parts\Blogs.Blog.Pager.cshtml" />
|
||||
<Content Include="Views\Parts\Blogs.RecentBlogPosts.cshtml" />
|
||||
<Content Include="Views\Parts\Blogs.Blog.BlogPostCount.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
@@ -3,6 +3,7 @@
|
||||
<!--
|
||||
Parts_Blogs_Blog_Manage
|
||||
Parts_Blogs_Blog_Description
|
||||
Parts_Blogs_Blog_BlogPostCount
|
||||
Parts_Blogs_Blog_Pager
|
||||
Parts_Blogs_BlogPost_List -> when in the blog detail display the blog post list is currently hard-coded to Content:5 to enable the current state of blog paging
|
||||
Parts_Blogs_BlogPost_List_Admin
|
||||
@@ -10,9 +11,12 @@
|
||||
<!-- widget and edit shapes just get default placement -->
|
||||
<!-- edit "shapes" -->
|
||||
<Place Parts_Blogs_Blog_Fields="Primary:2"/>
|
||||
<Place Parts_Blogs_BlogArchives_Editor="Primary:5"/>
|
||||
<Place Parts_Blogs_RecentBlogPosts_Editor="Primary:5"/>
|
||||
<!-- widgets -->
|
||||
<Place Parts_Blogs_BlogArchives="Content"/>
|
||||
<Place Parts_Blogs_RecentBlogPosts="Content"/>
|
||||
<!-- default positioning -->
|
||||
<Match ContentType="Blog">
|
||||
<Match DisplayType="Detail">
|
||||
<!-- blog posts currently added to the blog within the controller into Content:5 <Place Parts_Blogs_BlogPost_List="Content:5" />-->
|
||||
@@ -25,7 +29,8 @@
|
||||
Parts_Blogs_Blog_Description="Manage:after"/>
|
||||
</Match>
|
||||
<Match DisplayType="Summary">
|
||||
<Place Parts_Blogs_Blog_Description="Content:before"/>
|
||||
<Place Parts_Blogs_Blog_Description="Content:before"
|
||||
Parts_Blogs_Blog_BlogPostCount="Meta:3"/>
|
||||
</Match>
|
||||
<Match DisplayType="SummaryAdmin">
|
||||
<Place Parts_Blogs_Blog_Description="Content:before"/>
|
||||
|
@@ -1,2 +1 @@
|
||||
@Display(Model.Meta)
|
||||
@Display(Model.Content)
|
||||
@Display(Model)
|
@@ -1,4 +1 @@
|
||||
@{
|
||||
Html.AddTitleParts((string)Model.Title);
|
||||
}
|
||||
@Display(Model)
|
@@ -0,0 +1,7 @@
|
||||
@using Orchard.Mvc.Html;
|
||||
@{
|
||||
Html.AddTitleParts((string)Model.Title);
|
||||
}
|
||||
@Display(Model.Primary)
|
||||
@Display(Model.Secondary)
|
||||
<fieldset><button class="primaryAction" type="submit">@T("Save")</button></fieldset>
|
@@ -1,6 +0,0 @@
|
||||
@using Orchard.Mvc.Html;
|
||||
@{
|
||||
Html.AddTitleParts((string)Model.Title);
|
||||
}
|
||||
@Display(Model.Primary)
|
||||
<fieldset><input class="button primaryAction" type="submit" value="@T("Add")" /></fieldset>
|
@@ -1,10 +0,0 @@
|
||||
@using Orchard.Blogs.Extensions;
|
||||
@using Orchard.Blogs.Models;
|
||||
<h2>@Html.Link((string)Model.Title, Url.Blog((string)Model.Slug))</h2>
|
||||
<div class="blog metadata">
|
||||
@T.Plural("1 post", "{0} posts", (int)Model.PostCount)
|
||||
@if (Model.Meta != null) {
|
||||
@T(" | ")@Display(Model.Meta)
|
||||
}
|
||||
</div>
|
||||
@Display(Model.Content)
|
@@ -1,3 +0,0 @@
|
||||
<h1>@Html.TitleForPage((string)Model.Title)</h1>
|
||||
@Display(Model.Meta)
|
||||
@Display(Model.Content)
|
@@ -10,7 +10,7 @@
|
||||
<div class="secondary">
|
||||
@Display(Model.Secondary)
|
||||
<fieldset>
|
||||
<input class="button primaryAction" type="submit" name="submit.Save" value="@T("Save")"/>
|
||||
<button class="primaryAction" type="submit" name="submit.Save">@T("Save")</button>
|
||||
@* TODO: (erikpo) In the future, remove the HasPublished check so the user can delete the content item from here if the choose to *@
|
||||
@if (blogPost.HasDraft && blogPost.HasPublished) {
|
||||
@Html.AntiForgeryTokenValueOrchardLink(T("Discard Draft").ToString(), Url.Action("DiscardDraft", new {Area = "Orchard.Blogs", Controller = "BlogPostAdmin", id = Model.Item.Id}), new {@class = "button"})
|
||||
|
@@ -1,8 +0,0 @@
|
||||
@using Orchard.Blogs.Extensions;
|
||||
@using Orchard.Blogs.Models;
|
||||
@using Orchard.Core.Common.Extensions;
|
||||
@using Orchard.Core.Common.Models;
|
||||
@using Orchard.Core.Common.ViewModels;
|
||||
<h2>@Html.Link((string)Model.Title, Url.BlogPost((BlogPostPart)Model.ContentItem.Get(typeof(BlogPostPart))))</h2>
|
||||
<div class="meta">@Html.PublishedState(new CommonMetadataViewModel((CommonPart)Model.ContentItem.Get(typeof(CommonPart))), T) | @Display(Model.Meta)</div>
|
||||
<div class="content">@Display(Model.Content)</div>
|
@@ -1,11 +0,0 @@
|
||||
<article>
|
||||
<header>
|
||||
@Display(Model.Header)
|
||||
<p class="metadata">
|
||||
@Display(Model.Meta)
|
||||
</p>
|
||||
</header>
|
||||
<section>
|
||||
@Display(Model.Content)
|
||||
</section>
|
||||
</article>
|
@@ -0,0 +1 @@
|
||||
<div class="blogpost-count">@T.Plural("1 post", "{0} posts", (int)Model.PostCount)</div>
|
@@ -6,14 +6,8 @@
|
||||
var shapeTable = workContext.Resolve<IShapeTableManager>().GetShapeTable(workContext.CurrentTheme.ThemeName);
|
||||
<!--
|
||||
<ul>
|
||||
@foreach(var descriptor in shapeTable.Descriptors) {
|
||||
<li>@descriptor.Key : @descriptor.Value.BindingSource
|
||||
@if(descriptor.Value.Wrappers.Any()){
|
||||
foreach(var wrapper in descriptor.Value.Wrappers) {
|
||||
@(" +"+wrapper)
|
||||
}
|
||||
}
|
||||
</li>
|
||||
@foreach(var binding in shapeTable.Bindings) {
|
||||
<li>@binding.Key : @binding.Value.BindingSource</li>
|
||||
}
|
||||
</ul>
|
||||
-->
|
||||
|
@@ -29,6 +29,8 @@ namespace Orchard.Utility.Extensions {
|
||||
}
|
||||
|
||||
public static string HtmlClassify(this string text) {
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return text;
|
||||
var friendlier = text.CamelFriendly();
|
||||
return Regex.Replace(friendlier, @"[^a-zA-Z]+", m => m.Index == 0 ? "" : "-").ToLowerInvariant();
|
||||
}
|
||||
|
Reference in New Issue
Block a user