From 14f187a970def1ed1cea19367b25da4229cbe0e1 Mon Sep 17 00:00:00 2001
From: Miss Pasture <miss@pasture.moe>
Date: Thu, 3 Jun 2021 22:18:31 -0400
Subject: [PATCH] add info banner, slightly adjust about page

---
 VARIABLES.md                                  |  2 ++
 .../Settings/InstanceSettings.cs              |  2 ++
 .../Controllers/HomeController.cs             |  7 ++++--
 src/BirdsiteLive/Views/About/Index.cshtml     |  4 ++--
 src/BirdsiteLive/Views/Home/Index.cshtml      | 23 ++++++++++++-------
 src/BirdsiteLive/appsettings.json             |  3 ++-
 6 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/VARIABLES.md b/VARIABLES.md
index 681bd3f..0a11ed7 100644
--- a/VARIABLES.md
+++ b/VARIABLES.md
@@ -48,6 +48,7 @@ If both whitelisting and blacklisting are set, only the whitelisting will be act
 * `Instance:PublishReplies` (default: false) to enable or disable replies publishing.
 * `Instance:UnlistedTwitterAccounts` (default: null) to enable unlisted publication for selected twitter accounts, separated by `;` (please limit this to brands and other public profiles).
 * `Instance:TwitterDomain` (default: twitter.com) redirect to a different domain (i.e. a Nitter instance) instead of Twitter
+* `Instance:InfoBanner` (default: '') text to show in a banner on the front page
 
 # Docker Compose full example
 
@@ -80,6 +81,7 @@ services:
 +           - Instance:PublishReplies=true
 +           - Instance:UnlistedTwitterAccounts=cocacola;twitter
 +           - Instance:TwitterDomain=twiiit.com
++           - Instance:InfoBanner=This is my BirdsiteLIVE instance. There are many like it, but this one is mine.
         networks:
         [...]
 
diff --git a/src/BirdsiteLive.Common/Settings/InstanceSettings.cs b/src/BirdsiteLive.Common/Settings/InstanceSettings.cs
index cd5d495..7338aae 100644
--- a/src/BirdsiteLive.Common/Settings/InstanceSettings.cs
+++ b/src/BirdsiteLive.Common/Settings/InstanceSettings.cs
@@ -12,5 +12,7 @@
         public string UnlistedTwitterAccounts { get; set; }
 
         public string TwitterDomain { get; set; }
+
+        public string InfoBanner { get; set; }
     }
 }
\ No newline at end of file
diff --git a/src/BirdsiteLive/Controllers/HomeController.cs b/src/BirdsiteLive/Controllers/HomeController.cs
index ef41b65..e0d6855 100644
--- a/src/BirdsiteLive/Controllers/HomeController.cs
+++ b/src/BirdsiteLive/Controllers/HomeController.cs
@@ -6,21 +6,24 @@ using System.Threading.Tasks;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Logging;
 using BirdsiteLive.Models;
+using BirdsiteLive.Common.Settings;
 
 namespace BirdsiteLive.Controllers
 {
     public class HomeController : Controller
     {
         private readonly ILogger<HomeController> _logger;
+        private readonly InstanceSettings _instanceSettings;
 
-        public HomeController(ILogger<HomeController> logger)
+        public HomeController(ILogger<HomeController> logger, InstanceSettings instanceSettings)
         {
             _logger = logger;
+            _instanceSettings = instanceSettings;
         }
 
         public IActionResult Index()
         {
-            return View();
+            return View(_instanceSettings);
         }
 
         public IActionResult Privacy()
diff --git a/src/BirdsiteLive/Views/About/Index.cshtml b/src/BirdsiteLive/Views/About/Index.cshtml
index 458c3e4..d540115 100644
--- a/src/BirdsiteLive/Views/About/Index.cshtml
+++ b/src/BirdsiteLive/Views/About/Index.cshtml
@@ -1,4 +1,4 @@
-﻿@model BirdsiteLive.Services.CachedStatistics
+@model BirdsiteLive.Services.CachedStatistics
 @{
     ViewData["Title"] = "About";
 }
@@ -13,7 +13,7 @@
 
         <br /><br />
 
-        BirdsiteLIVE does not make any public posts; every post is scoped appropriately using the "followers-only" or "unlisted" ActivityPub audiences. See "Why do accounts I follow on this node post followers-only?", below.
+        BirdsiteLIVE does not make any public posts; every post is scoped appropriately using the "followers-only" or "unlisted" ActivityPub audiences.
     </p>
 
     <h4 id="followers-only">Why do accounts I follow on this node post followers-only?</h4>
diff --git a/src/BirdsiteLive/Views/Home/Index.cshtml b/src/BirdsiteLive/Views/Home/Index.cshtml
index 450ad5c..d275a65 100644
--- a/src/BirdsiteLive/Views/Home/Index.cshtml
+++ b/src/BirdsiteLive/Views/Home/Index.cshtml
@@ -1,7 +1,6 @@
-﻿@using BirdsiteLive.Controllers;
-@{
-    ViewData["Title"] = "Home Page";
-}
+@using BirdsiteLive.Common.Settings;
+@model InstanceSettings
+@{ ViewData["Title"] = "Home Page"; }
 
 <div class="text-center">
     <h1 class="display-4">Welcome</h1>
@@ -10,7 +9,7 @@
         This instance is a Twitter to ActivityPub bridge.<br />
         <a asp-controller="About" asp-action="Index">Learn more</a> or find a Twitter account below:
     </p>
-    
+
     <form method="POST">
         <div class="form-group">
             <input type="text" class="form-control col-8 col-sm-8 col-md-6 col-lg-4 mx-auto" id="handle" name="handle" autocomplete="off" placeholder="Twitter Handle">
@@ -18,9 +17,17 @@
         <button type="submit" class="btn btn-primary">Show</button>
     </form>
 
+    <br /><br />
+
+    @if (Model.InfoBanner.Length > 0)
+    {
+    <div class="alert alert-danger">
+        @Html.Raw(Model.InfoBanner)
+    </div>
+    }
 
     @*@if (HtmlHelperExtensions.IsDebug())
-    {
-        <a class="nav-link text-dark" asp-area="" asp-controller="Debuging" asp-action="Index">Debug</a>
-    }*@
+        {
+            <a class="nav-link text-dark" asp-area="" asp-controller="Debuging" asp-action="Index">Debug</a>
+        }*@
 </div>
diff --git a/src/BirdsiteLive/appsettings.json b/src/BirdsiteLive/appsettings.json
index b0f61e3..2989082 100644
--- a/src/BirdsiteLive/appsettings.json
+++ b/src/BirdsiteLive/appsettings.json
@@ -22,7 +22,8 @@
     "PublishReplies": false,
     "MaxUsersCapacity": 1500,
     "UnlistedTwitterAccounts": null,
-    "TwitterDomain": "twitter.com"
+    "TwitterDomain": "twitter.com",
+    "InfoBanner": ""
   },
   "Db": {
     "Type": "postgres",
