Thanks David for pointing to the Active Forum custom solution.
Will seem to have adopted a strategy similar to ours.
However, he came out with a specific rewriting engine with its own reversing http module. And he's not the only one; as most 3rd party rewriting providers hardly account for module specifics, many module developers have started pushing their own rewriting engine.
We believe that this is going in the wrong direction and it could even harm the whole ecosystem while the native rewriter architecture gets increasingly hijacked in favor of custom module-specific solutions : our generic engine comes with an open interface that ease adding friendly urls capabilities to any module out there at no performance cost.
Below is for instance what it takes to implement a dedicated provider for the Dnn Core Forum; It's just about declaring the human readable groups mentioned in my earlier post, and implementing the corresponding computation of those SEO parts. I'm positive a similar provider for Active Forums would require less than 100 lines of code, it would provide all of the features that Will's new "vantity url" engine will bring and the many more, which come with our module.
Our vision is that module developers should stick dealing with real urls, while enabling human urls only requires implementing a similar provider.
Think of it like the IPortable or ISearchable of Url rewriting.
Public Class DnnForumUrlRewriter
Implements IUrlRewriterProvider
Public Function GetModuleRewrites() As List(Of GroupParamsRewrite) Implements IUrlRewriterProvider.GetRewrites
Dim toReturn As New List(Of GroupParamsRewrite)
Dim desc As String = "Name of the current forums' group browsed, filtered accordingly to the general parameters"
toReturn.Add(New GroupParamsRewrite("GroupName", desc, RewriteType.SubPath, UrlParam.FromSyntax("groupid")))
desc = "Name of the current forum browsed, or the current thread's forum, filtered accordingly to the general parameters"
toReturn.Add(New GroupParamsRewrite("ForumName", desc, RewriteType.SubPath, UrlParam.FromSyntax("forumid")))
desc = "Name of the current thread browsed, or the current post's thread, filtered accordingly to the general parameters"
toReturn.Add(New GroupParamsRewrite("ThreadName", desc, RewriteType.SubPath, UrlParam.FromSyntax("threadid")))
Return toReturn
End Function
Public Function RewriteParams(ByVal groupName As String, ByVal objRewriteType As RewriteType, ByVal params As Dictionary(Of UrlParam, String), _
ByVal behaviour As FriendlierUrlStrategy) As GroupRewriteResult Implements IUrlRewriterProvider.RewriteParams
Dim toReturn As New GroupRewriteResult()
Select Case groupName.ToLowerInvariant
Case "groupname"
Dim groupeId As Integer = Integer.Parse(params(UrlParam.FromSyntax("groupid")), CultureInfo.InvariantCulture)
toReturn.RewriteValue = GetGroupName(groupeId, behaviour)
toReturn.ConsumedParameters(UrlParam.FromSyntax("groupid")) = True
Case "forumname"
Dim forumId As Integer = Integer.Parse(params(UrlParam.FromSyntax("forumid")), CultureInfo.InvariantCulture)
toReturn.RewriteValue = GetForumName(forumId, behaviour)
toReturn.ConsumedParameters(UrlParam.FromSyntax("forumid")) = True
Case "threadname"
Dim threadId As Integer = Integer.Parse(params(UrlParam.FromSyntax("threadid")), CultureInfo.InvariantCulture)
toReturn.RewriteValue = GetThreadName(threadId, behaviour)
toReturn.ConsumedParameters(UrlParam.FromSyntax("threadid")) = True
End Select
Return toReturn
End Function
Public Function GetGroupName(ByVal groupeId As Integer, ByVal strategy As FriendlierUrlStrategy) As String
Dim GroupInf As GroupInfo = New GroupController().GroupGet(groupeId)
Dim toReturn As String = String.Empty
If GroupInf IsNot Nothing Then
toReturn = GroupInf.Name
End If
Return strategy.StringEscaper.EscapeString(toReturn)
End Function
Public Function GetForumName(ByVal forumId As Integer, ByVal strategy As FriendlierUrlStrategy) As String
Dim fc As New ForumController
Dim ForumInf As ForumInfo = fc.GetForum(forumId)
Dim toReturn As String = String.Empty
If ForumInf IsNot Nothing Then
toReturn = ForumInf.Name
Else
toReturn = forumId
End If
Return strategy.StringEscaper.EscapeString(toReturn)
End Function
Public Function GetThreadName(ByVal threadId As Integer, ByVal strategy As FriendlierUrlStrategy) As String
Dim tc As New ThreadController
Dim ThreadInf As ThreadInfo = tc.ThreadGet(threadId)
Dim toReturn As String = String.Empty
If ThreadInf IsNot Nothing Then
toReturn = ThreadInf.Subject
End If
Return strategy.StringEscaper.EscapeString(toReturn)
End Function
End Class
|