iam 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -31,7 +31,7 @@ Also you may log in using user_id (e.g. 42):
31
31
  Add gem to your gemfile:
32
32
 
33
33
  ```ruby
34
- gem 'iam', '~> 0.1.10'
34
+ gem 'iam', '~> 0.1.11'
35
35
  ```
36
36
  ##Configuration
37
37
 
data/Rakefile CHANGED
@@ -37,8 +37,8 @@ def uglify_js
37
37
  require 'uglifier'
38
38
 
39
39
  Dir[File.join('vendor', 'assets', 'javascripts', '*.js')].each do |file|
40
- uglified_file = file.gsub /js\Z/, 'ujs'
41
- File.open(uglified_file, 'w') { |f| f << Uglifier.compile(File.read(file)) }
40
+ javascript = File.read(file)
41
+ File.open(file, 'w') { |f| f << Uglifier.compile(javascript) }
42
42
  p "File #{file} uglified"
43
43
  end
44
44
  end
data/lib/iam/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Iam
2
- VERSION = '0.1.10'
2
+ VERSION = '0.1.11'
3
3
  end
@@ -1,26 +1,18 @@
1
1
  module Rack
2
2
  module AssetHelpers
3
- def html_code
4
- (css_code << js_code).gsub '\\', '\\\\\\\\'
3
+ TEMPLATE = ActionView::Base.new
4
+
5
+ def head_code
6
+ css_code << js_code
5
7
  end
6
8
 
7
9
  private
8
10
  def css_code
9
- "<style type='text/css'>#{typed_asset('stylesheets', 'iam.css')}</style>"
11
+ TEMPLATE.stylesheet_link_tag 'iam'
10
12
  end
11
13
 
12
14
  def js_code
13
- "<script type='text/javascript'>#{typed_asset('javascripts', 'iam.ujs', 'jquery.cookie.ujs')}</script>"
14
- end
15
-
16
- def typed_asset(type, *files)
17
- files.map { |f| asset type, f }.reduce :+
18
- end
19
-
20
- def asset(type, file)
21
- @assets ||= {}
22
- output = ::File.read ::File.join(::File.dirname(__FILE__), '..', '..', 'vendor', 'assets', type, file)
23
- @assets[file] ||= output
15
+ TEMPLATE.javascript_include_tag 'iam', 'jquery.cookie'
24
16
  end
25
17
  end
26
18
  end
data/lib/rack/assets.rb CHANGED
@@ -17,7 +17,7 @@ module Rack
17
17
  end
18
18
 
19
19
  # Inject the html, css and js code to the view
20
- response_body.gsub!('</body>', "#{html_code}</body>")
20
+ response_body.gsub!('</head>', "#{head_code}</head>")
21
21
 
22
22
  headers['Content-Length'] = response_body.bytesize.to_s
23
23
 
@@ -1,101 +1,2 @@
1
1
  // Generated by CoffeeScript 1.3.3
