helios 0.0.5 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +3 -1
  3. data/Gemfile.lock +38 -44
  4. data/bin/helios +2 -2
  5. data/example/Gemfile +2 -2
  6. data/example/Gemfile.lock +60 -49
  7. data/example/Procfile +1 -1
  8. data/example/Sample.xcdatamodeld/Sample.xcdatamodel/contents +11 -17
  9. data/example/config.ru +12 -1
  10. data/helios-0.1.0.gem +0 -0
  11. data/helios.gemspec +5 -3
  12. data/lib/helios.rb +9 -5
  13. data/lib/helios/backend.rb +27 -17
  14. data/lib/helios/backend/accounts.rb +38 -0
  15. data/lib/helios/backend/data.rb +7 -6
  16. data/lib/helios/backend/in-app-purchase.rb +10 -2
  17. data/lib/helios/backend/passbook.rb +12 -2
  18. data/lib/helios/backend/push-notification.rb +8 -1
  19. data/lib/helios/commands.rb +3 -1
  20. data/lib/helios/commands/link.rb +18 -0
  21. data/lib/helios/commands/new.rb +43 -6
  22. data/lib/helios/commands/server.rb +16 -0
  23. data/lib/helios/frontend.rb +11 -5
  24. data/lib/helios/frontend/fonts/icons.eot +0 -0
  25. data/lib/helios/frontend/fonts/icons.ttf +0 -0
  26. data/lib/helios/frontend/fonts/icons.woff +0 -0
  27. data/lib/helios/frontend/images/bg.jpg +0 -0
  28. data/lib/helios/frontend/javascripts/helios.coffee +5 -5
  29. data/lib/helios/frontend/javascripts/helios/collections.coffee +67 -6
  30. data/lib/helios/frontend/javascripts/helios/models.coffee +1 -4
  31. data/lib/helios/frontend/javascripts/helios/router.coffee +0 -14
  32. data/lib/helios/frontend/javascripts/helios/views.coffee +164 -23
  33. data/lib/helios/frontend/javascripts/vendor/backbone.paginator.js +1046 -0
  34. data/lib/helios/frontend/javascripts/vendor/codemirror.javascript.js +411 -0
  35. data/lib/helios/frontend/javascripts/vendor/codemirror.js +3047 -0
  36. data/lib/helios/frontend/javascripts/vendor/date.js +104 -0
  37. data/lib/helios/frontend/javascripts/{foundation → vendor}/foundation.js +0 -0
  38. data/lib/helios/frontend/javascripts/{foundation → vendor/foundation}/foundation.alerts.js +0 -0
  39. data/lib/helios/frontend/javascripts/{foundation → vendor/foundation}/foundation.clearing.js +0 -0
  40. data/lib/helios/frontend/javascripts/{foundation → vendor/foundation}/foundation.cookie.js +0 -0
  41. data/lib/helios/frontend/javascripts/{foundation → vendor/foundation}/foundation.dropdown.js +0 -0
  42. data/lib/helios/frontend/javascripts/{foundation → vendor/foundation}/foundation.forms.js +0 -0
  43. data/lib/helios/frontend/javascripts/{foundation → vendor/foundation}/foundation.joyride.js +0 -0
  44. data/lib/helios/frontend/javascripts/{foundation → vendor/foundation}/foundation.magellan.js +0 -0
  45. data/lib/helios/frontend/javascripts/{foundation → vendor/foundation}/foundation.orbit.js +0 -0
  46. data/lib/helios/frontend/javascripts/{foundation → vendor/foundation}/foundation.placeholder.js +0 -0
  47. data/lib/helios/frontend/javascripts/{foundation → vendor/foundation}/foundation.reveal.js +0 -0
  48. data/lib/helios/frontend/javascripts/{foundation → vendor/foundation}/foundation.section.js +0 -0
  49. data/lib/helios/frontend/javascripts/{foundation → vendor/foundation}/foundation.tooltips.js +0 -0
  50. data/lib/helios/frontend/javascripts/{foundation → vendor/foundation}/foundation.topbar.js +0 -0
  51. data/lib/helios/frontend/stylesheets/_codemirror.sass +219 -0
  52. data/lib/helios/frontend/stylesheets/_fonts.sass +80 -0
  53. data/lib/helios/frontend/stylesheets/_iphone.sass +141 -0
  54. data/lib/helios/frontend/stylesheets/_settings.scss +12 -11
  55. data/lib/helios/frontend/stylesheets/screen.sass +119 -34
  56. data/lib/helios/frontend/views/compose.jst.tpl +70 -0
  57. data/lib/helios/frontend/views/devices.jst.tpl +15 -2
  58. data/lib/helios/frontend/views/entities.jst.tpl +6 -4
  59. data/lib/helios/frontend/views/index.haml +24 -8
  60. data/lib/helios/frontend/views/passes.jst.tpl +10 -2
  61. data/lib/helios/frontend/views/receipts.jst.tpl +10 -2
  62. data/lib/helios/templates/Gemfile.erb +5 -2
  63. data/lib/helios/templates/Procfile.erb +1 -1
  64. data/lib/helios/templates/README.md.erb +1 -1
  65. data/lib/helios/templates/config.ru.erb +8 -1
  66. data/lib/helios/version.rb +1 -1
  67. metadata +174 -102
  68. data/helios-0.0.2.gem +0 -0
  69. data/helios-0.0.3.gem +0 -0
  70. data/helios-0.0.4.gem +0 -0
  71. data/lib/helios/frontend/images/data.png +0 -0
  72. data/lib/helios/frontend/images/data.svg +0 -1
  73. data/lib/helios/frontend/images/in-app-purchase.png +0 -0
  74. data/lib/helios/frontend/images/in-app-purchase.svg +0 -1
  75. data/lib/helios/frontend/images/passbook.png +0 -0
  76. data/lib/helios/frontend/images/passbook.svg +0 -1
  77. data/lib/helios/frontend/images/push-notification.png +0 -0
  78. data/lib/helios/frontend/images/push-notification.svg +0 -1
  79. data/lib/helios/frontend/templates/data/entities.hbs +0 -7
  80. data/lib/helios/frontend/templates/data/entity.hbs +0 -17
  81. data/lib/helios/frontend/templates/in-app-purchase/receipt.hbs +0 -53
  82. data/lib/helios/frontend/templates/in-app-purchase/receipts.hbs +0 -39
  83. data/lib/helios/frontend/templates/passbook/passes.hbs +0 -25
  84. data/lib/helios/frontend/templates/push-notification/device.hbs +0 -35
  85. data/lib/helios/frontend/templates/push-notification/devices.hbs +0 -37
