singularity-jquery 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/Rakefile +1 -0
- data/lib/assets/javascripts/singularity.js.erb +59 -0
- data/lib/singularity/jquery.rb +2 -0
- data/lib/singularity/jquery/engine.rb +5 -0
- data/lib/singularity/jquery/version.rb +5 -0
- data/singularity-jquery.gemspec +20 -0
- metadata +87 -0
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Lyconic
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,59 @@
|
|
1
|
+
var Singularity = (function () {
|
2
|
+
|
3
|
+
this.master_auth = "<%= Singularity.auth_path %>";
|
4
|
+
this.logged_in = false;
|
5
|
+
this.session_token = '';
|
6
|
+
|
7
|
+
this.extend = function ( options ) {
|
8
|
+
jQuery.extend( true, this, options );
|
9
|
+
}
|
10
|
+
|
11
|
+
this.init = function ( command ) {
|
12
|
+
if ( this.logged_in === true )
|
13
|
+
if ( command === 'register' ) {
|
14
|
+
this.registerMasterAuth();
|
15
|
+
}
|
16
|
+
|
17
|
+
if ( this.logged_in === false )
|
18
|
+
if ( command === 'lookup' ) {
|
19
|
+
this.checkMasterAuth();
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
function login ( result ) {
|
24
|
+
$(Singularity).trigger(result['logged_in'] ? 'login.success' : 'login.failure')
|
25
|
+
}
|
26
|
+
|
27
|
+
function register ( result ) {
|
28
|
+
$(Singularity).trigger(result['logged_in'] ? 'register.success' : 'register.failure');
|
29
|
+
}
|
30
|
+
|
31
|
+
var xhr, timeout;
|
32
|
+
|
33
|
+
this.checkMasterAuth = function () {
|
34
|
+
$(this).trigger('lookup');
|
35
|
+
|
36
|
+
var url = this.master_auth + '/lookup?token=' + this.session_token + '&callback=?';
|
37
|
+
xhr = $.getJSON(url).then(login).fail(function () { $(Singularity).trigger('login.failure') });
|
38
|
+
timeout = setTimeout(requestTimeout, 5000);
|
39
|
+
|
40
|
+
return xhr;
|
41
|
+
}
|
42
|
+
|
43
|
+
function requestTimeout () {
|
44
|
+
if ( xhr.readyState !== 4 ) xhr.abort();
|
45
|
+
}
|
46
|
+
|
47
|
+
this.registerMasterAuth = function () {
|
48
|
+
$(this).trigger('register');
|
49
|
+
|
50
|
+
var url = this.master_auth + '/register?token=' + this.session_token + '&callback=?';
|
51
|
+
return xhr = $.getJSON(url).then(register).fail(function () { $(Singularity).trigger('register.failure') });
|
52
|
+
}
|
53
|
+
|
54
|
+
$(this).on('login.success', function () { window.location.reload(true) });
|
55
|
+
$(this).on('login.success login.failure', function () { clearTimeout(timeout) });
|
56
|
+
|
57
|
+
return this;
|
58
|
+
|
59
|
+
}).apply({});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'singularity/jquery/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "singularity-jquery"
|
8
|
+
spec.version = Singularity::Jquery::VERSION
|
9
|
+
spec.authors = ["Adam Lassek"]
|
10
|
+
spec.email = ["alassek@lyconic.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Front-end adapter for Singularity that utilizes jQuery}
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
19
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: singularity-jquery
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Adam Lassek
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-11-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.10'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.10'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '10.0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '10.0'
|
46
|
+
description:
|
47
|
+
email:
|
48
|
+
- alassek@lyconic.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- Gemfile
|
54
|
+
- LICENSE.txt
|
55
|
+
- Rakefile
|
56
|
+
- lib/assets/javascripts/singularity.js.erb
|
57
|
+
- lib/singularity/jquery.rb
|
58
|
+
- lib/singularity/jquery/engine.rb
|
59
|
+
- lib/singularity/jquery/version.rb
|
60
|
+
- singularity-jquery.gemspec
|
61
|
+
homepage:
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.8.23.2
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: Front-end adapter for Singularity that utilizes jQuery
|
86
|
+
test_files: []
|
87
|
+
has_rdoc:
|