summaryrefslogtreecommitdiff
path: root/users/lib/webfinger/host_meta_presenter.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-01-25 11:46:22 +0100
committerAzul <azul@leap.se>2013-01-25 11:46:22 +0100
commitdac578781baf73a006cc78e29588dd1f6fdc0fd3 (patch)
treea56ecff398a87efdd4840a8fc897d6471fbdaa69 /users/lib/webfinger/host_meta_presenter.rb
parent75442ad26f3d30519f747bc98bc83cdc76aff750 (diff)
parent9d053b6c9b61c68bf11f95bcb37631a518f1fba4 (diff)
Merge branch 'feature/webfinger' of https://github.com/leapcode/leap_web
Conflicts: users/app/views/users/edit.html.haml
Diffstat (limited to 'users/lib/webfinger/host_meta_presenter.rb')
-rw-r--r--users/lib/webfinger/host_meta_presenter.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/users/lib/webfinger/host_meta_presenter.rb b/users/lib/webfinger/host_meta_presenter.rb
new file mode 100644
index 0000000..84ab7a9
--- /dev/null
+++ b/users/lib/webfinger/host_meta_presenter.rb
@@ -0,0 +1,30 @@
+require 'uri'
+
+class Webfinger::HostMetaPresenter
+ def initialize(request)
+ @request = request
+ end
+
+ def to_json(options = {})
+ {
+ subject: subject,
+ links: links
+ }.to_json(options)
+ end
+
+ def subject
+ url = URI.parse(@request.url)
+ url.path = ''
+ url.to_s
+ end
+
+ def links
+ { lrdd: { type: 'application/xrd+xml', template: webfinger_template } }
+ end
+
+ protected
+
+ def webfinger_template(path = 'webfinger', query_param='q')
+ "#{subject}/#{path}?#{query_param}={uri}"
+ end
+end