VRFS-360: added dynamic generation of jnlp pages for isp latency testing; added att, comcast, other isp options
This commit is contained in:
parent
c57b17c00a
commit
e28352c8fc
|
|
@ -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 <count>] [-s <size>] -u <url> -i <isp> [-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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +1,10 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Test Internet Latency</title>
|
||||
<script src="http://www.java.com/js/deployJava.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>My ISP is Time Warner</h1>
|
||||
<script>
|
||||
// using JavaScript to get location of JNLP
|
||||
// file relative to HTML page
|
||||
var dir = location.href.substring(0, location.href.lastIndexOf('/')+1);
|
||||
var url = dir + "pingtw.jnlp";
|
||||
deployJava.createWebStartLaunchButton(url, '1.6.0');
|
||||
</script>
|
||||
<h1>My ISP is Verizon</h1>
|
||||
<script>
|
||||
// using JavaScript to get location of JNLP
|
||||
// file relative to HTML page
|
||||
var dir = location.href.substring(0, location.href.lastIndexOf('/')+1);
|
||||
var url = dir + "pingvz.jnlp";
|
||||
deployJava.createWebStartLaunchButton(url, '1.6.0');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<%= content_for(:title) { 'Internet Latency Test' }%>
|
||||
<script src="http://www.java.com/js/deployJava.js"></script>
|
||||
<% @isps.each do |isp_id, isp_name| %>
|
||||
<h1>My ISP is <%= isp_name %></h1>
|
||||
<script>
|
||||
var url = "<%= isp_ping_url(:isp => isp_id, :format => :jnlp) %>";
|
||||
deployJava.createWebStartLaunchButton(url, '1.6.0');
|
||||
</script>
|
||||
<p>Or click <a href="https://dl.dropboxusercontent.com/u/5471230/ping/ping#{isp_id}.jnlp">here</a>.</p>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jnlp spec="1.0+" href="pingtw.jnlp" codebase="https://dl.dropboxusercontent.com/u/5471230/ping">
|
||||
<information>
|
||||
<title>Ping</title>
|
||||
<vendor>JamKazam</vendor>
|
||||
</information>
|
||||
<resources>
|
||||
<!-- Application Resources -->
|
||||
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
|
||||
<jar href="ping.jar" main="true"/>
|
||||
</resources>
|
||||
<application-desc name="Ping" main-class="com.jamkazam.ping.Ping" width="400" height="600">
|
||||
<!-- usage: Ping [label=]addr[:port] ... [-c <count>] [-s <size>] -u <url> -i <isp> [-a] -->
|
||||
<argument>foo=etch.dyndns.org:4442</argument>
|
||||
<argument>bar=etch.dyndns.org:4442</argument>
|
||||
<argument>-uhttp://www.jamkazam.com/api/users/isp_scoring</argument>
|
||||
<argument>-itw</argument>
|
||||
<argument>-a</argument>
|
||||
</application-desc>
|
||||
<update check="background"/>
|
||||
</jnlp>
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jnlp spec="1.0+" href="pingvz.jnlp" codebase="https://dl.dropboxusercontent.com/u/5471230/ping">
|
||||
<information>
|
||||
<title>Ping</title>
|
||||
<vendor>JamKazam</vendor>
|
||||
</information>
|
||||
<resources>
|
||||
<!-- Application Resources -->
|
||||
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
|
||||
<jar href="ping.jar" main="true"/>
|
||||
</resources>
|
||||
<application-desc name="Ping" main-class="com.jamkazam.ping.Ping" width="400" height="600">
|
||||
<!-- usage: Ping [label=]addr[:port] ... [-c <count>] [-s <size>] -u <url> -i <isp> [-a] -->
|
||||
<argument>foo=etch.dyndns.org:4442</argument>
|
||||
<argument>bar=etch.dyndns.org:4442</argument>
|
||||
<argument>-uhttp://www.jamkazam.com/api/users/isp_scoring</argument>
|
||||
<argument>-ivz</argument>
|
||||
<argument>-a</argument>
|
||||
</application-desc>
|
||||
<update check="background"/>
|
||||
</jnlp>
|
||||
Loading…
Reference in New Issue