mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 19:04:51 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -84,6 +84,13 @@ namespace Orchard.Core.Tests.Routable.Services {
|
||||
Assert.That(_routableService.IsSlugValid("some/page"), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DotsAroundSlugAreAllowed() {
|
||||
Assert.That(_routableService.IsSlugValid(".slug"), Is.False);
|
||||
Assert.That(_routableService.IsSlugValid("slug."), Is.False);
|
||||
Assert.That(_routableService.IsSlugValid("slug.slug"), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EmptySlugsShouldBeConsideredValid() {
|
||||
// so that automatic generation on Publish occurs
|
||||
|
@@ -82,8 +82,14 @@ namespace Orchard.Core.Routable.Drivers {
|
||||
part.Title = model.Title;
|
||||
part.Slug = model.Slug;
|
||||
|
||||
if (!_routableService.IsSlugValid(part.Slug)) {
|
||||
updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your slugs: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\". No spaces are allowed (please use dashes or underscores instead)."));
|
||||
if ( !_routableService.IsSlugValid(part.Slug) ) {
|
||||
var slug = (part.Slug ?? String.Empty);
|
||||
if ( slug.StartsWith(".") || slug.EndsWith(".") ) {
|
||||
updater.AddModelError("Routable.Slug", T("The \".\" can't be used around routes."));
|
||||
}
|
||||
else {
|
||||
updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your slugs: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\". No spaces are allowed (please use dashes or underscores instead)."));
|
||||
}
|
||||
}
|
||||
|
||||
string originalSlug = part.Slug;
|
||||
|
@@ -26,6 +26,9 @@ namespace Orchard.Core.Routable.Services {
|
||||
if (slug.Length > 1000)
|
||||
slug = slug.Substring(0, 1000);
|
||||
|
||||
// dots are not allowed at the begin and the end of routes
|
||||
slug = slug.Trim('.');
|
||||
|
||||
model.Slug = slug.ToLowerInvariant();
|
||||
}
|
||||
|
||||
@@ -63,8 +66,7 @@ namespace Orchard.Core.Routable.Services {
|
||||
}
|
||||
|
||||
public bool IsSlugValid(string slug) {
|
||||
// see http://tools.ietf.org/html/rfc3987 for prohibited chars
|
||||
return slug == null || String.IsNullOrEmpty(slug.Trim()) || Regex.IsMatch(slug, @"^[^:?#\[\]@!$&'()*+,;=\s]+$");
|
||||
return String.IsNullOrWhiteSpace(slug) || Regex.IsMatch(slug, @"^[^:?#\[\]@!$&'()*+,;=\s]+$") && !(slug.StartsWith(".") || slug.EndsWith("."));
|
||||
}
|
||||
|
||||
public bool ProcessSlug(RoutePart part) {
|
||||
@@ -80,7 +82,6 @@ namespace Orchard.Core.Routable.Services {
|
||||
// of slugs to consider for conflict detection
|
||||
pathsLikeThis = pathsLikeThis.Where(p => p.ContentItem.Id != part.ContentItem.Id);
|
||||
|
||||
//todo: (heskew) need better messages
|
||||
if (pathsLikeThis.Count() > 0) {
|
||||
var originalSlug = part.Slug;
|
||||
//todo: (heskew) make auto-uniqueness optional
|
||||
|
@@ -43,7 +43,6 @@ namespace Orchard.Blogs.Controllers {
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
public ActionResult Create() {
|
||||
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to create blogs")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
@@ -57,7 +56,6 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
[HttpPost, ActionName("Create")]
|
||||
public ActionResult CreatePOST() {
|
||||
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't create blog")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
@@ -79,7 +77,6 @@ namespace Orchard.Blogs.Controllers {
|
||||
}
|
||||
|
||||
public ActionResult Edit(string blogSlug) {
|
||||
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to edit blog")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
@@ -93,7 +90,6 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
[HttpPost, ActionName("Edit")]
|
||||
public ActionResult EditPOST(string blogSlug) {
|
||||
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't edit blog")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
@@ -112,7 +108,6 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Remove(string blogSlug) {
|
||||
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't delete blog")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
|
@@ -18,21 +18,21 @@ namespace Orchard.Blogs.Handlers {
|
||||
private static void RecalculateBlogArchive(IRepository<BlogPartArchiveRecord> blogArchiveRepository, IRepository<CommonPartRecord> commonRepository, BlogPostPart blogPostPart) {
|
||||
blogArchiveRepository.Flush();
|
||||
|
||||
//INFO: (erikpo) Remove all current blog archive records
|
||||
// remove all current blog archive records
|
||||
var blogArchiveRecords =
|
||||
from bar in blogArchiveRepository.Table
|
||||
where bar.BlogPart == blogPostPart.BlogPart.Record
|
||||
select bar;
|
||||
blogArchiveRecords.ToList().ForEach(blogArchiveRepository.Delete);
|
||||
|
||||
//INFO: (erikpo) Get all blog posts for the current blog
|
||||
// get all blog posts for the current blog
|
||||
var postsQuery =
|
||||
from bpr in commonRepository.Table
|
||||
where bpr.ContentItemRecord.ContentType.Name == "BlogPost" && bpr.Container.Id == blogPostPart.BlogPart.Record.Id
|
||||
orderby bpr.PublishedUtc
|
||||
select bpr;
|
||||
|
||||
//INFO: (erikpo) Create a dictionary of all the year/month combinations and their count of posts that are published in this blog
|
||||
// create a dictionary of all the year/month combinations and their count of posts that are published in this blog
|
||||
var inMemoryBlogArchives = new Dictionary<DateTime, int>(postsQuery.Count());
|
||||
foreach (var post in postsQuery) {
|
||||
if (!post.PublishedUtc.HasValue)
|
||||
@@ -46,7 +46,7 @@ namespace Orchard.Blogs.Handlers {
|
||||
inMemoryBlogArchives[key] = 1;
|
||||
}
|
||||
|
||||
//INFO: (erikpo) Create the new blog archive records based on the in memory values
|
||||
// create the new blog archive records based on the in memory values
|
||||
foreach (KeyValuePair<DateTime, int> item in inMemoryBlogArchives) {
|
||||
blogArchiveRepository.Create(new BlogPartArchiveRecord {BlogPart = blogPostPart.BlogPart.Record, Year = item.Key.Year, Month = item.Key.Month, PostCount = item.Value});
|
||||
}
|
||||
|
@@ -9,7 +9,6 @@ namespace Orchard.Blogs.Models {
|
||||
set { this.As<RoutePart>().Title = value; }
|
||||
}
|
||||
|
||||
//TODO: (erikpo) Need a data type for slug
|
||||
public string Slug {
|
||||
get { return this.As<RoutePart>().Slug; }
|
||||
set { this.As<RoutePart>().Slug = value; }
|
||||
|
@@ -27,7 +27,7 @@ namespace Orchard.ContentTypes.Controllers {
|
||||
#region Types
|
||||
|
||||
public ActionResult List() {
|
||||
return View(new ListContentTypesViewModel {
|
||||
return View("List", new ListContentTypesViewModel {
|
||||
Types = _contentDefinitionService.GetTypes()
|
||||
});
|
||||
}
|
||||
|
@@ -243,9 +243,8 @@
|
||||
<IISUrl>
|
||||
</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<UseCustomServer>True</UseCustomServer>
|
||||
<CustomServerUrl>http://orchard.codeplex.com</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
|
@@ -195,7 +195,6 @@ namespace Orchard.Mvc.Html {
|
||||
return value.HasValue ? htmlHelper.DateTimeRelative(value.Value, T) : defaultIfNull;
|
||||
}
|
||||
|
||||
//TODO: (erikpo) This method needs localized
|
||||
public static LocalizedString DateTimeRelative(this HtmlHelper htmlHelper, DateTime value, Localizer T) {
|
||||
var time = htmlHelper.Resolve<IClock>().UtcNow - value;
|
||||
|
||||
|
Reference in New Issue
Block a user