2
- (function() {
3
-
4
- $(function() {
5
- var $menu, controlKeys, controlKeysMatch, iamNotice, initialize, input, inputMode, inputSelected, isTilde, logInByInput, logInByLink, menuLink, processInput, templateLink;
6
- $menu = $('#iam-menu');
7
- templateLink = '/iam/log_in_as/:id';
8
- menuLink = '/iam/menu';
9
- inputMode = false;
10
- input = '';
11
- controlKeys = ['alt', 'ctrl', 'shift'];
12
- initialize = function() {
13
- $('.iam-settings-header').on('click', function() {
14
- return $('.iam-settings').toggle();
15
- });
16
- $('#iam-menu').on('click', 'td', function() {
17
- var $tr, link;
18
- $tr = $(this).parents('tr');
19
- link = $tr.attr('href');
20
- if (link) {
21
- return logInByLink(link);
22
- }
23
- });
24
- return $.each(controlKeys, function() {
25
- var $checkbox, cookieName;
26
- $checkbox = $(".iam-" + this + "-settings input");
27
- cookieName = "iam-" + this + "-checked";
28
- $checkbox[0].checked = $.cookie(cookieName) === 'true';
29
- return $checkbox.on('click', function() {
30
- return $.cookie(cookieName, this.checked);
31
- });
32
- });
33
- };
34
- iamNotice = function(notice) {
35
- var $notice;
36
- $notice = $("<div class='iam-notice'>" + notice + "</div>");
37
- $('body').append($notice);
38
- return $notice.fadeIn(200).delay(1000).fadeOut(600);
39
- };
40
- logInByLink = function(link) {
41
- return $.post(link, function(data) {
42
- $menu.hide();
43
- window.location.reload();
44
- return iamNotice(data.notice);
45
- });
46
- };
47
- isTilde = function(code) {
48
- return String.fromCharCode(code) === 'À';
49
- };
50
- controlKeysMatch = function(e) {
51
- var key, keyOn, _i, _len;
52
- for (_i = 0, _len = controlKeys.length; _i < _len; _i++) {
53
- key = controlKeys[_i];
54
- keyOn = $.cookie("iam-" + key + "-checked") === 'true';
55
- if (keyOn !== e["" + key + "Key"]) {
56
- return false;
57
- }
58
- }
59
- return true;
60
- };
61
- inputSelected = function() {
62
- return $(document.getSelection().focusNode).find('input, textarea').length > 0;
63
- };
64
- processInput = function(input) {
65
- var link;
66
- if (input.match(/^\d+$/)) {
67
- link = templateLink.replace(/:id/, input);
68
- return logInByLink(link);
69
- } else {
70
- if (input) {
71
- return iamNotice("" + input + " is invalid id.");
72
- }
73
- }
74
- };
75
- logInByInput = function() {
76
- if (inputMode) {
77
- processInput(input);
78
- $('#iam-menu').remove();
79
- } else {
80
- $.get(menuLink, function(menu) {
81
- $('body').append(menu);
82
- return initialize();
83
- });
84
- }
85
- return input = '';
86
- };
87
- return $(document).on('keydown', function(e) {
88
- var _ref;
89
- if (!inputSelected() && isTilde(e.keyCode) && controlKeysMatch(e)) {
90
- logInByInput();
91
- inputMode = !inputMode;
92
- return $menu.toggle();
93
- } else {
94
- if ((48 <= (_ref = e.keyCode) && _ref <= 57)) {
95
- return input += String.fromCharCode(e.keyCode);
96
- }
97
- }
98
- });
99
- });
100
-
101
- }).call(this);
2
+ (function(){$(function(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p;return e=$("#iam-menu"),p="/iam/log_in_as/:id",c="/iam/menu",o=!1,s="",t=["alt","ctrl","shift"],i=function(){return $(".iam-settings-header").on("click",function(){return $(".iam-settings").toggle()}),$("#iam-menu").on("click","td",function(){var e,t;e=$(this).parents("tr"),t=e.attr("href");if(t)return l(t)}),$.each(t,function(){var e,t;return e=$(".iam-"+this+"-settings input"),t="iam-"+this+"-checked",e[0].checked=$.cookie(t)==="true",e.on("click",function(){return $.cookie(t,this.checked)})})},r=function(e){var t;return t=$("<div class='iam-notice'>"+e+"</div>"),$("body").append(t),t.fadeIn(200).delay(1e3).fadeOut(600)},l=function(t){return $.post(t,function(t){return e.hide(),window.location.reload(),r(t.notice)})},a=function(e){return String.fromCharCode(e)==="À"},n=function(e){var n,r,i,s;for(i=0,s=t.length;i<s;i++){n=t[i],r=$.cookie("iam-"+n+"-checked")==="true";if(r!==e[""+n+"Key"])return!1}return!0},u=function(){return $(document.getSelection().focusNode).find("input, textarea").length>0},h=function(e){var t;if(e.match(/^\d+$/))return t=p.replace(/:id/,e),l(t);if(e)return r(""+e+" is invalid id.")},f=function(){return o?(h(s),$("#iam-menu").remove()):$.get(c,function(e){return $("body").append(e),i()}),s=""},$(document).on("keydown",function(t){var r;if(!u()&&a(t.keyCode)&&n(t))return f(),o=!o,e.toggle();if(48<=(r=t.keyCode)&&r<=57)return s+=String.fromCharCode(t.keyCode)})})}).call(this);
@@ -7,66 +7,4 @@
7
7
  * http://www.opensource.org/licenses/mit-license.php
