From 428ae29e787281c4d46da28579d4e84b1eef2f48 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 13 Aug 2023 20:03:59 +0200 Subject: [PATCH] Continued: - switched: PLATFORM before GENERATOR, the last one can be "personalized" --- fba/helpers/version.py | 4 +++- fba/http/federation.py | 18 +++++++++--------- templates/views/scoreboard.html | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/fba/helpers/version.py b/fba/helpers/version.py index 1396b4e..5dda159 100644 --- a/fba/helpers/version.py +++ b/fba/helpers/version.py @@ -16,6 +16,8 @@ import logging import re +from fba.helpers import software as software_helper + logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) @@ -80,7 +82,7 @@ def remove(software: str) -> str: software = temp[0:end].strip() if " version" in software: logger.debug("software='%s' contains word ' version'", software) - software = strip_until(software, " version") + software = software_helper.strip_until(software, " version") logger.debug("software='%s' - EXIT!", software) return software diff --git a/fba/http/federation.py b/fba/http/federation.py index 9b3bc2a..40564e3 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -268,15 +268,7 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str: platform = doc.find("meta", {"property": "og:platform"}) logger.debug("generator[]='%s',site_name[]='%s',platform[]='%s'", type(generator), type(site_name), type(platform)) - if isinstance(generator, bs4.element.Tag) and isinstance(generator.get("content"), str): - logger.debug("Found generator meta tag: domain='%s'", domain) - software = tidyup.domain(generator.get("content")) - - logger.debug("software[%s]='%s'", type(software), software) - if software is not None and software != "": - logger.info("domain='%s' is generated by software='%s' - Setting detection_mode=GENERATOR ...", domain, software) - instances.set_detection_mode(domain, "GENERATOR") - elif isinstance(platform, bs4.element.Tag) and isinstance(platform.get("content"), str): + if isinstance(platform, bs4.element.Tag) and isinstance(platform.get("content"), str): logger.debug("Found property=og:platform, domain='%s'", domain) software = tidyup.domain(platform.get("content")) @@ -284,6 +276,14 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str: if software is not None and software != "": logger.debug("domain='%s' has og:platform='%s' - Setting detection_mode=PLATFORM ...", domain, software) instances.set_detection_mode(domain, "PLATFORM") + elif isinstance(generator, bs4.element.Tag) and isinstance(generator.get("content"), str): + logger.debug("Found generator meta tag: domain='%s'", domain) + software = tidyup.domain(generator.get("content")) + + logger.debug("software[%s]='%s'", type(software), software) + if software is not None and software != "": + logger.info("domain='%s' is generated by software='%s' - Setting detection_mode=GENERATOR ...", domain, software) + instances.set_detection_mode(domain, "GENERATOR") elif isinstance(site_name, bs4.element.Tag) and isinstance(site_name.get("content"), str): logger.debug("Found property=og:site_name, domain='%s'", domain) software = tidyup.domain(site_name.get("content")) diff --git a/templates/views/scoreboard.html b/templates/views/scoreboard.html index 034c405..7f92de0 100644 --- a/templates/views/scoreboard.html +++ b/templates/views/scoreboard.html @@ -85,8 +85,8 @@
  1. AUTO_DISCOVERY: /.well-known/nodeinfo was reachable and software type was found in nodeinfo response
  2. STATIC_CHECK: Node information was found by probing for well-known URLs
  3. -
  4. GENERATOR: Meta data generator was found in HTML code
  5. PLATFORM: Meta data og:platform was found in HTML code
  6. +
  7. GENERATOR: Meta data generator was found in HTML code
  8. SITE_NAME: Meta data og:site_name was found in HTML code
  9. None: the instance was not reachable or the used software was not stated
-- 2.39.5