# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
+import os
+import os.path
import re
from datetime import datetime
from email.utils import format_datetime
+from pathlib import Path
+
+import fastapi
from fastapi import Request, HTTPException, Query
from fastapi.responses import JSONResponse
from fastapi.responses import PlainTextResponse
+from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
-import fastapi
import uvicorn
import requests
import validators
from fba.models import blocks
router = fastapi.FastAPI(docs_url=config.get("base_url") + "/docs", redoc_url=config.get("base_url") + "/redoc")
+router.mount(
+ "/static",
+ StaticFiles(directory=Path(__file__).parent.absolute() / "static"),
+ name="static",
+)
+
templates = Jinja2Templates(directory="templates")
@router.get(config.get("base_url") + "/api/info.json", response_class=JSONResponse)
return templates.TemplateResponse("views/scoreboard.html", {
"base_url" : config.get("base_url"),
"slogan" : config.get("slogan"),
+ "theme" : config.get("theme"),
"request" : request,
"scoreboard": True,
"mode" : mode,
return templates.TemplateResponse("views/index.html", {
"request": request,
+ "theme" : config.get("theme"),
"info" : response.json()
})
"found" : found,
"blocklist": blocklist,
"info" : info,
+ "theme" : config.get("theme"),
})
@router.get(config.get("base_url") + "/rss")
--- /dev/null
+body {
+ background-color: #ffffff;
+ color: #000022;
+ text-align: center;
+ font-family: sans;
+}
+
+#header {
+ margin-bottom: 20px;
+}
+
+h1 {
+ background-color: #eaeaea;
+ border-radius: 5px;
+ padding-left: 5px;
+ padding-right: 5px;
+ width: auto;
+}
+
+#content {
+ margin-bottom: 20px;
+}
+
+table {
+ width: 100%;
+ border: 2px solid #eaeaea;
+ border-spacing: 0px;
+ border-radius: 5px;
+}
+
+th {
+ padding-top: 4px;
+ padding-bottom: 4px;
+}
+
+table.with-rows > tbody > tr:nth-of-type(2n),
+table.with-rows > thead {
+ background-color: #eaeaea;
+}
+
+table td {
+ padding: 4px;
+ text-align: left;
+}
+
+.block_level {
+ width: 100%;
+ margin: auto;
+ margin-top: 10px;
+}
+.block {
+ padding: 5px;
+ margin: 5px;
+}
+
+a {
+ color: #000000;
+}
+a.listlink {
+ text-decoration: none;
+}
+a:hover {
+ color: #f00000;
+}
+
+input {
+ padding: 5px;
+ border-radius: 5px;
+ font-size: 16px;
+}
+input[type="submit"] {
+ cursor: pointer;
+}
+input:hover {
+ border-color: #f00000;
+}
+
+span[title] {
+ text-decoration: underline dotted;
+}
+
+.scoreboard {
+ margin-left: auto;
+ margin-right: auto;
+ min-width: 50%;
+ width: 50em;
+}
+
+/* notice box */
+.notice {
+ margin-left: auto;
+ margin-right: auto;
+ margin-bottom: 20px;
+ width: 50em;
+ text-align: left;
+ border: 1px solid #eaeaea;
+ border-radius: 5px;
+}
+/* notice header */
+.notice > h3 {
+ margin: 0px;
+ padding: 5px;
+ background-color: #eaeaea;
+ text-align: center;
+}
+/* notice text/body */
+.notice > div {
+ margin: 0px;
+ padding: 5px;
+}
+
+li {
+ padding-bottom: 4px;
+}
+
+code {
+ padding: 3px;
+ background-color: #eaeaea;
+ border-radius: 5px;
+}
+
+ul.nav > li {
+ margin: 2px;
+ display: inline;
+}
<!DOCTYPE html>
<head>
<title>fedi-block-api - {% block title %}{% endblock %}</title>
- {% block rss %}
- <link rel="alternate" type="application/rss+xml" title="RSS Feed for latest blocked instances" href="{{base_url}}/rss" />
- {% endblock %}
- <style>
- body {
- background-color: #ffffff;
- color: #000022;
- text-align: center;
- font-family: sans;
- }
-
- #header {
- margin-bottom: 20px;
- }
-
- h1 {
- background-color: #eaeaea;
- border-radius: 5px;
- padding-left: 5px;
- padding-right: 5px;
- width: auto;
- }
-
- #content {
- margin-bottom: 20px;
- }
-
- table {
- width: 100%;
- border: 2px solid #eaeaea;
- border-spacing: 0px;
- border-radius: 5px;
- }
-
- th {
- padding-top: 4px;
- padding-bottom: 4px;
- }
-
- table.with-rows > tbody > tr:nth-of-type(2n),
- table.with-rows > thead {
- background-color: #eaeaea;
- }
-
- table td {
- padding: 4px;
- text-align: left;
- }
-
- .block_level {
- width: 100%;
- margin: auto;
- margin-top: 10px;
- }
- .block {
- padding: 5px;
- margin: 5px;
- }
-
- a {
- color: #000000;
- }
- a.listlink {
- text-decoration: none;
- }
- a:hover {
- color: #f00000;
- }
-
- input {
- padding: 5px;
- border-radius: 5px;
- font-size: 16px;
- }
- input[type="submit"] {
- cursor: pointer;
- }
- input:hover {
- border-color: #f00000;
- }
-
- span[title] {
- text-decoration: underline dotted;
- }
-
- .scoreboard {
- margin-left: auto;
- margin-right: auto;
- min-width: 50%;
- width: 50em;
- }
- .notice {
- margin-left: auto;
- margin-right: auto;
- margin-bottom: 20px;
- width: 50em;
- text-align: left;
- border: 1px solid #eaeaea;
- border-radius: 5px;
- }
- .notice > div {
- margin: 0px;
- padding: 5px;
- }
- .notice > h3 {
- margin: 0px;
- padding: 5px;
- background-color: #eaeaea;
- text-align: center;
- }
- li {
- padding-bottom: 4px;
- }
- code {
- padding: 3px;
- background-color: #eaeaea;
- border-radius: 5px;
- }
- ul.nav > li {
- margin: 2px;
- display: inline;
- }
- </style>
+ <link rel="alternate" type="application/rss+xml" title="RSS Feed for latest blocked instances" href="{{base_url}}/rss" />
+ {% block rss %}{% endblock %}
+ <link rel="stylesheet" type="text/css" href="{{ url_for('static', path='css/' + theme + '.css') }}" media="all" />
</head>
<body>
NO SLOGAN WAS FOUND!!!
{% endif %}
{% endblock %}
- </p>
+ </div>
</body>
</html>