8
8
  * http://www.opensource.org/licenses/GPL-2.0
9
9
  */
10
- (function ($, document, undefined) {
11
-
12
- var pluses = /\+/g;
13
-
14
- function raw(s) {
15
- return s;
16
- }
17
-
18
- function decoded(s) {
19
- return decodeURIComponent(s.replace(pluses, ' '));
20
- }
21
-
22
- var config = $.cookie = function (key, value, options) {
23
-
24
- // write
25
- if (value !== undefined) {
26
- options = $.extend({}, config.defaults, options);
27
-
28
- if (value === null) {
29
- options.expires = -1;
30
- }
31
-
32
- if (typeof options.expires === 'number') {
33
- var days = options.expires, t = options.expires = new Date();
34
- t.setDate(t.getDate() + days);
35
- }
36
-
37
- value = config.json ? JSON.stringify(value) : String(value);
38
-
39
- return (document.cookie = [
40
- encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
41
- options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
42
- options.path ? '; path=' + options.path : '',
43
- options.domain ? '; domain=' + options.domain : '',
44
- options.secure ? '; secure' : ''
45
- ].join(''));
46
- }
47
-
48
- // read
49
- var decode = config.raw ? raw : decoded;
50
- var cookies = document.cookie.split('; ');
51
- for (var i = 0, l = cookies.length; i < l; i++) {
52
- var parts = cookies[i].split('=');
53
- if (decode(parts.shift()) === key) {
54
- var cookie = decode(parts.join('='));
55
- return config.json ? JSON.parse(cookie) : cookie;
56
- }
57
- }
58
-
59
- return null;
60
- };
61
-
62
- config.defaults = {};
63
-
64
- $.removeCookie = function (key, options) {
65
- if ($.cookie(key) !== null) {
66
- $.cookie(key, null, options);
67
- return true;
68
- }
69
- return false;
70
- };
71
-
72
- })(jQuery, document);
10
+ (function(e,t,n){function i(e){return e}function s(e){return decodeURIComponent(e.replace(r," "))}var r=/\+/g,o=e.cookie=function(r,u,a){if(u!==n){a=e.extend({},o.defaults,a),u===null&&(a.expires=-1);if(typeof a.expires=="number"){var f=a.expires,l=a.expires=new Date;l.setDate(l.getDate()+f)}return u=o.json?JSON.stringify(u):String(u),t.cookie=[encodeURIComponent(r),"=",o.raw?u:encodeURIComponent(u),a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+a.domain:"",a.secure?"; secure":""].join("")}var c=o.raw?i:s,h=t.cookie.split("; ");for(var p=0,d=h.length;p<d;p++){var v=h[p].split("=");if(c(v.shift())===r){var m=c(v.join("="));return o.json?JSON.parse(m):m}}return null};o.defaults={},e.removeCookie=function(t,n){return e.cookie(t)!==null?(e.cookie(t,null,n),!0):!1}})(jQuery,document);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -267,9 +267,7 @@ files:
267
267
  - spec/support/database_cleaner.rb
268
268
  - vendor/assets/javascripts/iam.coffee
269
269
  - vendor/assets/javascripts/iam.js
270
- - vendor/assets/javascripts/iam.ujs
271
270
  - vendor/assets/javascripts/jquery.cookie.js
272
- - vendor/assets/javascripts/jquery.cookie.ujs
273
271
  - vendor/assets/stylesheets/.sass-cache/99c7326b15538dc9b4651af91a5f076fe779d5ec/iam.css.sassc
274
272
  - vendor/assets/stylesheets/iam.css
275
273
  - vendor/assets/stylesheets/iam.css.sass
@@ -1,2 +0,0 @@
1
- // Generated by CoffeeScript 1.3.3
2
- (function(){$(function(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p;return e=$("#iam-menu"),p="/iam/log_in_as/:id",c="/iam/menu",o=!1,s="",t=["alt","ctrl","shift"],i=function(){return $(".iam-settings-header").on("click",function(){return $(".iam-settings").toggle()}),$("#iam-menu").on("click","td",function(){var e,t;e=$(this).parents("tr"),t=e.attr("href");if(t)return l(t)}),$.each(t,function(){var e,t;return e=$(".iam-"+this+"-settings input"),t="iam-"+this+"-checked",e[0].checked=$.cookie(t)==="true",e.on("click",function(){return $.cookie(t,this.checked)})})},r=function(e){var t;return t=$("<div class='iam-notice'>"+e+"</div>"),$("body").append(t),t.fadeIn(200).delay(1e3).fadeOut(600)},l=function(t){return $.post(t,function(t){return e.hide(),window.location.reload(),r(t.notice)})},a=function(e){return String.fromCharCode(e)==="À"},n=function(e){var n,r,i,s;for(i=0,s=t.length;i<s;i++){n=t[i],r=$.cookie("iam-"+n+"-checked")==="true";if(r!==e[""+n+"Key"])return!1}return!0},u=function(){return $(document.getSelection().focusNode).find("input, textarea").length>0},h=function(e){var t;if(e.match(/^\d+$/))return t=p.replace(/:id/,e),l(t);if(e)return r(""+e+" is invalid id.")},f=function(){return o?(h(s),$("#iam-menu").remove()):$.get(c,function(e){return $("body").append(e),i()}),s=""},$(document).on("keydown",function(t){var r;if(!u()&&a(t.keyCode)&&n(t))return f(),o=!o,e.toggle();if(48<=(r=t.keyCode)&&r<=57)return s+=String.fromCharCode(t.keyCode)})})}).call(this);
@@ -1,10 +0,0 @@
1
- /*!
2
- * jQuery Cookie Plugin v1.3
3
- * https://github.com/carhartl/jquery-cookie
4
- *
5
- * Copyright 2011, Klaus Hartl
6
- * Dual licensed under the MIT or GPL Version 2 licenses.
7
- * http://www.opensource.org/licenses/mit-license.php
8
- * http://www.opensource.org/licenses/GPL-2.0
9
- */
10
- (function(e,t,n){function i(e){return e}function s(e){return decodeURIComponent(e.replace(r," "))}var r=/\+/g,o=e.cookie=function(r,u,a){if(u!==n){a=e.extend({},o.defaults,a),u===null&&(a.expires=-1);if(typeof a.expires=="number"){var f=a.expires,l=a.expires=new Date;l.setDate(l.getDate()+f)}return u=o.json?JSON.stringify(u):String(u),t.cookie=[encodeURIComponent(r),"=",o.raw?u:encodeURIComponent(u),a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+a.domain:"",a.secure?"; secure":""].join("")}var c=o.raw?i:s,h=t.cookie.split("; ");for(var p=0,d=h.length;p<d;p++){var v=h[p].split("=");if(c(v.shift())===r){var m=c(v.join("="));return o.json?JSON.parse(m):m}}return null};o.defaults={},e.removeCookie=function(t,n){return e.cookie(t)!==null?(e.cookie(t,null,n),!0):!1}})(jQuery,document);