Skip to content

Commit 3530827

Browse files
Merge pull request #6738 from sachatrauwaen/dev-pageservice
Priority-based IPageService for page metadata, head tags, and messages
2 parents f4a5c81 + 57faa11 commit 3530827

File tree

15 files changed

+1110
-32
lines changed

15 files changed

+1110
-32
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information
4+
5+
namespace DotNetNuke.Abstractions.Pages
6+
{
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Text;
10+
11+
/// <summary>
12+
/// Provides services for managing page content with priority-based storage.
13+
/// </summary>
14+
public interface IPageService
15+
{
16+
/// <summary>
17+
/// Set the Page Title.
18+
/// </summary>
19+
/// <param name="value">The title value to set.</param>
20+
/// <param name="priority">The priority of this title (lower number = higher priority).</param>
21+
void SetTitle(string value, int priority = PagePriority.Default);
22+
23+
/// <summary>
24+
/// Set the Page Description.
25+
/// </summary>
26+
/// <param name="value">The description value to set.</param>
27+
/// <param name="priority">The priority of this description (lower number = higher priority).</param>
28+
void SetDescription(string value, int priority = PagePriority.Default);
29+
30+
/// <summary>
31+
/// Set the Page Keywords.
32+
/// </summary>
33+
/// <param name="value">The keywords value to set.</param>
34+
/// <param name="priority">The priority of these keywords (lower number = higher priority).</param>
35+
void SetKeyWords(string value, int priority = PagePriority.Default);
36+
37+
/// <summary>
38+
/// Set the Page Canonical Link URL.
39+
/// </summary>
40+
/// <param name="value">The canonical link URL value to set.</param>
41+
/// <param name="priority">The priority of this canonical link URL (lower number = higher priority).</param>
42+
void SetCanonicalLinkUrl(string value, int priority = PagePriority.Default);
43+
44+
/// <summary>
45+
/// Add a tag to the header of the page.
46+
/// </summary>
47+
/// <param name="tagItem">Priority item containing the tag and priority information.</param>
48+
void AddToHead(PageTag tagItem);
49+
50+
/// <summary>
51+
/// Add a standard meta header tag.
52+
/// </summary>
53+
/// <param name="metaItem">Priority meta item containing the meta tag information and priority.</param>
54+
void AddMeta(PageMeta metaItem);
55+
56+
/// <summary>
57+
/// Add a message to be displayed on the page.
58+
/// </summary>
59+
/// <param name="messageItem">Priority message item containing the message information and priority.</param>
60+
void AddMessage(PageMessage messageItem);
61+
62+
/// <summary>
63+
/// Gets the current title value with highest priority.
64+
/// </summary>
65+
/// <returns>The title value or null if not set.</returns>
66+
string GetTitle();
67+
68+
/// <summary>
69+
/// Gets the current description value with highest priority.
70+
/// </summary>
71+
/// <returns>The description value or null if not set.</returns>
72+
string GetDescription();
73+
74+
/// <summary>
75+
/// Gets the current keywords value with highest priority.
76+
/// </summary>
77+
/// <returns>The keywords value or null if not set.</returns>
78+
string GetKeyWords();
79+
80+
/// <summary>
81+
/// Gets the canonical link URL.
82+
/// </summary>
83+
/// <returns>The canonical link URL or null if not set.</returns>
84+
string GetCanonicalLinkUrl();
85+
86+
/// <summary>
87+
/// Gets all head tags ordered by priority (lowest priority first).
88+
/// </summary>
89+
/// <returns>List of head tags ordered by priority.</returns>
90+
IEnumerable<PageTag> GetHeadTags();
91+
92+
/// <summary>
93+
/// Gets all meta tags ordered by priority (lowest priority first).
94+
/// </summary>
95+
/// <returns>List of meta tags ordered by priority.</returns>
96+
IEnumerable<PageMeta> GetMetaTags();
97+
98+
/// <summary>
99+
/// Gets all messages ordered by priority (lowest priority first).
100+
/// </summary>
101+
/// <returns>List of messages ordered by priority.</returns>
102+
IEnumerable<PageMessage> GetMessages();
103+
104+
/// <summary>
105+
/// Clears all stored page data. Useful for testing or resetting state.
106+
/// </summary>
107+
void Clear();
108+
}
109+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information
4+
5+
namespace DotNetNuke.Abstractions.Pages
6+
{
7+
/// <summary>
8+
/// Represents a message with priority information for display on a page.
9+
/// Messages can include success notifications, warnings, errors, or informational content.
10+
/// </summary>
11+
/// <remarks>
12+
/// This class is used to store messages that will be displayed to users on a page.
13+
/// Priority determines the order in which messages are displayed, with lower numbers having higher priority.
14+
/// Common priority values are defined in <see cref="PagePriority"/>.
15+
/// </remarks>
16+
/// <example>
17+
/// <code>
18+
/// // Create a success message with high priority
19+
/// var successMessage = new PriorityMessage(
20+
/// "Operation Successful",
21+
/// "The data has been saved successfully.",
22+
/// MessageType.Success,
23+
/// "/images/success-icon.png",
24+
/// PagePriority.Site);
25+
///
26+
/// // Create an error message with default priority
27+
/// var errorMessage = new PriorityMessage(
28+
/// "Validation Error",
29+
/// "Please check the required fields.",
30+
/// MessageType.Error,
31+
/// "",
32+
/// PagePriority.Default);
33+
/// </code>
34+
/// </example>
35+
public class PageMessage
36+
{
37+
/// <summary>
38+
/// Initializes a new instance of the <see cref="PageMessage"/> class.
39+
/// </summary>
40+
/// <param name="heading">The heading text for the message.</param>
41+
/// <param name="message">The message text content. Cannot be null or empty.</param>
42+
/// <param name="messageType">The type/severity of the message.</param>
43+
/// <param name="iconSrc">The optional icon source URL for the message. Use empty string if no icon is needed.</param>
44+
/// <param name="priority">The priority of the message. Use values from <see cref="PagePriority"/> for consistency.</param>
45+
public PageMessage(string heading, string message, PageMessageType messageType, string iconSrc, int priority)
46+
{
47+
this.Heading = heading;
48+
this.Message = message;
49+
this.MessageType = messageType;
50+
this.IconSrc = iconSrc;
51+
this.Priority = priority;
52+
}
53+
54+
/// <summary>
55+
/// Gets or sets the heading text for the message.
56+
/// </summary>
57+
/// <value>
58+
/// A string containing the heading text that will be displayed prominently.
59+
/// This should be a concise summary of the message.
60+
/// </value>
61+
public string Heading { get; set; }
62+
63+
/// <summary>
64+
/// Gets or sets the message text content.
65+
/// </summary>
66+
/// <value>
67+
/// A string containing the detailed message content that will be displayed to the user.
68+
/// This can contain HTML markup for formatting.
69+
/// </value>
70+
public string Message { get; set; }
71+
72+
/// <summary>
73+
/// Gets or sets the type/severity of the message.
74+
/// </summary>
75+
/// <value>
76+
/// A <see cref="MessageType"/> value indicating the severity or type of the message.
77+
/// This affects how the message is styled and displayed to the user.
78+
/// </value>
79+
public PageMessageType MessageType { get; set; }
80+
81+
/// <summary>
82+
/// Gets or sets the optional icon source URL for the message.
83+
/// </summary>
84+
/// <value>
85+
/// A string containing the URL or path to an icon image, or an empty string if no icon is needed.
86+
/// The icon will be displayed alongside the message to provide visual context.
87+
/// </value>
88+
public string IconSrc { get; set; }
89+
90+
/// <summary>
91+
/// Gets or sets the priority of the message (lower number = higher priority).
92+
/// </summary>
93+
/// <value>
94+
/// An integer representing the display priority of the message.
95+
/// Messages with lower priority numbers will be displayed before those with higher numbers.
96+
/// Use constants from <see cref="PagePriority"/> for consistent priority values.
97+
/// </value>
98+
public int Priority { get; set; }
99+
}
100+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information
4+
5+
namespace DotNetNuke.Abstractions.Pages
6+
{
7+
/// <summary>
8+
/// Defines the types and severity levels for page messages.
9+
/// Message types determine how messages are styled and presented to users.
10+
/// </summary>
11+
/// <remarks>
12+
/// These enumeration values are used to categorize messages by their purpose and severity.
13+
/// The UI layer typically uses these values to apply appropriate styling, colors, and icons
14+
/// to provide visual context to users about the nature of the message.
15+
/// </remarks>
16+
/// <example>
17+
/// <code>
18+
/// // Success message for completed operations
19+
/// var successMsg = new PageMessage("Operation Complete", "Data saved successfully", MessageType.Success, "", PagePriority.Default);
20+
///
21+
/// // Warning message for potential issues
22+
/// var warningMsg = new PageMessage("Warning", "This action cannot be undone", MessageType.Warning, "", PagePriority.Default);
23+
///
24+
/// // Error message for failed operations
25+
/// var errorMsg = new PageMessage("Error", "Failed to save data", MessageType.Error, "", PagePriority.Default);
26+
///
27+
/// // Informational message for general notifications
28+
/// var infoMsg = new PageMessage("Notice", "System maintenance scheduled", MessageType.Info, "", PagePriority.Default);
29+
/// </code>
30+
/// </example>
31+
public enum PageMessageType
32+
{
33+
/// <summary>
34+
/// Success message type.
35+
/// Used for messages indicating successful completion of operations.
36+
/// Typically displayed with green styling and success icons.
37+
/// </summary>
38+
/// <example>
39+
/// Use for: Data saved, user created, operation completed, etc.
40+
/// </example>
41+
Success = 0,
42+
43+
/// <summary>
44+
/// Warning message type.
45+
/// Used for messages indicating potential issues or important notices that require user attention.
46+
/// Typically displayed with yellow/orange styling and warning icons.
47+
/// </summary>
48+
/// <example>
49+
/// Use for: Validation warnings, deprecation notices, cautionary information, etc.
50+
/// </example>
51+
Warning = 1,
52+
53+
/// <summary>
54+
/// Error message type.
55+
/// Used for messages indicating failed operations or critical issues.
56+
/// Typically displayed with red styling and error icons.
57+
/// </summary>
58+
/// <example>
59+
/// Use for: Validation errors, operation failures, system errors, etc.
60+
/// </example>
61+
Error = 2,
62+
63+
/// <summary>
64+
/// Informational message type.
65+
/// Used for general notifications and informational content.
66+
/// Typically displayed with blue styling and info icons.
67+
/// </summary>
68+
/// <example>
69+
/// Use for: General notifications, tips, system status updates, etc.
70+
/// </example>
71+
Info = 3,
72+
}
73+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information
4+
5+
namespace DotNetNuke.Abstractions.Pages
6+
{
7+
/// <summary>
8+
/// Represents a meta tag with priority information for inclusion in the HTML head section.
9+
/// Meta tags provide metadata about the HTML document and are used by search engines and browsers.
10+
/// </summary>
11+
/// <remarks>
12+
/// This class is used to store meta tag information that will be rendered in the HTML head section.
13+
/// Priority determines the order in which meta tags are rendered, with lower numbers having higher priority.
14+
/// Common priority values are defined in <see cref="PagePriority"/>.
15+
/// </remarks>
16+
/// <example>
17+
/// <code>
18+
/// // Create a description meta tag with page priority
19+
/// var descriptionMeta = new PriorityMeta(
20+
/// "description",
21+
/// "This is the page description for SEO purposes.",
22+
/// PagePriority.Page);
23+
///
24+
/// // Create a keywords meta tag with default priority
25+
/// var keywordsMeta = new PriorityMeta(
26+
/// "keywords",
27+
/// "DNN, CMS, content management",
28+
/// PagePriority.Default);
29+
///
30+
/// // Create a viewport meta tag with site priority
31+
/// var viewportMeta = new PriorityMeta(
32+
/// "viewport",
33+
/// "width=device-width, initial-scale=1.0",
34+
/// PagePriority.Site);
35+
/// </code>
36+
/// </example>
37+
public class PageMeta
38+
{
39+
/// <summary>
40+
/// Initializes a new instance of the <see cref="PageMeta"/> class.
41+
/// </summary>
42+
/// <param name="name">The name attribute of the meta tag. Cannot be null or empty.</param>
43+
/// <param name="content">The content attribute of the meta tag. Cannot be null.</param>
44+
/// <param name="priority">The priority of the meta tag (lower number = higher priority). Use values from <see cref="PagePriority"/> for consistency.</param>
45+
/// <exception cref="System.ArgumentNullException">Thrown when name or content is null.</exception>
46+
/// <exception cref="System.ArgumentException">Thrown when name is empty.</exception>
47+
public PageMeta(string name, string content, int priority)
48+
{
49+
this.Name = name;
50+
this.Content = content;
51+
this.Priority = priority;
52+
}
53+
54+
/// <summary>
55+
/// Gets or sets the name attribute of the meta tag.
56+
/// </summary>
57+
/// <value>
58+
/// A string containing the name attribute value for the meta tag.
59+
/// Common values include "description", "keywords", "author", "viewport", etc.
60+
/// This will be rendered as: &lt;meta name="[Name]" content="[Content]" /&gt;.
61+
/// </value>
62+
public string Name { get; set; }
63+
64+
/// <summary>
65+
/// Gets or sets the content attribute of the meta tag.
66+
/// </summary>
67+
/// <value>
68+
/// A string containing the content attribute value for the meta tag.
69+
/// This contains the actual metadata information associated with the name attribute.
70+
/// The content should be appropriate for the specified name attribute.
71+
/// </value>
72+
public string Content { get; set; }
73+
74+
/// <summary>
75+
/// Gets or sets the priority of the meta tag (lower number = higher priority).
76+
/// </summary>
77+
/// <value>
78+
/// An integer representing the rendering priority of the meta tag in the HTML head section.
79+
/// Meta tags with lower priority numbers will be rendered before those with higher numbers.
80+
/// Use constants from <see cref="PagePriority"/> for consistent priority values.
81+
/// </value>
82+
public int Priority { get; set; }
83+
}
84+
}

0 commit comments

Comments
 (0)