$ req = web.tx.request $if req.method == "GET": <p>Bookmarklet: <a href="javascript:(function(){ window.location.href='https://ragt.ag/follow?url='+ encodeURIComponent(window.location.href) })()">Follow</a> <small>(drag to browser toolbar to install)</small></p> $ url = req.uri.query.get('url', [None])[0] <form method=post action=/rsvp> <label><small>Person URL:</small><br> <input name=person_url value="$url" style=width:30em></label><br> $if url: $ person = web.get(url).card <p>$person["name"][0]<br><img src="$person['photo'][0]"></p> <button>Follow</button> </form> <code style=font-size:.8em>$web.tx.user.session</code> $elif req.method == "POST": $ form = web.form("person_url", "response") $if token := web.tx.user.session.get("token", [None])[0]: $# mp_resp = web.post("https://micro.blog/micropub", $# headers={ $# "Authorization": f"Bearer {token}", $# "Content-Type": "application/x-www-form-urlencoded", $# }, $# data={ $# "h": "entry", $# "in_reply_to": form.event_url, $# "rsvp": form.response, $# }) $#mp_resp.text <p>Following <code>$form.person_url</code></p> $else: <p>Your host does not support access tokens.</p> |