@@ -3,4 +3,15 @@ Bundler.require
3
3
 
4
4
  DB = Sequel.connect(ENV['DATABASE_URL'])
5
5
 
6
- run Helios::Application.new(model: 'Sample.xcdatamodeld')
6
+ app = Helios::Application.new {
7
+ service :data, model: Dir['*.xcdatamodel*'].first
8
+ service :push_notification
9
+ service :in_app_purchase
10
+ service :passbook, admin: false
11
+ service :accounts do
12
+ provider :developer
13
+ provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: "user,repo,gist"
14
+ end
15
+ }
16
+
17
+ run app
Binary file
@@ -14,13 +14,15 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.add_dependency "commander", "~> 4.1.2"
16
16
  s.add_dependency "rack-core-data", "~> 0.2"
17
- s.add_dependency "rack-push-notification", "~> 0.2"
18
- s.add_dependency "rack-in-app-purchase", "~> 0.0.2"
19
- s.add_dependency "rack-passbook", "~> 0.0.2"
17
+ s.add_dependency "rack-push-notification", "~> 0.4"
18
+ s.add_dependency "rack-in-app-purchase", "~> 0.1"
19
+ s.add_dependency "rack-passbook", "~> 0.1"
20
20
  s.add_dependency "rack-smart-app-banner", "~> 0.0.1"
