summaryrefslogtreecommitdiff
path: root/lib/webfinger/host_meta_presenter.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-05-16 08:42:36 +0200
committerAzul <azul@leap.se>2014-05-16 08:42:36 +0200
commit8fbbb8717f0578536b97c2dc0883c632f120e976 (patch)
tree17aeb2b48ada703ac916a9a65fbf3c75a5dadb86 /lib/webfinger/host_meta_presenter.rb
parent81555ec6244ed76f92e3629880f68104b8705817 (diff)
parenta4f7a410c536d88c91c834cab6ee950c71005ddd (diff)
Merge remote-tracking branch 'origin/develop'
Conflicts: app/assets/javascripts/srp test/nagios/soledad_sync.py test/nagios/webapp_login.py
Diffstat (limited to 'lib/webfinger/host_meta_presenter.rb')
-rw-r--r--lib/webfinger/host_meta_presenter.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/webfinger/host_meta_presenter.rb b/lib/webfinger/host_meta_presenter.rb
new file mode 100644
index 0000000..84ab7a9
--- /dev/null
+++ b/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