import fba
app = fastapi.FastAPI(docs_url=fba.config["base_url"] + "/docs", redoc_url=fba.config["base_url"] + "/redoc")
-templates = Jinja2Templates(directory=".")
+templates = Jinja2Templates(directory="templates")
@app.get(fba.config["base_url"] + "/api/info")
def info():
elif not res.ok:
raise HTTPException(status_code=res.status_code, detail=res.text)
- return templates.TemplateResponse("index.html", {
+ return templates.TemplateResponse("scoreboard.html", {
"base_url" : fba.config["base_url"],
"request" : request,
"scoreboard": True,
+++ /dev/null
-<!DOCTYPE html>
-<head>
- <title>fedi-block-api{% if domain %} {{domain}}{% endif %}</title>
- <link rel="alternate" type="application/rss+xml" title="RSS Feed for latest blocked instances" href="{{base_url}}/rss" />
- {% if domain %}
- <link rel="alternate" type="application/rss+xml" title="RSS Feed for blocked domain {{domain}}" href="{{base_url}}/rss?domain={{domain}}" />
- {% elif reverse %}
- <link rel="alternate" type="application/rss+xml" title="RSS Feed for blocking domain {{reverse}}" href="{{base_url}}/rss?reverse={{reverse}}" />
- {% endif %}
- <style>
- body {
- background-color: #000022;
- color: #ffffff;
- text-align: center;
- font-family: sans;
- }
- .block_level {
- background-color: #1c1c3c;
- width: 80em;
- padding: 5px;
- margin: auto;
- margin-top: 10px;
- }
- .scoreboard {
- background-color: #1c1c3c;
- width: 40em;
- padding: 5px;
- margin: auto;
- margin-top: 10px;
- }
- table {
- width: 100%;
- background-color: #2d2d4d;
- border-spacing: 0px;
- }
- table tr:nth-of-type(2n) {
- background-color: #1c1c3c;
- }
- table td {
- padding: 4px;
- }
- .block_level table td:nth-of-type(1), .block_level table td:nth-of-type(2),
- .block_level table td:nth-of-type(4), .block_level table td:nth-of-type(5) {
- white-space: nowrap;
- }
- .block {
- background-color: #2d2d4d;
- padding: 5px;
- margin: 5px;
- }
- a {
- color: #ffffff;
- }
- a.listlink {
- text-decoration: none;
- font-size: 0.8em;
- }
- .info {
- margin-top: 25px;
- }
- input[type="text"], input[type="submit"] {
- padding: 5px;
- border-radius: 5px;
- color: white;
- background: #445;
- font-size: 16px;
- }
-
- input[type="text"]:hover {
- border-color: #f08;
- }
-
- input[type="submit"] {
- cursor: pointer;
- }
-
- input[type="submit"]:hover {
- border-color: #f08;
- }
-
- span[title] {
- text-decoration: underline dotted;
- }
- </style>
-</head>
-<body>
- {% if scoreboard %}
- {% if blockers %}
- <h1>Top {{blockers}} defederating instances</h1>
- {% elif blocked %}
- <h1>Top {{blocked}} defederated instances</h1>
- {% elif reference %}
- <h1>Top {{reference}} referencing instances</h1>
- {% elif software %}
- <h1>Top {{software}} used software</h1>
- {% endif %}
- <div class="scoreboard">
- <table>
- <th>№</th>
- <th>{% if software %}Software{% else %}Instance{% endif %}</th>
- <th>{% if reference %}References{% elif software %}Total{% else %}Blocks{% endif %}</th>
- {% for entry in scores %}
- <tr>
- <td>{{loop.index}}</td>
- <td>
- {% if software %}
- {{entry['domain']}}
- {% else %}
- <a href="{{base_url}}/?{% if blockers %}reverse{% elif blocked or reference %}domain{% endif %}={{entry['domain']}}" rel="nofollow noopener noreferrer">{{entry['domain']}}</a>
- <a class="listlink" href="https://{{entry['domain']}}" rel="external" target="_blank">↗</a>
- {% endif %}
- </td>
- <td>{{entry['highscore']}}</td>
- </tr>
- {% endfor %}
- </table>
- </div>
- {% elif reason or domain or reverse %}
- {% if reason %}
- <h1>Instances that use "{{reason}}" in their reason</h1>
- {% elif reverse %}
- <h1>Instances that are blocked by {{reverse}}</h1>
- {% elif domain %}
- <h1>Instances that block {{domain}}</h1>
- {% endif %}
- {% for block_level in blocks %}
- <div class="block_level" id="{{block_level}}">
- <h2>{{block_level}} ({{blocks[block_level]|length}})</h2>
- <table>
- <th>Blocker</th>
- <th>{% if block_level == 'accept' %}Accepted{% else %}Blocked{% endif %}</th>
- <th>Reason</th>
- <th>First added</th>
- <th>Last seen</th>
- {% for block in blocks[block_level] %}
- <tr>
- <td>
- <a href="https://{{block['blocker']}}" rel="nofollow noopener noreferrer">{{block['blocker']}}</a>
- {% if reason or domain %}<a class="listlink" href="{{base_url}}/?reverse={{block['blocker']}}">↘</a>{% endif %}
- </td>
- <td>
- <a href="https://{{domain or block['blocked']}}" rel="nofollow noopener noreferrer">{{block['blocked']}}</a>
- {% if reason or reverse %}<a class="listlink" href="{{base_url}}/?domain={{domain or block['blocked']}}">↘</a>{% endif %}
- </td>
- <td>{{block['reason']}}</td>
- <td>{{block['first_seen']}}</td>
- <td>{{block['last_seen']}}</td>
- </tr>
- {% endfor %}
- </table>
- </div>
- {% endfor %}
- {% else %}
- <h1>Enter a Domain</h1>
- <form>
- <input type="text" name="domain" placeholder="example.com" required="required" />
- <input type="submit" value="Submit" />
- </form>
- <h1>Enter a Reason</h1>
- <form>
- <input type="text" name="reason" placeholder="free speech" required="required" />
- <input type="submit" value="Submit" />
- </form>
- <h1>Reverse search</h1>
- <form>
- <input type="text" name="reverse" placeholder="example.com" required="required" />
- <input type="submit" value="Submit" />
- </form>
- <p>
- <a href="{{base_url}}/scoreboard?blockers=50">top 50 defederating</a> /
- <a href="{{base_url}}/scoreboard?blocked=50">defederated instances</a> /
- <a href="{{base_url}}/scoreboard?reference=50">referencing instances</a> /
- <a href="{{base_url}}/scoreboard?software=50">used software</a>
- </p>
- <div class="info">
- known instances: {{info.known_instances}}<br/>
- indexed instances: {{info.indexed_instances}}<br/>
- blocks recorded: {{info.blocks_recorded}}<br/>
- errorous instances: {{info.errorous_instances}}<br/>
- source code: <a href="https://git.mxchange.org/?p=fba.git;a=summary" rel="source" target="_blank">git.mxchange.org</a><br /><br />
- {{info.slogan}}
- </div>
- {% endif %}
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<rss version="2.0">
-<channel>
- <title>fedi-block-api{% if domain %} {{domain}}{% endif %}</title>
- <description>Feed of latest blocks{% if domain %} for {{domain}}{% endif %} from fedi-block-api</description>
- <pubDate>{{timestamp}}</pubDate>
- <ttl>1800</ttl>
- {% for block in blocks %}
- <item>
- <title>{{block['blocker']}} has applied '{{block['block_level']}}' restriction to {{block['blocked']}}</title>
- <description>{{block['reason']}}</description>
- <link>https://fba.ryona.agency/?reverse={{block['blocker']}}</link>
- <pubDate>{{block['first_seen']}}</pubDate>
- </item>
- {% endfor %}
-</channel>
-</rss>
--- /dev/null
+<!DOCTYPE html>
+<head>
+ <title>fedi-block-api{% if domain %} {{domain}}{% endif %}</title>
+ <link rel="alternate" type="application/rss+xml" title="RSS Feed for latest blocked instances" href="{{base_url}}/rss" />
+ {% if domain %}
+ <link rel="alternate" type="application/rss+xml" title="RSS Feed for blocked domain {{domain}}" href="{{base_url}}/rss?domain={{domain}}" />
+ {% elif reverse %}
+ <link rel="alternate" type="application/rss+xml" title="RSS Feed for blocking domain {{reverse}}" href="{{base_url}}/rss?reverse={{reverse}}" />
+ {% endif %}
+ <style>
+ body {
+ background-color: #000022;
+ color: #ffffff;
+ text-align: center;
+ font-family: sans;
+ }
+ .block_level {
+ background-color: #1c1c3c;
+ width: 80em;
+ padding: 5px;
+ margin: auto;
+ margin-top: 10px;
+ }
+ .scoreboard {
+ background-color: #1c1c3c;
+ width: 40em;
+ padding: 5px;
+ margin: auto;
+ margin-top: 10px;
+ }
+ table {
+ width: 100%;
+ background-color: #2d2d4d;
+ border-spacing: 0px;
+ }
+ table tr:nth-of-type(2n) {
+ background-color: #1c1c3c;
+ }
+ table td {
+ padding: 4px;
+ }
+ .block_level table td:nth-of-type(1), .block_level table td:nth-of-type(2),
+ .block_level table td:nth-of-type(4), .block_level table td:nth-of-type(5) {
+ white-space: nowrap;
+ }
+ .block {
+ background-color: #2d2d4d;
+ padding: 5px;
+ margin: 5px;
+ }
+ a {
+ color: #ffffff;
+ }
+ a.listlink {
+ text-decoration: none;
+ font-size: 0.8em;
+ }
+ .info {
+ margin-top: 25px;
+ }
+ input[type="text"], input[type="submit"] {
+ padding: 5px;
+ border-radius: 5px;
+ color: white;
+ background: #445;
+ font-size: 16px;
+ }
+
+ input[type="text"]:hover {
+ border-color: #f08;
+ }
+
+ input[type="submit"] {
+ cursor: pointer;
+ }
+
+ input[type="submit"]:hover {
+ border-color: #f08;
+ }
+
+ span[title] {
+ text-decoration: underline dotted;
+ }
+ </style>
+</head>
+<body>
+ {% if scoreboard %}
+ {% if blockers %}
+ <h1>Top {{blockers}} defederating instances</h1>
+ {% elif blocked %}
+ <h1>Top {{blocked}} defederated instances</h1>
+ {% elif reference %}
+ <h1>Top {{reference}} referencing instances</h1>
+ {% elif software %}
+ <h1>Top {{software}} used software</h1>
+ {% endif %}
+ <div class="scoreboard">
+ <table>
+ <th>№</th>
+ <th>{% if software %}Software{% else %}Instance{% endif %}</th>
+ <th>{% if reference %}References{% elif software %}Total{% else %}Blocks{% endif %}</th>
+ {% for entry in scores %}
+ <tr>
+ <td>{{loop.index}}</td>
+ <td>
+ {% if software %}
+ {{entry['domain']}}
+ {% else %}
+ <a href="{{base_url}}/?{% if blockers %}reverse{% elif blocked or reference %}domain{% endif %}={{entry['domain']}}" rel="nofollow noopener noreferrer">{{entry['domain']}}</a>
+ <a class="listlink" href="https://{{entry['domain']}}" rel="external" target="_blank">↗</a>
+ {% endif %}
+ </td>
+ <td>{{entry['highscore']}}</td>
+ </tr>
+ {% endfor %}
+ </table>
+ </div>
+ {% elif reason or domain or reverse %}
+ {% if reason %}
+ <h1>Instances that use "{{reason}}" in their reason</h1>
+ {% elif reverse %}
+ <h1>Instances that are blocked by {{reverse}}</h1>
+ {% elif domain %}
+ <h1>Instances that block {{domain}}</h1>
+ {% endif %}
+ {% for block_level in blocks %}
+ <div class="block_level" id="{{block_level}}">
+ <h2>{{block_level}} ({{blocks[block_level]|length}})</h2>
+ <table>
+ <th>Blocker</th>
+ <th>{% if block_level == 'accept' %}Accepted{% else %}Blocked{% endif %}</th>
+ <th>Reason</th>
+ <th>First added</th>
+ <th>Last seen</th>
+ {% for block in blocks[block_level] %}
+ <tr>
+ <td>
+ <a href="https://{{block['blocker']}}" rel="nofollow noopener noreferrer">{{block['blocker']}}</a>
+ {% if reason or domain %}<a class="listlink" href="{{base_url}}/?reverse={{block['blocker']}}">↘</a>{% endif %}
+ </td>
+ <td>
+ <a href="https://{{domain or block['blocked']}}" rel="nofollow noopener noreferrer">{{block['blocked']}}</a>
+ {% if reason or reverse %}<a class="listlink" href="{{base_url}}/?domain={{domain or block['blocked']}}">↘</a>{% endif %}
+ </td>
+ <td>{{block['reason']}}</td>
+ <td>{{block['first_seen']}}</td>
+ <td>{{block['last_seen']}}</td>
+ </tr>
+ {% endfor %}
+ </table>
+ </div>
+ {% endfor %}
+ {% else %}
+ <h1>Enter a Domain</h1>
+ <form>
+ <input type="text" name="domain" placeholder="example.com" required="required" />
+ <input type="submit" value="Submit" />
+ </form>
+ <h1>Enter a Reason</h1>
+ <form>
+ <input type="text" name="reason" placeholder="free speech" required="required" />
+ <input type="submit" value="Submit" />
+ </form>
+ <h1>Reverse search</h1>
+ <form>
+ <input type="text" name="reverse" placeholder="example.com" required="required" />
+ <input type="submit" value="Submit" />
+ </form>
+ <p>
+ <a href="{{base_url}}/scoreboard?blockers=50">top 50 defederating</a> /
+ <a href="{{base_url}}/scoreboard?blocked=50">defederated instances</a> /
+ <a href="{{base_url}}/scoreboard?reference=50">referencing instances</a> /
+ <a href="{{base_url}}/scoreboard?software=50">used software</a>
+ </p>
+ <div class="info">
+ known instances: {{info.known_instances}}<br/>
+ indexed instances: {{info.indexed_instances}}<br/>
+ blocks recorded: {{info.blocks_recorded}}<br/>
+ errorous instances: {{info.errorous_instances}}<br/>
+ source code: <a href="https://git.mxchange.org/?p=fba.git;a=summary" rel="source" target="_blank">git.mxchange.org</a><br /><br />
+ {{info.slogan}}
+ </div>
+ {% endif %}
+</body>
+</html>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<rss version="2.0">
+<channel>
+ <title>fedi-block-api{% if domain %} {{domain}}{% endif %}</title>
+ <description>Feed of latest blocks{% if domain %} for {{domain}}{% endif %} from fedi-block-api</description>
+ <pubDate>{{timestamp}}</pubDate>
+ <ttl>1800</ttl>
+ {% for block in blocks %}
+ <item>
+ <title>{{block['blocker']}} has applied '{{block['block_level']}}' restriction to {{block['blocked']}}</title>
+ <description>{{block['reason']}}</description>
+ <link>https://fba.ryona.agency/?reverse={{block['blocker']}}</link>
+ <pubDate>{{block['first_seen']}}</pubDate>
+ </item>
+ {% endfor %}
+</channel>
+</rss>