21
+ s.add_dependency "omniauth", "~> 1.0"
21
22
  s.add_dependency "json", "~> 1.7"
22
23
  s.add_dependency "coffee-script", "~> 2.2"
23
24
  s.add_dependency "sinatra", "~> 1.3"
25
+ s.add_dependency "sinatra-contrib", "~> 1.3"
24
26
  s.add_dependency "sinatra-assetpack", "~> 0.1"
25
27
  s.add_dependency "sinatra-backbone", "~> 0.1.0.rc2"
26
28
  s.add_dependency "sinatra-param", "~> 0.1"
@@ -1,13 +1,17 @@
1
+ require 'rack'
2
+
1
3
  module Helios
2
- class Helios::Application < Rack::Builder
4
+ class Helios::Application
3
5
  def initialize(app = nil, options = {}, &block)
4
- super(app, &block)
5
-
6
6
  map = {}
7
- map['/admin'] = Helios::Frontend.new if options.fetch(:frontend, true)
8
7
  map['/'] = Helios::Backend.new(&block)
8
+ map['/admin'] = Helios::Frontend.new if options.fetch(:frontend, true)
9
+
10
+ @app = Rack::URLMap.new(map)
11
+ end
9
12
 
10
- run Rack::URLMap.new map
13
+ def call(env)
14
+ @app.call(env)
11
15
  end
12
16
  end
13
17
  end
@@ -20,27 +20,37 @@ module Helios
20
20
  private
21
21
 
22
22
  def service(identifier, options = {}, &block)
23
- middleware = case identifier
24
- when :data
25
- Helios::Backend::Data.new(options[:model]) if options[:model]
26
- when :push_notification
27
- Helios::Backend::PushNotification.new
28
- when :in_app_purchase
29
- Helios::Backend::InAppPurchase.new
30
- when :passbook
31
- Helios::Backend::Passbook.new
32
- else
33
- raise ArgumentError, "Unknown service #{identifer}"
34
- end
35
-
36
- # middleware.set :frontend, options.fetch(:frontend, true)
37
-
38
- @services << middleware if middleware
23
+ if identifier.is_a?(Class)
24
+ middleware = identifier
25
+ else
26
+ begin
27
+ middleware = Helios::Backend.const_get(constantize(identifier))
28
+ rescue NameError
29
+ raise LoadError, "Could not find matching service for #{identifier.inspect}. You may need to install an additional gem (such as helios-#{identifier})."
30
+ end
31
+ end
32
+
33
+ middleware.instance_eval{ include Helios::Administerable } if options.fetch(:frontend, true)
34
+
35
+ @services << middleware.new(self, options, &block) if middleware
36
+ end
37
+
38
+ def constantize(identifier)
39
+ identifier.to_s.split(/([[:alpha:]]*)/).select{|c| /[[:alpha:]]/ === c}.map(&:capitalize).join("")
40
+ end
41
+ end
42
+
43
+ module Administerable
44
+ attr_accessor :admin
45
+
46
+ def admin?
47
+ !!@admin
39
48
  end
40
49
  end
41
50
  end
42
51
 
52
+ require 'helios/backend/accounts'
43
53
  require 'helios/backend/data'
44
54
  require 'helios/backend/push-notification'
45
55
  require 'helios/backend/in-app-purchase'
