From bb143d7236e81e59f520cdd3e576dc4595396c6d Mon Sep 17 00:00:00 2001 From: mahsaro Date: Mon, 3 Aug 2015 12:28:16 +0100 Subject: [PATCH] Fixed format settings. Made IsManaged optional with default value false in IAliasService. --- .../Modules/Orchard.Alias/AdminMenu.cs | 9 +- .../Controllers/AdminController.cs | 26 ++--- .../Modules/Orchard.Alias/IAliasService.cs | 8 +- .../Implementation/AliasRoute.cs | 3 +- .../Implementation/DefaultAliasService.cs | 24 ++-- .../Implementation/Holder/IAliasHolder.cs | 2 +- .../Implementation/Map/AliasMap.cs | 35 +++--- .../Implementation/Storage/AliasStorage.cs | 11 +- .../Updater/AliasHolderUpdater.cs | 4 +- .../Updater/IAliasUpdateCursor.cs | 2 +- .../Modules/Orchard.Alias/Migrations.cs | 5 +- .../Recipes/Builders/AliasStep.cs | 17 ++- .../Recipes/Executors/AliasStep.cs | 23 ++-- .../Modules/Orchard.Alias/Routes.cs | 2 +- .../ViewModels/AdminIndexViewModel.cs | 3 +- .../Orchard.Alias/Views/Admin/Add.cshtml | 44 +++---- .../Orchard.Alias/Views/Admin/Delete.cshtml | 14 +-- .../Orchard.Alias/Views/Admin/Edit.cshtml | 44 +++---- .../Orchard.Alias/Views/Admin/Index.cshtml | 110 +++++++++--------- .../Services/AutorouteService.cs | 3 +- .../Routing/ArchiveConstraint.CS | 9 +- 21 files changed, 189 insertions(+), 209 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Alias/AdminMenu.cs b/src/Orchard.Web/Modules/Orchard.Alias/AdminMenu.cs index 5d524b196..15b1cc5d4 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/AdminMenu.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/AdminMenu.cs @@ -3,17 +3,14 @@ using Orchard.Localization; using Orchard.Security; using Orchard.UI.Navigation; -namespace Orchard.Alias -{ +namespace Orchard.Alias { [OrchardFeature("Orchard.Alias.UI")] - public class AdminMenu : INavigationProvider - { + public class AdminMenu : INavigationProvider { public Localizer T { get; set; } public string MenuName { get { return "admin"; } } - public void GetNavigation(NavigationBuilder builder) - { + public void GetNavigation(NavigationBuilder builder) { builder .Add(T("Aliases"), "4", item => item.Action("Index", "Admin", new { area = "Orchard.Alias" }).Permission(StandardPermissions.SiteOwner)); } diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Alias/Controllers/AdminController.cs index 93ab2feb5..c7aa21242 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Controllers/AdminController.cs @@ -45,7 +45,7 @@ namespace Orchard.Alias.Controllers { if (options == null) options = new AdminIndexOptions(); - + var aliases = _aliasHolder.GetMaps().SelectMany(x => x.GetAliases()); if (!String.IsNullOrWhiteSpace(options.Search)) { @@ -55,8 +55,7 @@ namespace Orchard.Alias.Controllers { aliases = aliases.ToList(); - switch (options.Filter) - { + switch (options.Filter) { case AliasFilter.Managed: aliases = aliases.Where(x => x.IsManaged); break; @@ -111,7 +110,7 @@ namespace Orchard.Alias.Controllers { break; default: throw new ArgumentOutOfRangeException(); - } + } return RedirectToAction("Index"); } @@ -146,9 +145,9 @@ namespace Orchard.Alias.Controllers { } try { - _aliasService.Set(aliasPath, routePath, "Custom",false); + _aliasService.Set(aliasPath, routePath, "Custom", false); } - catch(Exception ex) { + catch (Exception ex) { Services.TransactionManager.Cancel(); Services.Notifier.Error(T("An error occured while creating the alias {0}: {1}. Please check the values are correct.", aliasPath, ex.Message)); Logger.Error(ex, T("An error occured while creating the alias {0}", aliasPath).Text); @@ -210,10 +209,9 @@ namespace Orchard.Alias.Controllers { } try { - _aliasService.Set(aliasPath, routePath, "Custom",false); + _aliasService.Set(aliasPath, routePath, "Custom", false); } - catch (Exception ex) - { + catch (Exception ex) { Services.TransactionManager.Cancel(); Services.Notifier.Error(T("An error occured while editing the alias '{0}': {1}. Please check the values are correct.", aliasPath, ex.Message)); Logger.Error(ex, T("An error occured while creating the alias '{0}'", aliasPath).Text); @@ -251,8 +249,7 @@ namespace Orchard.Alias.Controllers { return this.RedirectLocal(returnUrl, Url.Action("Index")); } - private string GetExistingPathForAlias(string aliasPath) - { + private string GetExistingPathForAlias(string aliasPath) { var routeValues = _aliasService.Get(aliasPath.TrimStart('/', '\\')); if (routeValues == null) return null; @@ -261,8 +258,7 @@ namespace Orchard.Alias.Controllers { .FirstOrDefault(); } - private bool CheckAndWarnIfAliasExists(string aliasPath) - { + private bool CheckAndWarnIfAliasExists(string aliasPath) { var routePath = GetExistingPathForAlias(aliasPath); if (routePath == null) return false; @@ -273,8 +269,8 @@ namespace Orchard.Alias.Controllers { var changeLink = T("change", editUrl); var deleteLink = T("delete", deleteUrl); - Services.Notifier.Error(T("Cannot save alias {0}. It conflicts with existing one pointing to {1}. Please {2} or {3} the existing alias first.", - aliasPath, + Services.Notifier.Error(T("Cannot save alias {0}. It conflicts with existing one pointing to {1}. Please {2} or {3} the existing alias first.", + aliasPath, routePathLink, changeLink, deleteLink)); diff --git a/src/Orchard.Web/Modules/Orchard.Alias/IAliasService.cs b/src/Orchard.Web/Modules/Orchard.Alias/IAliasService.cs index 843f78932..0f433eac6 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/IAliasService.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/IAliasService.cs @@ -5,8 +5,8 @@ using System.Web.Routing; namespace Orchard.Alias { public interface IAliasService : IDependency { RouteValueDictionary Get(string aliasPath); - void Set(string aliasPath, RouteValueDictionary routeValues, string aliasSource, bool isManaged); - void Set(string aliasPath, string routePath, string aliasSource, bool isManaged); + void Set(string aliasPath, RouteValueDictionary routeValues, string aliasSource, bool isManaged = false); + void Set(string aliasPath, string routePath, string aliasSource, bool isManaged = false); void Delete(string aliasPath); void Delete(string aliasPath, string aliasSource); /// @@ -18,8 +18,8 @@ namespace Orchard.Alias { IEnumerable Lookup(RouteValueDictionary routeValues); IEnumerable Lookup(string routePath); - void Replace(string aliasPath, RouteValueDictionary routeValues, string aliasSource, bool isManaged); - void Replace(string aliasPath, string routePath, string aliasSource, bool isManaged); + void Replace(string aliasPath, RouteValueDictionary routeValues, string aliasSource, bool isManaged = false); + void Replace(string aliasPath, string routePath, string aliasSource, bool isManaged = false); IEnumerable> List(); IEnumerable> List(string sourceStartsWith); diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/AliasRoute.cs b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/AliasRoute.cs index b6555e678..2be33d808 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/AliasRoute.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/AliasRoute.cs @@ -32,8 +32,7 @@ namespace Orchard.Alias.Implementation { //IDictionary routeValues; AliasInfo aliasInfo; // TODO: Might as well have the lookup in AliasHolder... - if (_aliasMap.TryGetAlias(virtualPath, out aliasInfo)) - { + if (_aliasMap.TryGetAlias(virtualPath, out aliasInfo)) { // Construct RouteData from the route values var data = new RouteData(this, _routeHandler); foreach (var routeValue in aliasInfo.RouteValues) { diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/DefaultAliasService.cs b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/DefaultAliasService.cs index e373ecbba..23e0043ac 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/DefaultAliasService.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/DefaultAliasService.cs @@ -80,8 +80,7 @@ namespace Orchard.Alias.Implementation { Set(aliasPath, routeValues, aliasSource, isManaged); } - public void Replace(string aliasPath, string routePath, string aliasSource, bool isManaged) - { + public void Replace(string aliasPath, string routePath, string aliasSource, bool isManaged) { Replace(aliasPath, ToDictionary(routePath).ToRouteValueDictionary(), aliasSource, isManaged); } @@ -92,7 +91,7 @@ namespace Orchard.Alias.Implementation { // the route has an area, lookup in the specific alias map var map = _aliasHolder.GetMap(area.ToString()); - + if (map == null) { return Enumerable.Empty(); } @@ -105,7 +104,7 @@ namespace Orchard.Alias.Implementation { return new[] { locate.Item2 }; } - + // no specific area, lookup in all alias maps var result = new List(); foreach (var map in _aliasHolder.GetMaps()) { @@ -118,7 +117,7 @@ namespace Orchard.Alias.Implementation { return result; } - + public IEnumerable> List() { return _aliasStorage.List().Select(item => Tuple.Create(item.Item1, item.Item3.ToRouteValueDictionary())); } @@ -148,21 +147,20 @@ namespace Orchard.Alias.Implementation { private IEnumerable GetRouteDescriptors() { return _routeProviders .SelectMany(routeProvider => { - var routes = new List(); - routeProvider.GetRoutes(routes); - return routes; - }) + var routes = new List(); + routeProvider.GetRoutes(routes); + return routes; + }) .Where(routeDescriptor => !(routeDescriptor.Route is AliasRoute)) .OrderByDescending(routeDescriptor => routeDescriptor.Priority); } private class StubHttpContext : HttpContextBase { - public override HttpRequestBase Request - { - get{return new StubHttpRequest();} + public override HttpRequestBase Request { + get { return new StubHttpRequest(); } } - private class StubHttpRequest : HttpRequestBase {} + private class StubHttpRequest : HttpRequestBase { } } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Holder/IAliasHolder.cs b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Holder/IAliasHolder.cs index cff41f482..f198c978e 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Holder/IAliasHolder.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Holder/IAliasHolder.cs @@ -26,7 +26,7 @@ namespace Orchard.Alias.Implementation.Holder { /// Adds or updates a set of aliases in the tree /// void SetAliases(IEnumerable aliases); - + /// /// Removes an alias from the tree based on its path /// diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Map/AliasMap.cs b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Map/AliasMap.cs index 93eb18635..3667db0b4 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Map/AliasMap.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Map/AliasMap.cs @@ -8,12 +8,12 @@ using System.Collections.Concurrent; namespace Orchard.Alias.Implementation.Map { public class AliasMap { - private readonly string _area; + private readonly string _area; private readonly ConcurrentDictionary _aliases; - private readonly Node _root; + private readonly Node _root; public AliasMap(string area) { - _area = area; + _area = area; _aliases = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); _root = new Node(); } @@ -21,9 +21,8 @@ namespace Orchard.Alias.Implementation.Map { public IEnumerable GetAliases() { return _aliases.Select(x => new AliasInfo { Area = _area, Path = x.Key, RouteValues = x.Value.RouteValues, IsManaged = x.Value.IsManaged }); } - - public bool TryGetAlias(string virtualPath, out AliasInfo aliasInfo) - { + + public bool TryGetAlias(string virtualPath, out AliasInfo aliasInfo) { return _aliases.TryGetValue(virtualPath, out aliasInfo); } @@ -36,7 +35,7 @@ namespace Orchard.Alias.Implementation.Map { /// /// The intance to add public void Insert(AliasInfo info) { - if(info == null) { + if (info == null) { throw new ArgumentNullException(); } _aliases[info.Path] = info; @@ -73,18 +72,18 @@ namespace Orchard.Alias.Implementation.Map { } // Set the path at the end of the tree object takenPath; - focus.Paths.TryRemove(path,out takenPath); + focus.Paths.TryRemove(path, out takenPath); } } private static void ExpandTree(Node root, string path, IDictionary routeValues) { - foreach(var expanded in Expand(routeValues)) { + foreach (var expanded in Expand(routeValues)) { var focus = root; foreach (var routeValue in expanded.OrderBy(kv => kv.Key, StringComparer.InvariantCultureIgnoreCase)) { // See if we already have a stem for this route key (i.e. "controller") and create if not - var stem = focus.Stems.GetOrAdd(routeValue.Key,key=>new ConcurrentDictionary(StringComparer.InvariantCultureIgnoreCase)); + var stem = focus.Stems.GetOrAdd(routeValue.Key, key => new ConcurrentDictionary(StringComparer.InvariantCultureIgnoreCase)); // See if the stem has a node for this value (i.e. "Item") and create if not - var node = stem.GetOrAdd(routeValue.Value, key=>new Node()); + var node = stem.GetOrAdd(routeValue.Value, key => new Node()); // Keep switching to new node until we reach deepest match // TODO: (PH) Thread safety: at this point something could techincally traverse and find an empty node with a blank path ... not fatal // since it will simply not match and therefore return a default-looking route instead of the aliased one. And the changes of that route @@ -111,16 +110,16 @@ namespace Orchard.Alias.Implementation.Map { // For each key/value pair, we want a list containing a single list with either the term, or the term and the "default" value var termSets = ordered.Select(term => { - if (term.Key.EndsWith("-")) { - var termKey = term.Key.Substring(0, term.Key.Length - 1); - return new[] { + if (term.Key.EndsWith("-")) { + var termKey = term.Key.Substring(0, term.Key.Length - 1); + return new[] { // This entry will auto-match in some cases because it was omitted from the route values new [] { new KeyValuePair(termKey, "\u0000") }, new [] { new KeyValuePair(termKey, term.Value) } }; - } - return new[] {new[] {term}}; - }); + } + return new[] { new[] { term } }; + }); // Run each of those lists through an aggregation function, by taking the product of each set, so producting a tree of possibilities var produced = termSets.Aggregate(new[] { empty }.AsEnumerable(), (coords, termSet) => Product(coords, termSet, (coord, term) => coord.Concat(term))); @@ -191,7 +190,7 @@ namespace Orchard.Alias.Implementation.Map { } public ConcurrentDictionary> Stems { get; set; } - public ConcurrentDictionary Paths { get; set; } + public ConcurrentDictionary Paths { get; set; } } } diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Storage/AliasStorage.cs b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Storage/AliasStorage.cs index ae9d37656..e8d8feb1d 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Storage/AliasStorage.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Storage/AliasStorage.cs @@ -110,12 +110,11 @@ namespace Orchard.Alias.Implementation.Storage { // Bulk updates might go wrong if we don't flush. _aliasRepository.Flush(); var dict = ToDictionary(aliasRecord); - _aliasHolder.RemoveAlias(new AliasInfo() { Path = dict.Item1, Area = dict.Item2, RouteValues = dict.Item3, IsManaged = dict.Item6}); + _aliasHolder.RemoveAlias(new AliasInfo() { Path = dict.Item1, Area = dict.Item2, RouteValues = dict.Item3, IsManaged = dict.Item6 }); } } - public IEnumerable, string, int, bool>> List() - { + public IEnumerable, string, int, bool>> List() { return List((Expression>)null); } @@ -129,13 +128,11 @@ namespace Orchard.Alias.Implementation.Storage { return table.OrderBy(a => a.Id).Select(ToDictionary).ToList(); } - public IEnumerable, string, int, bool>> List(string sourceStartsWith) - { + public IEnumerable, string, int, bool>> List(string sourceStartsWith) { return List(a => a.Source.StartsWith(sourceStartsWith)); } - private static Tuple, string, int, bool> ToDictionary(AliasRecord aliasRecord) - { + private static Tuple, string, int, bool> ToDictionary(AliasRecord aliasRecord) { IDictionary routeValues = new Dictionary(); if (aliasRecord.Action.Area != null) { routeValues.Add("area", aliasRecord.Action.Area); diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Updater/AliasHolderUpdater.cs b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Updater/AliasHolderUpdater.cs index 3763aabbe..9a3e03322 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Updater/AliasHolderUpdater.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Updater/AliasHolderUpdater.cs @@ -44,13 +44,13 @@ namespace Orchard.Alias.Implementation.Updater { } public class AliasUpdaterEvent : IOrchardShellEvents { - + private readonly IAliasHolderUpdater _aliasHolderUpdater; public AliasUpdaterEvent(IAliasHolderUpdater aliasHolderUpdater) { _aliasHolderUpdater = aliasHolderUpdater; } - + void IOrchardShellEvents.Activated() { _aliasHolderUpdater.Refresh(); } diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Updater/IAliasUpdateCursor.cs b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Updater/IAliasUpdateCursor.cs index c80d50678..9fa35b2e7 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Updater/IAliasUpdateCursor.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Updater/IAliasUpdateCursor.cs @@ -1,5 +1,5 @@ namespace Orchard.Alias.Implementation.Updater { public interface IAliasUpdateCursor : ISingletonDependency { - int Cursor { get; set; } + int Cursor { get; set; } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Alias/Migrations.cs index f8a222614..563bfa3de 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Migrations.cs @@ -20,11 +20,10 @@ namespace Orchard.Alias { return 1; } - public int UpdateFrom1() - { + public int UpdateFrom1() { SchemaBuilder.AlterTable("AliasRecord", table => table - .AddColumn("IsManaged", column => column.WithDefault(false)) + .AddColumn("IsManaged", column => column.WithDefault(false)) ); return 2; } diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Recipes/Builders/AliasStep.cs b/src/Orchard.Web/Modules/Orchard.Alias/Recipes/Builders/AliasStep.cs index d90ef7bb1..9439a29d7 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Recipes/Builders/AliasStep.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Recipes/Builders/AliasStep.cs @@ -7,12 +7,11 @@ using Orchard.Alias.Records; using Orchard.Alias.Implementation.Holder; namespace Orchard.Roles.Recipes.Builders { - public class RolesStep : RecipeBuilderStep { + public class AliasStep : RecipeBuilderStep { private readonly IRepository _aliasRecordepository; private readonly IAliasHolder _aliasHolder; - public RolesStep(IRepository aliasRecordRepository, IAliasHolder aliasHolder) - { + public AliasStep(IRepository aliasRecordRepository, IAliasHolder aliasHolder) { _aliasRecordepository = aliasRecordRepository; _aliasHolder = aliasHolder; } @@ -30,7 +29,7 @@ namespace Orchard.Roles.Recipes.Builders { } public override void Build(BuildContext context) { - var aliases = _aliasHolder.GetMaps().SelectMany(m => m.GetAliases()).Where(m => m.IsManaged== false).ToList(); + var aliases = _aliasHolder.GetMaps().SelectMany(m => m.GetAliases()).Where(m => m.IsManaged == false).ToList(); if (!aliases.Any()) return; @@ -38,13 +37,11 @@ namespace Orchard.Roles.Recipes.Builders { var root = new XElement("Aliases"); context.RecipeDocument.Element("Orchard").Add(root); - foreach (var alias in aliases.OrderBy(x => x.Path)) - { + foreach (var alias in aliases.OrderBy(x => x.Path)) { var aliasElement = new XElement("Alias", new XAttribute("Path", alias.Path)); - + var routeValuesElement = new XElement("RouteValues"); - foreach (var routeValue in alias.RouteValues) - { + foreach (var routeValue in alias.RouteValues) { routeValuesElement.Add(new XElement("Add", new XAttribute("Key", routeValue.Key), new XAttribute("Value", routeValue.Value))); } @@ -52,6 +49,6 @@ namespace Orchard.Roles.Recipes.Builders { root.Add(aliasElement); } } - + } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Recipes/Executors/AliasStep.cs b/src/Orchard.Web/Modules/Orchard.Alias/Recipes/Executors/AliasStep.cs index 290e40463..1988b1fa3 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Recipes/Executors/AliasStep.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Recipes/Executors/AliasStep.cs @@ -12,8 +12,7 @@ namespace Orchard.Alias.Recipes.Executors { public class AliasStep : RecipeExecutionStep { private readonly IAliasService _aliasService; - public AliasStep(IAliasService aliasService) - { + public AliasStep(IAliasService aliasService) { _aliasService = aliasService; } @@ -31,7 +30,7 @@ namespace Orchard.Alias.Recipes.Executors { */ - public override void Execute(RecipeExecutionContext context) { + public override void Execute(RecipeExecutionContext context) { foreach (var aliasElement in context.RecipeStep.Step.Elements()) { var aliasPath = aliasElement.Attribute("Path").Value; @@ -42,24 +41,22 @@ namespace Orchard.Alias.Recipes.Executors { var routeValuesElement = aliasElement.Descendants("RouteValues").FirstOrDefault(); - if (routeValuesElement != null) - { - foreach (var routeValue in routeValuesElement.Descendants("Add")) - { + if (routeValuesElement != null) { + foreach (var routeValue in routeValuesElement.Descendants("Add")) { rvd.Add(routeValue.Attribute("Key").Value, routeValue.Attribute("Value").Value); } } - + try { - _aliasService.Set(aliasPath, rvd, "Custom", false); - } - + _aliasService.Set(aliasPath, rvd, "Custom", false); + } + catch (Exception ex) { Logger.Error(ex, "Error while processing alias '{0}'.", aliasPath); throw; - } + } } } - } + } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Routes.cs b/src/Orchard.Web/Modules/Orchard.Alias/Routes.cs index f09bcac46..563516d65 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Routes.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Routes.cs @@ -10,7 +10,7 @@ namespace Orchard.Alias { public class Routes : IRouteProvider { private readonly ShellBlueprint _blueprint; private readonly IAliasHolder _aliasHolder; - + public Routes(ShellBlueprint blueprint, IAliasHolder aliasHolder) { _blueprint = blueprint; _aliasHolder = aliasHolder; diff --git a/src/Orchard.Web/Modules/Orchard.Alias/ViewModels/AdminIndexViewModel.cs b/src/Orchard.Web/Modules/Orchard.Alias/ViewModels/AdminIndexViewModel.cs index e0670dee3..e73634766 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/ViewModels/AdminIndexViewModel.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/ViewModels/AdminIndexViewModel.cs @@ -11,8 +11,9 @@ namespace Orchard.Alias.ViewModels { public class AliasEntry { public AliasInfo Alias { get; set; } - public bool IsChecked { get; set; } + public bool IsChecked { get; set; } } + public class AdminIndexOptions { public string Search { get; set; } public AliasOrder Order { get; set; } diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Add.cshtml b/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Add.cshtml index da790c3ad..364e52751 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Add.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Add.cshtml @@ -4,25 +4,25 @@ @using (Html.BeginFormAntiForgeryPost()) { @Html.ValidationSummary() -
- @T("Create Alias") -
- - @Html.TextBox("aliasPath", (object)ViewBag.Path, new { @class = "text large" }) - @Html.ValidationMessage("aliasPath") - @T("The path of the alias e.g., my-blog/my-post") -
-
- - @Html.TextBox("routePath", (object)ViewBag.Route, new { @class = "text medium" }) - @Html.ValidationMessage("routePath") - @T("The actual route Orchard should call when the path is requested e.g., Blogs/Blog/Item?blogId=18") -
-
-
-
- - @Html.ActionLink(T("Cancel").ToString(), "Index", new { }, new { @class = "button" }) -
-
- } \ No newline at end of file +
+ @T("Create Alias") +
+ + @Html.TextBox("aliasPath", (object)ViewBag.Path, new { @class = "text large" }) + @Html.ValidationMessage("aliasPath") + @T("The path of the alias e.g., my-blog/my-post") +
+
+ + @Html.TextBox("routePath", (object)ViewBag.Route, new { @class = "text medium" }) + @Html.ValidationMessage("routePath") + @T("The actual route Orchard should call when the path is requested e.g., Blogs/Blog/Item?blogId=18") +
+
+
+
+ + @Html.ActionLink(T("Cancel").ToString(), "Index", new { }, new { @class = "button" }) +
+
+} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Delete.cshtml b/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Delete.cshtml index bda927365..1c61a71a5 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Delete.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Delete.cshtml @@ -3,11 +3,11 @@ } @using (Html.BeginFormAntiForgeryPost()) { -
- @T("Delete alias") -

@T("Removing alias '{0}'. Are you sure?", ViewBag.Path)

- @Html.Hidden("path") - @Html.Hidden("confirmed", true) - -
+
+ @T("Delete alias") +

@T("Removing alias '{0}'. Are you sure?", ViewBag.Path)

+ @Html.Hidden("path") + @Html.Hidden("confirmed", true) + +
} diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Edit.cshtml b/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Edit.cshtml index 072569b9c..048173003 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Edit.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Edit.cshtml @@ -4,25 +4,25 @@ @using (Html.BeginFormAntiForgeryPost()) { @Html.ValidationSummary() -
- @T("Edit alias") -
- - @Html.TextBox("aliasPath", null, new { @class = "text large" }) - @Html.ValidationMessage("aliasPath") - @T("The path of the alias e.g., my-blog/my-post") -
-
- - @Html.TextBox("routePath", null, new { @class = "text medium" }) - @Html.ValidationMessage("routePath") - @T("The actual route Orchard should call when the path is requested e.g., Blogs/Blog/Item?blogId=18") -
-
-
-
- - @Html.ActionLink(T("Cancel").ToString(), "Index", new { }, new { @class = "button" }) -
-
- } +
+ @T("Edit alias") +
+ + @Html.TextBox("aliasPath", null, new { @class = "text large" }) + @Html.ValidationMessage("aliasPath") + @T("The path of the alias e.g., my-blog/my-post") +
+
+ + @Html.TextBox("routePath", null, new { @class = "text medium" }) + @Html.ValidationMessage("routePath") + @T("The actual route Orchard should call when the path is requested e.g., Blogs/Blog/Item?blogId=18") +
+
+
+
+ + @Html.ActionLink(T("Cancel").ToString(), "Index", new { }, new { @class = "button" }) +
+
+} diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Index.cshtml b/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Index.cshtml index c112c1b97..b2c92d4af 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Index.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Alias/Views/Admin/Index.cshtml @@ -1,5 +1,5 @@ @model AdminIndexViewModel - + @using Orchard.Alias @using Orchard.Alias.ViewModels @using Orchard.Environment.Configuration @@ -7,12 +7,12 @@ @{ var urlPrefix = WorkContext.Resolve().RequestUrlPrefix; - + Layout.Title = T("Manage Aliases").Text; var aliasService = WorkContext.Resolve(); AdminIndexOptions options = Model.Options; int index = -1; - + var pageSizes = new List() { 10, 50, 100 }; var defaultPageSize = WorkContext.CurrentSite.PageSize; if (!pageSizes.Contains(defaultPageSize)) { @@ -33,7 +33,7 @@
- + @@ -43,62 +43,62 @@ @Html.SelectOption(Model.Options.Filter, AliasFilter.Managed, T("Managed").ToString()) @Html.SelectOption(Model.Options.Filter, AliasFilter.Custom, T("Custom").ToString()) - - - + + +
-
+
- - - - - - - - - - @foreach (var aliasEntry in Model.AliasEntries) { - var alias = aliasEntry.Alias; - index++; - var virtualPathData = aliasService.LookupVirtualPaths(alias.RouteValues.ToRouteValueDictionary(), ViewContext.HttpContext).FirstOrDefault(); - - if (virtualPathData == null) { - continue; + + + + + + + + + + @foreach (var aliasEntry in Model.AliasEntries) { + var alias = aliasEntry.Alias; + index++; + var virtualPathData = aliasService.LookupVirtualPaths(alias.RouteValues.ToRouteValueDictionary(), ViewContext.HttpContext).FirstOrDefault(); + + if (virtualPathData == null) { + continue; + } + + var url = virtualPathData.VirtualPath; + + + + + + + } - - var url = virtualPathData.VirtualPath; - - - - - - - - }
@T("Alias")@T("Route")@T("IsManaged") 
@T("Alias")@T("Route")@T("IsManaged") 
+ + + + @Html.Link(alias.Path == String.Empty ? "/" : alias.Path, Href("~/" + urlPrefix + alias.Path)) + + @Html.Link(url, Href("~/" + urlPrefix + "/" + url)) + + + + @if (!alias.IsManaged) { + @Html.ActionLink(T("Edit").Text, "Edit", new { path = alias.Path == String.Empty ? "/" : alias.Path }) + | + @Html.ActionLink(T("Delete").Text, "Delete", new { path = alias.Path }, new { itemprop = "UnsafeUrl RemoveUrl" }) + } +
- - - - @Html.Link(alias.Path == String.Empty ? "/" : alias.Path, Href("~/" + urlPrefix + alias.Path)) - - @Html.Link(url, Href("~/" + urlPrefix + "/" + url)) - - - - @if (!alias.IsManaged) { - @Html.ActionLink(T("Edit").Text, "Edit", new { path = alias.Path == String.Empty ? "/" : alias.Path }) - | - @Html.ActionLink(T("Delete").Text, "Delete", new { path = alias.Path }, new { itemprop = "UnsafeUrl RemoveUrl" }) - } -
- + @Display(Model.Pager)
} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Autoroute/Services/AutorouteService.cs b/src/Orchard.Web/Modules/Orchard.Autoroute/Services/AutorouteService.cs index be917f062..dfedcf80d 100644 --- a/src/Orchard.Web/Modules/Orchard.Autoroute/Services/AutorouteService.cs +++ b/src/Orchard.Web/Modules/Orchard.Autoroute/Services/AutorouteService.cs @@ -146,7 +146,8 @@ namespace Orchard.Autoroute.Services { if (String.Equals(culture, _cultureManager.GetSiteCulture(), StringComparison.OrdinalIgnoreCase) && !String.IsNullOrWhiteSpace(patternIndex)) { settings.DefaultPatterns.Add(new DefaultPattern { PatternIndex = patternIndex, Culture = culture }); return settings.Patterns.Where(x => x.Culture == null).ElementAt(Convert.ToInt32(settings.DefaultPatterns.Where(x => x.Culture == culture).FirstOrDefault().PatternIndex)); - } else { + } + else { settings.DefaultPatterns.Add(new DefaultPattern { PatternIndex = "0", Culture = culture }); return new RoutePattern { Name = "Title", Description = "my-title", Pattern = "{Content.Slug}", Culture = culture }; } diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Routing/ArchiveConstraint.CS b/src/Orchard.Web/Modules/Orchard.Blogs/Routing/ArchiveConstraint.CS index 01bfb6373..a9de1cf0e 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Routing/ArchiveConstraint.CS +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Routing/ArchiveConstraint.CS @@ -39,18 +39,17 @@ namespace Orchard.Blogs.Routing { //IDictionary routeValues; AliasInfo aliasInfo; - if (!_aliasHolder.GetMap("Orchard.Blogs").TryGetAlias(path, out aliasInfo)) - { + if (!_aliasHolder.GetMap("Orchard.Blogs").TryGetAlias(path, out aliasInfo)) { return false; } - var isBlog = + var isBlog = //routeValues.ContainsKey("area") && //routeValues["area"] == "Orchard.Blogs" && aliasInfo.RouteValues.ContainsKey("controller") && aliasInfo.RouteValues["controller"] == "Blog" && aliasInfo.RouteValues.ContainsKey("action") && - aliasInfo.RouteValues["action"] == "Item" + aliasInfo.RouteValues["action"] == "Item" ; return isBlog; @@ -86,7 +85,7 @@ namespace Orchard.Blogs.Routing { } // archive for blog as homepage ? - if(path.StartsWith("archive/", StringComparison.OrdinalIgnoreCase)) { + if (path.StartsWith("archive/", StringComparison.OrdinalIgnoreCase)) { return String.Empty; }