webfinger mockup
authorMikael Frykholm <mikael@frykholm.com>
Tue, 29 Oct 2013 19:55:08 +0000 (20:55 +0100)
committerMikael Frykholm <mikael@frykholm.com>
Tue, 29 Oct 2013 19:55:08 +0000 (20:55 +0100)
webfinger mockup

friends/server.py [new file with mode: 0644]
friends/templates/user.xml [new file with mode: 0644]
friends/templates/xrd.xml [new file with mode: 0644]
setup.py [new file with mode: 0644]

diff --git a/friends/server.py b/friends/server.py
new file mode 100644 (file)
index 0000000..adddf23
--- /dev/null
@@ -0,0 +1,28 @@
+import tornado.ioloop
+import tornado.web
+import os
+import tornado.httpserver
+class XrdHandler(tornado.web.RequestHandler):
+    def get(self):
+        self.render("templates/xrd.xml", hostname="ronin.local", url="https://ronin.local")
+
+class UserHandler(tornado.web.RequestHandler):
+    def get(self, user):
+        #user = self.get_argument("user")
+        self.render("templates/user.xml", user=user)
+
+application = tornado.web.Application([
+    (r"/.well-known/host-meta", XrdHandler),
+    (r"/user/(.+)", UserHandler),
+    ],debug=True,
+    
+)
+srv = tornado.httpserver.HTTPServer(application, ssl_options={
+        "certfile":  "ronin.local.pem",
+        "keyfile":  "ronin.local.key",
+    })
+
+
+if __name__ == "__main__":
+    srv.listen(443)
+    tornado.ioloop.IOLoop.instance().start()
\ No newline at end of file
diff --git a/friends/templates/user.xml b/friends/templates/user.xml
new file mode 100644 (file)
index 0000000..d9862c4
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
+    <Subject>{{user}}</Subject>
+</XRD>
diff --git a/friends/templates/xrd.xml b/friends/templates/xrd.xml
new file mode 100644 (file)
index 0000000..91da8de
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
+     xmlns:hm='http://host-meta.net/xrd/1.0'>
+    <hm:Host>{{hostname}}</hm:Host>
+    <Link rel='lrdd'
+          template='{{ url }}/user/{uri}'>
+        <Title>Resource Descriptor</Title>
+    </Link>
+</XRD>
diff --git a/setup.py b/setup.py
new file mode 100644 (file)
index 0000000..ffcc9e6
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,17 @@
+from distutils.core import setup
+
+setup(
+    name='friends',
+    version='0.1.0',
+    author='Mikael Frykholm',
+    author_email='mikael@frykholm.com',
+    packages=['friends'],
+    
+    url='https://github.com/mikaelfrykholm/friends/',
+    license='LICENSE.txt',
+    description='Ostatus app.',
+    long_description=open('README.md').read(),
+    install_requires=[
+        "tornadoweb >= 3.1",
+    ],
+)