46
- require 'helios/backend/passbook'
56
+ require 'helios/backend/passbook'
@@ -0,0 +1,38 @@
1
+ require 'omniauth'
2
+ require 'rack/contrib'
3
+ require 'sinatra/multi_route'
4
+ require 'sinatra/param'
5
+
6
+ class Helios::Backend::Accounts < Sinatra::Base
7
+ use Rack::Session::Pool
8
+ use Rack::PostBodyContentTypeParser
9
+
10
+ register Sinatra::MultiRoute
11
+
12
+ # configure do
13
+ # use OmniAuth::Builder do
14
+ # provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: "user,repo,gist"
15
+ # end
16
+ # end
17
+
18
+ def initialize(app, options = {}, &block)
19
+ # self.instance_eval do
20
+ # self.class.use OmniAuth::Builder do
21
+ # block.call
22
+ # end
23
+ # end if block_given?
24
+ # super(nil, &nil)
25
+
26
+ # omni = OmniAuth::Builder.new(app) do
27
+ # provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: "user,repo,gist"
28
+ # end
29
+
30
+ super(nil, &nil)
31
+ end
32
+
33
+ route :get, :post, '/auth/:provider/callback/?' do
34
+ p env['omniauth.auth']
35
+
36
+ halt 500
37
+ end
38
+ end
@@ -1,12 +1,13 @@
1
1
  require 'rack/core-data'
2
+ require 'sinatra/param'
2
3
 
3
4
  class Helios::Backend::Data < Sinatra::Base
4
- use Rack::PostBodyContentTypeParser
5
+ helpers Sinatra::Param
5
6
 
6
- def initialize(xcdatamodel)
7
- super(Rack::CoreData(xcdatamodel))
7
+ def initialize(app, options = {})
8
+ super(Rack::CoreData(options[:model]))
8
9
 
9
- @model = Rack::CoreData::DataModel.new(xcdatamodel)
10
+ @model = Rack::CoreData::DataModel.new(options[:model])
10
11
  end
11
12
 
12
13
  before do
@@ -16,8 +17,8 @@ class Helios::Backend::Data < Sinatra::Base
16
17
  helpers Sinatra::Param
17
18
 
18
19
  options '/' do
19
- pass unless settings.frontend rescue false
20
-
20
+ pass unless self.class < Helios::Administerable
21
+
21
22
  links = []
22
23
  @model.entities.each do |entity|
