magis 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +2 -0
  3. data/Rakefile +2 -0
  4. data/bin/magis +83 -0
  5. data/boilerplate/plugin/Gemfile +4 -0
  6. data/boilerplate/plugin/Gemfile.lock +17 -0
  7. data/boilerplate/plugin/LICENSE.txt +22 -0
  8. data/boilerplate/plugin/README.md +29 -0
  9. data/boilerplate/plugin/Rakefile +2 -0
  10. data/boilerplate/plugin/lib/your_spi_plugin.rb +8 -0
  11. data/boilerplate/plugin/lib/your_spi_plugin/version.rb +3 -0
  12. data/boilerplate/plugin/pkg/your_spi_plugin-0.0.1.gem +0 -0
  13. data/boilerplate/plugin/pkg/your_spi_plugin-1.0.1.gem +0 -0
  14. data/boilerplate/plugin/pkg/your_spi_plugin2-1.0.1.gem +0 -0
  15. data/boilerplate/plugin/your_spi_plugin.gemspec +23 -0
  16. data/boilerplate/project/Gemfile +1 -0
  17. data/boilerplate/project/Gemfile.lock +129 -0
  18. data/boilerplate/project/assets/javascripts/application.coffee +9 -0
  19. data/boilerplate/project/assets/stylesheets/application.css +9 -0
  20. data/boilerplate/project/collections/documentation.yml +2 -0
  21. data/boilerplate/project/config.ru +3 -0
  22. data/boilerplate/project/config/app.yml +1 -0
  23. data/boilerplate/project/config/database.yml +1 -0
  24. data/boilerplate/project/config/facebook.yml +3 -0
  25. data/boilerplate/project/config/google.yml +3 -0
  26. data/boilerplate/project/config/twitter.yml +3 -0
  27. data/boilerplate/project/data/json/documentation.json +6 -0
  28. data/boilerplate/project/public/index.html +40 -0
  29. data/boilerplate/project/public/pages/authentication.html +14 -0
  30. data/boilerplate/project/public/pages/documentation.html +8 -0
  31. data/lib/magis.rb +72 -0
  32. data/lib/magis/auths/fb.rb +71 -0
  33. data/lib/magis/auths/google.rb +56 -0
  34. data/lib/magis/auths/twitter.rb +52 -0
  35. data/lib/magis/base.rb +108 -0
  36. data/lib/magis/collection.rb +47 -0
  37. data/lib/magis/collections.rb +80 -0
  38. data/lib/magis/version.rb +3 -0
  39. data/lib/magis/web.rb +138 -0
  40. data/magis/html/setup.html +82 -0
  41. data/magis/js/current_user.js +10 -0
  42. data/magis/js/finch.min.js +14 -0
  43. data/magis/js/main.js +112 -0
  44. data/magis/js/setup.js +16 -0
  45. metadata +409 -0
