Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 5354130

Browse files
Merge pull request #7 from DanielGilbert/dev
Release v3.0.6
2 parents a0829de + e308b92 commit 5354130

File tree

13 files changed

+306
-48
lines changed

13 files changed

+306
-48
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
## [3.0.6] - 2023-05-13
11+
12+
### Added
13+
- `Readme.md` now contains more explanation to get `Radia` up and running.
14+
15+
### Changed
16+
- Some changes under the hood now allow better caching.
17+
1018
## [3.0.5] - 2023-02-08
1119

1220
### Added
@@ -47,7 +55,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4755
- Majority of code is now under test.
4856

4957

50-
[unreleased]: https://github.com/DanielGilbert/Radia/compare/v3.0.5...HEAD
58+
[unreleased]: https://github.com/DanielGilbert/Radia/compare/v3.0.6...HEAD
59+
[3.0.6]: https://github.com/DanielGilbert/Radia/compare/v3.0.5...v3.0.6
5160
[3.0.5]: https://github.com/DanielGilbert/Radia/compare/v3.0.4...v3.0.5
5261
[3.0.4]: https://github.com/DanielGilbert/Radia/compare/v3.0.3...v3.0.4
5362
[3.0.3]: https://github.com/DanielGilbert/Radia/compare/v3.0.2...v3.0.3

README.md

