helios_aim 0.2.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.
- checksums.yaml +15 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +173 -0
- data/LICENSE +19 -0
- data/README.md +363 -0
- data/Rakefile +10 -0
- data/bin/helios +20 -0
- data/helios_aim.gemspec +47 -0
- data/lib/helios.rb +27 -0
- data/lib/helios/backend.rb +64 -0
- data/lib/helios/backend/data.rb +40 -0
- data/lib/helios/backend/in-app-purchase.rb +43 -0
- data/lib/helios/backend/newsstand.rb +97 -0
- data/lib/helios/backend/passbook.rb +41 -0
- data/lib/helios/backend/push-notification.rb +110 -0
- data/lib/helios/commands.rb +4 -0
- data/lib/helios/commands/console.rb +21 -0
- data/lib/helios/commands/link.rb +19 -0
- data/lib/helios/commands/new.rb +76 -0
- data/lib/helios/commands/server.rb +52 -0
- data/lib/helios/frontend.rb +66 -0
- data/lib/helios/frontend/fonts/icons.eot +0 -0
- data/lib/helios/frontend/fonts/icons.ttf +0 -0
- data/lib/helios/frontend/fonts/icons.woff +0 -0
- data/lib/helios/frontend/images/bg.jpg +0 -0
- data/lib/helios/frontend/images/helios.svg +33 -0
- data/lib/helios/frontend/javascripts/helios.coffee +72 -0
- data/lib/helios/frontend/javascripts/helios/collections.coffee +99 -0
- data/lib/helios/frontend/javascripts/helios/models.coffee +23 -0
- data/lib/helios/frontend/javascripts/helios/router.coffee +50 -0
- data/lib/helios/frontend/javascripts/helios/views.coffee +307 -0
- data/lib/helios/frontend/javascripts/vendor/backbone.datagrid.js +662 -0
- data/lib/helios/frontend/javascripts/vendor/backbone.js +1487 -0
- data/lib/helios/frontend/javascripts/vendor/backbone.paginator.js +1046 -0
- data/lib/helios/frontend/javascripts/vendor/codemirror.javascript.js +411 -0
- data/lib/helios/frontend/javascripts/vendor/codemirror.js +3047 -0
- data/lib/helios/frontend/javascripts/vendor/date.js +104 -0
- data/lib/helios/frontend/javascripts/vendor/foundation.js +331 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.alerts.js +50 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.clearing.js +478 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.cookie.js +74 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.dropdown.js +122 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.forms.js +403 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.joyride.js +613 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.magellan.js +130 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.orbit.js +355 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.placeholder.js +159 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.reveal.js +272 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.section.js +183 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.tooltips.js +195 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.topbar.js +208 -0
- data/lib/helios/frontend/javascripts/vendor/jquery.js +9597 -0
- data/lib/helios/frontend/javascripts/vendor/jquery/jquery.fileupload-ui.js +807 -0
- data/lib/helios/frontend/javascripts/vendor/jquery/jquery.fileupload.js +1201 -0
- data/lib/helios/frontend/javascripts/vendor/jquery/jquery.ui.widget.js +530 -0
- data/lib/helios/frontend/javascripts/vendor/linkheaders.js +117 -0
- data/lib/helios/frontend/javascripts/vendor/underscore.js +1227 -0
- data/lib/helios/frontend/stylesheets/_codemirror.sass +219 -0
- data/lib/helios/frontend/stylesheets/_fonts.sass +80 -0
- data/lib/helios/frontend/stylesheets/_iphone.sass +141 -0
- data/lib/helios/frontend/stylesheets/_settings.scss +989 -0
- data/lib/helios/frontend/stylesheets/screen.sass +187 -0
- data/lib/helios/frontend/templates/data/entities.jst.tpl +11 -0
- data/lib/helios/frontend/templates/in-app-purchase/receipts.jst.tpl +11 -0
- data/lib/helios/frontend/templates/navigation.jst.tpl +31 -0
- data/lib/helios/frontend/templates/newsstand/issues.jst.tpl +16 -0
- data/lib/helios/frontend/templates/newsstand/new.jst.tpl +28 -0
- data/lib/helios/frontend/templates/passbook/passes.jst.tpl +11 -0
- data/lib/helios/frontend/templates/push-notification/compose.jst.tpl +70 -0
- data/lib/helios/frontend/templates/push-notification/devices.jst.tpl +17 -0
- data/lib/helios/frontend/views/index.haml +22 -0
- data/lib/helios/templates/.env.erb +1 -0
- data/lib/helios/templates/.gitignore +3 -0
- data/lib/helios/templates/Gemfile.erb +10 -0
- data/lib/helios/templates/Procfile.erb +1 -0
- data/lib/helios/templates/README.md.erb +4 -0
- data/lib/helios/templates/config.ru.erb +11 -0
- data/lib/helios/version.rb +3 -0
- metadata +475 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
command :console do |c|
|
|
2
|
+
c.syntax = 'helios console'
|
|
3
|
+
c.summary = 'Open IRB session with Helios environment'
|
|
4
|
+
|
|
5
|
+
c.action do |args, options|
|
|
6
|
+
require 'irb'
|
|
7
|
+
require 'dotenv'
|
|
8
|
+
require 'sequel'
|
|
9
|
+
require 'helios'
|
|
10
|
+
|
|
11
|
+
include Rack
|
|
12
|
+
|
|
13
|
+
Dotenv.load
|
|
14
|
+
Sequel.connect(ENV['DATABASE_URL'])
|
|
15
|
+
|
|
16
|
+
ARGV.clear
|
|
17
|
+
IRB.start
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
alias_command :c, :console
|
|
@@ -0,0 +1,19 @@
|
|
|
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: path/to/Model.xcdatamodel" and abort if args.empty?
|
|
9
|
+
path = args.first
|
|
10
|
+
|
|
11
|
+
begin
|
|
12
|
+
File.link(path, File.basename(path))
|
|
13
|
+
say_ok "Xcode data model successfully linked"
|
|
14
|
+
say "Any changes made to the data model file will automatically be propagated to Helios the next time the server is started."
|
|
15
|
+
rescue => exception
|
|
16
|
+
say_error exception.message and abort
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
3
|
+
command :new do |c|
|
|
4
|
+
c.syntax = 'helios new path/to/app'
|
|
5
|
+
c.summary = 'Creates a new Helios project'
|
|
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"
|
|
26
|
+
|
|
27
|
+
c.action do |args, options|
|
|
28
|
+
say_error "Missing argument: path/to/app" and abort if args.empty?
|
|
29
|
+
path = args.first
|
|
30
|
+
app_name = path.split(/\//).last
|
|
31
|
+
|
|
32
|
+
begin
|
|
33
|
+
FileUtils.mkdir_p(path) and Dir.chdir(path)
|
|
34
|
+
|
|
35
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../templates/") + "*.erb", File::FNM_DOTMATCH).each do |template|
|
|
36
|
+
file = File.basename(template, ".erb")
|
|
37
|
+
erb = ERB.new(File.read(template))
|
|
38
|
+
|
|
39
|
+
next if file === "Gemfile" and options.skip_gemfile
|
|
40
|
+
|
|
41
|
+
if File.exist?(file)
|
|
42
|
+
if options.force and not options.skip
|
|
43
|
+
log "overwrite", file
|
|
44
|
+
else
|
|
45
|
+
log "exists", file
|
|
46
|
+
end
|
|
47
|
+
else
|
|
48
|
+
log "create", file
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
next if options.pretend
|
|
52
|
+
|
|
53
|
+
File.open(file, 'w') do |f|
|
|
54
|
+
f.puts erb.result binding
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
unless options.skip_bundle or not File.exist?("Gemfile")
|
|
59
|
+
log "run", "bundle install"
|
|
60
|
+
system 'bundle install'
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
unless options.skip_git
|
|
64
|
+
log "run", "git init"
|
|
65
|
+
system 'git init'
|
|
66
|
+
system 'git add .'
|
|
67
|
+
system 'git commit -m "Initial Commit"'
|
|
68
|
+
end
|
|
69
|
+
rescue => exception
|
|
70
|
+
say_error exception.message and abort
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
alias_command :create, :new
|
|
76
|
+
alias_command :generate, :new
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'dotenv'
|
|
2
|
+
require 'sequel'
|
|
3
|
+
|
|
4
|
+
command :server do |c|
|
|
5
|
+
c.syntax = 'helios server'
|
|
6
|
+
c.summary = 'Start running Helios locally'
|
|
7
|
+
c.option '-w', "--[no-]warn", "Warn about possible database issues"
|
|
8
|
+
|
|
9
|
+
c.action do |args, options|
|
|
10
|
+
validate_database_settings! unless options.warn == false
|
|
11
|
+
|
|
12
|
+
begin
|
|
13
|
+
exec 'foreman start'
|
|
14
|
+
rescue => exception
|
|
15
|
+
say_error exception.message and abort
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
alias_command :s, :server
|
|
21
|
+
alias_command :start, :server
|
|
22
|
+
alias_command :launch, :server
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def validate_database_settings!
|
|
27
|
+
Dotenv.load
|
|
28
|
+
|
|
29
|
+
say_error "DATABASE_URL environment variable not set in .env or in Rails config/database.yml" and abort if ENV['DATABASE_URL'].nil?
|
|
30
|
+
|
|
31
|
+
uri = URI(ENV['DATABASE_URL'])
|
|
32
|
+
|
|
33
|
+
say_error "DATABASE_URL environment variable not set to PostgreSQL database" and abort unless ["postgres", "postgresql"].include?(uri.scheme)
|
|
34
|
+
|
|
35
|
+
begin
|
|
36
|
+
db = Sequel.connect(ENV['DATABASE_URL'])
|
|
37
|
+
db.test_connection
|
|
38
|
+
rescue Sequel::DatabaseConnectionError => error
|
|
39
|
+
say_warning %{Error connecting to database: "#{error.message.strip}"}
|
|
40
|
+
case error.message
|
|
41
|
+
when /database "(.+)" does not exist/
|
|
42
|
+
if agree "Would you like to create this database now? (y/n)"
|
|
43
|
+
host, database = uri.host, uri.path.delete("/")
|
|
44
|
+
|
|
45
|
+
log 'createdb', database
|
|
46
|
+
system "createdb -h #{host} #{database}"
|
|
47
|
+
end
|
|
48
|
+
else
|
|
49
|
+
abort unless agree "Continue starting Helios? (y/n)"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require 'sinatra/base'
|
|
2
|
+
require 'sinatra/assetpack'
|
|
3
|
+
require 'sinatra/backbone'
|
|
4
|
+
require 'sinatra/support'
|
|
5
|
+
require 'rack/contrib'
|
|
6
|
+
|
|
7
|
+
require 'compass'
|
|
8
|
+
require 'zurb-foundation'
|
|
9
|
+
|
|
10
|
+
module Helios
|
|
11
|
+
class Frontend < Sinatra::Base
|
|
12
|
+
set :root, File.join(File.dirname(__FILE__), "frontend")
|
|
13
|
+
set :sass, load_paths: ["#{self.root}/stylesheets"]
|
|
14
|
+
|
|
15
|
+
register Sinatra::CompassSupport
|
|
16
|
+
register Sinatra::AssetPack
|
|
17
|
+
register Sinatra::JstPages
|
|
18
|
+
|
|
19
|
+
use Rack::BounceFavicon
|
|
20
|
+
|
|
21
|
+
assets do
|
|
22
|
+
serve '/javascripts', from: '/javascripts'
|
|
23
|
+
serve '/stylesheets', from: '/stylesheets'
|
|
24
|
+
serve '/images', from: '/images'
|
|
25
|
+
serve '/fonts', from: '/fonts'
|
|
26
|
+
|
|
27
|
+
js :application, '/javascripts/application.js', [
|
|
28
|
+
'javascripts/vendor/jquery.js',
|
|
29
|
+
'javascripts/vendor/jquery/jquery.ui.widget.js',
|
|
30
|
+
'javascripts/vendor/jquery/jquery.fileupload.js',
|
|
31
|
+
'javascripts/vendor/jquery/jquery.fileupload-ui.js',
|
|
32
|
+
'javascripts/vendor/underscore.js',
|
|
33
|
+
'javascripts/vendor/backbone.js',
|
|
34
|
+
'javascripts/vendor/backbone.paginator.js',
|
|
35
|
+
'javascripts/vendor/backbone.datagrid.js',
|
|
36
|
+
'javascripts/vendor/codemirror.js',
|
|
37
|
+
'javascripts/vendor/codemirror.javascript.js',
|
|
38
|
+
'javascripts/vendor/foundation.js',
|
|
39
|
+
'javascripts/vendor/foundation/foundation.dropdown.js',
|
|
40
|
+
'javascripts/vendor/foundation/foundation.reveal.js',
|
|
41
|
+
'javascripts/vendor/date.js',
|
|
42
|
+
'javascripts/vendor/linkheaders.js',
|
|
43
|
+
'javascripts/helios.js',
|
|
44
|
+
'javascripts/helios/models.js',
|
|
45
|
+
'javascripts/helios/collections.js',
|
|
46
|
+
'javascripts/helios/templates.js',
|
|
47
|
+
'javascripts/helios/views.js',
|
|
48
|
+
'javascripts/helios/router.js',
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
css :application, '/stylesheets/application.css', [
|
|
52
|
+
'stylesheets/screen.css'
|
|
53
|
+
]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
serve_jst '/javascripts/helios/templates.js', root: settings.root + '/templates'
|
|
57
|
+
|
|
58
|
+
get '' do
|
|
59
|
+
redirect request.fullpath + "/"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
get '/' do
|
|
63
|
+
haml :index
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
4
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
5
|
+
width="200px" height="100px" viewBox="0 0 200 100" enable-background="new 0 0 200 100" xml:space="preserve">
|
|
6
|
+
<g>
|
|
7
|
+
<path fill="#BFBC3D" d="M11.75,44.979c1.637-2.497,5.251-5.166,11.019-5.166c11.708,0,14.463,7.49,14.463,14.982v21.518
|
|
8
|
+
c0,2.587-2.065,4.477-4.647,4.477c-2.757,0-4.649-1.89-4.649-4.477V56.515c0-4.908-1.98-8.265-7.575-8.265
|
|
9
|
+
c-6.458,0-8.61,3.788-8.61,8.869v19.193c0,2.587-1.98,4.477-4.647,4.477c-2.669,0-4.65-1.89-4.65-4.477V23.457
|
|
10
|
+
c0-2.582,2.065-4.649,4.65-4.649c2.582,0,4.647,2.068,4.647,4.649V44.979z"/>
|
|
11
|
+
<path fill="#BFBC3D" d="M62.28,39.813c14.548,0,17.216,11.192,17.216,17.13c0,3.186,0,6.889-5.251,6.889H52.98
|
|
12
|
+
c0,6.196,4.392,9.041,10.074,9.041c3.788,0,6.455-1.296,8.522-2.67c0.945-0.604,1.635-0.949,2.755-0.949
|
|
13
|
+
c2.239,0,4.046,1.808,4.046,4.048c0,1.379-0.689,2.494-1.464,3.186c-1.464,1.379-6.026,4.735-13.859,4.735
|
|
14
|
+
c-11.967,0-19.372-6.459-19.372-20.835C43.683,47.217,50.571,39.813,62.28,39.813z M53.238,56.086h17.048
|
|
15
|
+
c0-4.221-2.412-8.352-8.006-8.352C57.286,47.734,53.669,50.574,53.238,56.086z"/>
|
|
16
|
+
<path fill="#BFBC3D" d="M95.676,23.457v47.175c0,1.033,1.033,1.55,1.637,1.55c2.409,0,4.304,1.895,4.304,4.306
|
|
17
|
+
c0,2.412-1.895,4.302-4.304,4.302c-6.715,0-10.934-3.785-10.934-11.019V23.457c0-2.582,2.066-4.649,4.647-4.649
|
|
18
|
+
C93.611,18.807,95.676,20.875,95.676,23.457z"/>
|
|
19
|
+
<path fill="#BFBC3D" d="M106.433,30.257c0-3.96,1.982-5.683,5.51-5.683c3.615,0,5.598,1.722,5.598,5.683
|
|
20
|
+
c0,3.356-1.982,5.424-5.598,5.424C108.415,35.682,106.433,33.614,106.433,30.257z M116.595,76.142c0,2.582-2.07,4.647-4.652,4.647
|
|
21
|
+
s-4.647-2.065-4.647-4.647V44.979c0-2.584,2.065-4.65,4.647-4.65s4.652,2.065,4.652,4.65V76.142z"/>
|
|
22
|
+
<path fill="#BFBC3D" d="M142.248,81.223c-11.623,0-18.857-6.63-18.857-20.664c0-14.116,7.234-20.746,18.857-20.746
|
|
23
|
+
c11.618,0,18.853,6.63,18.853,20.746C161.101,74.593,153.866,81.223,142.248,81.223z M142.248,47.734
|
|
24
|
+
c-6.201,0-9.471,4.304-9.471,12.825c0,8.437,3.27,12.743,9.471,12.743c6.196,0,9.47-4.307,9.47-12.743
|
|
25
|
+
C151.718,52.038,148.444,47.734,142.248,47.734z"/>
|
|
26
|
+
<path fill="#BFBC3D" d="M176.675,51.176c0,6.372,21.177,3.444,21.177,17.649c0,8.091-6.884,12.223-15.754,12.223
|
|
27
|
+
c-7.4,0-13.085-3.356-15.233-6.026c-0.692-0.857-1.038-1.632-1.038-2.665c0-2.24,1.896-4.136,4.136-4.136
|
|
28
|
+
c0.857,0,1.72,0.259,2.67,1.033c2.323,1.895,5.164,3.531,9.466,3.531c3.877,0,6.371-1.032,6.371-3.443
|
|
29
|
+
c0-6.977-21.089-3.357-21.089-17.993c0-7.748,6.455-11.536,14.376-11.536c6.109,0,11.536,2.324,13.947,5.336
|
|
30
|
+
c0.517,0.689,0.857,1.293,0.857,2.584c0,2.238-1.891,4.131-4.131,4.131c-1.203,0-1.979-0.517-2.928-1.206
|
|
31
|
+
c-1.896-1.376-4.219-2.755-7.746-2.755C178.57,47.904,176.675,49.025,176.675,51.176z"/>
|
|
32
|
+
</g>
|
|
33
|
+
</svg>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
window.Helios = {
|
|
2
|
+
Version: "0.0.1"
|
|
3
|
+
|
|
4
|
+
Models: {}
|
|
5
|
+
Collections: {}
|
|
6
|
+
Views: {}
|
|
7
|
+
Routers: {}
|
|
8
|
+
|
|
9
|
+
initialize: ->
|
|
10
|
+
window.app = new Helios.Routers.Root
|
|
11
|
+
|
|
12
|
+
for entity in Helios.entities.models
|
|
13
|
+
do (entity) ->
|
|
14
|
+
name = entity.get('name').toLowerCase()
|
|
15
|
+
window.app[name] = ->
|
|
16
|
+
@views.entity = new Helios.Views.Entity({model: entity})
|
|
17
|
+
window.app.route entity.url(), name
|
|
18
|
+
|
|
19
|
+
window.app.views.entities = new Helios.Views.Entities({collection: Helios.entities})
|
|
20
|
+
window.app.views.entities.render() if Helios.services['data']
|
|
21
|
+
|
|
22
|
+
Backbone.history.start({
|
|
23
|
+
root: window.location.pathname,
|
|
24
|
+
pushState: false,
|
|
25
|
+
hashChange: true
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
$ ->
|
|
30
|
+
$.fn.serializeMultipart = ->
|
|
31
|
+
obj = $(this)
|
|
32
|
+
|
|
33
|
+
formData = new FormData()
|
|
34
|
+
$.each $(obj).find("input[type='file']"), (i, tag) ->
|
|
35
|
+
$.each $(tag)[0].files, (j, file) ->
|
|
36
|
+
formData.append tag.name, file
|
|
37
|
+
|
|
38
|
+
params = $(obj).serializeArray()
|
|
39
|
+
$.each params, (i, val) ->
|
|
40
|
+
formData.append val.name, val.value
|
|
41
|
+
|
|
42
|
+
formData
|
|
43
|
+
|
|
44
|
+
$(document).foundation()
|
|
45
|
+
$('body').delegate 'a[href^=#]', 'click', (event) ->
|
|
46
|
+
event.preventDefault()
|
|
47
|
+
href = $(this).attr('href')
|
|
48
|
+
window.app.navigate(href, {trigger: true, replace: true})
|
|
49
|
+
|
|
50
|
+
Helios.services = {}
|
|
51
|
+
$.ajax(type: 'OPTIONS', url: "/", success: (data, status, xhr) ->
|
|
52
|
+
header = xhr.getResponseHeader("Link")
|
|
53
|
+
$.linkheaders(header).each (idx, link) ->
|
|
54
|
+
href = link.attr('href')
|
|
55
|
+
rel = link.rels()[0]
|
|
56
|
+
|
|
57
|
+
switch rel
|
|
58
|
+
when "Helios::Backend::Data"
|
|
59
|
+
Helios.services['data'] = href
|
|
60
|
+
when "Helios::Backend::InAppPurchase"
|
|
61
|
+
Helios.services['in-app-purchase'] = href
|
|
62
|
+
when "Helios::Backend::Newsstand"
|
|
63
|
+
Helios.services['newsstand'] = href
|
|
64
|
+
when "Helios::Backend::PushNotification"
|
|
65
|
+
Helios.services['push-notification'] = href
|
|
66
|
+
when "Helios::Backend::Passbook"
|
|
67
|
+
Helios.services['passbook'] = href
|
|
68
|
+
|
|
69
|
+
Helios.entities = new Helios.Collections.Entities
|
|
70
|
+
Helios.entities.fetch(type: 'OPTIONS', url: (Helios.services['data'] || "") + '/resources', success: Helios.initialize, error: Helios.initialize)
|
|
71
|
+
)
|
|
72
|
+
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
class Helios.Collection extends Backbone.Paginator.requestPager
|
|
2
|
+
paginator_ui:
|
|
3
|
+
firstPage: 1,
|
|
4
|
+
currentPage: 1,
|
|
5
|
+
perPage: 20
|
|
6
|
+
|
|
7
|
+
server_api:
|
|
8
|
+
'q': ->
|
|
9
|
+
@query || ""
|
|
10
|
+
'limit': ->
|
|
11
|
+
@perPage
|
|
12
|
+
'offset': ->
|
|
13
|
+
(@currentPage - 1) * @perPage
|
|
14
|
+
|
|
15
|
+
parse: (response, options) ->
|
|
16
|
+
if _.isArray(response)
|
|
17
|
+
response
|
|
18
|
+
else
|
|
19
|
+
if response.page?
|
|
20
|
+
@total = response.total
|
|
21
|
+
@page = response.page
|
|
22
|
+
@totalPages = Math.ceil(@total / @perPage)
|
|
23
|
+
|
|
24
|
+
_.detect response, (value, key) ->
|
|
25
|
+
_.isArray(value)
|
|
26
|
+
|
|
27
|
+
class Helios.Collections.Entities extends Backbone.Collection
|
|
28
|
+
model: Helios.Models.Entity
|
|
29
|
+
url: '/'
|
|
30
|
+
|
|
31
|
+
parse: (response, options) ->
|
|
32
|
+
if _.isArray(response)
|
|
33
|
+
response
|
|
34
|
+
else
|
|
35
|
+
if response.page?
|
|
36
|
+
@total = response.total
|
|
37
|
+
@page = response.page
|
|
38
|
+
@totalPages = Math.ceil(@total / @perPage)
|
|
39
|
+
|
|
40
|
+
_.detect response, (value, key) ->
|
|
41
|
+
_.isArray(value)
|
|
42
|
+
|
|
43
|
+
class Helios.Collections.Resources extends Backbone.Collection
|
|
44
|
+
model: Helios.Models.Resource
|
|
45
|
+
|
|
46
|
+
parse: (response, options) ->
|
|
47
|
+
if _.isArray(response)
|
|
48
|
+
response
|
|
49
|
+
else
|
|
50
|
+
if response.page?
|
|
51
|
+
@total = response.total
|
|
52
|
+
@page = response.page
|
|
53
|
+
@totalPages = Math.ceil(@total / @perPage)
|
|
54
|
+
|
|
55
|
+
_.detect response, (value, key) ->
|
|
56
|
+
_.isArray(value)
|
|
57
|
+
|
|
58
|
+
class Helios.Collections.Devices extends Helios.Collection
|
|
59
|
+
model: Helios.Models.Device
|
|
60
|
+
fields: ['token', 'alias', 'badge', 'locale', 'language', 'timezone', 'ip_address', 'lat', 'lng']
|
|
61
|
+
|
|
62
|
+
paginator_core:
|
|
63
|
+
type: 'GET'
|
|
64
|
+
dataType: 'json'
|
|
65
|
+
url: '/devices?'
|
|
66
|
+
|
|
67
|
+
comparator: (device) ->
|
|
68
|
+
device.get('token')
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class Helios.Collections.Receipts extends Helios.Collection
|
|
72
|
+
model: Helios.Models.Receipt
|
|
73
|
+
|
|
74
|
+
fields: ['transaction_id', 'product_id', 'purchase_date', 'original_transaction_id', 'original_purchase_date', 'app_item_id', 'version_external_identifier', 'bid', 'bvrs', 'ip_address']
|
|
75
|
+
|
|
76
|
+
paginator_core:
|
|
77
|
+
type: 'GET'
|
|
78
|
+
dataType: 'json'
|
|
79
|
+
url: '/receipts?'
|
|
80
|
+
|
|
81
|
+
class Helios.Collections.Passes extends Helios.Collection
|
|
82
|
+
model: Helios.Models.Pass
|
|
83
|
+
url: '/passes'
|
|
84
|
+
fields: ['pass_type_identifier', 'serial_number', 'authentication_token']
|
|
85
|
+
|
|
86
|
+
paginator_core:
|
|
87
|
+
type: 'GET'
|
|
88
|
+
dataType: 'json'
|
|
89
|
+
url: '/passes?'
|
|
90
|
+
|
|
91
|
+
class Helios.Collections.Issues extends Helios.Collection
|
|
92
|
+
model: Helios.Models.Issue
|
|
93
|
+
url: '/issues'
|
|
94
|
+
fields: ['name', 'title', 'summary', 'published_at', 'expires_at']
|
|
95
|
+
|
|
96
|
+
paginator_core:
|
|
97
|
+
type: 'GET'
|
|
98
|
+
dataType: 'json'
|
|
99
|
+
url: '/issues?'
|