Added support for XML sitemaps.
This commit is contained in:
parent
ab22f73cbb
commit
5722ba895a
5 changed files with 85 additions and 2 deletions
|
@ -16,5 +16,5 @@ using System.Reflection;
|
|||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("3.0.1.404")]
|
||||
[assembly: AssemblyFileVersion("3.0.1.404")]
|
||||
[assembly: AssemblyVersion("3.0.1.405")]
|
||||
[assembly: AssemblyFileVersion("3.0.1.405")]
|
||||
|
|
1
WebApplication/Sitemap.aspx
Normal file
1
WebApplication/Sitemap.aspx
Normal file
|
@ -0,0 +1 @@
|
|||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Sitemap.aspx.cs" Inherits="ScrewTurn.Wiki.Sitemap" %>
|
58
WebApplication/Sitemap.aspx.cs
Normal file
58
WebApplication/Sitemap.aspx.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Xml;
|
||||
using ScrewTurn.Wiki.PluginFramework;
|
||||
|
||||
namespace ScrewTurn.Wiki {
|
||||
|
||||
public partial class Sitemap : System.Web.UI.Page {
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e) {
|
||||
Response.ClearContent();
|
||||
Response.ContentType = "text/xml;charset=UTF-8";
|
||||
Response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
|
||||
|
||||
string mainUrl = Settings.MainUrl;
|
||||
|
||||
using(XmlWriter writer = XmlWriter.Create(Response.OutputStream)) {
|
||||
writer.WriteStartDocument();
|
||||
|
||||
writer.WriteStartElement("urlset");
|
||||
writer.WriteAttributeString("schemaLocation", "xsi", "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/09/sitemap.xsd");
|
||||
|
||||
foreach(PageInfo page in Pages.GetPages(null)) {
|
||||
WritePage(mainUrl, page, writer);
|
||||
}
|
||||
foreach(NamespaceInfo nspace in Pages.GetNamespaces()) {
|
||||
foreach(PageInfo page in Pages.GetPages(nspace)) {
|
||||
WritePage(mainUrl, page, writer);
|
||||
}
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
writer.WriteEndDocument();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a page to the output XML writer.
|
||||
/// </summary>
|
||||
/// <param name="mainUrl">The main wiki URL.</param>
|
||||
/// <param name="page">The page.</param>
|
||||
/// <param name="writer">The writer.</param>
|
||||
private void WritePage(string mainUrl, PageInfo page, XmlWriter writer) {
|
||||
writer.WriteStartElement("url");
|
||||
writer.WriteElementString("loc", mainUrl + Tools.UrlEncode(page.FullName) + Settings.PageExtension);
|
||||
writer.WriteElementString("priority", "0.5");
|
||||
writer.WriteElementString("changefreq", "daily");
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
16
WebApplication/Sitemap.aspx.designer.cs
generated
Normal file
16
WebApplication/Sitemap.aspx.designer.cs
generated
Normal file
|
@ -0,0 +1,16 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.4927
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ScrewTurn.Wiki {
|
||||
|
||||
|
||||
public partial class Sitemap {
|
||||
}
|
||||
}
|
|
@ -581,6 +581,13 @@
|
|||
<Compile Include="SessionRefresh.aspx.designer.cs">
|
||||
<DependentUpon>SessionRefresh.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Sitemap.aspx.cs">
|
||||
<DependentUpon>Sitemap.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Sitemap.aspx.designer.cs">
|
||||
<DependentUpon>Sitemap.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Thumb.aspx.cs">
|
||||
<DependentUpon>Thumb.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
|
@ -2363,6 +2370,7 @@
|
|||
<Content Include="Images\Editor\UL.png" />
|
||||
<Content Include="JS\SearchHighlight.js" />
|
||||
<Content Include="PageListBuilder.ascx" />
|
||||
<Content Include="Sitemap.aspx" />
|
||||
<Content Include="Themes\Default-v2\Icon.ico" />
|
||||
<Content Include="Themes\Default-v2\Images\Attachment.png" />
|
||||
<Content Include="Themes\Default-v2\Images\Background.gif" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue