diff --git a/src/OrchardCoreContrib.ViewCount/Handlers/IViewCountContentHandler.cs b/src/OrchardCoreContrib.ViewCount/Handlers/IViewCountContentHandler.cs index c4b9cd80..9cb75e13 100644 --- a/src/OrchardCoreContrib.ViewCount/Handlers/IViewCountContentHandler.cs +++ b/src/OrchardCoreContrib.ViewCount/Handlers/IViewCountContentHandler.cs @@ -1,8 +1,23 @@ namespace OrchardCoreContrib.ViewCount.Handlers; +/// +/// Defines methods for handling view count events for content. +/// public interface IViewCountContentHandler { + /// + /// Occurs before the content is viewed. + /// + /// The that identifies the content to record the view for. Cannot be + /// null. + /// A that represents the asynchronous operation. Task ViewingAsync(ViewCountContentContext context); + /// + /// Occurs after the content is viewed. + /// + /// The context containing information about the content whose view count should be updated. Must not be + /// null. + /// A that represents the asynchronous operation. Task ViewedAsync(ViewCountContentContext context); } diff --git a/src/OrchardCoreContrib.ViewCount/Handlers/ViewCountContentContext.cs b/src/OrchardCoreContrib.ViewCount/Handlers/ViewCountContentContext.cs index 120f85cc..10d08a45 100644 --- a/src/OrchardCoreContrib.ViewCount/Handlers/ViewCountContentContext.cs +++ b/src/OrchardCoreContrib.ViewCount/Handlers/ViewCountContentContext.cs @@ -3,7 +3,15 @@ namespace OrchardCoreContrib.ViewCount.Handlers; +/// +/// Represents a content context that includes a count of items within a collection. +/// +/// Use to associate a specific item of content with a count value, +/// such as the number of times the content has been viewed or the number of related items. public class ViewCountContentContext(ContentItem contentItem, int count) : ContentContextBase(contentItem) { + /// + /// Gets or sets the number of items contained in the collection. + /// public int Count { get; set; } = count; } diff --git a/src/OrchardCoreContrib.ViewCount/Handlers/ViewCountContentHandlerBase.cs b/src/OrchardCoreContrib.ViewCount/Handlers/ViewCountContentHandlerBase.cs index 2aa807b6..0b274c46 100644 --- a/src/OrchardCoreContrib.ViewCount/Handlers/ViewCountContentHandlerBase.cs +++ b/src/OrchardCoreContrib.ViewCount/Handlers/ViewCountContentHandlerBase.cs @@ -1,8 +1,13 @@ namespace OrchardCoreContrib.ViewCount.Handlers; +/// +/// Provides a base implementation for handling view count events for content items. +/// public abstract class ViewCountContentHandlerBase : IViewCountContentHandler { + /// public virtual Task ViewingAsync(ViewCountContentContext context) => Task.CompletedTask; + /// public virtual Task ViewedAsync(ViewCountContentContext context) => Task.CompletedTask; } diff --git a/src/OrchardCoreContrib.ViewCount/Models/ViewCountPart.cs b/src/OrchardCoreContrib.ViewCount/Models/ViewCountPart.cs index e1cdd4e4..3acdeaa1 100644 --- a/src/OrchardCoreContrib.ViewCount/Models/ViewCountPart.cs +++ b/src/OrchardCoreContrib.ViewCount/Models/ViewCountPart.cs @@ -1,7 +1,16 @@ using OrchardCore.ContentManagement; namespace OrchardCoreContrib.ViewCount.Models; + +/// +/// Represents a content part that tracks the number of times an item has been viewed. +/// +/// Use to associate a view count with content items, enabling features such +/// as analytics or popularity tracking. public class ViewCountPart : ContentPart { + /// + /// Gets or sets the number of items contained in the collection. + /// public int Count { get; set; } } diff --git a/src/OrchardCoreContrib.ViewCount/OrchardCoreContrib.ViewCount.csproj b/src/OrchardCoreContrib.ViewCount/OrchardCoreContrib.ViewCount.csproj index f0967cb3..98c68655 100644 --- a/src/OrchardCoreContrib.ViewCount/OrchardCoreContrib.ViewCount.csproj +++ b/src/OrchardCoreContrib.ViewCount/OrchardCoreContrib.ViewCount.csproj @@ -6,6 +6,7 @@ The Orchard Core Contrib Team Allows to count the content item views. + README.md BSD-3-Clause https://github.com/OrchardCoreContrib/OrchardCoreContrib.Modules/tree/main/src/OrchardCoreContrib.ViewCount/README.md https://github.com/OrchardCoreContrib/OrchardCoreContrib.Modules @@ -26,6 +27,7 @@ + diff --git a/src/OrchardCoreContrib.ViewCount/README.md b/src/OrchardCoreContrib.ViewCount/README.md new file mode 100644 index 00000000..2f9fb724 --- /dev/null +++ b/src/OrchardCoreContrib.ViewCount/README.md @@ -0,0 +1,42 @@ +# View Count Module + +This module provides settings and services to send SMS messages using Azure Communication Service. + +## Version + +1.0.0 + +## Category + +Content Management + +## Dependencies + +| Product | Module | +|-------------|-----------------------------------| +| OrchardCore | Contents (`OrchardCore.Contents`) | + +## Features + +| | | +|------------------|--------------------------------------------| +| **Name** | View Count (`OrchardCoreContrib.ViewCount`)| +| **Description** | Allow you to send SMS via ACS SMS service. | +| **Dependencies** | `OrchardCore.Contents` | + +## NuGet Packages + +| Name | Version | +|---------------------------------------------------------------------------------------------------------|---------| +| [`OrchardCoreContrib.ViewCount`](https://www.nuget.org/packages/OrchardCoreContrib.ViewCount/1.0.0) | 1.0.0 | + +## Get Started + +1. Install the [`OrchardCoreContrib.ViewCount`](https://www.nuget.org/packages/OrchardCoreContrib.ViewCount/) NuGet package to your Orchard Core host project. +2. Go to the admin site +3. Select **Configuration -> Features** menu. +4. Enable the `View Count` feature. +5. Go to the **Contents -> Content Definitions -> Content Types** +6. Edit the content type that you want to track its number of views. +7. Click the `Add Part` button. +8. Choose `View Count` from the list. diff --git a/src/OrchardCoreContrib.ViewCount/Services/IViewCountService.cs b/src/OrchardCoreContrib.ViewCount/Services/IViewCountService.cs index 80ab69d2..c6c97f52 100644 --- a/src/OrchardCoreContrib.ViewCount/Services/IViewCountService.cs +++ b/src/OrchardCoreContrib.ViewCount/Services/IViewCountService.cs @@ -2,9 +2,25 @@ namespace OrchardCoreContrib.ViewCount.Services; +/// +/// Defines methods for retrieving and recording view counts for content items. +/// +/// Implementations of this interface provide functionality to track how many times a content item has +/// been viewed and to record new views. This is typically used for analytics, popularity metrics, or display purposes +/// in content management scenarios. public interface IViewCountService { + /// + /// Returns the total number of views recorded for the specified content item. + /// + /// The content item for which to retrieve the view count. Cannot be null. + /// The number of times the specified content item has been viewed. Returns 0 if no views have been recorded. int GetViewsCount(ContentItem contentItem); + /// + /// Increments the views number for the specified content item asynchronously in the current view context. + /// + /// The content item to be displayed. Cannot be null. + /// A task that represents the asynchronous display operation. Task ViewAsync(ContentItem contentItem); } diff --git a/src/OrchardCoreContrib.ViewCount/Services/ViewCountService.cs b/src/OrchardCoreContrib.ViewCount/Services/ViewCountService.cs index e5ae4750..644891f8 100644 --- a/src/OrchardCoreContrib.ViewCount/Services/ViewCountService.cs +++ b/src/OrchardCoreContrib.ViewCount/Services/ViewCountService.cs @@ -7,11 +7,20 @@ namespace OrchardCoreContrib.ViewCount.Services; +/// +/// Provides functionality for tracking and updating view counts on content items. +/// +/// The enables retrieval and incrementing of view counts for content +/// items. It coordinates with registered instances to allow custom logic to be +/// executed before and after a view is recorded. This service is typically used to monitor content popularity or +/// engagement. +/// public class ViewCountService( IContentManager contentManager, IEnumerable handlers, ILogger logger) : IViewCountService { + /// public int GetViewsCount(ContentItem contentItem) { Guard.ArgumentNotNull(contentItem, nameof(contentItem)); @@ -21,6 +30,7 @@ public int GetViewsCount(ContentItem contentItem) return viewCountPart?.Count ?? 0; } + /// public async Task ViewAsync(ContentItem contentItem) { Guard.ArgumentNotNull(contentItem, nameof(contentItem));