diff --git a/Gemfile b/Gemfile index cab573d..34b7d6d 100644 --- a/Gemfile +++ b/Gemfile @@ -23,6 +23,7 @@ gem 'dynamic_form', '~> 1.1.4' gem 'country_code_select', '~> 1.0.1' gem 'active_link_to', '~> 1.0.2' gem 'rmagick', '~> 2.13.2', require: false +gem 'steam-condenser', github: 'koraktor/steam-condenser-ruby' # Please install nodejs locally. gem 'therubyracer', '~> 0.12.1' if RUBY_PLATFORM == 'x86_64-linux' diff --git a/Gemfile.lock b/Gemfile.lock index ddc067b..11f37e6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,11 @@ +GIT + remote: git://github.com/koraktor/steam-condenser-ruby.git + revision: c8a7b69d3dc73d56c1de6b6653ec45491d047db1 + specs: + steam-condenser (1.3.9) + multi_json (~> 1.6) + multi_xml (~> 0.5) + GEM remote: http://rubygems.org/ specs: @@ -128,6 +136,7 @@ GEM mime-types (1.25.1) mini_portile (0.5.3) multi_json (1.10.1) + multi_xml (0.5.5) multipart-post (2.0.0) mysql2 (0.3.15) neat (1.6.0) @@ -295,6 +304,7 @@ DEPENDENCIES selenium-webdriver (~> 2.41.0) simplecov (~> 0.7.1) sprockets (~> 2.2.1) + steam-condenser! timecop (~> 0.7.1) tinymce-rails (~> 3.5.9) uglifier (~> 2.5.0) diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index 29a6f8f..cc5b14b 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -34,4 +34,15 @@ $ -> $('select.autosubmit').change -> $(this).closest('form').submit() - $('#notification').delay(3000).fadeOut() \ No newline at end of file + $('#notification').delay(3000).fadeOut() + + $('#steam-search a').click (event) -> + event.preventDefault() + + $search = $('#steam-search') + id = $search.data 'user-id' + + $search.html "
Searching...
" + + $.get "/api/v1/users/#{id}", (data) -> + $search.html "Steam Profile: #{data.steam.nickname}" diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 1898db6..95128cf 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -1,5 +1,17 @@ class Api::V1::UsersController < Api::V1::BaseController def index - respond_with Api::V1::UsersCollection.as_json + render json: Api::V1::UsersCollection.as_json + end + + def show + @user = User.find(params[:id]) + @steam = SteamCondenser::Community::SteamId.from_steam_id("STEAM_#{@user.steamid}") + + render json: { + steam: { + url: @steam.base_url, + nickname: @steam.nickname + } + } end end diff --git a/app/views/users/_general.html.erb b/app/views/users/_general.html.erb index 509f423..4dfb4c6 100644 --- a/app/views/users/_general.html.erb +++ b/app/views/users/_general.html.erb @@ -10,8 +10,10 @@<%= @user.steamid %>
+