diff --git a/src/Orchard.Web/Core/Common/Controllers/BodyDriver.cs b/src/Orchard.Web/Core/Common/Controllers/BodyDriver.cs
index 5613793b5..0368c9f46 100644
--- a/src/Orchard.Web/Core/Common/Controllers/BodyDriver.cs
+++ b/src/Orchard.Web/Core/Common/Controllers/BodyDriver.cs
@@ -20,11 +20,12 @@ namespace Orchard.Core.Common.Controllers {
// \/\/ Haackalicious on many accounts - don't copy what has been done here for the wrapper \/\/
protected override DriverResult Display(BodyAspect part, string displayType) {
- var model = new BodyDisplayViewModel { BodyAspect = part, Text = BbcodeReplace(part.Text)};
+ var model = new BodyDisplayViewModel { BodyAspect = part, Text = BbcodeReplace(part.Text) };
+
return Combined(
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/ManageWrapperPre").Location("primary", "5") : null,
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Manage").Location("primary", "5") : null,
- ContentPartTemplate(model, TemplateName, Prefix).Location("primary", "5"),
+ ContentPartTemplate(model, TemplateName, Prefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5"),
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/ManageWrapperPost").Location("primary", "5") : null);
}
diff --git a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.Summary.ascx b/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.Summary.ascx
new file mode 100644
index 000000000..681573b99
--- /dev/null
+++ b/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Body.Summary.ascx
@@ -0,0 +1,9 @@
+<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
+<%@ Import Namespace="Orchard.Core.Common.ViewModels"%>
+<%--//doing excerpt generation on the way out for now so we don't stick ourselves with needing to regen excerpts for existing data
+ //also, doing this here, inline, until we have a pluggable processing model (both in and out)
+ //also, ...this is ugly--%>
+<%=string.Format(
+ "{0} {1}
",
+ Html.Excerpt(Model.Text, 200).ToString().Replace("\r\n", "
\r\n"),
+ Html.ItemDisplayLink(T("[more]").ToString(), Model.BodyAspect.ContentItem)) %>
\ No newline at end of file
diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj
index 663d68b27..54e3401f0 100644
--- a/src/Orchard.Web/Core/Orchard.Core.csproj
+++ b/src/Orchard.Web/Core/Orchard.Core.csproj
@@ -225,6 +225,7 @@
+
diff --git a/src/Orchard/ContentManagement/Drivers/ContentPartTemplateResult.cs b/src/Orchard/ContentManagement/Drivers/ContentPartTemplateResult.cs
index 40017d303..99800ec9d 100644
--- a/src/Orchard/ContentManagement/Drivers/ContentPartTemplateResult.cs
+++ b/src/Orchard/ContentManagement/Drivers/ContentPartTemplateResult.cs
@@ -1,3 +1,4 @@
+using System.Linq;
using Orchard.ContentManagement.Handlers;
namespace Orchard.ContentManagement.Drivers {
@@ -34,5 +35,22 @@ namespace Orchard.ContentManagement.Drivers {
Position = position;
return this;
}
+
+ public ContentPartTemplateResult LongestMatch(string displayType, params string[] knownDisplayTypes) {
+
+ if (string.IsNullOrEmpty(displayType))
+ return this;
+
+ var longest = knownDisplayTypes.Aggregate("", (best, x) => {
+ if (displayType.StartsWith(x) && x.Length > best.Length) return x;
+ return best;
+ });
+
+ if (string.IsNullOrEmpty(longest))
+ return this;
+
+ TemplateName += "." + longest;
+ return this;
+ }
}
}
\ No newline at end of file
diff --git a/src/Orchard/Extensions/StringExtensions.cs b/src/Orchard/Extensions/StringExtensions.cs
new file mode 100644
index 000000000..398530049
--- /dev/null
+++ b/src/Orchard/Extensions/StringExtensions.cs
@@ -0,0 +1,19 @@
+using System.Linq;
+using System.Text.RegularExpressions;
+
+namespace Orchard.Extensions {
+ public static class StringExtensions {
+ public static string Ellipsize(this string text, int characterCount) {
+ return text.Ellipsize(characterCount, " …");
+ }
+
+ public static string Ellipsize(this string text, int characterCount, string ellipsis) {
+ var cleanTailRegex = new Regex(@"\s+\S*$");
+
+ if (string.IsNullOrEmpty(text) || characterCount < 0 || text.Length <= characterCount)
+ return text;
+
+ return cleanTailRegex.Replace(text.Substring(0, characterCount + 1), "") + ellipsis;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs b/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs
index 5880be132..01edf2374 100644
--- a/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs
+++ b/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs
@@ -3,9 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
+using System.Text.RegularExpressions;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;
+using Orchard.Extensions;
using Orchard.Services;
using Orchard.Settings;
using Orchard.Utility;
@@ -88,6 +90,17 @@ namespace Orchard.Mvc.Html {
#endregion
+ #region Excerpt
+
+ public static MvcHtmlString Excerpt(this HtmlHelper html, string markup, int length) {
+ var tagRegex = new Regex("<[^<>]*>", RegexOptions.Singleline);
+ var text = html.Encode(tagRegex.Replace(markup, ""));
+
+ return MvcHtmlString.Create(text.Ellipsize(length));
+ }
+
+ #endregion
+
#region Format Date/Time
public static string DateTimeRelative(this HtmlHelper htmlHelper, DateTime? value, string defaultIfNull) {
diff --git a/src/Orchard/Orchard.csproj b/src/Orchard/Orchard.csproj
index c0ea69e2a..1c9875f90 100644
--- a/src/Orchard/Orchard.csproj
+++ b/src/Orchard/Orchard.csproj
@@ -151,6 +151,7 @@
+