mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Removing autoroute from Orchard.Tags
--HG-- branch : autoroute
This commit is contained in:
@@ -61,8 +61,6 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Projections\TagsFilterForms.cs" />
|
||||
<Compile Include="Providers\TagPatterns.cs" />
|
||||
<Compile Include="Providers\TagTokens.cs" />
|
||||
<Compile Include="ResourceManifest.cs" />
|
||||
<Compile Include="Services\ITagService.cs" />
|
||||
<Compile Include="Services\XmlRpcHandler.cs" />
|
||||
@@ -106,10 +104,6 @@
|
||||
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
|
||||
<Name>Orchard.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Tokens\Orchard.Tokens.csproj">
|
||||
<Project>{6F759635-13D7-4E94-BCC9-80445D63F117}</Project>
|
||||
<Name>Orchard.Tokens</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Placement.info">
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.Tags.Services;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Tags.Models;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Events;
|
||||
|
||||
namespace Orchard.Tags.Providers {
|
||||
|
||||
public interface IRoutePatternProvider : IEventHandler {
|
||||
void Describe(dynamic describe);
|
||||
void Suggest(dynamic suggest);
|
||||
}
|
||||
public class TagPatterns : IRoutePatternProvider {
|
||||
|
||||
private readonly ITagService _tagService;
|
||||
|
||||
public TagPatterns(
|
||||
ITagService tagService
|
||||
) {
|
||||
_tagService = tagService;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public void Describe(dynamic describe) {
|
||||
describe.For<TagRecord>("Tags", T("Tags"), T("Tags url patterns"), (Func<TagRecord, string>)GetId, (Func<string, TagRecord>)GetTag, (Func<TagRecord, IDictionary<string, object>>)GetContext)
|
||||
.Pattern("Tags", T("View all tags"), T("A list of all tags are displayed on this page"), (Func<TagRecord, RouteValueDictionary>)GetTagsRouteValues)
|
||||
.Pattern("View", T("View tagged content"), T("Tagged content will be listed on this Url for each tag"), (Func<TagRecord, RouteValueDictionary>)GetRouteValues);
|
||||
}
|
||||
|
||||
public RouteValueDictionary GetRouteValues(TagRecord tag) {
|
||||
return new RouteValueDictionary(new{
|
||||
area = "Orchard.Tags",
|
||||
controller = "Home",
|
||||
action = "Search",
|
||||
tagName = tag.TagName
|
||||
});
|
||||
}
|
||||
|
||||
public RouteValueDictionary GetTagsRouteValues(TagRecord tag) {
|
||||
return new RouteValueDictionary(new {
|
||||
area = "Orchard.Tags",
|
||||
controller = "Home",
|
||||
action = "Index"
|
||||
});
|
||||
}
|
||||
|
||||
public IDictionary<string,object> GetContext(TagRecord tag) {
|
||||
return new Dictionary<string, object> { { "Tag", tag } };
|
||||
}
|
||||
|
||||
public string GetId(TagRecord tag) {
|
||||
return tag.Id.ToString();
|
||||
}
|
||||
|
||||
public TagRecord GetTag(string id) {
|
||||
return _tagService.GetTag(Convert.ToInt32(id));
|
||||
}
|
||||
|
||||
public void Suggest(dynamic suggest) {
|
||||
suggest.For("Tags")
|
||||
.Suggest("View", "tags/tag-name", "{Tag.Name.Slug}", T("Slugified tag name"))
|
||||
.Suggest("Tags", "tags", "tags", T("Plain /tags url"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.Tokens;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Tags.Models;
|
||||
|
||||
namespace Orchard.Tags.Providers {
|
||||
public class TagTokens : ITokenProvider {
|
||||
|
||||
public TagTokens() {
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
|
||||
}
|
||||
public Localizer T { get; set; }
|
||||
public void Describe(DescribeContext context) {
|
||||
|
||||
context.For("Tag", T("Tags"), T("Tag records"))
|
||||
.Token("Name", T("Tag name"), T("Tag name"), "Text");
|
||||
|
||||
}
|
||||
|
||||
public void Evaluate(EvaluateContext context) {
|
||||
context.For<TagRecord>("Tag")
|
||||
.Token("", t => t.TagName)
|
||||
.Token("Name", t => t.TagName)
|
||||
// By chaining the name to text it can be slugified in Autoroute
|
||||
.Chain("Name", "Text", t => t.TagName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user