23
24
  links << %{</#{entity.name.downcase.pluralize}>; rel="resource"}
@@ -1,8 +1,13 @@
1
1
  require 'rack/in-app-purchase'
2
+ require 'sinatra/param'
2
3
 
3
- class Helios::Backend::InAppPurchase < Rack::InAppPurchase
4
- use Rack::PostBodyContentTypeParser
4
+ class Helios::Backend::InAppPurchase < Sinatra::Base
5
+ helpers Sinatra::Param
5
6
 
7
+ def initialize(app, options = {})
8
+ super(Rack::InAppPurchase.new)
9
+ end
10
+
6
11
  before do
7
12
  content_type :json
8
13
  end
@@ -10,7 +15,10 @@ class Helios::Backend::InAppPurchase < Rack::InAppPurchase
10
15
  helpers Sinatra::Param
11
16
 
12
17
  get '/receipts' do
18
+ param :q, String
19
+
13
20
  receipts = Rack::InAppPurchase::Receipt.dataset
21
+ receipts = receipts.filter("tsv @@ to_tsquery('english', ?)", "#{params[:q]}:*") if params[:q] and not params[:q].empty?
14
22
 
15
23
  if params[:page] or params[:per_page]
16
24
  param :page, Integer, default: 1, min: 1
@@ -1,9 +1,19 @@
1
1
  require 'rack/passbook'
2
+ require 'sinatra/param'
3
+
4
+ class Helios::Backend::Passbook < Sinatra::Base
5
+ helpers Sinatra::Param
6
+
7
+ def initialize(app, options = {})
8
+ super(Rack::Passbook.new)
9
+ end
2
10
 
3
- class Helios::Backend::Passbook < Rack::Passbook
4
11
  get '/passes' do
5
- passes = Rack::Passbook::Pass.dataset
12
+ param :q, String
6
13
 
14
+ passes = Rack::Passbook::Pass.dataset
15
+ passes = passes.filter("tsv @@ to_tsquery('english', ?)", "#{params[:q]}:*") if params[:q] and not params[:q].empty?
16
+
7
17
  if params[:page] or params[:per_page]
8
18
  param :page, Integer, default: 1, min: 1
9
19
  param :per_page, Integer, default: 100, in: (1..100)
@@ -1,6 +1,13 @@
1
1
  require 'rack/push-notification'
2
+ require 'sinatra/param'
3
+
4
+ class Helios::Backend::PushNotification < Sinatra::Base
5
+ helpers Sinatra::Param
6
+
7
+ def initialize(app, options = {})
8
+ super(Rack::PushNotification.new)
9
+ end
2
10
 
3
- class Helios::Backend::PushNotification < Rack::PushNotification
4
11
  get '/devices/?' do
5
12
  param :q, String
6
13
 
@@ -1 +1,3 @@
1
- require 'helios/commands/new'
1
+ require 'helios/commands/new'
2
+ require 'helios/commands/link'
3
+ require 'helios/commands/server'
@@ -0,0 +1,18 @@
1
+ require 'fileutils'
2
+
3
+ command :link do |c|
4
+ c.syntax = 'helios link path/to/Model.xcdatamodel'
5
+ c.summary = 'Links a Core Data model'
6
+
7
+ c.action do |args, options|
8
+ say_error "Missing argument" and abort if args.empty?
9
+ path = args.first
10
+
11
+ begin
12
+ `cp -r #{path} .` # TODO symbolic link with git mount
13
+ say "Xcode Data Model successfully linked"
14
+ rescue => exception
15
+ say_error exception.message and abort
16
+ end
17
+ end
18
+ end
@@ -3,7 +3,26 @@ require 'fileutils'
3
3
  command :new do |c|
4
4
  c.syntax = 'helios new path/to/app'
5
5
  c.summary = 'Creates a new Helios project'
6
- c.description = ''
6
+ c.description = <<-EOF
7
+ The `helios new` command creates a new Helios application with a default
8
+ directory structure and configuration at the path you specify.
9
+ EOF
10
+ # c.example = <<-EOF
11
+ # helios new #{File.join(Dir.pwd, "app")}
12
+
13
+ # This generates a skeletal Helios installation in #{File.join(Dir.pwd, "app")}.
14
+ # See the README in the newly created application to get going.
15
+ # EOF
16
+
17
+ c.option '--skip-gemfile', "Don't create a Gemfile"
18
+ c.option '-B', '--skip-bundle', "Don't run bundle install"
19
+ c.option '-G', '--skip-git', "Don't create a git repository"
20
+
21
+ c.option '--edge', "Setup the application with Gemfile pointing to Helios repository"
22
+
23
+ c.option '-f', '--force', "Overwrite files that already exist"
24
+ c.option '-p', '--pretend', "Run but do not make any changes"
25
+ c.option '-s', '--skip', "Skip files that already exist"
7
26
 
8
27
  c.action do |args, options|
9
28
  say_error "Missing argument" and abort if args.empty?
@@ -12,16 +31,34 @@ command :new do |c|
12
31
 
13
32
  begin
14
33
  FileUtils.mkdir_p(path) and Dir.chdir(path)
15
- Dir.glob(File.join(File.dirname(__FILE__), "../templates/") + "*.erb", File::FNM_DOTMATCH).each do |file|
16
- template = ERB.new(File.read(file))
34
+ Dir.glob(File.join(File.dirname(__FILE__), "../templates/") + "*.erb", File::FNM_DOTMATCH).each do |template|
35
+ file = File.basename(template, ".erb")
36
+ erb = ERB.new(File.read(template))
37
+
38
+ next if file === "Gemfile" and options.skip_gemfile
17
39
 
18
- log "create", File.basename(file, ".erb")
19
- File.open(File.basename(file, ".erb"), 'w') do |f|
20
- f.puts template.result
40
+ if File.exist?(file)
41
+ if options.force and not options.skip
42
+ log "create", file
43
+ else
44
+ log "exists", file
45
+ end
46
+ end
47
+
48
+ next if options.pretend
49
+
50
+ File.open(file, 'w') do |f|
51
+ f.puts erb.result binding
21
52
  end
22
53
  end
54
+
55
+ `bundle` unless options.skip_bundle or not File.exist?("Gemfile")
56
+ `git init` unless options.skip_git
23
57
  rescue => exception
24
58
  say_error exception.message and abort
25
59
  end
26
60
  end
27
61
  end
62
+
63
+ alias_command :create, :new
64
+ alias_command :generate, :new
@@ -0,0 +1,16 @@
1
+ command :server do |c|
2
+ c.syntax = 'helios server'
3
+ c.summary = 'Start running Helios locally'
4
+
5
+ c.action do |args, options|
6
+ begin
7
+ `foreman start`
8
+ rescue => exception
9
+ say_error exception.message and abort
10
+ end
11
+ end
12
+ end
13
+
14
+ alias_command :s, :server
15
+ alias_command :start, :server
16
+ alias_command :launch, :server
@@ -9,23 +9,31 @@ require 'zurb-foundation'
9
9
  module Helios
10
10
  class Frontend < Sinatra::Base
11
11
  set :root, File.join(File.dirname(__FILE__), "frontend")
12
+ set :sass, load_paths: ["#{self.root}/stylesheets"]
12
13
 
13
14
  register Sinatra::CompassSupport
14
15
  register Sinatra::AssetPack
15
16
  register Sinatra::JstPages
16
-
17
+
17
18
  assets do
18
19
  serve '/javascripts', from: '/javascripts'
19
20
  serve '/stylesheets', from: '/stylesheets'
20
21
  serve '/images', from: '/images'
22
+ serve '/fonts', from: '/fonts'
21
23
 
22
24
  js :application, '/javascripts/application.js', [
23
25
  'javascripts/vendor/jquery.js',
24
26
  'javascripts/vendor/underscore.js',
25
27
  'javascripts/vendor/backbone.js',
28
+ 'javascripts/vendor/backbone.paginator.js',
26
29
  'javascripts/vendor/backbone.datagrid.js',
27
- 'javascripts/foundation/foundation.js',
28
- 'javascripts/foundation/*',
30
+ 'javascripts/vendor/codemirror.js',
31
+ 'javascripts/vendor/codemirror.javascript.js',
32
+ 'javascripts/vendor/foundation.js',
33
+ 'javascripts/vendor/foundation/foundation.dropdown.js',
34
+ 'javascripts/vendor/foundation/foundation.reveal.js',
35
+ 'javascripts/vendor/foundation/*',
36
+ 'javascripts/vendor/date.js',
29
37
  'javascripts/helios.js',
30
38
  'javascripts/helios/models.js',
31
39
  'javascripts/helios/collections.js',
@@ -46,8 +54,6 @@ module Helios
46
54
  end
47
55
 
48
56
  get '/' do
49
- content_type :html
50
-
51
57
  haml :index
52
58
  end
53
59
  end
@@ -7,10 +7,7 @@ window.Helios = {
7
7
  Routers: {}
8
8
 
9
9
  initialize: ->
10
- console.log("initialize")
11
-
12
10
  @entities = Helios.entities
13
-
14
11
 
15
12
  window.app = new Helios.Routers.Root
16
13
  for entity in @entities.models
@@ -20,17 +17,20 @@ window.Helios = {
20
17
  @views.entity = new Helios.Views.Entity({model: entity})
21
18
  window.app.route entity.url(), name
22
19
 
20
+
23
21
  window.app.views.entities = new Helios.Views.Entities({collection: @entities})
24
22
  window.app.views.entities.render()
25
-
23
+
26
24
  Backbone.history.start({
27
25
  root: window.location.pathname,
28
- pushState: false,
26
+ pushState: false,
29
27
  hashChange: true
30
28
  })
31
29
  }
32
30
 
33
31
  $ ->
32
+ $(document).foundation()
33
+
34
34
  # $('a').on('click', (event) ->
35
35
  # console.log("click!", $(this).attr('href'))
36
36
  # href = $(this).attr('href')