Added support for rel="canonical" meta.
This commit is contained in:
parent
9d52f36079
commit
78d4d07a73
5 changed files with 37 additions and 9 deletions
|
@ -16,5 +16,5 @@ using System.Reflection;
|
||||||
//
|
//
|
||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("3.0.5.609")]
|
[assembly: AssemblyVersion("3.0.5.610")]
|
||||||
[assembly: AssemblyFileVersion("3.0.5.609")]
|
[assembly: AssemblyFileVersion("3.0.5.610")]
|
|
@ -103,6 +103,24 @@ namespace ScrewTurn.Wiki {
|
||||||
return buffer.ToString();
|
return buffer.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the canonical URL tag for a page.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUrl">The request URL.</param>
|
||||||
|
/// <param name="currentPage">The current page.</param>
|
||||||
|
/// <param name="nspace">The namespace.</param>
|
||||||
|
/// <returns>The canonical URL, or an empty string if <paramref name="requestUrl"/> is already canonical.</returns>
|
||||||
|
public static string GetCanonicalUrlTag(string requestUrl, PageInfo currentPage, NamespaceInfo nspace) {
|
||||||
|
string url = "";
|
||||||
|
if(nspace == null && currentPage.FullName == Settings.DefaultPage) url = Settings.GetMainUrl().ToString();
|
||||||
|
else url = Settings.GetMainUrl() + "/" + currentPage.FullName + Settings.PageExtension;
|
||||||
|
url = url.Replace("//", "/");
|
||||||
|
|
||||||
|
// Case sensitive
|
||||||
|
if(url == requestUrl) return "";
|
||||||
|
else return "<link rel=\"canonical\" href=\"" + url + "\" />";
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts a byte number into a string, formatted using KB, MB or GB.
|
/// Converts a byte number into a string, formatted using KB, MB or GB.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -81,6 +81,12 @@ namespace ScrewTurn.Wiki {
|
||||||
SetupEmailNotification();
|
SetupEmailNotification();
|
||||||
|
|
||||||
SetupPageContent(canPostDiscussion, canManageDiscussion);
|
SetupPageContent(canPostDiscussion, canManageDiscussion);
|
||||||
|
|
||||||
|
if(currentPage != null) {
|
||||||
|
Literal canonical = new Literal();
|
||||||
|
canonical.Text = Tools.GetCanonicalUrlTag(Request.Url.ToString(), currentPage, Pages.FindNamespace(NameTools.GetNamespace(currentPage.FullName)));
|
||||||
|
Page.Header.Controls.Add(canonical);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -39,6 +39,10 @@ namespace ScrewTurn.Wiki {
|
||||||
|
|
||||||
content = Content.GetPageContent(page, true);
|
content = Content.GetPageContent(page, true);
|
||||||
|
|
||||||
|
Literal canonical = new Literal();
|
||||||
|
canonical.Text = Tools.GetCanonicalUrlTag(Request.Url.ToString(), page, Pages.FindNamespace(NameTools.GetNamespace(page.FullName)));
|
||||||
|
Page.Header.Controls.Add(canonical);
|
||||||
|
|
||||||
Page.Title = FormattingPipeline.PrepareTitle(content.Title, false, FormattingContext.PageContent, page) + " - " + Settings.WikiTitle;
|
Page.Title = FormattingPipeline.PrepareTitle(content.Title, false, FormattingContext.PageContent, page) + " - " + Settings.WikiTitle;
|
||||||
|
|
||||||
PrintContent();
|
PrintContent();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue