Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ ConnectionStrings__umbracoDbDSN="Data Source=|DataDirectory|/Umbraco.sqlite.db;C
SGFDevs__AzureBlobStorageKey=
SGFDevs__NewsletterEndpoint=
SGFDevs__NewsletterListId=
SGFDevs__Site__AnalyticsEnabled=false
SGFDevs__Site__SearchIndexingEnabled=false
Umbraco__CMS__Global__Smtp__From="Sgf Devs <website@email.sgf.dev>"
Umbraco__CMS__Global__Smtp__Host=
Umbraco__CMS__Global__Smtp__Port=
Expand Down
7 changes: 7 additions & 0 deletions SgfDevs/Dev/SiteFeaturesOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SgfDevs.Dev;

public class SiteFeaturesOptions
{
public bool AnalyticsEnabled { get; set; }
public bool SearchIndexingEnabled { get; set; }
}
11 changes: 11 additions & 0 deletions SgfDevs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Data.Sqlite;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using SGFDevs.Controllers;
using SgfDevs.Dev;
using SgfDevs.Dev.EventSync;
Expand Down Expand Up @@ -51,6 +53,7 @@
.AddCheck<ReadinessHealthCheck>("ready", tags: ["ready"]);
builder.Services.AddHttpClient();
builder.Services.Configure<EventSyncOptions>(builder.Configuration.GetSection("SGFDevs"));
builder.Services.Configure<SiteFeaturesOptions>(builder.Configuration.GetSection("SGFDevs:Site"));
builder.Services.AddScoped<MemberConverter>();
builder.Services.AddScoped<MemberTagDisplayService>();
builder.Services.AddScoped<PresentationPresenterDisplayService>();
Expand Down Expand Up @@ -90,6 +93,14 @@
Predicate = static check => check.Tags.Contains("ready"),
ResponseWriter = healthCheckOptions.ResponseWriter
}).AllowAnonymous();
app.MapGet("/robots.txt", (IOptions<SiteFeaturesOptions> siteFeatures) =>
Results.Text(
siteFeatures.Value.SearchIndexingEnabled
? "User-agent: *\nAllow: /\n"
: "User-agent: *\nDisallow: /\n",
"text/plain"
)
).AllowAnonymous();

app.UseUmbraco()
.WithMiddleware(u =>
Expand Down
12 changes: 10 additions & 2 deletions SgfDevs/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@using Umbraco.Cms.Web.Common.PublishedModels;
@using Microsoft.Extensions.Options
@using SgfDevs.Dev
@inject IOptions<SiteFeaturesOptions> SiteFeatures
@* @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.Base> *@
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;

Expand All @@ -18,21 +21,26 @@
<meta property="og:title" content="@pageTitle" />
@*<meta property="og:description" content="" />*@
<meta property="og:image" content="https://sgf.dev/images/og.jpg" />
@if (!SiteFeatures.Value.SearchIndexingEnabled)
{
<meta name="robots" content="noindex, nofollow" />
}
<title>@pageTitle</title>

<link rel="stylesheet" href="/css/styles.css?data=@rand.Next()" />
@RenderSection("Head", required: false)

@RenderSection("TopScripts", required: false)

<environment names="Production">
@if (SiteFeatures.Value.AnalyticsEnabled)
{
<!-- Privacy-friendly analytics by Plausible -->
<script async src="https://plausible.sgf.dev/js/pa-aOg8YJ_yiLgBbrOwNU2_7.js"></script>
<script>
window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};
plausible.init()
</script>
</environment>
}

<style>
/*.dev_night_banner ul.presentations_1 {
Expand Down
2 changes: 1 addition & 1 deletion SgfDevs/appsettings-schema.Umbraco.Cms.json
Original file line number Diff line number Diff line change
Expand Up @@ -2288,4 +2288,4 @@
}
}
}
}
}
4 changes: 4 additions & 0 deletions SgfDevs/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"NewsletterEndpoint": "",
"NewsletterListId": "",
"EventTimeZoneId": "America/Chicago",
"Site": {
"AnalyticsEnabled": false,
"SearchIndexingEnabled": false
},
"Sessionize": {
"BaseUrl": ""
},
Expand Down