-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Add] ResourceLoader and ascii-art
- Loading branch information
samatrhea
committed
Mar 20, 2024
1 parent
29fadcc
commit 4bb26e9
Showing
8 changed files
with
261 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
map $http_connection $connection_upgrade { | ||
"~*Upgrade" $http_connection; | ||
default keep-alive; | ||
} | ||
|
||
server { | ||
server_name viewer.reqifsharp.org; | ||
|
||
location / { | ||
proxy_pass http://127.0.0.1:5000; | ||
|
||
# Configuration for WebSockets | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection $connection_upgrade; | ||
proxy_cache off; | ||
|
||
# WebSockets were implemented after http/1.0 | ||
proxy_http_version 1.1; | ||
|
||
# Configuration for LongPolling or if your KeepAliveInterval is longer than 60 seconds | ||
proxy_read_timeout 100s; | ||
|
||
proxy_set_header Host $host; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
|
||
# kill cache | ||
add_header Last-Modified $date_gmt; | ||
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; | ||
if_modified_since off; | ||
expires off; | ||
etag off; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// <copyright file="IResourceLoader.cs" company="RHEA System S.A."> | ||
// | ||
// Copyright 2021-2024 RHEA System S.A. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// </copyright> | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
namespace ReqifViewer.Resources | ||
{ | ||
/// <summary> | ||
/// Definition of the interface used to load (embedded) resources | ||
/// </summary> | ||
public interface IResourceLoader | ||
{ | ||
/// <summary> | ||
/// Load an embedded resource | ||
/// </summary> | ||
/// <param name="path"> | ||
/// The path of the embedded resource | ||
/// </param> | ||
/// <returns> | ||
/// a string containing the contents of the embedded resource | ||
/// </returns> | ||
string LoadEmbeddedResource(string path); | ||
|
||
/// <summary> | ||
/// queries the version number from the executing assembly | ||
/// </summary> | ||
/// <returns> | ||
/// a string representation of the version of the application | ||
/// </returns> | ||
string QueryVersion(); | ||
|
||
/// <summary> | ||
/// Queries the logo with version info from the embedded resources | ||
/// </summary> | ||
/// <returns> | ||
/// the logo | ||
/// </returns> | ||
string QueryLogo(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// <copyright file="ResourceLoader.cs" company="RHEA System S.A."> | ||
// | ||
// Copyright 2021-2024 RHEA System S.A. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// </copyright> | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
namespace ReqifViewer.Resources | ||
{ | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Resources; | ||
|
||
/// <summary> | ||
/// Class responsible for loading embedded resources. | ||
/// </summary> | ||
public class ResourceLoader : IResourceLoader | ||
{ | ||
/// <summary> | ||
/// Load an embedded resource | ||
/// </summary> | ||
/// <param name="path"> | ||
/// The path of the embedded resource | ||
/// </param> | ||
/// <returns> | ||
/// a string containing the contents of the embedded resource | ||
/// </returns> | ||
public string LoadEmbeddedResource(string path) | ||
{ | ||
var assembly = Assembly.GetExecutingAssembly(); | ||
|
||
using var stream = assembly.GetManifestResourceStream(path); | ||
|
||
using var reader = new StreamReader(stream ?? throw new MissingManifestResourceException()); | ||
|
||
return reader.ReadToEnd(); | ||
} | ||
|
||
/// <summary> | ||
/// queries the version number from the executing assembly | ||
/// </summary> | ||
/// <returns> | ||
/// a string representation of the version of the application | ||
/// </returns> | ||
public string QueryVersion() | ||
{ | ||
var assembly = Assembly.GetExecutingAssembly(); | ||
var infoVersion = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>(); | ||
|
||
if (infoVersion != null) | ||
{ | ||
var plusIndex = infoVersion.InformationalVersion.IndexOf('+'); | ||
|
||
if (plusIndex != -1) | ||
{ | ||
return infoVersion.InformationalVersion.Substring(0, plusIndex); | ||
} | ||
|
||
return infoVersion.InformationalVersion; | ||
} | ||
|
||
var fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); | ||
var fileVersion = fileVersionInfo.FileVersion; | ||
return fileVersion; | ||
} | ||
|
||
/// <summary> | ||
/// Queries the logo with version info from the embedded resources | ||
/// </summary> | ||
/// <returns> | ||
/// the logo | ||
/// </returns> | ||
public string QueryLogo() | ||
{ | ||
var version = this.QueryVersion(); | ||
|
||
var logo = this.LoadEmbeddedResource("reqifviewer.Resources.ascii-art.txt") | ||
.Replace("reqifviewerVersion", version); | ||
|
||
return logo; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
| ||
|
||
██████╗ ███████╗ ██████╗ ██╗███████╗███████╗██╗ ██╗ █████╗ ██████╗ ██████╗ | ||
██╔══██╗██╔════╝██╔═══██╗██║██╔════╝██╔════╝██║ ██║██╔══██╗██╔══██╗██╔══██╗ | ||
██████╔╝█████╗ ██║ ██║██║█████╗ ███████╗███████║███████║██████╔╝██████╔╝ | ||
██╔══██╗██╔══╝ ██║▄▄ ██║██║██╔══╝ ╚════██║██╔══██║██╔══██║██╔══██╗██╔═══╝ | ||
██║ ██║███████╗╚██████╔╝██║██║ ███████║██║ ██║██║ ██║██║ ██║██║ | ||
═╝ ╚═╝╚══════╝ ╚══▀▀═╝ ╚═╝╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ | ||
|
||
Copyright (c) 2022-2024 RHEA System S.A. | ||
reqifviewer version: reqifviewerVersion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"Kestrel": { | ||
"Endpoints": { | ||
"MyHttpEndpoint": { | ||
"Url": "http://localhost:5000" | ||
} | ||
} | ||
}, | ||
"Serilog": { | ||
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ], | ||
"MinimumLevel": { | ||
"Default": "Information", | ||
"Override": { | ||
"Microsoft": "Warning", | ||
"System": "Warning" | ||
} | ||
}, | ||
"WriteTo:Async": { | ||
"Name": "Async", | ||
"Args": { | ||
"configure": [ | ||
{ | ||
"Name": "File", | ||
"Args": { | ||
"path": "logs/log-reqifviewer-.txt", | ||
"rollingInterval": "Day", | ||
"rollOnFileSizeLimit": true | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId" ], | ||
"Properties": { | ||
"Application": "dmap-cdao", | ||
"Environment": "Production" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters