55\=============================================================================================================================*/
66using System ;
77using System . Collections . Generic ;
8+ using System . Collections . ObjectModel ;
89using System . Globalization ;
910using System . Linq ;
1011using System . Xml ;
@@ -23,6 +24,22 @@ namespace OnTopic.AspNetCore.Mvc.Controllers {
2324 /// Responds to requests for a sitemap according to sitemap.org's schema. The view is expected to recursively loop over
2425 /// child topics to generate the appropriate markup.
2526 /// </summary>
27+ /// <remarks>
28+ /// <para>
29+ /// By default, some <see cref="Topic"/>s are <i>excluded</i> based on their content types—which includes not only the
30+ /// <see cref="Topic"/>, but also all of its descendents. Other <see cref="Topic"/>s are <i>skipped</i>, also based on
31+ /// their content types; in this case, the <see cref="Topic"/> is excluded, but its descendents are not. What content
32+ /// types are excluded or skipped can be configured, respectively, by modifying the static <see cref="ExcludedContentTypes
33+ /// "/> and <see cref="SkippedContentTypes"/> collections.
34+ /// </i>.
35+ /// </para>
36+ /// <para>
37+ /// The <see cref="Extended(Boolean)"/> action enables an extended sitemap with Google's custom <c>PageMap</c> schema for
38+ /// exposing <see cref="Topic.Attributes"/>, <see cref="Topic.Relationships"/>, and <see cref="Topic.References"/>. By
39+ /// default, some content attributes, such as <c>Body</c>, <c>IsDisabled</c>, and <c>NoIndex</c>, are hidden. This list
40+ /// can be modified by updating the static <see cref="ExcludedAttributes"/> collection.
41+ /// </para>
42+ /// </remarks>
2643 public class SitemapController : Controller {
2744
2845 /*==========================================================================================================================
@@ -37,32 +54,37 @@ public class SitemapController : Controller {
3754 private static readonly XNamespace _pagemapNamespace = "http://www.google.com/schemas/sitemap-pagemap/1.0" ;
3855
3956 /*==========================================================================================================================
40- | EXCLUDE CONTENT TYPES
57+ | EXCLUDED CONTENT TYPES
4158 \-------------------------------------------------------------------------------------------------------------------------*/
4259 /// <summary>
4360 /// Specifies what content types should not be listed in the sitemap, including any descendents.
4461 /// </summary>
45- private static string [ ] ExcludeContentTypes { get ; } = { "List" } ;
62+ public static Collection < string > ExcludedContentTypes { get ; } = new ( ) {
63+ "List"
64+ } ;
4665
4766 /*==========================================================================================================================
4867 | SKIPPED CONTENT TYPES
4968 \-------------------------------------------------------------------------------------------------------------------------*/
5069 /// <summary>
5170 /// Specifies what content types should not be listed in the sitemap—but whose descendents should still be evaluated.
5271 /// </summary>
53- private static string [ ] SkippedContentTypes { get ; } = { "PageGroup" , "Container" } ;
72+ public static Collection < string > SkippedContentTypes { get ; } = new ( ) {
73+ "PageGroup" ,
74+ "Container"
75+ } ;
5476
5577 /*==========================================================================================================================
56- | EXCLUDE ATTRIBUTES
78+ | EXCLUDED ATTRIBUTES
5779 \-------------------------------------------------------------------------------------------------------------------------*/
5880 /// <summary>
5981 /// Specifies what attributes should not be listed in the sitemap.
6082 /// </summary>
61- private static string [ ] ExcludeAttributes { get ; } = {
83+ public static Collection < string > ExcludedAttributes { get ; } = new ( ) {
6284 "Body" ,
6385 "IsDisabled" ,
64- "ParentID" ,
65- "TopicID" ,
86+ "ParentID" , //Legacy, but exposed for avoid leacking legacy data
87+ "TopicID" , //Legacy, but exposed for avoid leacking legacy data
6688 "IsHidden" ,
6789 "NoIndex" ,
6890 "SortOrder"
@@ -178,7 +200,7 @@ private IEnumerable<XElement> AddTopic(Topic topic, bool includeMetadata = false
178200 if ( topic is null ) return topics ;
179201 if ( topic . Attributes . GetBoolean ( "NoIndex" ) ) return topics ;
180202 if ( topic . Attributes . GetBoolean ( "IsDisabled" ) ) return topics ;
181- if ( ExcludeContentTypes . Any ( c => topic . ContentType . Equals ( c , StringComparison . OrdinalIgnoreCase ) ) ) return topics ;
203+ if ( ExcludedContentTypes . Any ( c => topic . ContentType . Equals ( c , StringComparison . OrdinalIgnoreCase ) ) ) return topics ;
182204
183205 /*------------------------------------------------------------------------------------------------------------------------
184206 | Establish variables
@@ -227,7 +249,7 @@ XElement getAttributes() =>
227249 new XText ( topic . ContentType ?? "Page" )
228250 ) ,
229251 from attribute in topic . Attributes
230- where ! ExcludeAttributes . Contains ( attribute . Key , StringComparer . OrdinalIgnoreCase )
252+ where ! ExcludedAttributes . Contains ( attribute . Key , StringComparer . OrdinalIgnoreCase )
231253 where topic . Attributes . GetValue ( attribute . Key ) ? . Length < 256
232254 select new XElement ( _pagemapNamespace + "Attribute" ,
233255 new XAttribute ( "name" , attribute . Key ) ,
0 commit comments