From e28352c8fce14e58fcd2ab5b8be8a56fcb96c9ee Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Thu, 13 Jun 2013 22:34:34 -0500 Subject: [PATCH] VRFS-360: added dynamic generation of jnlp pages for isp latency testing; added att, comcast, other isp options --- app/controllers/users_controller.rb | 46 +++++++++++++++++++++++++++++ app/views/users/isp.html.erb | 34 +++++++-------------- config/routes.rb | 3 +- public/pingtw.jnlp | 21 ------------- public/pingvz.jnlp | 21 ------------- 5 files changed, 58 insertions(+), 67 deletions(-) delete mode 100644 public/pingtw.jnlp delete mode 100644 public/pingvz.jnlp diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b220ffd8a..4a6a022d9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,3 +1,7 @@ +# -*- coding: utf-8 -*- + +require 'builder' + class UsersController < ApplicationController before_filter :signed_in_user, only: [:index, :edit, :update, :destroy] @@ -177,7 +181,49 @@ class UsersController < ApplicationController render :layout => 'landing' end + def jnlp + headers["Content-Type"] = "application/x-java-jnlp-file" + headers["Cache-Control"] = "public" + headers["Content-Disposition"] = "attachment;filename='ping#{params[:isp]}.jnlp'" + jnlp = '' + xml = Builder::XmlMarkup.new(:indent => 2, :target => jnlp) + xml.instruct! + xml.jnlp(:spec => '1.0+', + :href => "ping#{params[:isp]}.jnlp", + :codebase => "https://dl.dropboxusercontent.com/u/5471230/ping") do + xml.information do + xml.title 'Ping' + xml.vendor 'JamKazam' + end + xml.resources do + xml.j2ee(:version => "1.6+", :href => "http://java.sun.com/products/autodl/j2se") + xml.jar(:href => 'ping.jar', :main => 'true') + end + xml.tag!('application-desc', + :name => "Ping", + 'main-class' => "com.jamkazam.ping.Ping", + :width => "400", + :height => "600") do + xml.comment!('usage: Ping [label=]addr[:port] ... [-c ] [-s ] -u -i [-a]') + xml.argument('foo=etch.dyndns.org:4442') + xml.argument('bar=etch.dyndns.org:4442') + xml.argument("-uhttp://www.jamkazam.com#{isp_scoring_path}") + xml.argument("-i#{params[:isp]}") + xml.argument('-a') + end + xml.update(:check => 'background') + end + send_data jnlp, :type=>"application/x-java-jnlp-file" + end + def isp + @isps = { + 'tw' => 'Time Warner', + 'vz' => 'Verizon', + 'att' => 'AT&T', + 'cc' => 'Comcast', + 'other' => 'Other' + } render :layout => "landing" end diff --git a/app/views/users/isp.html.erb b/app/views/users/isp.html.erb index ce89a418a..4ca344f50 100644 --- a/app/views/users/isp.html.erb +++ b/app/views/users/isp.html.erb @@ -1,24 +1,10 @@ - - - Test Internet Latency - - - -

My ISP is Time Warner

- -

My ISP is Verizon

- - - +<%= content_for(:title) { 'Internet Latency Test' }%> + +<% @isps.each do |isp_id, isp_name| %> +

My ISP is <%= isp_name %>

+ +

Or click here.

+<% end %> diff --git a/config/routes.rb b/config/routes.rb index bb806f418..a2cce809b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -27,6 +27,7 @@ SampleApp::Application.routes.draw do match '/auth/failure', :to => 'sessions#failure' match '/isp', :to => 'users#isp' + match '/isp/ping:isp', :to => 'users#jnlp', :constraints => {:format => :jnlp}, :as => 'isp_ping' match '/help', to: 'static_pages#help' match '/about', to: 'static_pages#about' @@ -71,7 +72,7 @@ SampleApp::Application.routes.draw do match '/genres' => 'api_genres#index', :via => :get # users - match '/users/isp_scoring' => 'api_users#isp_scoring', :via => :post + match '/users/isp_scoring' => 'api_users#isp_scoring', :via => :post , :as => 'isp_scoring' match '/users' => 'api_users#index', :via => :get match '/users/:id' => 'api_users#show', :via => :get, :as => 'api_user_detail' diff --git a/public/pingtw.jnlp b/public/pingtw.jnlp deleted file mode 100644 index 8f10cd814..000000000 --- a/public/pingtw.jnlp +++ /dev/null @@ -1,21 +0,0 @@ - - - - Ping - JamKazam - - - - - - - - - foo=etch.dyndns.org:4442 - bar=etch.dyndns.org:4442 - -uhttp://www.jamkazam.com/api/users/isp_scoring - -itw - -a - - - diff --git a/public/pingvz.jnlp b/public/pingvz.jnlp deleted file mode 100644 index 87e31ab97..000000000 --- a/public/pingvz.jnlp +++ /dev/null @@ -1,21 +0,0 @@ - - - - Ping - JamKazam - - - - - - - - - foo=etch.dyndns.org:4442 - bar=etch.dyndns.org:4442 - -uhttp://www.jamkazam.com/api/users/isp_scoring - -ivz - -a - - - \ No newline at end of file