kopia lustrzana https://github.com/snarfed/bridgy-fed
rodzic
2bae0c999c
commit
a4fede524f
|
@ -1,37 +1,19 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
|
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
|
||||||
|
|
||||||
<Subject>{{ uri }}</Subject>
|
<Subject>{{ subject }}</Subject>
|
||||||
<Alias>{{ urls[0] }}</Alias>
|
{% for alias in aliases %}
|
||||||
|
<Alias>{{ alias }}</Alias>
|
||||||
{% for url in urls %}
|
|
||||||
<Link rel='http://webfinger.net/rel/profile-page' type='text/html'
|
|
||||||
href='{{ url }}' />
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if magic_public_key %}
|
{% for link in links %}
|
||||||
|
<Link rel='{{ link.rel }}' type='{{ link.type }}' href='{{ link.href }}' />
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% for key in magic_keys %}
|
||||||
<Property xmlns:mk="http://salmon-protocol.org/ns/magic-key"
|
<Property xmlns:mk="http://salmon-protocol.org/ns/magic-key"
|
||||||
type="http://salmon-protocol.org/ns/magic-key">
|
type="http://salmon-protocol.org/ns/magic-key">
|
||||||
{{ magic_public_key }}
|
{{ key.value }}
|
||||||
</Property>
|
</Property>
|
||||||
<Link rel='magic-public-key'
|
|
||||||
href='{{ magic_public_key }}' />
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% for avatar in avatars %}
|
|
||||||
<Link rel='http://webfinger.net/rel/avatar'
|
|
||||||
href='{{ avatar }}' />
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if poco_url %}
|
|
||||||
<Link rel='http://portablecontacts.net/spec/1.0'
|
|
||||||
href='{{ poco_url }}' />
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if activitystreams_url %}
|
|
||||||
<Link rel='http://ns.opensocial.org/2008/opensocial/activitystreams'
|
|
||||||
href='{{ activitystreams_url }}' />
|
|
||||||
<Link rel='http://activitystrea.ms/spec/1.0'
|
|
||||||
href='{{ activitystreams_url }}' />
|
|
||||||
{% endif %}
|
|
||||||
</XRD>
|
</XRD>
|
||||||
|
|
10
webfinger.py
10
webfinger.py
|
@ -15,6 +15,7 @@ import logging
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
|
from granary.microformats2 import get_text
|
||||||
import mf2util
|
import mf2util
|
||||||
from oauth_dropins.webutil import handlers, util
|
from oauth_dropins.webutil import handlers, util
|
||||||
from oauth_dropins.webutil.util import json_dumps
|
from oauth_dropins.webutil.util import json_dumps
|
||||||
|
@ -31,8 +32,9 @@ class UserHandler(common.Handler, handlers.XrdOrJrdHandler):
|
||||||
"""Fetches a site's home page, converts its mf2 to WebFinger, and serves."""
|
"""Fetches a site's home page, converts its mf2 to WebFinger, and serves."""
|
||||||
JRD_TEMPLATE = False
|
JRD_TEMPLATE = False
|
||||||
|
|
||||||
@handlers.cache_response(CACHE_TIME)
|
@handlers.cache_response(CACHE_TIME, headers=['Accept'])
|
||||||
def get(self, *args, **kwargs):
|
def get(self, *args, **kwargs):
|
||||||
|
logging.debug(f'Headers: {self.request.headers.items()}')
|
||||||
return super(UserHandler, self).get(*args, **kwargs)
|
return super(UserHandler, self).get(*args, **kwargs)
|
||||||
|
|
||||||
def template_prefix(self):
|
def template_prefix(self):
|
||||||
|
@ -97,7 +99,6 @@ Couldn't find a representative h-card (http://microformats.org/wiki/representati
|
||||||
else:
|
else:
|
||||||
hub = 'https://bridgy-fed.superfeedr.com/'
|
hub = 'https://bridgy-fed.superfeedr.com/'
|
||||||
|
|
||||||
|
|
||||||
# generate webfinger content
|
# generate webfinger content
|
||||||
data = util.trim_nulls({
|
data = util.trim_nulls({
|
||||||
'subject': 'acct:' + acct,
|
'subject': 'acct:' + acct,
|
||||||
|
@ -109,7 +110,7 @@ Couldn't find a representative h-card (http://microformats.org/wiki/representati
|
||||||
'href': url,
|
'href': url,
|
||||||
}] for url in urls if url.startswith("http")), []) + [{
|
}] for url in urls if url.startswith("http")), []) + [{
|
||||||
'rel': 'http://webfinger.net/rel/avatar',
|
'rel': 'http://webfinger.net/rel/avatar',
|
||||||
'href': url,
|
'href': get_text(url),
|
||||||
} for url in props.get('photo', [])] + [{
|
} for url in props.get('photo', [])] + [{
|
||||||
'rel': 'canonical_uri',
|
'rel': 'canonical_uri',
|
||||||
'type': 'text/html',
|
'type': 'text/html',
|
||||||
|
@ -151,9 +152,6 @@ Couldn't find a representative h-card (http://microformats.org/wiki/representati
|
||||||
|
|
||||||
|
|
||||||
class WebfingerHandler(UserHandler):
|
class WebfingerHandler(UserHandler):
|
||||||
def is_jrd(self):
|
|
||||||
return True
|
|
||||||
|
|
||||||
def template_vars(self):
|
def template_vars(self):
|
||||||
resource = util.get_required_param(self, 'resource')
|
resource = util.get_required_param(self, 'resource')
|
||||||
try:
|
try:
|
||||||
|
|
Ładowanie…
Reference in New Issue