@@ -0,0 +1,3 @@
1
+ module Magis
2
+ VERSION = "0.0.1"
3
+ end
data/lib/magis/web.rb ADDED
@@ -0,0 +1,138 @@
1
+ class Api < Sinatra::Base
2
+ use Rack::Session::Cookie, :key => 'rack.session',
3
+ :domain => ENV['SESSION_DOMAIN'] || Magis.load_configuration('app')["session_domain"],
4
+ :secret => ENV['SESSION_SECRET'] || Magis.load_configuration('app')["session_secret"]
5
+
6
+ use Faye::RackAdapter, :mount => '/faye', :timeout => 25
7
+
8
+ register Sinatra::AssetPipeline
9
+
10
+ use OmniAuth::Builder do
11
+ google = Magis.omni_auth_config("google")
12
+ google_id = ENV["GOOGLE_ID"] || google["id"] || ""
13
+ google_secret = ENV["GOOGLE_SECRET"] || google["secret"] || ""
14
+
15
+ facebook = Magis.omni_auth_config("facebook")
16
+ facebook_id = ENV["FACEBOOK_ID"] || facebook["id"] || ""
17
+ facebook_secret = ENV["FACEBOOK_SECRET"] || facebook["secret"] || ""
18
+
19
+ twitter = Magis.omni_auth_config("twitter")
20
+ twitter_id = ENV["TWITTER_ID"] || twitter["id"] || ""
21
+ twitter_secret = ENV["TWITTER_SECRET"] || twitter["secret"] || ""
22
+
23
+ provider :facebook, facebook_id, facebook_secret, scope: "email, user_friends"
24
+ provider :twitter, twitter_id, twitter_secret
25
+ provider :google_oauth2, google_id, google_secret, {
26
+ name: "google",
27
+ scope: "userinfo.email, userinfo.profile, plus.me, http://gdata.youtube.com",
28
+ prompt: "select_account",
29
+ image_aspect_ratio: "square",
30
+ image_size: 50,
31
+ }
32
+ end
33
+
34
+ before /^(?!\/(join|payment))/ do
35
+ @app = Magis.load_configuration("app")
36
+ if @app && @app["subdomain_scope"] && request.subdomains[0] != @app["subdomain_scope"]["home"]
37
+ @subdomain_scope = true
38
+ @subdomain = request.subdomains[0]
39
+ end
40
+ end
41
+
42
+ get '/magis.js' do
43
+ content_type :js
44
+ if current_user
45
+ user = current_user
46
+ user["_id"] = user["_id"].to_s
47
+ current_user_json = user.to_json
48
+ else
49
+ current_user_json = {}.to_json
50
+ end
51
+
52
+ js = Magis.file('/magis/js/finch.min.js') + Magis.file('/magis/js/main.js') + ["\n"]
53
+ js += ["currentUser = #{current_user_json};"] + ["\n"]
54
+ js += Magis.file('/magis/js/current_user.js') + ["\n"]
55
+ if Magis.env.setup?
56
+ js += Magis.file('/magis/js/setup.js')
57
+ end
58
+ js
59
+ end
60
+
61
+ get '/' do
62
+ if Magis.env.setup?
63
+ send_file File.join(Magis.framework_path, "magis/html/setup.html")
64
+ else
65
+ if @subdomain_scope
66
+ send_file File.join(settings.public_folder, @subdomain, '/index.html')
67
+ else
68
+ send_file File.join(settings.public_folder, 'index.html')
69
+ end
70
+ end
71
+ end
72
+
73
+ get '/pages/:page' do
74
+ if @subdomain_scope
75
+ send_file File.join(settings.public_folder, @subdomain, "pages/#{params[:page]}.html")
76
+ else
77
+ send_file File.join(settings.public_folder, "pages/#{params[:page]}.html")
78
+ end
79
+ end
80
+
81
+ get '/auth/:provider/callback' do
82
+ case params[:provider]
83
+ when "facebook"
84
+ user = FBTether.store(request.env['omniauth.auth'])
85
+ when "twitter"
86
+ user = TwitterTether.store(request.env['omniauth.auth'])
87
+ when "google"
88
+ user = GoogleTether.store(request.env['omniauth.auth'])
89
+ end
90
+
91
+ if user
92
+ session[:user_id] = user["_id"]
93
+ end
94
+ redirect "/"
95
+ end
96
+
97
+ get '/me' do
98
+ content_type :json
99
+
100
+ current_user.to_json
101
+ end
102
+
103
+ get '/friends' do
104
+ content_type :json
105
+ friends.to_json
106
+ end
107
+
108
+ delete '/logout' do
109
+ session[:user_id] = nil
110
+ end
111
+
112
+ get "/favicon.ico" do
113
+ end
114
+
115
+ post "/setup/:name" do
116
+ if Magis.env.setup?
117
+ config = params[params[:name]]
118
+ File.open(Magis.home_folder+"/config/#{params[:name]}.yml", 'w') do |f|
119
+ f.write config.to_yaml
120
+ end
121
+ ""
122
+ end
123
+ end
124
+
125
+ def current_user
126
+ @user ||= Magis.db["users"].find(_id: session[:user_id]).to_a.first || Hash.new
127
+ @user
128
+ end
129
+
130
+ def friends
131
+ Array.new
132
+ if current_user["provider"].to_s == "facebook"
133
+ @friends ||= FBTether.friends(current_user)
134
+ end
135
+ end
136
+
137
+ set :public_folder, 'public'
138
+ end
@@ -0,0 +1,82 @@
1
+ <html>
2
+ <head>
3
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
4
+ <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />
5
+ <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
6
+ <script type="text/javascript" src="http://localhost:9292/faye/client.js"></script>
7
+ <link href="http://bootswatch.com/cerulean/bootstrap.min.css" rel="stylesheet" />
8
+ <script src='http://cdn.ractivejs.org/latest/ractive.js'></script>
9
+ <script src="/magis.js"></script>
10
+ <script src="/assets/application.js"></script>
11
+ <link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro' rel='stylesheet' type='text/css'>
12
+ <link href="/assets/application.css" rel="stylesheet" />
13
+ </head>
14
+ <body>
15
+ <div class="container text-center">
16
+ <h2>Magis Setup</h2>
17
+ <div class="magis-setup" class="carousel slide" data-interval=false>
18
+
19
+ <!-- Wrapper for slides -->
20
+ <div class="carousel-inner">
21
+ <div class="item active">
22
+ <div class="col-sm-4 center-block text" data-name="facebook">
23
+ <h4>Facebook</h4>
24
+ <div class="form-group">
25
+ <input type="test" name="id" class="form-control" placeholder="Facebook Id" />
26
+ </div>
27
+ <div class="form-group">
28
+ <input type="test" name="secret" class="form-control" placeholder="Facebook Secret" />
29
+ </div>
30
+ <div class="next btn btn-primary">Next</div>
31
+ </div>
32
+ </div>
33
+ <div class="item">
34
+ <div class="col-sm-4 center-block" data-name="twitter">
35
+ <h4>Twitter</h4>
36
+ <div class="form-group">
37
+ <input type="test" name="id" class="form-control" placeholder="Twitter Id" />
38
+ </div>
39
+ <div class="form-group">
40
+ <input type="test" name="secret" class="form-control" placeholder="Twitter Secret" />
41
+ </div>
42
+ <div class="next btn btn-primary">Next</div>
43
+ </div>
44
+ </div>
45
+
46
+ <div class="item">
47
+ <div class="col-sm-4 center-block" data-name="google">
48
+ <h4>Google</h4>
49
+ <div class="form-group">
50
+ <input type="test" class="form-control" name="id" placeholder="Google Id" />
51
+ </div>
52
+ <div class="form-group">
53
+ <input type="test" class="form-control" name="secret" placeholder="Google Secret" />
54
+ </div>
55
+ <div class="next btn btn-primary">Next</div>
56
+ </div>
57
+ </div>
58
+ </div>
59
+ </div>
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+ </div>
79
+ </div>
80
+ </body>
81
+ </html>
82
+
@@ -0,0 +1,10 @@
1
+ currentUser.friends = function(callback){
2
+ return $.get("/friends", callback);
3
+ }
4
+
5
+ currentUser.logout = function(){
6
+ return $.ajax({
7
+ type: "DELETE",
8
+ url: "/logout"
9
+ })
10
+ }
@@ -0,0 +1,14 @@
1
+ /*
2
+ Finch.js - Powerfully simple javascript routing
3
+ by Rick Allen (stoodder) and Greg Smith (smrq)
4
+
5
+ Version 0.5.15
6
+ Full source at https://github.com/stoodder/finchjs
7
+ Copyright (c) 2011 RokkinCat, http://www.rokkincat.com
8
+
9
+ MIT License, https://github.com/stoodder/finchjs/blob/master/LICENSE.md
10
+ This file is generated by `cake build`, do not edit it by hand.
11
+ */
12
+
13
+
14
+ (function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,ab,bb,cb,db,eb,fb,gb,hb=[].slice;N=function(a){return typeof a==typeof{}&&null!==a},L=function(a){return"[object Function]"===Object.prototype.toString.call(a)},K=function(a){return"[object Boolean]"===Object.prototype.toString.call(a)},J=function(a){return"[object Array]"===Object.prototype.toString.call(a)},O=function(a){return"[object String]"===Object.prototype.toString.call(a)},M=function(a){return"[object Number]"===Object.prototype.toString.call(a)},eb=function(a){return a.replace(/^\s+/,"").replace(/\s+$/,"")},fb=function(a){return a.replace(/^\//,"").replace(/\/$/,"")},$=function(a,b){return 0===a.indexOf(b)},B=function(a,b){return-1!==a.indexOf(b,a.length-b.length)},y=function(a,b){var c,d,e;if(L(a.indexOf))return-1!==a.indexOf(b);if(J(a))for(d=0,e=a.length;e>d;d++)if(c=a[d],c===b)return!0;return!1},V=function(a){return a[a.length-1]},z=function(a,b){return a.split(b).length-1},P=function(a){var b,c;c=[];for(b in a)c.push(b);return c},Q=function(a){var b,c,d;d=[];for(b in a)c=a[b],d.push(c);return d},C=function(a,b){var c,d;N(a)||(a={}),N(b)||(b={});for(c in b)d=b[c],a[c]=d;return a},w=function(a){var b,c,d;N(a)||(a={}),c={};for(b in a)d=a[b],null!=d&&(c[b]=d);return c},R=function(a,b){var c,d;for(c in a)if(d=a[c],b[c]!==d)return!1;for(c in b)if(d=b[c],a[c]!==d)return!1;return!0},v=function(a,b){var c,d,e,f;if(a.length!==b.length)return!1;for(c=e=0,f=a.length;f>e;c=++e)if(d=a[c],b[c]!==d)return!1;return!0},A=function(a,b){var c,d,e;null==a&&(a={}),null==b&&(b={}),d={};for(c in a)e=a[c],b[c]!==e&&(d[c]=b[c]);for(c in b)e=b[c],a[c]!==e&&(d[c]=e);return d},x=null!=(gb=window.console)?gb:{},null==x.log&&(x.log=function(){}),null==x.warn&&(x.warn=function(){}),n=function(){function a(a){var b,c;c=a.components,b=a.childIndex,this.components=null!=c?c:[],this.childIndex=null!=b?b:0}return a}(),q=function(){function a(a){var b,c,d,e;e=null!=a?a:{},b=e.name,c=e.nodeType,d=e.parent,this.name=null!=b?b:"",this.nodeType=null!=c?c:null,this.parent=null!=d?d:null,this.routeSettings=null,this.childLiterals={},this.childVariable=null,this.bindings=[]}return a}(),s=function(){function a(a){var b,c,d,e,f,g;g=null!=a?a:{},d=g.setup,e=g.teardown,c=g.load,f=g.unload,b=g.context,this.setup=L(d)?d:function(){},this.load=L(c)?c:function(){},this.unload=L(f)?f:function(){},this.teardown=L(e)?e:function(){},this.context=N(b)?b:{}}return a}(),r=function(){function a(a){var b,c,d,e;e=null!=a?a:{},c=e.node,b=e.boundValues,d=e.parameterObservables,this.node=null!=c?c:null,this.boundValues=null!=b?b:[],this.parameterObservables=null!=d?d:[[]]}return a.prototype.getBindings=function(){var a,b,c,d,e,f;for(b={},f=this.node.bindings,c=d=0,e=f.length;e>d;c=++d)a=f[c],b[a]=this.boundValues[c];return S(b)},a.prototype.isEqual=function(a){return null!=a&&this.node===a.node&&v(this.boundValues,a.boundValues)},a.prototype.isRoot=function(){return null==this.node.parent},a.prototype.getParent=function(){var b,c,d,e,f;return null==this.node?null:(b=null!=(e=null!=(f=this.node.parent)?f.bindings.length:void 0)?e:0,c=this.boundValues.slice(0,b),d=this.parameterObservables.slice(0,-1),new a({node:this.node.parent,boundValues:c,parameterObservables:d}))},a.prototype.getChild=function(a){for(var b;null!=a&&!this.isEqual(b=a.getParent());)a=b;return a.parameterObservables=this.parameterObservables.slice(0),a.parameterObservables.push([]),a},a}(),m=function(){function a(a){this.callback=a,L(this.callback)||(this.callback=function(){}),this.dependencies=[],this.initialized=!1}return a.prototype.notify=function(a){var b,c=this;return b=function(){var b,d,e,f;if(!c.initialized)return!0;for(f=c.dependencies,d=0,e=f.length;e>d;d++)if(b=f[d],y(a,b))return!0;return!1}(),b?this.trigger():void 0},a.prototype.trigger=function(){var a,c=this;return this.dependencies=[],a=function(a){return y(c.dependencies,a)||c.dependencies.push(a),b[a]},this.callback(a),this.initialized=!0},a}(),k=new r({node:null}),j={Literal:"Literal",Variable:"Variable"},T=function(a){var b,c,d,e,f,g,h,i;if(a=O(a)?eb(a):"",d={},""!==a)for(h=a.split("&"),f=0,g=h.length;g>f;f++)c=h[f],i=c.split("=",2),b=i[0],e=i[1],d[b]=e;return S(d)},H=function(){var a;return"#"+(null!=(a=window.location.href.split("#",2)[1])?a:"")},Y=function(a){return O(a)||(a=""),a=eb(a),"#"===a.slice(0,1)&&(a=a.slice(1)),window.location.hash=a},S=function(a){var b,c;if(N(a)||(a={}),l.CoerceParameterTypes)for(b in a)c=a[b],"true"===c?c=!0:"false"===c?c=!1:/^[0-9]+$/.test(c)?c=parseInt(c):/^[0-9]+\.[0-9]*$/.test(c)&&(c=parseFloat(c)),a[b]=c;return a},Z=function(a){var b;return a=fb(a),b=""===a?[]:a.split("/"),b.unshift("/"),b},U=function(a){var b,c,d,e,f,g,h,i,j;for(f=y(a,"[")||y(a,"]"),f&&!function(){var b,c;return c=z(a,"["),1!==c?(c>1&&x.warn('[FINCH] Parsing failed on "'+a+'": Extra ['),1>c&&x.warn('[FINCH] Parsing failed on "'+a+'": Missing ['),null):(b=z(a,"]"),1!==b?(b>1&&x.warn('[FINCH] Parsing failed on "'+a+'": Extra ]'),1>b&&x.warn('[FINCH] Parsing failed on "'+a+'": Missing ]'),null):$(a,"[")?void 0:(x.warn('[FINCH] Parsing failed on "'+a+'": [ not at beginning'),null))}(),e=a.replace(/[\[\]]/g,""),d=""===e?[]:Z(e),i=0,j=d.length;j>i;i++)if(c=d[i],""===c)return x.warn('[FINCH] Parsing failed on "'+a+'": Blank component'),null;if(b=0,f){if(h=a.split("]")[0],g=Z(h.replace("[","")),g[g.length-1]!==d[g.length-1])return x.warn('[FINCH] Parsing failed on "'+a+'": ] in the middle of a component'),null;if(g.length===d.length)return x.warn('[FINCH] Parsing failed on "'+a+'": No child components'),null;b=g.length}return new n({components:d,childIndex:b})},G=function(a){return $(a,":")?j.Variable:j.Literal},F=function(a){switch(G(a)){case j.Literal:return a;case j.Variable:return a.slice(1)}},u=function(a,b,c){var d,e,f,g,h;return f=b.components,e=b.childIndex,g=a,d=[],(h=function(i,k){var l,m,n,o,p;if(k===e&&(g=i),b.components.length<=0)return i.parent=g,i.bindings=d,i.routeSettings=new s(c);switch(l=f.shift(),n=G(l),m=F(l),n){case j.Literal:o=null!=(p=i.childLiterals)[m]?(p=i.childLiterals)[m]:p[m]=new q({name:""+i.name+l+"/",nodeType:n,parent:a});break;case j.Variable:o=null!=i.childVariable?i.childVariable:i.childVariable=new q({name:""+i.name+l+"/",nodeType:n,parent:a}),d.push(m)}return h(o,k+1)})(a,0)},E=function(a,b){var c,d,e;return e=Z(b),c=[],(d=function(a,b){var e,f;if(b.length<=0&&null!=a.routeSettings)return new r({node:a,boundValues:c});if(e=b[0],null!=a.childLiterals[e]&&(f=d(a.childLiterals[e],b.slice(1)),null!=f))return f;if(null!=a.childVariable){if(c.push(e),f=d(a.childVariable,b.slice(1)),null!=f)return f;c.pop()}return null})(a,e)},D=function(a,b){var c,d,e,f,g;for(d=[],e=b;null!=e;)d.push(e),e=e.getParent();for(e=a;null!=e;){for(f=0,g=d.length;g>f;f++)if(c=d[f],e.isEqual(c))return e;e=e.getParent()}return null},p=c=d=null,o=b=null,f=a=null,g=!1,h=t=!1,i=!1,l={CoerceParameterTypes:!1},(W=function(){return p=new q({name:"*"}),c=k,o={},b={},d=null,f=null,a=null,g=!1,h=!1,t=!1,i=!1})(),_=function(){var a;return null===d?X():i?db():d.isEqual(c)?ab():(a=D(c,d),c.isEqual(a)?bb():cb())},bb=function(){var a,b,e,f,g,h,i,j,k,l;return t=!0,f=(null!=(i=null!=(j=c.node)?j.routeSettings:void 0)?i:{context:null}).context,c=c.getChild(d),l=null!=(k=c.node.routeSettings)?k:{},b=l.context,h=l.setup,e=l.load,null==b&&(b={}),b.parent=f,null==h&&(h=function(){}),null==e&&(e=function(){}),a=c.getBindings(),g=function(){return _()},2===h.length?h.call(b,a,g):(h.call(b,a),g())},ab=function(){var a,b,e,f,g,h,j;return f=function(){return i=!0,d=null,_()},null==c.node?f():(j=null!=(h=c.node.routeSettings)?h:{},b=j.context,g=j.setup,e=j.load,null==b&&(b={}),null==g&&(g=function(){}),null==e&&(e=function(){}),a=c.getBindings(),2===e.length?e.call(b,a,f):(e.call(b,a),f()))},db=function(){var a,b,d,e,f,g;return i=!1,d=function(){return _()},g=null!=(f=c.node.routeSettings)?f:{},b=g.context,e=g.unload,null==b&&(b={}),null==e&&(e=function(){}),a=c.getBindings(),2===e.length?e.call(b,a,d):(e.call(b,a),d())},cb=function(){var a,b,d,e,f,g;return t=!1,g=null!=(f=c.node.routeSettings)?f:{},b=g.context,e=g.teardown,null==b&&(b={}),null==e&&(e=function(){}),a=c.getBindings(),d=function(){return c=c.getParent(),_()},2===e.length?e.call(b,a,d):(e.call(b,a),d())},X=function(){var a,d,e,f,g,h,i;for(a=P(A(o,b)),o=b,h=c.parameterObservables,i=[],f=0,g=h.length;g>f;f++)e=h[f],i.push(function(){var b,c,f;for(f=[],b=0,c=e.length;c>b;b++)d=e[b],f.push(d.notify(a));return f}());return i},I=function(){var b;return b=H(),$(b,"#")&&(b=b.slice(1)),b=unescape(b),b!==a?e.call(b)?a=b:Y(null!=a?a:""):void 0},e={route:function(a,b){var c,d;return L(b)&&(c=b,b={setup:c},b.load=2===c.length?function(a,b){return t?b():(h=!0,c(a,b))}:function(a){return t?void 0:(h=!0,c(a))}),N(b)||(b={}),O(a)||(a=""),a=eb(a),a.length>0||(a="/"),d=U(a),null==d?!1:(u(p,d,b),this)},call:function(a){var e,f,g,h,i,j;return O(a)||(a="/"),""===a&&(a="/"),j=a.split("?",2),a=j[0],i=j[1],f=E(p,a),null==f?(x.warn("[FINCH] Could not find route for: "+a),!1):(h=T(i),e=f.getBindings(),b=C(h,e),null===d&&c.isEqual(f)?_():(g=d,d=f,null==g&&_()),!0)},reload:function(){var a;return i?null==c||null==c.node?this:(a=c,d=k,_(),i=!1,d=c=a,_(),this):this},observe:function(){var a,b,d,f;return a=1<=arguments.length?hb.call(arguments,0):[],h?h=!1:(b=a.pop(),L(b)||(b=function(){}),a.length>0?(d=1===a.length&&J(a[0])?a[0]:a,e.observe(function(a){var c,e;return e=function(){var b,e,f;for(f=[],b=0,e=d.length;e>b;b++)c=d[b],f.push(a(c));return f}(),b.apply(null,e)})):(f=new m(b),V(c.parameterObservables).push(f)))},abort:function(){return d=null},listen:function(){return g||("onhashchange"in window&&(L(window.addEventListener)?(window.addEventListener("hashchange",I,!0),g=!0):L(window.attachEvent)&&(window.attachEvent("hashchange",I),g=!0)),g||(f=setInterval(I,33),g=!0),I()),g},ignore:function(){return g&&(null!==f?(clearInterval(f),f=null,g=!1):"onhashchange"in window&&(L(window.removeEventListener)?(window.removeEventListener("hashchange",I,!0),g=!1):L(window.detachEvent)&&(window.detachEvent("hashchange",I),g=!1))),!g},navigate:function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p;if(o=H().split("?",2),g=o[0],f=o[1],null==g&&(g=""),null==f&&(f=""),"#"===g.slice(0,1)&&(g=g.slice(1)),g=unescape(g),e=T(f),K(b)&&(c=b),N(a)&&(b=a),O(a)||(a=""),N(b)||(b={}),K(c)||(c=!1),a=eb(a),0===a.length&&(a=null),c&&(!function(){var a,b,c;b={};for(a in e)c=e[a],b[unescape(a)]=unescape(c);return e=b}(),b=C(e,b)),null===a&&(a=g),p=a.split("?",2),a=p[0],l=p[1],"#"===a.slice(0,1)&&(a=a.slice(1)),$(a,"./")||$(a,"../")){for(d=g;$(a,"./")||$(a,"../");)k=a.indexOf("/"),i=a.slice(0,k),a=a.slice(k+1),".."===i&&(d=d.slice(0,d.lastIndexOf("/")));a=a.length>0?""+d+"/"+a:d}return m=O(l)?T(l):{},b=C(m,b),b=w(b),a=escape(a),j=function(){var a;a=[];for(h in b)n=b[h],a.push(escape(h)+"="+escape(n));return a}().join("&"),j.length>0&&(a+="?"+j),Y(a)},reset:function(){e.options({CoerceParameterTypes:!1}),d=k,_(),e.ignore(),W()},options:function(a){return C(l,a)}},this.Finch=e}).call(this);
data/magis/js/main.js ADDED
@@ -0,0 +1,112 @@
1
+ Router = Object();
2
+ Router.addRoute = function(name, callBack){
3
+ return Finch.route(name, callBack);
4
+ }
5
+
6
+ $.capsuleForm = (function(formName){
7
+
8
+ $(document).on("click", "[data-name='"+formName+"'].form .submit", function(){
9
+ submitData = Object();
10
+ $form = $(this).parents(".form");
11
+ $form.find("input").each(function(i, input){
12
+ submitData[$(this).attr("name")] = $(this).val()
13
+ })
14
+ $.post("/api/collections/" + formName, {data: submitData})
15
+ })
16
+
17
+ })
18
+
19
+ function Page(target, collection){
20
+ var defer = $.Deferred()
21
+ $.get("/pages/" + collection, function(data){
22
+ $("body").append(data);
23
+ Router.addRoute("/"+collection, function() {
24
+ View.render(target, collection, "collections/"+collection);
25
+ });
26
+ defer.resolve()
27
+ })
28
+ return defer;
29
+ }
30
+
31
+ var View = Object();
32
+ View.cog = function(element, template, data){
33
+ return new Ractive({
34
+ el: element,
35
+ template: template,
36
+ data: data
37
+ });
38
+ }
39
+
40
+ View.render = function(target, templateName, url){
41
+ var defer = $.Deferred()
42
+ collection = App.collections[templateName] || (App.collections[templateName] = new Collection(templateName))
43
+ collection.find().then(function(data){
44
+ collection.data = data;
45
+ customData = Object();
46
+ customData[templateName] = collection.data;
47
+ View.cog(target, $("[name='"+templateName+"']").html(), customData);
48
+ defer.resolve()
49
+ });
50
+ return defer;
51
+ }
52
+
53
+ App = Object();
54
+ App.collections = Object();
55
+ App.initialize = function(){
56
+ Finch.listen();
57
+ }
58
+
59
+ App.fayeClient = new Faye.Client("/faye");
60
+
61
+ currentUser = Object();
62
+
63
+ Collection = function(name){
64
+ this.name = name;
65
+
66
+ localCollection = this;
67
+
68
+ App.fayeClient.subscribe('/'+this.name, function(data) {
69
+ localCollection.data.push(JSON.parse(data.json));
70
+ });
71
+
72
+ this.create = function(params){
73
+ return $.post("/api/collections/"+name, params);
74
+ }
75
+
76
+ this.find = function(params){
77
+ return $.get("/api/collections/"+name, params);
78
+ }
79
+
80
+ this.update = function(id, params){
81
+ name = this.name
82
+ request = $.ajax({
83
+ url: "/api/collections/"+name+"/"+id,
84
+ type: "PUT",
85
+ data: params,
86
+ dataType: "json"
87
+ });
88
+
89
+ return request;
90
+ }
91
+
92
+ this.remove = function(id){
93
+ request = $.ajax({
94
+ url: "/api/collections/"+name+"/"+id,
95
+ type: "DELETE",
96
+ dataType: "json"
97
+ });
98
+
99
+ return request;
100
+ }
101
+
102
+ this.findOne = function(params){
103
+ var defer = $.Deferred()
104
+
105
+ $.get("/api/collections/"+name, params).then(function(data){
106
+ data = data[0];
107
+ defer.resolve(data);
108
+ });
109
+
110
+ defer
111
+ }
112
+ }
data/magis/js/setup.js ADDED
@@ -0,0 +1,16 @@
1
+ $(document).on("click", ".magis-setup .next", function(){
2
+ var $form = $(this).closest(".item")
3
+ var name=$form.children().data("name")
4
+
5
+ params = Object();
6
+ params[name] = Object()
7
+ $form.find("input").each( function(index, authInput){
8
+ params[name][$(authInput).attr("name")] = $(authInput).val();
9
+ })
10
+
11
+ $auth = $.post("/setup/"+name, params)
12
+ $auth.then(function(response){
13
+ $(".magis-setup").carousel('next')
14
+ })
15
+ });
16
+
metadata ADDED
@@ -0,0 +1,409 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: magis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Carson Wright
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.4.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.4.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: sinatra-asset-pipeline
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.5.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.5.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: puma
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 2.9.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.9.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: bson_ext
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.11.1
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.11.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: mongo
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.11.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.11.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: i18n
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.6.11
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.6.11
97
+ - !ruby/object:Gem::Dependency
98
+ name: json
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 1.8.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 1.8.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: activesupport-inflector
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 0.1.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 0.1.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: faye
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 1.0.3
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 1.0.3
139
+ - !ruby/object:Gem::Dependency
140
+ name: koala
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 1.10.1
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 1.10.1
153
+ - !ruby/object:Gem::Dependency
154
+ name: omniauth
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 1.2.2
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 1.2.2
167
+ - !ruby/object:Gem::Dependency
168
+ name: omniauth-oauth2
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 1.2.0
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '='
179
+ - !ruby/object:Gem::Version
180
+ version: 1.2.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: omniauth-facebook
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '='
186
+ - !ruby/object:Gem::Version
187
+ version: 2.0.0
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '='
193
+ - !ruby/object:Gem::Version
194
+ version: 2.0.0
195
+ - !ruby/object:Gem::Dependency
196
+ name: omniauth-twitter
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - '='
200
+ - !ruby/object:Gem::Version
201
+ version: 1.0.1
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - '='
207
+ - !ruby/object:Gem::Version
208
+ version: 1.0.1
209
+ - !ruby/object:Gem::Dependency
210
+ name: omniauth-google-oauth2
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - '='
214
+ - !ruby/object:Gem::Version
215
+ version: 0.2.5
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - '='
221
+ - !ruby/object:Gem::Version
222
+ version: 0.2.5
223
+ - !ruby/object:Gem::Dependency
224
+ name: pry
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - '='
228
+ - !ruby/object:Gem::Version
229
+ version: 0.10.1
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - '='
235
+ - !ruby/object:Gem::Version
236
+ version: 0.10.1
237
+ - !ruby/object:Gem::Dependency
238
+ name: rspec
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - '='
242
+ - !ruby/object:Gem::Version
243
+ version: 3.1.0
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - '='
249
+ - !ruby/object:Gem::Version
250
+ version: 3.1.0
251
+ - !ruby/object:Gem::Dependency
252
+ name: rack-test
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - '='
256
+ - !ruby/object:Gem::Version
257
+ version: 0.6.2
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - '='
263
+ - !ruby/object:Gem::Version
264
+ version: 0.6.2
265
+ - !ruby/object:Gem::Dependency
266
+ name: simplecov
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - '='
270
+ - !ruby/object:Gem::Version
271
+ version: 0.9.1
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - '='
277
+ - !ruby/object:Gem::Version
278
+ version: 0.9.1
279
+ - !ruby/object:Gem::Dependency
280
+ name: webmock
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - '='
284
+ - !ruby/object:Gem::Version
285
+ version: 01.19.0
286
+ type: :development
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - '='
291
+ - !ruby/object:Gem::Version
292
+ version: 01.19.0
293
+ - !ruby/object:Gem::Dependency
294
+ name: capybara
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - '='
298
+ - !ruby/object:Gem::Version
299
+ version: 2.4.2
300
+ type: :development
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - '='
305
+ - !ruby/object:Gem::Version
306
+ version: 2.4.2
307
+ - !ruby/object:Gem::Dependency
308
+ name: selenium-webdriver
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - '='
312
+ - !ruby/object:Gem::Version
313
+ version: 2.43.0
314
+ type: :development
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - '='
319
+ - !ruby/object:Gem::Version
320
+ version: 2.43.0
321
+ - !ruby/object:Gem::Dependency
322
+ name: poltergeist
323
+ requirement: !ruby/object:Gem::Requirement
324
+ requirements:
325
+ - - '='
326
+ - !ruby/object:Gem::Version
327
+ version: 1.5.1
328
+ type: :development
329
+ prerelease: false
330
+ version_requirements: !ruby/object:Gem::Requirement
331
+ requirements:
332
+ - - '='
333
+ - !ruby/object:Gem::Version
334
+ version: 1.5.1
335
+ description: Magis Framework Gem
336
+ email: carsonnwright@gmail.com
337
+ executables:
338
+ - magis
339
+ extensions: []
340
+ extra_rdoc_files: []
341
+ files:
342
+ - README.md
343
+ - Rakefile
344
+ - bin/magis
345
+ - boilerplate/plugin/Gemfile
346
+ - boilerplate/plugin/Gemfile.lock
347
+ - boilerplate/plugin/LICENSE.txt
348
+ - boilerplate/plugin/README.md
349
+ - boilerplate/plugin/Rakefile
350
+ - boilerplate/plugin/lib/your_spi_plugin.rb
351
+ - boilerplate/plugin/lib/your_spi_plugin/version.rb
352
+ - boilerplate/plugin/pkg/your_spi_plugin-0.0.1.gem
353
+ - boilerplate/plugin/pkg/your_spi_plugin-1.0.1.gem
354
+ - boilerplate/plugin/pkg/your_spi_plugin2-1.0.1.gem
355
+ - boilerplate/plugin/your_spi_plugin.gemspec
356
+ - boilerplate/project/Gemfile
357
+ - boilerplate/project/Gemfile.lock
358
+ - boilerplate/project/assets/javascripts/application.coffee
359
+ - boilerplate/project/assets/stylesheets/application.css
360
+ - boilerplate/project/collections/documentation.yml
361
+ - boilerplate/project/config.ru
362
+ - boilerplate/project/config/app.yml
363
+ - boilerplate/project/config/database.yml
364
+ - boilerplate/project/config/facebook.yml
365
+ - boilerplate/project/config/google.yml
366
+ - boilerplate/project/config/twitter.yml
367
+ - boilerplate/project/data/json/documentation.json
368
+ - boilerplate/project/public/index.html
369
+ - boilerplate/project/public/pages/authentication.html
370
+ - boilerplate/project/public/pages/documentation.html
371
+ - lib/magis.rb
372
+ - lib/magis/auths/fb.rb
373
+ - lib/magis/auths/google.rb
374
+ - lib/magis/auths/twitter.rb
375
+ - lib/magis/base.rb
376
+ - lib/magis/collection.rb
377
+ - lib/magis/collections.rb
378
+ - lib/magis/version.rb
379
+ - lib/magis/web.rb
380
+ - magis/html/setup.html
381
+ - magis/js/current_user.js
382
+ - magis/js/finch.min.js
383
+ - magis/js/main.js
384
+ - magis/js/setup.js
385
+ homepage: http://magisframework.github.io/magis
386
+ licenses:
387
+ - MIT
388
+ metadata: {}
389
+ post_install_message:
390
+ rdoc_options: []
391
+ require_paths:
392
+ - lib
393
+ required_ruby_version: !ruby/object:Gem::Requirement
394
+ requirements:
395
+ - - ">="
396
+ - !ruby/object:Gem::Version
397
+ version: '0'
398
+ required_rubygems_version: !ruby/object:Gem::Requirement
399
+ requirements:
400
+ - - ">="
401
+ - !ruby/object:Gem::Version
402
+ version: '0'
403
+ requirements: []
404
+ rubyforge_project:
405
+ rubygems_version: 2.4.2
406
+ signing_key:
407
+ specification_version: 4
408
+ summary: Magis Framework
409
+ test_files: []