From bc814e566f8d65c4fc6de8c683d72985c3f97415 Mon Sep 17 00:00:00 2001 From: suhacan Date: Wed, 25 Nov 2009 23:20:19 +0000 Subject: [PATCH] - Add route descriptors for the tags module so the front end urls are user-friendly. /Tags will get you the tag cloud, /Tags/ will get you the content items tagged by --HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4042253 --- .../Controllers/HomeController.cs | 2 +- .../Packages/Orchard.Tags/Orchard.Tags.csproj | 1 + .../Packages/Orchard.Tags/Routes.cs | 32 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/Orchard.Web/Packages/Orchard.Tags/Routes.cs diff --git a/src/Orchard.Web/Packages/Orchard.Tags/Controllers/HomeController.cs b/src/Orchard.Web/Packages/Orchard.Tags/Controllers/HomeController.cs index f47c817ec..e4adee318 100644 --- a/src/Orchard.Web/Packages/Orchard.Tags/Controllers/HomeController.cs +++ b/src/Orchard.Web/Packages/Orchard.Tags/Controllers/HomeController.cs @@ -93,7 +93,7 @@ namespace Orchard.Tags.Controllers { } catch (Exception exception) { _notifier.Error(T("Retrieving tagged items failed: " + exception.Message)); - return Index(); + return RedirectToAction("Index"); } } } diff --git a/src/Orchard.Web/Packages/Orchard.Tags/Orchard.Tags.csproj b/src/Orchard.Web/Packages/Orchard.Tags/Orchard.Tags.csproj index 991458989..2c4131362 100644 --- a/src/Orchard.Web/Packages/Orchard.Tags/Orchard.Tags.csproj +++ b/src/Orchard.Web/Packages/Orchard.Tags/Orchard.Tags.csproj @@ -69,6 +69,7 @@ + diff --git a/src/Orchard.Web/Packages/Orchard.Tags/Routes.cs b/src/Orchard.Web/Packages/Orchard.Tags/Routes.cs new file mode 100644 index 000000000..9f0de6bfd --- /dev/null +++ b/src/Orchard.Web/Packages/Orchard.Tags/Routes.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Web.Mvc; +using System.Web.Routing; +using Orchard.Mvc.Routes; + +namespace Orchard.Tags { + public class Routes : IRouteProvider { + public void GetRoutes(ICollection routes) { + foreach (var routeDescriptor in GetRoutes()) + routes.Add(routeDescriptor); + } + + public IEnumerable GetRoutes() { + return new[] { + new RouteDescriptor { Priority = 5, + Route = new Route( + "Tags/{tagName}", + new RouteValueDictionary { + {"area", "Orchard.Tags"}, + {"controller", "Home"}, + {"action", "Search"} + }, + new RouteValueDictionary(), + new RouteValueDictionary { + {"area", "Orchard.Tags"} + }, + new MvcRouteHandler()) + } + }; + } + } +} \ No newline at end of file