Skip to content

Commit c3d16a1

Browse files
committed
+changelog-ignore: initial commit
0 parents  commit c3d16a1

File tree

83 files changed

+10237
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+10237
-0
lines changed

.github/CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Contributing Guidelines
2+
3+
Contributions to this package are most welcome!
4+
5+
There is a test site in the solution to make working with this repository easier.

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: "Bug report"
2+
description: "File a bug report to help improve this package."
3+
labels: "bug"
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Thanks for taking the time to report this issue as thoroughly as possible.
9+
- type: input
10+
id: "PackageVersion"
11+
attributes:
12+
label: "Which jcdcdev.Umbraco.ReadingTime version are you using?"
13+
description: "Leave blank if you're not sure: the latest version will be assumed."
14+
validations:
15+
required: false
16+
- type: input
17+
id: "umbracoVersion"
18+
attributes:
19+
label: "Which Umbraco version are you using? For example: 10.4.0 - don't just write v10"
20+
description: "Use the help icon in the Umbraco backoffice to find the version you're using."
21+
validations:
22+
required: true
23+
- type: textarea
24+
id: "summary"
25+
attributes:
26+
label: "Bug summary"
27+
description: "Write a summary of the bug. Remember that you can format code and logs nicely with the `<>` button"
28+
placeholder: >
29+
Try to pinpoint it as much as possible.
30+
31+
Try to state the actual problem, and not just what you think the solution might be.
32+
validations:
33+
required: true
34+
- type: textarea
35+
attributes:
36+
label: "Steps to reproduce"
37+
id: "reproduction"
38+
description: "How can we reproduce the problem on a clean AdminOnlyPackage + Umbraco install?"
39+
placeholder: >
40+
Please include any links, screenshots, stack-traces, etc.
41+
validations:
42+
required: true
43+
- type: textarea
44+
attributes:
45+
label: "Expected result / actual result"
46+
id: "result"
47+
description: "What did you expect that would happen on your Umbraco site and what is the actual result of the above steps?"
48+
placeholder: >
49+
Describe the intended/desired outcome after you did the steps mentioned.
50+
51+
Describe the behaviour of the bug

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
blank_issues_enabled: false
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "Feature request"
2+
description: "Suggest an idea for this package."
3+
labels: "enhancement"
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
Thanks for taking the time to suggest this feature request!
9+
- type: textarea
10+
id: "summary"
11+
attributes:
12+
label: "Feature summary"
13+
description: "Write a brief summary of the feature"
14+
validations:
15+
required: true
16+
- type: textarea
17+
id: "details"
18+
attributes:
19+
label: "Additional details"
20+
description: "Provide any additional details or comments about the feature you are suggesting"
21+
validations:
22+
required: false

