diff options
Diffstat (limited to 'users/lib/webfinger')
-rw-r--r-- | users/lib/webfinger/host_meta_presenter.rb | 17 | ||||
-rw-r--r-- | users/lib/webfinger/user_presenter.rb | 16 |
2 files changed, 33 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..3901a28 --- /dev/null +++ b/users/lib/webfinger/host_meta_presenter.rb @@ -0,0 +1,17 @@ +require 'uri' + +class Webfinger::HostMetaPresenter + def initialize(request) + @request = request + end + + def subject + url = URI.parse(@request.url) + url.path = '' + url.to_s + end + + def webfinger_template(path = 'webfinger', query_param='q') + "#{subject}/#{path}?#{query_param}={uri}" + end +end diff --git a/users/lib/webfinger/user_presenter.rb b/users/lib/webfinger/user_presenter.rb new file mode 100644 index 0000000..bbfc908 --- /dev/null +++ b/users/lib/webfinger/user_presenter.rb @@ -0,0 +1,16 @@ +class Webfinger::UserPresenter + attr_accessor :subject + + def initialize(subject, request) + @subject = subject + @request = request + end + + def email_identifier + "#{@subject.username}@#{@request.host}" + end + + def key + Base64.encode64(@subject.public_key.to_s) + end +end |