Lines changed: 105 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,119 @@
11
# Radia
22
[![Publish Docker image](https://github.com/DanielGilbert/Radia/actions/workflows/docker.yml/badge.svg)](https://github.com/DanielGilbert/Radia/actions/workflows/docker.yml)
33
![Docker Pulls](https://img.shields.io/docker/pulls/herrgilbert/radia)
4+
45
## Introduction
56
*Radia* is inspired by the old days of Internet, where you would slab your web directory into the wild. Just start the Docker, add a Github repo as source, and you are good to go. You can of course also just reference a local folder on the file system. It's totally up to you.
7+
68
## History
79
*Radia* started with the simple name of *Directory Listing* (🥱) in 2019. It powered my [private website](https://g5t.de) ever since. I was tired of dealing with a full-blown CMS and didn't like the static page generators. I just want it to work, being lean and easy at the same time.
810

911
I also happen to like to build stuff. So there goes that.
1012

11-
The name comes from the likes of [Radia Perlman](https://en.wikipedia.org/wiki/Radia_Perlman), who is most famous for the invention of the [Spanning Tree Protocol](https://en.wikipedia.org/wiki/Spanning_Tree_Protocol). With this, she laid the foundation of what we nowadays refer to as "The Internet". Also, I like the name.
13+
Recently, I got told that I have "no sufficient knowledge of backend technology" and my job application got turned down. So I'm currently building up knowledge, knowing that I will never apply at that place again.
14+
15+
The name comes from the likes of [Radia Perlman](https://en.wikipedia.org/wiki/Radia_Perlman), who is most famous for the invention of the [Spanning Tree Protocol](https://en.wikipedia.org/wiki/Spanning_Tree_Protocol). With this, she laid the foundation of what we nowadays refer to as "The Internet". Also, I like the name.
16+
1217
## Features
18+
- Works on folders and/or repositories
1319
- Clones given git repositories
1420
- Can serve from multiple file repositories. Want your template in a different repo than your content? No Problem!
15-
- Renders Markdown files natively
21+
- Renders Markdown files
1622
- Respects hidden file attributes
17-
- Just works.™
23+
- ~~Just~~ Kinda works.™
24+
25+
## Usage
26+
Your best bet is to use the provided docker container. I included a `docker-compose` file, which should help you get things going. There is `appsettings.json` located in the root of the `/app` folder, which you will need to adopt to your own needs. Let's have a look:
27+
28+
29+
``` json
30+
{
31+
"Logging": {
32+
"LogLevel": {
33+
"Default": "Information",
34+
"Microsoft.AspNetCore": "Warning"
35+
}
36+
},
37+
"AllowedHosts": "*",
38+
"AppConfiguration": {
39+
"FileProviderConfigurations": [
40+
{
41+
"AllowListing": true,
42+
"Settings": {
43+
"RootDirectory": "/app/content/"
44+
}
45+
},
46+
{
47+
"AllowListing": false,
48+
"Settings": {
49+
"RootDirectory": "/app/templates/default/views/"
50+
}
51+
},
52+
{
53+
"AllowListing": false,
54+
"Settings": {
55+
"RootDirectory": "/app/templates/default/"
56+
}
57+
}
58+
],
59+
"WebsiteTitle": "Radia",
60+
"FooterCopyright": "© <Your name should go here>, 1970 - {{CurrentYear}}",
61+
"DefaultPageHeader": "Welcome to Radia"
62+
}
63+
}
64+
```
65+
66+
This is the default `appsettings.json`, as it is in the docker container and in the repository.
67+
68+
## Properties
69+
70+
| Property | Description |
71+
| -------------------------- | --------------------------------------------------------------------------------------------------------- |
72+
| Logging | This allows you to define and set the logging level. |
73+
| FileProviderConfigurations | This contains the main gist of Radia. Here you are able to reference all the different sources of content |
74+
| WebsiteTitle | This will set the title you can see on the browser window |
75+
| FooterCopyright | The Copyright information to display in your footer, if any. |
76+
| DefaultPageHeader | You can set the page header of the default template. |
77+
78+
79+
## File Providers
80+
### Filesystem
81+
This is the default file provider for Radia. It takes a directory from the file system, and will display it's contents on the root. So, if you want to have a directory called `bar` visible on the index page, and this directory is under `foo/bar`, then your RootDirectory in this case becomes `foo`. So you always refer to the parent directory of the directory you want to see in the index.
82+
83+
You use the `Filesystem File Provider` simply by adding `RootDirectory` to the `Settings` object, as you can see above.
84+
85+
``` json
86+
{
87+
"FileProviderConfigurations": [
88+
{
89+
"AllowListing": true,
90+
"Settings": {
91+
"RootDirectory": "/app/content/"
92+
}
93+
}
94+
]
95+
}
96+
```
97+
98+
### Git
99+
Another nice aspect about Radia is that it can directly display the contents of a git repository. It does that by checking out the repository on the first run, and then fetching it every 10 minutes. In future versions, this might be configurable. As the repository is cloned locally, you need to have enough space available.
100+
101+
``` json
102+
{
103+
"FileProviderConfigurations": [
104+
{
105+
"AllowListing": true,
106+
"Settings": {
107+
"Repository": "https://github.com/DanielGilbert/g5t.de.git",
108+
"Branch": "main"
109+
}
110+
}
111+
]
112+
}
113+
```
114+
115+
### General Settings
116+
117+
| Property | Description |
118+
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
119+
| AllowListing | This boolean decides if the content of this directory will be listed on the index page. I do not recommend that for template directories or similar. |

Radia.Tests/DefaultRadiaTestContext.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.AspNetCore.Http;
22
using Microsoft.Extensions.Configuration;
3+
using Microsoft.Extensions.Logging;
4+
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
35
using Moq;
46
using Radia.Factories;
57
using Radia.Factories.ContentProcessor;
@@ -28,6 +30,8 @@ public class DefaultRadiaTestContext
2830
public IVersionService VersionService { get; internal set; }
2931
public IFooterService FooterService { get; }
3032

33+
public ILogger<ViewModelFactory> ViewModelFactoryLogger { get; }
34+
3135
public DefaultRadiaTestContext(string rootDirectory) : this(rootDirectory,
3236
DefaultRadiaTestContext.DefaultFileProvider(rootDirectory)) { }
3337

@@ -44,6 +48,12 @@ public DefaultRadiaTestContext(string rootDirectory, IRadiaFileProvider fileProv
4448
DateTimeService = MockDateTimeService();
4549
VersionService = MockVersionService();
4650
FooterService = MockFooterService();
51+
ViewModelFactoryLogger = MockViewModelFactoryLogger();
52+
}
53+
54+
private ILogger<ViewModelFactory> MockViewModelFactoryLogger()
55+
{
56+
return Mock.Of<ILogger<ViewModelFactory>>();
4757
}
4858

4959
private IFooterService MockFooterService()
@@ -85,7 +95,8 @@ private IViewModelFactory BuildViewModelFactory()
8595
ContentProcessorFactory,
8696
HttpContextAccessor,
8797
new ByteSizeService(),
88-
null);
98+
null,
99+
this.ViewModelFactoryLogger);
89100

90101
}
91102

Radia.Tests/Factories/ViewModel/ViewModelFactoryTests.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
using FluentAssertions;
2+
using Microsoft.Extensions.Logging;
3+
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
4+
using Moq;
25
using Radia.Factories.ViewModel;
36
using Radia.Services;
47
using Radia.ViewModels;
@@ -24,13 +27,16 @@ public void WhenGivenAFolderPath_WillReturnTheFolderViewModel()
2427
{
2528
DefaultRadiaTestContext defaultRadiaTestContext = new DefaultRadiaTestContext(TestContext!.TestRunResultsDirectory!);
2629

30+
var logger = Mock.Of<ILogger<ViewModelFactory>>();
31+
2732
ViewModelFactory viewModelFactory = new ViewModelFactory(defaultRadiaTestContext.FileProvider,
2833
defaultRadiaTestContext.ConfigurationService,
2934
defaultRadiaTestContext.ContentTypeIdentifierService,
3035
defaultRadiaTestContext.ContentProcessorFactory,
3136
defaultRadiaTestContext.HttpContextAccessor,
3237
new ByteSizeService(),
33-
defaultRadiaTestContext.FooterService);
38+
defaultRadiaTestContext.FooterService,
39+
logger);
3440

3541
ViewModelFactoryArgs factoryArgs = new ViewModelFactoryArgs("/", "TestTitle");
3642

@@ -45,13 +51,16 @@ public void WhenGivenAnInvalidFolderPath_WillReturnTheFileNotFoundViewModel()
4551
{
4652
DefaultRadiaTestContext defaultRadiaTestContext = new DefaultRadiaTestContext(TestContext!.TestRunResultsDirectory!);
4753

54+
var logger = Mock.Of<ILogger<ViewModelFactory>>();
55+
4856
ViewModelFactory viewModelFactory = new ViewModelFactory(defaultRadiaTestContext.FileProvider,
4957
defaultRadiaTestContext.ConfigurationService,
5058
defaultRadiaTestContext.ContentTypeIdentifierService,
5159
defaultRadiaTestContext.ContentProcessorFactory,
5260
defaultRadiaTestContext.HttpContextAccessor,
5361
new ByteSizeService(),
54-
defaultRadiaTestContext.FooterService);
62+
defaultRadiaTestContext.FooterService,
63+
logger);
5564

5665
ViewModelFactoryArgs factoryArgs = new ViewModelFactoryArgs("/invalidViewModel", "TestTitle");
5766

@@ -70,13 +79,16 @@ public void WhenGivenAValidFilePath_WillReturnTheDownloadableFileViewModel()
7079

7180
File.WriteAllText(path, "test");
7281

82+
var logger = Mock.Of<ILogger<ViewModelFactory>>();
83+
7384
ViewModelFactory viewModelFactory = new ViewModelFactory(defaultRadiaTestContext.FileProvider,
7485
defaultRadiaTestContext.ConfigurationService,
7586
defaultRadiaTestContext.ContentTypeIdentifierService,
7687
defaultRadiaTestContext.ContentProcessorFactory,
7788
defaultRadiaTestContext.HttpContextAccessor,
7889
new ByteSizeService(),
79-
defaultRadiaTestContext.FooterService);
90+
defaultRadiaTestContext.FooterService,
91+
logger);
8092

8193
ViewModelFactoryArgs factoryArgs = new ViewModelFactoryArgs("/test.txt", "TestTitle");
8294

@@ -96,13 +108,16 @@ public void WhenGivenAValidLargeFilePath_WillReturnTheDownloadableFileViewModel(
96108
byte[] data = new byte[1024 * 1024 * 4];
97109
File.WriteAllBytes(path, data);
98110

111+
var logger = Mock.Of<ILogger<ViewModelFactory>>();
112+
99113
ViewModelFactory viewModelFactory = new ViewModelFactory(defaultRadiaTestContext.FileProvider,
100114
defaultRadiaTestContext.ConfigurationService,
101115
defaultRadiaTestContext.ContentTypeIdentifierService,
102116
defaultRadiaTestContext.ContentProcessorFactory,
103117
defaultRadiaTestContext.HttpContextAccessor,
104118
new ByteSizeService(),
105-
defaultRadiaTestContext.FooterService);
119+
defaultRadiaTestContext.FooterService,
120+
logger);
106121

107122
ViewModelFactoryArgs factoryArgs = new ViewModelFactoryArgs("/test2.png", "TestTitle");
108123

@@ -121,13 +136,16 @@ public void WhenGivenAMarkdownFilePath_WillReturnTheProcessedFileViewModel()
121136

122137
File.WriteAllText(path, "## Header2");
123138

139+
var logger = Mock.Of<ILogger<ViewModelFactory>>();
140+
124141
ViewModelFactory viewModelFactory = new ViewModelFactory(defaultRadiaTestContext.FileProvider,
125142
defaultRadiaTestContext.ConfigurationService,
126143
defaultRadiaTestContext.ContentTypeIdentifierService,
127144
defaultRadiaTestContext.ContentProcessorFactory,
128145
defaultRadiaTestContext.HttpContextAccessor,
129146
new ByteSizeService(),
130-
defaultRadiaTestContext.FooterService);
147+
defaultRadiaTestContext.FooterService,
148+
logger);
131149

132150
ViewModelFactoryArgs factoryArgs = new ViewModelFactoryArgs("/test.md", "TestTitle");
133151

Radia.Tests/Services/ConfigurationServiceTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public void WhenGivenFileProviderConfigurations_ThenWillReturnSameAmountOfFilePr
203203
}
204204

205205
[TestMethod]
206-
public void WhenGivenNoWebsiteTitle_ThenWillThrowArgumentException()
206+
public void WhenGivenNoFileProviderConfigurations_ThenWillReturnAnEmptyList()
207207
{
208208
var configuration = new Dictionary<string, string?>
209209
{
@@ -212,9 +212,7 @@ public void WhenGivenNoWebsiteTitle_ThenWillThrowArgumentException()
212212

213213
IConfigurationService configurationService = BuildConfigurationService(configuration);
214214

215-
Action act = () => configurationService.GetFileProviderConfigurations();
216-
217-
act.Should().Throw<ArgumentException>();
215+
configurationService.GetFileProviderConfigurations().Should().BeEmpty();
218216
}
219217
}
220218

0 commit comments

Comments
 (0)