$ domain = web.tx.request.uri.query.get("domain", [None])[0] <form> <label>Domain: <input name=domain value="$domain"><label> <button>Validate</button> </form> $if domain: $ website = web.get(domain) $if card := website.card: <div style="display:grid;grid-template-columns:8em auto;"> $if photo := card.get("photo", [None])[0]: $if "value" in photo and "alt" in photo: $ img_src = photo["value"] $ img_alt = photo["alt"] $else: $ img_src = photo $ img_alt = "" <div><img src=$:img_src alt="$:img_alt" style=max-width:100%></div> <div> <h2 style=margin-top:0><big>$card["name"][0]</big></h2> $if note := card.pop("note", [None])[0]: <p>$:note.replace("\n", " ")</p> $if email := card.pop("email", [None])[0]: <p>$email<p> $if key := card.pop("key", [None])[0]: <p>$key</p> </div> </div> $if feed := website.feed: $if card and feed and card["name"][0] != feed["name"]: <h3>$feed["name"]</h3> <ul> $for item in feed["items"]: $ type = item.pop("type")[0].partition("-")[2] $ item.pop("author", None) <li> <small>$type</small> <div>$item.pop("url")[0] $item.pop("published")[0] $item.pop("updated", [None])[0]</div> <pre>$:item</pre> </li> </ul> $ mf2json = website.mf2json <h4>Rels</h4> <dl> $for rel, rel_values in sorted(mf2json["rels"].items()): <dt>$rel <dd><ul> $for rel_value in rel_values: $ stripped_rel_value = rel_value $for removal in (domain, f"www.{domain}", f"https://{domain}", f"https://www.{domain}", f"http://{domain}", f"http://www.{domain}"): $ stripped_rel_value = stripped_rel_value.removeprefix(removal) <li> $if stripped_rel_value.startswith("/"): <a href=$rel_value>$stripped_rel_value</a> $else: <a href=$rel_value>$rel_value</a> </ul> </dl> <style> form { margin-bottom: 1em; } dl { align-items: start; display: grid; font-size: .8em; grid-template-columns: 1fr 7fr; } dt { grid-column: 1; font-weight: bold; } dd { grid-column: 2; margin: 0; } </style> |