VRFS-2698 refactoring
This commit is contained in:
parent
9f27ef8429
commit
90f3d9efe1
|
|
@ -42,8 +42,4 @@ class SpikesController < ApplicationController
|
|||
render :layout => 'web'
|
||||
end
|
||||
|
||||
def username_validate
|
||||
render :layout => 'web'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,14 +1,19 @@
|
|||
= javascript_include_tag "site_validator"
|
||||
div style="width:50%"
|
||||
= render "clients/site_validator", site_type: 'url'
|
||||
= render "clients/site_validator", site_type: params[:site_type] || 'url'
|
||||
= stylesheet_link_tag "client/site_validator"
|
||||
<br />
|
||||
= select_tag "site_type", options_for_select(Utils::SITE_TYPES, params[:site_type] || 'url')
|
||||
|
||||
javascript:
|
||||
var initialized = false;
|
||||
$(document).on('JAMKAZAM_READY', function(e, data) {
|
||||
setTimeout(function() {
|
||||
window.site_validator = new JK.SiteValidator('url')
|
||||
site_validator.init()
|
||||
$('#validate_input_url').val('http://www.jamkazam.com')
|
||||
window.site_validator = new JK.SiteValidator('#{params[:site_type] || 'url'}');
|
||||
site_validator.init();
|
||||
$('#validate_input_'+'#{params[:site_type] || 'url'}').val('jonathankolyer');
|
||||
}, 1)
|
||||
})
|
||||
});
|
||||
$('#site_type').change(function(){
|
||||
location.href = 'site_validate?site_type='+$(this).val();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
= javascript_include_tag "site_validator"
|
||||
div style="width:50%"
|
||||
= render "clients/site_validator", site_type: 'youtube'
|
||||
= stylesheet_link_tag "client/site_validator"
|
||||
|
||||
javascript:
|
||||
var initialized = false;
|
||||
$(document).on('JAMKAZAM_READY', function(e, data) {
|
||||
setTimeout(function() {
|
||||
window.site_validator = new JK.SiteValidator('youtube')
|
||||
site_validator.init()
|
||||
$('#validate_input_youtube').val('jonathankolyer')
|
||||
}, 1)
|
||||
})
|
||||
|
|
@ -1,14 +1,17 @@
|
|||
class Utils
|
||||
|
||||
USERNAME_SITES = %W{youtube facebook soundcloud bandcamp fandalism twitter reverbnation}
|
||||
SITE_TYPES = ['url'].concat(USERNAME_SITES)
|
||||
|
||||
def self.username_url(username, site)
|
||||
case site
|
||||
when 'youtube'
|
||||
"https://www.youtube.com/c/#{username}"
|
||||
when 'facebook'
|
||||
when 'facebook' #
|
||||
"https://www.facebook.com/#{username}"
|
||||
when 'soundcloud'
|
||||
when 'soundcloud' #
|
||||
"https://soundcloud.com/#{username}"
|
||||
when 'bandcamp'
|
||||
when 'bandcamp' #
|
||||
"http://#{username}.bandcamp.com"
|
||||
when 'fandalism'
|
||||
"http://fandalism.com/#{username}"
|
||||
|
|
@ -21,7 +24,7 @@ class Utils
|
|||
end
|
||||
end
|
||||
|
||||
def self.url_validator(url)
|
||||
def self.site_validator(url)
|
||||
result = `curl --output /dev/null --silent --head --fail --show-error '#{url}' 2>&1`.chomp
|
||||
if $?.success?
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue