personage 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/personage/engine.rb +21 -14
- data/lib/personage/version.rb +1 -1
- data/personage-0.0.1.gem +0 -0
- data/personage.gemspec +1 -1
- data/vendor/assets/javascripts/personage.js +120 -0
- metadata +5 -4
data/lib/personage/engine.rb
CHANGED
@@ -1,17 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Engine < Rails::Engine
|
4
|
-
|
5
|
-
initializer "personage.load_app_instance_data" do |app|
|
6
|
-
Personage.setup do |config|
|
7
|
-
config.app_root = app.root
|
8
|
-
end
|
9
|
-
end
|
1
|
+
require 'rails'
|
10
2
|
|
11
|
-
|
12
|
-
app.middleware.use ::ActionDispatch::Static, "#{root}/public"
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
3
|
+
module Personage
|
16
4
|
|
5
|
+
module Rails
|
6
|
+
class Engine < ::Rails::Engine
|
7
|
+
|
8
|
+
initializer "personage.load_app_instance_data" do |app|
|
9
|
+
Personage.setup do |config|
|
10
|
+
config.app_root = app.root
|
11
|
+
unless ENV["RAILS_ENV"] == 'production'
|
12
|
+
app.config.assets.precompile += %w{ load_personage.js }
|
13
|
+
app.config.session_store :cookie_store, :httponly => false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
initializer "personage.load_static_assets" do |app|
|
19
|
+
app.middleware.use ::ActionDispatch::Static, "#{root}/public"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
17
24
|
end
|
data/lib/personage/version.rb
CHANGED
data/personage-0.0.1.gem
ADDED
Binary file
|
data/personage.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.authors = [ "Zane Shannon" ]
|
11
11
|
s.email = [ "z@zcs.me" ]
|
12
|
-
s.homepage = "http://github.com/zshannon"
|
12
|
+
s.homepage = "http://github.com/zshannon/personage"
|
13
13
|
s.description = "Personage lets your manage your user sessions."
|
14
14
|
s.summary = "team_page-#{s.version}"
|
15
15
|
|
@@ -0,0 +1,120 @@
|
|
1
|
+
var Personage = {isAlt:false};
|
2
|
+
Personage.listenForActivationKeys = function() {
|
3
|
+
$(document).keyup(function (e) {
|
4
|
+
if(e.which == 18) Personage.isAlt=false;
|
5
|
+
}).keydown(function (e) {
|
6
|
+
if(e.which == 18) Personage.isAlt=true;
|
7
|
+
if(e.which == 9 && Personage.isAlt == true) {
|
8
|
+
Personage.showSwitcher();
|
9
|
+
return false;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
}
|
13
|
+
Personage.listenForSwitchButtons = function() {
|
14
|
+
$('.personage_switch_session').unbind('click');
|
15
|
+
$('.personage_switch_session').click(function(e){
|
16
|
+
e.preventDefault();
|
17
|
+
Personage.switchSession($(e.target).attr('personage_session_id'));
|
18
|
+
return false;
|
19
|
+
});
|
20
|
+
$('.personage_delete_session').unbind('click');
|
21
|
+
$('.personage_delete_session').click(function(e){
|
22
|
+
e.preventDefault();
|
23
|
+
Personage.removeSession($(e.target).attr('personage_session_id'));
|
24
|
+
$(e.target).parent().parent().parent().remove();
|
25
|
+
return false;
|
26
|
+
});
|
27
|
+
}
|
28
|
+
Personage.getCookies = function(){
|
29
|
+
var pairs = document.cookie.split(";");
|
30
|
+
var cookies = {};
|
31
|
+
for (var i=0; i<pairs.length; i++){
|
32
|
+
var pair = pairs[i].split("=");
|
33
|
+
cookies[pair[0]] = unescape(pair[1]);
|
34
|
+
}
|
35
|
+
return cookies;
|
36
|
+
}
|
37
|
+
Personage.showSwitcher = function() {
|
38
|
+
if (!Personage.modal) {
|
39
|
+
Personage.modal = $('<div class="modal hide fade in" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h3>Personage</h3></div><div class="modal-body"><table id="personage_session_list" class="table"></table></div><div class="modal-footer form-search"><div class="input-append"><input type="text" class="span3 search-query" placeholder="User A Session" id="personage_session_name"><a href="#" class="btn btn-primary personage_switch_session">Start New Session</a></div></div></div>');
|
40
|
+
$('body').append(Personage.modal);
|
41
|
+
}
|
42
|
+
Personage.populateSessionList();
|
43
|
+
Personage.listenForSwitchButtons();
|
44
|
+
Personage.modal.modal('show');
|
45
|
+
}
|
46
|
+
Personage.populateSessionList = function() {
|
47
|
+
list = $('#personage_session_list');
|
48
|
+
list.children().remove(); // clear list
|
49
|
+
sessions = Personage.getSessions();
|
50
|
+
if (sessions.length == 0) {
|
51
|
+
list.append('<tr><td><p class="lead">No Sessions. Start one with the blue button.</p></td><td></td></tr>');
|
52
|
+
}
|
53
|
+
else {
|
54
|
+
$.each(sessions, function(i,id){
|
55
|
+
list.append('<tr><td>' + Personage.getSessionName(id) + '</td><td><div class="btn-group pull-right"><a href="#" class="personage_switch_session btn" personage_session_id="'+id+'">Adopt</a><a href="#" class="personage_delete_session btn btn-danger" personage_session_id="'+id+'">Delete</a></div></td></tr>');
|
56
|
+
});
|
57
|
+
}
|
58
|
+
}
|
59
|
+
Personage.getSessions = function() {
|
60
|
+
sessions = JSON.parse(localStorage.getItem('personage_sessions'));
|
61
|
+
if (!sessions) sessions = [];
|
62
|
+
return sessions;
|
63
|
+
}
|
64
|
+
Personage.setSessions = function(new_sessions) {
|
65
|
+
localStorage.setItem('personage_sessions', JSON.stringify(new_sessions));
|
66
|
+
}
|
67
|
+
Personage.getSessionName = function(id) {
|
68
|
+
return localStorage.getItem('personage_session_name_'+id);
|
69
|
+
}
|
70
|
+
Personage.setSessionName = function(id, name) {
|
71
|
+
localStorage.setItem('personage_session_name_'+id, name);
|
72
|
+
}
|
73
|
+
Personage.getSession = function(id) {
|
74
|
+
s = localStorage.getItem('personage_session_'+id);
|
75
|
+
if (!s) s = '';
|
76
|
+
return s;
|
77
|
+
}
|
78
|
+
Personage.setSession = function(id, session) {
|
79
|
+
localStorage.setItem('personage_session_'+id, session);
|
80
|
+
}
|
81
|
+
Personage.newSessionId = function() {
|
82
|
+
sessions = Personage.getSessions();
|
83
|
+
id = 1 + sessions.length;
|
84
|
+
sessions.push(id);
|
85
|
+
Personage.setSessions(sessions);
|
86
|
+
return id;
|
87
|
+
}
|
88
|
+
Personage.clearCookies = function() {
|
89
|
+
cookies = document.cookie.split(";");
|
90
|
+
for (var i = 0; i < cookies.length; i++) {
|
91
|
+
var cookie = cookies[i];
|
92
|
+
var eqPos = cookie.indexOf("=");
|
93
|
+
var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
|
94
|
+
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
|
95
|
+
}
|
96
|
+
}
|
97
|
+
Personage.switchSession = function(session_id) {
|
98
|
+
if (!session_id) {
|
99
|
+
session_id = Personage.newSessionId();
|
100
|
+
name = $('#personage_session_name').val();
|
101
|
+
if (name.length == 0) name = "Session #" + session_id;
|
102
|
+
Personage.setSessionName(session_id, name);
|
103
|
+
Personage.setSession(session_id, document.cookie);
|
104
|
+
Personage.clearCookies();
|
105
|
+
}
|
106
|
+
else {
|
107
|
+
console.log(Personage.getSession(session_id));
|
108
|
+
document.cookie = Personage.getSession(session_id);
|
109
|
+
}
|
110
|
+
document.location.reload(true);
|
111
|
+
}
|
112
|
+
Personage.removeSession = function(id) {
|
113
|
+
sessions = Personage.getSessions();
|
114
|
+
sessions.splice(sessions.indexOf(id), 1);
|
115
|
+
Personage.setSessions(sessions);
|
116
|
+
localStorage.removeItem('personage_session_'+id);
|
117
|
+
localStorage.removeItem('personage_session_name_'+id);
|
118
|
+
}
|
119
|
+
|
120
|
+
Personage.listenForActivationKeys();
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: personage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/personage.rb
|
77
77
|
- lib/personage/engine.rb
|
78
78
|
- lib/personage/version.rb
|
79
|
+
- personage-0.0.1.gem
|
79
80
|
- personage.gemspec
|
80
81
|
- test/dummy/Rakefile
|
81
82
|
- test/dummy/app/controllers/application_controller.rb
|
@@ -115,7 +116,7 @@ files:
|
|
115
116
|
- test/test_helper.rb
|
116
117
|
- test/test_personage.rb
|
117
118
|
- vendor/assets/javascripts/personage.js
|
118
|
-
homepage: http://github.com/zshannon
|
119
|
+
homepage: http://github.com/zshannon/personage
|
119
120
|
licenses: []
|
120
121
|
post_install_message:
|
121
122
|
rdoc_options: []
|
@@ -138,6 +139,6 @@ rubyforge_project: personage
|
|
138
139
|
rubygems_version: 1.8.21
|
139
140
|
signing_key:
|
140
141
|
specification_version: 3
|
141
|
-
summary: team_page-0.0.
|
142
|
+
summary: team_page-0.0.2
|
142
143
|
test_files: []
|
143
144
|
has_rdoc:
|