From de48efcf2a6b5fb096fd209b1efea482f743c19c Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 22 Jan 2013 12:02:18 +0100 Subject: some basic webfinger routes, controller, presenters, views --- users/app/controllers/webfinger_controller.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 users/app/controllers/webfinger_controller.rb (limited to 'users/app/controllers') diff --git a/users/app/controllers/webfinger_controller.rb b/users/app/controllers/webfinger_controller.rb new file mode 100644 index 0000000..e86cd2d --- /dev/null +++ b/users/app/controllers/webfinger_controller.rb @@ -0,0 +1,15 @@ +class WebfingerController < ApplicationController + + layout false + + def host_meta + @host_meta = Webfinger::HostMetaPresenter.new(request) + end + + def search + username = params[:q].split('@')[0].to_s.downcase + + user = User.find_by_login(username) + @subject = Webfinger::UserPresenter.new(user, request) + end +end -- cgit v1.2.3 From 0d1da13914675790daaf8def26f27017bf2d2a44 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 22 Jan 2013 13:07:03 +0100 Subject: render 404 if needed --- users/app/controllers/webfinger_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'users/app/controllers') diff --git a/users/app/controllers/webfinger_controller.rb b/users/app/controllers/webfinger_controller.rb index e86cd2d..ac05934 100644 --- a/users/app/controllers/webfinger_controller.rb +++ b/users/app/controllers/webfinger_controller.rb @@ -8,8 +8,8 @@ class WebfingerController < ApplicationController def search username = params[:q].split('@')[0].to_s.downcase - - user = User.find_by_login(username) + user = User.find_by_login(username) || not_found @subject = Webfinger::UserPresenter.new(user, request) end + end -- cgit v1.2.3 From 31d18779fe1af0c55b72be7bc554302322025ee5 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 22 Jan 2013 15:46:47 +0100 Subject: adding json jrd responses to webfinger --- users/app/controllers/webfinger_controller.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'users/app/controllers') diff --git a/users/app/controllers/webfinger_controller.rb b/users/app/controllers/webfinger_controller.rb index ac05934..d3a4ad3 100644 --- a/users/app/controllers/webfinger_controller.rb +++ b/users/app/controllers/webfinger_controller.rb @@ -1,15 +1,18 @@ class WebfingerController < ApplicationController + respond_to :xml, :json layout false def host_meta @host_meta = Webfinger::HostMetaPresenter.new(request) + respond_with @host_meta end def search username = params[:q].split('@')[0].to_s.downcase user = User.find_by_login(username) || not_found @subject = Webfinger::UserPresenter.new(user, request) + respond_with @subject end end -- cgit v1.2.3 From def5a00415ebced58bb0f7c1254f6cbedb27a23f Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 23 Jan 2013 09:23:18 +0100 Subject: make raising not found error less confusing --- users/app/controllers/webfinger_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'users/app/controllers') diff --git a/users/app/controllers/webfinger_controller.rb b/users/app/controllers/webfinger_controller.rb index d3a4ad3..f28dd3e 100644 --- a/users/app/controllers/webfinger_controller.rb +++ b/users/app/controllers/webfinger_controller.rb @@ -10,7 +10,8 @@ class WebfingerController < ApplicationController def search username = params[:q].split('@')[0].to_s.downcase - user = User.find_by_login(username) || not_found + user = User.find_by_login(username) + raise RECORD_NOT_FOUND, 'User not found' unless user.present? @subject = Webfinger::UserPresenter.new(user, request) respond_with @subject end -- cgit v1.2.3 From 30f406de954bac1da5fef7cdd753c0af16f11051 Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 23 Jan 2013 13:13:41 +0100 Subject: added unit tests for user presenter changed the way the presenter works. Will need functional testing --- users/app/controllers/webfinger_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'users/app/controllers') diff --git a/users/app/controllers/webfinger_controller.rb b/users/app/controllers/webfinger_controller.rb index f28dd3e..8872802 100644 --- a/users/app/controllers/webfinger_controller.rb +++ b/users/app/controllers/webfinger_controller.rb @@ -12,8 +12,8 @@ class WebfingerController < ApplicationController username = params[:q].split('@')[0].to_s.downcase user = User.find_by_login(username) raise RECORD_NOT_FOUND, 'User not found' unless user.present? - @subject = Webfinger::UserPresenter.new(user, request) - respond_with @subject + @presenter = Webfinger::UserPresenter.new(user, request) + respond_with @presenter end end -- cgit v1.2.3