Skip to content

Commit

Permalink
feat: support for static website content
Browse files Browse the repository at this point in the history
Merge pull request #126 from eurofurence/feature/115-add-static-content
  • Loading branch information
Fenrikur authored Jul 26, 2024
2 parents c42af9f + e79f079 commit 51d0004
Show file tree
Hide file tree
Showing 41 changed files with 1,747 additions and 26 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ RUN dotnet tool install --global dotnet-ef \
ENTRYPOINT dotnet artifacts/Eurofurence.App.Server.Web.dll http://*:30001
EXPOSE 30001

FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled AS prod
COPY --from=build /app/artifacts/* /app/
COPY /src/Eurofurence.App.Server.Web/wwwroot /app/wwwroot
WORKDIR /app
ENTRYPOINT ["dotnet", "Eurofurence.App.Server.Web.dll", "http://*:30001"]
EXPOSE 30001
3 changes: 2 additions & 1 deletion Dockerfile-backoffice
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ COPY ./test/ /app/test/
COPY ./ef-app_backend-dotnet-core.sln /app/
COPY ./NuGet.config /app/
WORKDIR /app
RUN dotnet restore \
RUN touch src/Eurofurence.App.Backoffice/wwwroot/appsettings.json \
&& dotnet restore \
&& dotnet build src/Eurofurence.App.Backoffice/Eurofurence.App.Backoffice.csproj --configuration Release \
&& dotnet publish src/Eurofurence.App.Backoffice/Eurofurence.App.Backoffice.csproj --output "/app/backoffice" --configuration Release
ENTRYPOINT dotnet artifacts/Eurofurence.App.Backoffice.dll http://*:30002
Expand Down
10 changes: 9 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ default:
@_create_from_sample PROJECT NAME EXTENSION TARGET:
if [ ! -f "{{TARGET}}.{{EXTENSION}}" ]; then echo "Creating {{TARGET}}.{{EXTENSION}} from sample…"; cp "src/{{PROJECT}}/{{NAME}}.sample.{{EXTENSION}}" "{{TARGET}}.{{EXTENSION}}"; else echo "Skipping {{TARGET}}.{{EXTENSION}} because it already exists."; fi

# Open a url (or file) and print it to stdout
@_open_url TITLE TARGET_URL:
echo "Opening {{TITLE}} at {{TARGET_URL}} …"
open {{TARGET_URL}}

# create an empty file if it doesn't exist
@_create_if_not_exists FILE:
if [[ ! -e {{FILE}} ]]; then touch {{FILE}}; fi

# Initialize configuration files in root folder
init: (_create_from_sample "Eurofurence.App.Server.Web" "appsettings" "json" "appsettings") (_create_from_sample "Eurofurence.App.Server.Web" "firebase" "json" "firebase") (_create_from_sample "Eurofurence.App.Backoffice/wwwroot" "appsettings" "json" "appsettings-backoffice")

Expand Down Expand Up @@ -39,7 +44,7 @@ clean:
docker rmi ghcr.io/eurofurence/ef-app_backend-dotnet-core:nightly || true

# Perform restore, build & publish with dotnet
build $MYSQL_VERSION=env_var('EF_MOBILE_APP_MYSQL_VERSION'):
build $MYSQL_VERSION=env_var('EF_MOBILE_APP_MYSQL_VERSION'): (_create_if_not_exists 'src/Eurofurence.App.Backoffice/wwwroot/appsettings.json')
dotnet tool install --global dotnet-ef
dotnet restore
dotnet build src/Eurofurence.App.Server.Web/Eurofurence.App.Server.Web.csproj --configuration Release
Expand Down Expand Up @@ -68,5 +73,8 @@ containerize-backoffice-dev:
# Open Swagger UI in default browser
swagger: (_open_url "Swagger UI" ("http://localhost:"+env_var('EF_MOBILE_APP_BACKEND_PORT')+"/swagger/ui/index.html"))

# Open homepage in default browser
homepage: (_open_url "Homepage" ("http://localhost:"+env_var('EF_MOBILE_APP_BACKEND_PORT')+"/"))

# Open Backoffice UI in default browser
backoffice: (_open_url "Backoffice UI" ("https://localhost:"+env_var('EF_MOBILE_APP_BACKOFFICE_PORT')+env_var('EF_MOBILE_APP_BACKOFFICE_BASE_PATH')+"/"))
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ConventionSettings
public string AppIdITunes { get; set; }
public string AppIdPlay { get; set; }
public string ApiBaseUrl => $"{BaseUrl}/Api";
public string ContentBaseUrl => $"{BaseUrl}/Web/Static";
public string ContentBaseUrl => $"{BaseUrl}";
public string WebBaseUrl => $"{BaseUrl}/Web";

public static ConventionSettings FromConfiguration(IConfiguration configuration)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Eurofurence.App.Server.Services.Abstractions.QrCode
{
public interface IQrCodeService
{
string GetTarget(string id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace Eurofurence.App.Server.Services.Abstractions.QrCode
{
public class QrCodeConfiguration
{
public Dictionary<string, string> Targets { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Eurofurence.App.Server.Services.Abstractions.Maps;
using Eurofurence.App.Server.Services.Abstractions.MinIO;
using Eurofurence.App.Server.Services.Abstractions.PushNotifications;
using Eurofurence.App.Server.Services.Abstractions.QrCode;
using Eurofurence.App.Server.Services.Abstractions.Telegram;
using Eurofurence.App.Server.Services.Abstractions.Validation;
using Eurofurence.App.Server.Services.Announcements;
Expand Down Expand Up @@ -121,6 +122,7 @@ private void RegisterServices(ContainerBuilder builder)
builder.RegisterType<PushNotificationChannelStatisticsService>()
.As<IPushNotificationChannelStatisticsService>();
builder.RegisterType<PushNotificiationChannelService>().As<IPushNotificiationChannelService>();
builder.RegisterType<QrCodeService>().As<IQrCodeService>();
builder.RegisterType<StorageServiceFactory>().As<IStorageServiceFactory>();
builder.RegisterType<TableRegistrationService>().As<ITableRegistrationService>();
builder.RegisterType<TelegramMessageBroker>()
Expand Down
21 changes: 21 additions & 0 deletions src/Eurofurence.App.Server.Services/QrCode/QrCodeService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Eurofurence.App.Server.Services.Abstractions.QrCode;
using Microsoft.Extensions.Options;

namespace Eurofurence.App.Server.Services.Communication
{
public class QrCodeService : IQrCodeService
{
private readonly QrCodeConfiguration _qrCodeConfiguration;

public QrCodeService(
IOptionsMonitor<QrCodeConfiguration> qrCodeConfiguration
)
{
_qrCodeConfiguration = qrCodeConfiguration.CurrentValue;
}
public string GetTarget(string id)
{
return _qrCodeConfiguration.Targets[id];
}
}
}
32 changes: 32 additions & 0 deletions src/Eurofurence.App.Server.Web/Controllers/QrCodeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Eurofurence.App.Server.Services.Abstractions.QrCode;
using Microsoft.AspNetCore.Mvc;
using System;

namespace Eurofurence.App.Server.Web.Controllers
{
[Route("qr")]
public class QrCodeController : BaseController
{
private readonly IQrCodeService _qrCodeService;

public QrCodeController(
IQrCodeService qrCodeService
)
{
_qrCodeService = qrCodeService;
}

[HttpGet("{targetId}")]
public ActionResult GetTargetRedirect(string targetId)
{
try
{
return new RedirectResult(_qrCodeService.GetTarget(targetId));
}
catch (Exception)
{
return NotFound();
}
}
}
}
6 changes: 5 additions & 1 deletion src/Eurofurence.App.Server.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using Microsoft.AspNetCore.Authentication;
using Minio;
using ILogger = Microsoft.Extensions.Logging.ILogger;
using Eurofurence.App.Server.Services.Abstractions.QrCode;

namespace Eurofurence.App.Server.Web
{
Expand Down Expand Up @@ -152,6 +153,8 @@ public void ConfigureServices(IServiceCollection services)

});

services.Configure<QrCodeConfiguration>(Configuration.GetSection("QrCode"));

services.Configure<IdentityOptions>(Configuration.GetSection("Identity"));
services.Configure<AuthorizationOptions>(Configuration.GetSection("Authorization"));
services.ConfigureOptions<ConfigureOAuth2IntrospectionOptions>();
Expand Down Expand Up @@ -259,7 +262,8 @@ IHostApplicationLifetime appLifetime
app.UseCors("CorsPolicy");
app.UseAuthentication();

app.UseStaticFiles("/Web/Static");
app.UseDefaultFiles();
app.UseStaticFiles();

app.Use(async (context, next) =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="//fonts.googleapis.com/css?family=Fira+Sans:400,300,600" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/fontawesome.min.css" rel="stylesheet" />
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/brands.min.css" rel="stylesheet" />
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/solid.min.css" rel="stylesheet" />
<link href="//cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" rel="stylesheet" />
<link href="//cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css" rel="stylesheet" />
<link href="@contentBaseUrl/css/fontawesome-all.min.css" rel="stylesheet" />
<link href="@contentBaseUrl/css/normalize.min.css" rel="stylesheet" />
<link href="@contentBaseUrl/css/skeleton.min.css" rel="stylesheet" />
<link href="@contentBaseUrl/css/webpreview.css" rel="stylesheet" />
<link rel="shortcut icon" href="@contentBaseUrl/images/favicon.ico">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@{
Layout = "~/Views/Shared/_WebPreviewLayout.cshtml";

var contentBaseUrl = ViewData[WebPreviewController.VIEWDATA_CONTENT_BASE_URL] as string;
var apiBaseUrl = ViewData[WebPreviewController.VIEWDATA_API_BASE_URL] as string;

var displayName = string.IsNullOrEmpty(Model.DisplayName) ? Model.AttendeeNickname : (Model.DisplayName.Equals(Model.AttendeeNickname) ? Model.DisplayName : $"{Model.DisplayName} ({Model.AttendeeNickname})");
Expand All @@ -23,12 +24,8 @@
}

@section head {
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css"
integrity="sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.8.0/dist/leaflet.js"
integrity="sha512-BB3hKbKWOc9Ez/TAwyWxNXeoV9c1v6FIeYiBieIWkpLjauysF18NzgR1MBNBXf8/KABdlkX68nAhlwcDFLGPCQ=="
crossorigin=""></script>
<link rel="stylesheet" href="@contentBaseUrl/css/leaflet.css" />
<script src="@contentBaseUrl/scripts/leaflet.js" ></script>
}

<header>
Expand All @@ -41,6 +38,7 @@
<h1>
@displayName
<span>@categories</span>
<!-- TODO: Add Keywords? -->
</h1>
<p>
@Model.ShortDescription
Expand All @@ -50,19 +48,20 @@
<section class="summary">
@if (!string.IsNullOrEmpty(Model.TwitterHandle))
{
<a href="https://twitter.com/@Model.TwitterHandle" title="Twitter: @@Model.TwitterHandle" class="button button-primary"><i class="fab fa-twitter"></i> @Model.TwitterHandle</a>
<a href="https://twitter.com/@Model.TwitterHandle" title="Twitter: @@Model.TwitterHandle" class="button button-primary"><i class="fa-twitter"></i> @Model.TwitterHandle</a>
}
@if (!string.IsNullOrEmpty(Model.TelegramHandle))
{
<a href="https://t.me/@Model.TelegramHandle" title="Telegram: @@@Model.TelegramHandle" class="button button-primary"><i class="fab fa-telegram"></i> @Model.TelegramHandle</a>
<a href="https://t.me/@Model.TelegramHandle" title="Telegram: @@@Model.TelegramHandle" class="button button-primary"><i class="fa-telegram"></i> @Model.TelegramHandle</a>
}
<!-- TODO: Add Discord, Mastodon etc. -->
@if (days.Length > 0)
{
<div class="infobox"><label><i class="fas fa-calendar"></i> Available:</label> @string.Join(", ", days)</div>
<div class="infobox"><label><i class="fa-calendar"></i> Available:</label> @string.Join(", ", days)</div>
}
@if (Model.IsAfterDark)
{
<div class="infobox"><label><i class="fas fa-moon"></i> After Dark</label></div>
<div class="infobox"><label><i class="fa-moon-o"></i> After Dark</label></div>
}
</section>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
var knowledgeEntries = (ViewData["knowledgeEntries"] as IList<Eurofurence.App.Domain.Model.Knowledge.KnowledgeEntryRecord>);
}

@section head {
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
}

<header>
<h1>
Knowledge Base
Expand Down
8 changes: 8 additions & 0 deletions src/Eurofurence.App.Server.Web/appsettings.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,13 @@
"secretKey": "minioVerySecretKey",
"secure": false,
"bucket": "ef-mobile-app-local"
},
"QrCode": {
"Targets": {
"getWindowsApp": "",
"getAndroidApp": "",
"getiPhoneApp": "",
"aatablereg": ""
}
}
}
Empty file.
Loading

0 comments on commit 51d0004

Please sign in to comment.