.github/README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# jcdcdev.Umbraco.ReadingTime
2+
3+
[![Umbraco Version](https://img.shields.io/badge/Umbraco-10.4+-%233544B1?style=flat&logo=umbraco)](https://umbraco.com/products/umbraco-cms/)
4+
[![NuGet](https://img.shields.io/nuget/vpre/jcdcdev.Umbraco.ReadingTime?color=0273B3)](https://www.nuget.org/packages/jcdcdev.Umbraco.ReadingTime)
5+
[![GitHub license](https://img.shields.io/github/license/jcdcdev/jcdcdev.Umbraco.ReadingTime?color=8AB803)](../LICENSE)
6+
[![Downloads](https://img.shields.io/nuget/dt/jcdcdev.Umbraco.ReadingTime?color=cc9900)](https://www.nuget.org/packages/jcdcdev.Umbraco.ReadingTime/)
7+
8+
Custom Data Type for calculating reading time.
9+
10+
The following editors are currently supported:
11+
12+
- Rich Text
13+
- Markdown
14+
- Block Grid
15+
- Block List
16+
- Nested Content
17+
- Textstring
18+
- Textarea
19+
20+
## Quick Start
21+
22+
1. Install the [NuGet package](https://www.nuget.org/packages/jcdcdev.Umbraco.ReadingTime) in your Umbraco CMS website project.
23+
2. Add the Reading Time data type to a document type.
24+
- Note: You can configure the words per minute in the data type settings.
25+
3. Save and publish content.
26+
4. Reading Time will display in the backoffice
27+
28+
![A screenshot of the BackOffice showing Reading Time](https://raw.githubusercontent.com/jcdcdev/jcdcdev.Umbraco.ReadingTime/main/docs/screenshots/backoffice.png)
29+
30+
## Using the value in your templates
31+
32+
In your template, you can accessing the Reading Time property.
33+
34+
```csharp
35+
<div class="alert alert-info">
36+
Read in @Model.ReadingTime.DisplayTime()
37+
</div>
38+
```
39+
40+
## Configuration
41+
42+
You can change the average words per minute in the data type settings.
43+
44+
When creating a new data type, the default will be 200 words per minute. To change this default, adjust your `appsettings.json` file:
45+
46+
```json
47+
{
48+
"ReadingTime": {
49+
"WordsPerMinute": 200
50+
}
51+
}
52+
```
53+
54+
## Limitations
55+
56+
**Values are derived from published content only.**
57+
58+
Draft content is _not_ included in the calculation.
59+
60+
## Extending
61+
62+
You can extend the data type to support additional editors by implementing the `IReadingTimeValueProvider` interface.
63+
64+
```csharp
65+
public class MyCustomReadingTimeValueProvider : IReadingTimeValueProvider
66+
{
67+
public bool CanConvert(IPropertyType type)
68+
{
69+
return type.EditorAlias == "MyCustomEditorAlias";
70+
}
71+
72+
public TimeSpan? GetReadingTime(IProperty property, string? culture, string? segment, IEnumerable<string> availableCultures, ReadingTimeConfiguration config)
73+
{
74+
var value = property.GetValue(culture, segment, true);
75+
if (value is string text)
76+
{
77+
return text.GetReadingTime(config.WordsPerMinute);
78+
}
79+
80+
return null;
81+
}
82+
}
83+
```
84+
85+
Don't forget to register your custom value provider:
86+
87+
```csharp
88+
public class Composer : IComposer
89+
{
90+
public void Compose(IUmbracoBuilder builder)
91+
{
92+
builder.ReadingTimeValueProviders().Append<MyCustomReadingTimeValueProvider>();
93+
}
94+
}
95+
```
96+
## Contributing
97+
98+
Contributions to this package are most welcome! Please read the [Contributing Guidelines](CONTRIBUTING.md).
99+
100+
## Acknowledgments (thanks!)
101+
102+
- LottePitcher - [opinionated-package-starter](https://github.com/LottePitcher/opinionated-package-starter)

.github/workflows/build.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Build
2+
on:
3+
pull_request:
4+
branches: "*"
5+
workflow_dispatch:
6+
jobs:
7+
build:
8+
uses: jcdcdev/jcdcdev.Github.UmbracoSimpleDeploy/.github/workflows/build-template.yml@main
9+
with:
10+
project-name: 'jcdcdev.Umbraco.ReadingTime'
11+
project-path: './src/jcdcdev.Umbraco.ReadingTime/jcdcdev.Umbraco.ReadingTime.csproj'

.github/workflows/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Release
2+
on:
3+
pull_request:
4+
branches: "main"
5+
types: [ closed ]
6+
workflow_dispatch:
7+
jobs:
8+
build:
9+
uses: jcdcdev/jcdcdev.Github.UmbracoSimpleDeploy/.github/workflows/build-template.yml@main
10+
with:
11+
project-name: 'jcdcdev.Umbraco.ReadingTime'
12+
project-path: './src/jcdcdev.Umbraco.ReadingTime/jcdcdev.Umbraco.ReadingTime.csproj'
13+
release:
14+
needs:
15+
- build
16+
permissions:
17+
contents: write
18+
uses: jcdcdev/jcdcdev.Github.UmbracoSimpleDeploy/.github/workflows/release-template.yml@main
19+
with:
20+
artifact-name: ${{ needs.build.outputs.artifact-name }}
21+
version: ${{ needs.build.outputs.version }}
22+
secrets:
23+
nuget-api-key: ${{ secrets.NUGET_API_KEY }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 jcdcdev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

docs/icon.png

1.49 KB
Loading

0 commit comments

Comments
 (0)