mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Adding blog/archive route
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Blogs.Extensions;
|
||||
@@ -7,6 +8,7 @@ using Orchard.Blogs.Services;
|
||||
using Orchard.Core.Feeds;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Themes;
|
||||
|
||||
namespace Orchard.Blogs.Controllers {
|
||||
@@ -49,10 +51,15 @@ namespace Orchard.Blogs.Controllers {
|
||||
return HttpNotFound();
|
||||
|
||||
BlogPart blogPart = _blogService.Get(blogPath);
|
||||
|
||||
if (blogPart == null)
|
||||
return HttpNotFound();
|
||||
|
||||
|
||||
if (archive.ToDateTime() == DateTime.MinValue) {
|
||||
// render the archive data
|
||||
return new ShapeResult(this, Shape.Parts_Blogs_BlogArchives(Blog: blogPart, Archives: _blogPostService.GetArchives(blogPart)));
|
||||
}
|
||||
|
||||
var list = Shape.List();
|
||||
list.AddRange(_blogPostService.Get(blogPart, archive).Select(b => _services.ContentManager.BuildDisplay(b, "Summary")));
|
||||
|
||||
|
||||
@@ -46,10 +46,31 @@ namespace Orchard.Blogs.Routing {
|
||||
}
|
||||
|
||||
public string FindPath(string path) {
|
||||
// my-blog/archive
|
||||
if (path.EndsWith("/archive")) {
|
||||
return path.Substring(0, path.Length - "/archive".Length);
|
||||
}
|
||||
|
||||
// my-blog/archive/
|
||||
if (path.EndsWith("/archive/")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// my-blog/archive/2014
|
||||
var archiveIndex = path.IndexOf("/archive/", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (archiveIndex == -1) {
|
||||
|
||||
|
||||
// archive/
|
||||
if (path.EndsWith("archive/")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// archive
|
||||
if (path.EndsWith("archive")) {
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
// archive for blog as homepage ?
|
||||
if(path.StartsWith("archive/", StringComparison.OrdinalIgnoreCase)) {
|
||||
return String.Empty;
|
||||
@@ -62,10 +83,30 @@ namespace Orchard.Blogs.Routing {
|
||||
}
|
||||
|
||||
public ArchiveData FindArchiveData(string path) {
|
||||
// my-blog/archive
|
||||
if (path.EndsWith("/archive")) {
|
||||
return new ArchiveData("");
|
||||
}
|
||||
|
||||
// my-blog/archive/
|
||||
if (path.EndsWith("/archive/")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var archiveIndex = path.IndexOf("/archive/", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (archiveIndex == -1) {
|
||||
|
||||
|
||||
// archive/
|
||||
if (path.EndsWith("archive/")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// archive
|
||||
if (path.EndsWith("archive")) {
|
||||
return new ArchiveData("");
|
||||
}
|
||||
|
||||
// archive for blog as homepage ?
|
||||
if (path.StartsWith("archive/", StringComparison.OrdinalIgnoreCase)) {
|
||||
return new ArchiveData(path.Substring("archive/".Length));
|
||||
|
||||
Reference in New Issue
Block a user