fanforce-app-factory 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +21 -0
- data/Gemfile +2 -0
- data/README.md +182 -0
- data/Rakefile +16 -0
- data/fanforce-app-factory.gemspec +40 -0
- data/lib/fanforce/app_factory.rake +71 -0
- data/lib/fanforce/app_factory.rb +56 -0
- data/lib/fanforce/app_factory/_init_sinatra.rb +54 -0
- data/lib/fanforce/app_factory/assets/css/dashboard.scss +24 -0
- data/lib/fanforce/app_factory/assets/css/promotional.scss +1 -0
- data/lib/fanforce/app_factory/assets/img/icon-16.png +0 -0
- data/lib/fanforce/app_factory/assets/img/icon-32.png +0 -0
- data/lib/fanforce/app_factory/assets/img/icon-42.png +0 -0
- data/lib/fanforce/app_factory/assets/img/marketplace.png +0 -0
- data/lib/fanforce/app_factory/assets/img/marketplace.psd +0 -0
- data/lib/fanforce/app_factory/assets/js/dashboard.coffee +18 -0
- data/lib/fanforce/app_factory/assets/js/promotional.js +1 -0
- data/lib/fanforce/app_factory/assets/lib/common/_mixins.scss +97 -0
- data/lib/fanforce/app_factory/assets/lib/common/_tags.scss +83 -0
- data/lib/fanforce/app_factory/assets/lib/common/_variables.scss +27 -0
- data/lib/fanforce/app_factory/assets/lib/common/icons/dropdown-arrow.png +0 -0
- data/lib/fanforce/app_factory/assets/lib/common/icons/initiative.png +0 -0
- data/lib/fanforce/app_factory/assets/lib/common/layouts/_dashboard.scss +18 -0
- data/lib/fanforce/app_factory/assets/lib/common/layouts/_promotional.scss +27 -0
- data/lib/fanforce/app_factory/assets/lib/common/layouts/dashboard.js +6 -0
- data/lib/fanforce/app_factory/assets/lib/common/layouts/promotional.js +1 -0
- data/lib/fanforce/app_factory/assets/lib/promotional/fanforce_bg.png +0 -0
- data/lib/fanforce/app_factory/assets/lib/promotional/icon-42.png +0 -0
- data/lib/fanforce/app_factory/assets/lib/promotional/icon-plus.png +0 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/bootstrap/css/bootstrap.css +6103 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/bootstrap/css/bootstrap.min.css +868 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/bootstrap/img/glyphicons-halflings-white.png +0 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/bootstrap/img/glyphicons-halflings.png +0 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/bootstrap/js/bootstrap.js +2170 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/bootstrap/js/bootstrap.min.js +7 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/chosen/chosen-sprite.png +0 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/chosen/chosen.jquery.min.js +10 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/chosen/chosen.scss +399 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/font-awesome/css/font-awesome.css +540 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/font-awesome/css/font-awesome.min.css +33 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/font-awesome/font/FontAwesome.otf +0 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/font-awesome/font/fontawesome-webfont.eot +0 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/font-awesome/font/fontawesome-webfont.svg +284 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/font-awesome/font/fontawesome-webfont.ttf +0 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/font-awesome/font/fontawesome-webfont.woff +0 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/jquery/jquery.inputHint.js +154 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/jquery/jquery.tmpl.debug.js +484 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/knockout/knockout.custom-handlers.coffee +131 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/knockout/knockout.debug.js +3223 -0
- data/lib/fanforce/app_factory/assets/lib/vendors/underscore/underscore.debug.js +999 -0
- data/lib/fanforce/app_factory/config/_error_handling.rb +26 -0
- data/lib/fanforce/app_factory/config/helpers/assets.rb +23 -0
- data/lib/fanforce/app_factory/config/helpers/fanforce.rb +21 -0
- data/lib/fanforce/app_factory/config/helpers/json.rb +10 -0
- data/lib/fanforce/app_factory/config/sinatra_config.rb +51 -0
- data/lib/fanforce/app_factory/initializers/ff_globals.rb +72 -0
- data/lib/fanforce/app_factory/layouts/dashboard.haml +14 -0
- data/lib/fanforce/app_factory/layouts/promotional.haml +14 -0
- data/lib/fanforce/app_factory/public/favicon.ico +0 -0
- data/lib/fanforce/app_factory/routes.rb +41 -0
- data/lib/fanforce/app_factory/sprockets/compiler.rb +105 -0
- data/lib/fanforce/app_factory/sprockets/hacks.rb +43 -0
- data/lib/fanforce/app_factory/version.rb +5 -0
- data/lib/fanforce/app_factory/views/dashboard.haml +38 -0
- data/lib/fanforce/app_factory/views/index.haml +38 -0
- data/lib/fanforce/app_factory_workers.rb +1 -0
- data/lib/fanforce_app_factory.rb +2 -0
- metadata +376 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MjFjYjNmZjFhZGEyZGYxNTZkZThkZjI0NWU0NzgxMDg5NTM2ZjZmNQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzZjYmIzZmFiYWZhZjI1YTZkNWI4ZDA1MTYzNGFiMDMxNDUxZDU4Mw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZmQzZmQxZjBkMTM1OTU5ODEwMTAwYWMxNDUyNWY1MzAwZTIxMmU2MTliODAw
|
10
|
+
Mzk5YjM5MTFlMDcxMjViNjYxZGZhZTljZDU1ZjE1ZGNhYzc1NzlhY2IyZjkx
|
11
|
+
OTUwYWI1ZjhjMWNhMDVmN2JlNzAzNmVmNTJmOWY0NzU4MzFiNjM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ODI5OGI2NjI5MDAzNTIyYjZlYjEyMjg3MDRmOTVkMTQ3MzIxN2FhMTc4YzQ0
|
14
|
+
NTc2YjhmY2I2ZjA5YTNmYWQ0MzI4ZjQ2YThjODZmNTkwN2M1NDllMTkxYTlk
|
15
|
+
OWUwYTcxYmQ5NzY4NWUzMjczNzA4MDJlMTEwYzUzZTk4MWYzYzE=
|
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
coverage
|
6
|
+
InstalledFiles
|
7
|
+
lib/bundler/man
|
8
|
+
pkg
|
9
|
+
rdoc
|
10
|
+
spec/reports
|
11
|
+
test/tmp
|
12
|
+
test/version_tmp
|
13
|
+
tmp
|
14
|
+
.idea/
|
15
|
+
.DS_STORE
|
16
|
+
Gemfile.lock
|
17
|
+
|
18
|
+
# YARD artifacts
|
19
|
+
.yardoc
|
20
|
+
_yardoc
|
21
|
+
doc/
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
fanforce-app-factory
|
2
|
+
========
|
3
|
+
The fanforce-app-factory is a gem that makes it really easy to create new Fanforce Apps using convention over configuration.
|
4
|
+
|
5
|
+
# Easy Setup
|
6
|
+
Only two files are required to setup a new project:
|
7
|
+
1. Gemfile
|
8
|
+
2. config.ru
|
9
|
+
|
10
|
+
### /Gemfile
|
11
|
+
Since the fanforce-app-factory gem is hosted on a private gem server so you'll need to specify the source for both rubygems and the private server.
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
source 'https://rubygems.org'
|
15
|
+
source 'https://gems.gemfury.com/xF8KY9sm8eS9yUQqw1jD/'
|
16
|
+
ruby '1.9.3'
|
17
|
+
|
18
|
+
gem 'fanforce-app-factory'
|
19
|
+
```
|
20
|
+
One you've created the Gemfile you'll need to run bundle install.
|
21
|
+
|
22
|
+
### /config.ru
|
23
|
+
Only four lines are required (you must have a Redis server).
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'bundler'; Bundler.setup
|
27
|
+
require 'fanforce/app'
|
28
|
+
FanforceApp.config { |config| config._id = 'facebook' }
|
29
|
+
run FanforceApp
|
30
|
+
```
|
31
|
+
You can replace config._id (as in the example above) with an environment variable: ENV['FANFORCE_APP_ID']
|
32
|
+
|
33
|
+
### Ready for the Fanforce Marketplace!
|
34
|
+
Your app can now be added to the Fanforce Marketplace. Use the follow config settings when adding your new app into Fanforce
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
"public_urls": {
|
38
|
+
"marketplace_img": "http://${PRIMARY_DOMAIN}/assets/marketplace.png",
|
39
|
+
"icon_16": "http://${PRIMARY_DOMAIN}/assets/icon-16.png",
|
40
|
+
"icon_32": "http://${PRIMARY_DOMAIN}/assets/icon-32.png"
|
41
|
+
"icon_42": "http://${PRIMARY_DOMAIN}/assets/icon-42.png"
|
42
|
+
},
|
43
|
+
"staffer_ui_urls": {
|
44
|
+
"dashboard": "http://${PRIMARY_DOMAIN}/dashboard.html"
|
45
|
+
},
|
46
|
+
"callback_urls": {
|
47
|
+
"install": "http://${PRIMARY_DOMAIN}/install",
|
48
|
+
"uninstall": "http://${PRIMARY_DOMAIN}/uninstall"
|
49
|
+
},
|
50
|
+
"plugin_dependencies": []
|
51
|
+
```
|
52
|
+
Note: for development and testing we recommend using the [POW server](http://pow.cx/), but you can use rackup or any other server to run your new app.
|
53
|
+
|
54
|
+
====================
|
55
|
+
|
56
|
+
# Customizing/Building Your App
|
57
|
+
There are lots of ways you can start building out and customizing your app...
|
58
|
+
|
59
|
+
### /assets
|
60
|
+
Use the assets folder to store all your images, css, and javascript files. There are six asset files that are required. If any are missing, the fanforce-app-factory sends default versions when requested.
|
61
|
+
|
62
|
+
*Default Assets:*
|
63
|
+
* /js
|
64
|
+
* /dashboard.js - this is included in the dashboard.html file.
|
65
|
+
* /css
|
66
|
+
* /dashboard.css - this is also included in the dashboard.html file.
|
67
|
+
* /img
|
68
|
+
* /icon-16.png - this icon must be 16px by 16px.
|
69
|
+
* /icon-32.png - this icon must be 32px by 32px.
|
70
|
+
* /icon-42.png - this icon must be 42px by 42px.
|
71
|
+
* /marketplace.png - this icon must be 220px by 142px.
|
72
|
+
|
73
|
+
### /views
|
74
|
+
HAML is setup by default. The extension is changed to .html when served in the browser.
|
75
|
+
|
76
|
+
*Default Views:*
|
77
|
+
* /index.haml - default page visitors will see if they try to access domain
|
78
|
+
* /dashboard.haml - used in the Command Center
|
79
|
+
|
80
|
+
### /layouts
|
81
|
+
You can turn off layouts from be used (see Advanced Configuration)
|
82
|
+
|
83
|
+
*Default Layouts:*
|
84
|
+
* /dashboard.haml - the wrapper layout for views/dashboard.haml
|
85
|
+
* /promotional.haml - the wrapper layout for views/index.haml
|
86
|
+
|
87
|
+
### /public
|
88
|
+
Anything you put in here will be publicly available. The only folder you should not use is /assets, since it is used for precompiling assets (see below).
|
89
|
+
|
90
|
+
*Default Files:*
|
91
|
+
* /favicon.ico
|
92
|
+
|
93
|
+
### /config/routes.rb
|
94
|
+
The fanforce-app-factory sets up all the required routes. If you want to customize existing routes or add new ones, create a config/routes.rb file and specify routes within the FanforceApp:Sinatra class:
|
95
|
+
```
|
96
|
+
class FanforceApp::Sinatra
|
97
|
+
get '/test' do
|
98
|
+
"Custom route!"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
```
|
102
|
+
Check out [Sinatra's](http://www.sinatrarb.com/documentation) documentation for more details on routes and much more. The FanforceApp::Sinatra inherits from the Sinatra::Base, which gives you full control to customize the fanforce-app-factory's sinatra implementation as much as you want.
|
103
|
+
|
104
|
+
Overwrite any existing routes by specifying them in your config/routes.rb. You can also pull default route logic into your new custom routes by calling route_[NAME_OF_ROUTE] method.
|
105
|
+
```
|
106
|
+
class FanforceApp::Sinatra
|
107
|
+
any '/install' do
|
108
|
+
# do whatever you want here
|
109
|
+
route_install
|
110
|
+
end
|
111
|
+
end
|
112
|
+
```
|
113
|
+
*Default Routes:*
|
114
|
+
- route_index: get ['/','/index.html']
|
115
|
+
- route_dashboard: get '/dashboard.html'
|
116
|
+
- route_install: post '/install'
|
117
|
+
- route_uninstall: post '/uninstall'
|
118
|
+
|
119
|
+
### /config/initializer.rb
|
120
|
+
If you need to run Sinatra middleware or other non-route code, you'll want to create a config/initializer.rb file. This file is required before config/routes.rb. As an example, if you want to use the OmniAuth Facebook Strategy, you would include the following in config/initializer.rb:
|
121
|
+
```
|
122
|
+
require 'omniauth'
|
123
|
+
require 'omniauth-constantcontact2'
|
124
|
+
|
125
|
+
class FanforceApp::Sinatra
|
126
|
+
|
127
|
+
use Rack::Session::Cookie
|
128
|
+
use OmniAuth::Builder do
|
129
|
+
provider :constantcontact, ENV['CONSTANTCONTACT_API_KEY'], ENV['CONSTANTCONTACT_API_SECRET']
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
```
|
134
|
+
|
135
|
+
### /lib/*
|
136
|
+
If you create a lib/ folder in your app's home directory, it will be automatically added to your app's ruby path. This allows you to require 'any_file' that has been put in this folder.
|
137
|
+
|
138
|
+
|
139
|
+
# Loading Pages/Layouts In Controllers
|
140
|
+
Fanforce-app-factory adds a helper method on top of the Sinatra code base to load pages and layouts. It's called page:
|
141
|
+
```
|
142
|
+
get '/custom.html' do
|
143
|
+
page :custom, :layout => :custom
|
144
|
+
end
|
145
|
+
```
|
146
|
+
*Other Examples*
|
147
|
+
- :custom_page
|
148
|
+
- :custom_page, :layout => :false
|
149
|
+
|
150
|
+
# Rendering JSON, JSONP, and JSONR
|
151
|
+
Fanforce-app-factory adds a "json" method you use in your routes to convert the object to json and set the correct application/json header:
|
152
|
+
```
|
153
|
+
get '/custom.html' do
|
154
|
+
json first_name: 'Caleb', last_name: 'Clark'
|
155
|
+
end
|
156
|
+
```
|
157
|
+
If a callback param is sent in the request then your json is automatically converted to JSONR[http://github.com/calebclark/rack-jsonr] (JSON Resource).
|
158
|
+
|
159
|
+
|
160
|
+
# Precompile Your Assets for Faster Delivery
|
161
|
+
Heroku tries to run `rake assets:precompile` when pushing new code changes. Fanforce-app-factory has this rake task built-in. To activate, just create a new Rakefile in your app directory with the following:
|
162
|
+
```
|
163
|
+
require 'bundler'; Bundler.setup
|
164
|
+
require 'fanforce/app'
|
165
|
+
load 'fanforce/app.rake'
|
166
|
+
```
|
167
|
+
|
168
|
+
# Create App-Specific ENV Variables In Development
|
169
|
+
Documentation coming soon.
|
170
|
+
|
171
|
+
# Configure Redis
|
172
|
+
By default fanforce-app-factory looks for ENV['REDIS_URL'] and if that isn't found, it falls back to redis://localhost:6379. You can specify a custom redis url with `config.redis_url = ` in config.ru:
|
173
|
+
```
|
174
|
+
require 'bundler'; Bundler.setup
|
175
|
+
require 'fanforce/app'
|
176
|
+
FanforceApp.config do |config|
|
177
|
+
config.redis_url = 'redis://USERNAME:PASSWORD@HOST:PORT'
|
178
|
+
end
|
179
|
+
load 'fanforce/app.rake'
|
180
|
+
```
|
181
|
+
|
182
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# Default Rake task is compile
|
7
|
+
#task :default => :compile
|
8
|
+
|
9
|
+
########################################################################
|
10
|
+
|
11
|
+
Rake::TestTask.new do |t|
|
12
|
+
t.libs.push "lib"
|
13
|
+
t.libs.push "test"
|
14
|
+
t.pattern = 'test/**/*_test.rb'
|
15
|
+
t.verbose = false
|
16
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fanforce/app_factory/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'fanforce-app-factory'
|
8
|
+
gem.version = Fanforce::AppFactory::VERSION
|
9
|
+
gem.date = '2012-10-19'
|
10
|
+
gem.summary = %q{Everything needed to setup a new app on Fanforce}
|
11
|
+
gem.authors = ['Caleb Clark']
|
12
|
+
gem.email = ['cclark@fanforce.com']
|
13
|
+
gem.homepage = 'http://github.com/mlabs/fanforce-app-factory'
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ['lib']
|
18
|
+
|
19
|
+
gem.add_development_dependency 'rake', '~> 0.8.7'
|
20
|
+
gem.add_runtime_dependency 'redis', '~> 3.0'
|
21
|
+
gem.add_runtime_dependency 'sinatra', '~> 1.3'
|
22
|
+
gem.add_runtime_dependency 'multi_json', '~> 1.3.6'
|
23
|
+
gem.add_runtime_dependency 'sinatra-contrib'
|
24
|
+
gem.add_runtime_dependency 'rack-contrib'
|
25
|
+
gem.add_runtime_dependency 'haml', '~> 3.1'
|
26
|
+
gem.add_runtime_dependency 'coffee-script'
|
27
|
+
gem.add_runtime_dependency 'coffee-filter'
|
28
|
+
gem.add_runtime_dependency 'activesupport', '~> 3.2'
|
29
|
+
|
30
|
+
gem.add_runtime_dependency 'sass', '~> 3.2'
|
31
|
+
gem.add_runtime_dependency 'compass', '~> 0.12'
|
32
|
+
gem.add_runtime_dependency 'sprockets', '~> 2.9'
|
33
|
+
gem.add_runtime_dependency 'sprockets-sass', '~> 0.9'
|
34
|
+
gem.add_runtime_dependency 'yui-compressor', '~> 0.9'
|
35
|
+
gem.add_runtime_dependency 'uglifier', '~> 1.3'
|
36
|
+
|
37
|
+
gem.add_runtime_dependency 'rack-jsonr', '~> 0.2'
|
38
|
+
gem.add_runtime_dependency 'fanforce', '~> 0.8'
|
39
|
+
gem.add_runtime_dependency 'fanforce-errors', '~> 0.2'
|
40
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'fanforce'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'json'
|
4
|
+
require 'yaml'
|
5
|
+
require_relative 'app_factory/sprockets/hacks'
|
6
|
+
require_relative 'app_factory/sprockets/compiler'
|
7
|
+
|
8
|
+
def load_env_from_file(file)
|
9
|
+
File.open(file, 'rb') do |file|
|
10
|
+
contents = file.read
|
11
|
+
lines = contents.gsub('export ', '').split(/\n\r?/).reject{|line| line.blank?}
|
12
|
+
lines.each do |line|
|
13
|
+
keyValue = line.split("=", 2)
|
14
|
+
next unless keyValue.count == 2
|
15
|
+
ENV[keyValue.first] = keyValue.last.gsub("'",'').gsub('"','')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
if (!ENV['RACK_ENV'] or ENV['RACK_ENV'] == 'development')
|
21
|
+
load_env_from_file("#{FanforceApp.config.root_dir}/.powenv") if File.exists?("#{FanforceApp.config.root_dir}/.powenv")
|
22
|
+
load_env_from_file("#{FanforceApp.config.root_dir}/.appenv") if File.exists?("#{FanforceApp.config.root_dir}/.appenv")
|
23
|
+
end
|
24
|
+
|
25
|
+
FanforceApp.config.load_redis
|
26
|
+
|
27
|
+
namespace :assets do
|
28
|
+
root_dir = FanforceApp.config.root_dir
|
29
|
+
factory_root_dir = FanforceApp.config.factory_root_dir
|
30
|
+
|
31
|
+
desc 'Precompile assets for production'
|
32
|
+
task :precompile => :clean do
|
33
|
+
sprockets = SprocketsCompiler.setup(root_dir)
|
34
|
+
|
35
|
+
puts 'PRECOMPILING ASSETS... '
|
36
|
+
SprocketsCompiler.new(sprockets: sprockets, precompile: [/(\/|^)[^_\/]+[^\/]*\.(css|js|png|gif|jpeg|jpg|otf|eot|svg|ttf|woff)/]).compile
|
37
|
+
puts 'DONE'
|
38
|
+
|
39
|
+
print 'GENERATING ASSET MANIFESTS... '
|
40
|
+
asset_list = {}
|
41
|
+
sprockets.each_logical_path do |logical_path|
|
42
|
+
if File.basename(logical_path) !~ /^[_]/ and asset = sprockets.find_asset(logical_path)
|
43
|
+
asset_list[logical_path] = "/assets/#{asset.digest_path}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
IO.write File.join(root_dir, '/public/asset_manifest.json'), JSON.generate(asset_list)
|
47
|
+
IO.write File.join(root_dir, '/public/asset_manifest.json'), "ASSETS=#{JSON.generate(asset_list)}"
|
48
|
+
IO.write File.join(root_dir, '/public/asset_manifest.json'), asset_list.to_yaml
|
49
|
+
puts 'DONE'
|
50
|
+
|
51
|
+
print 'ENSURING FAVICON EXISTS... '
|
52
|
+
if !File.exists?(root_dir+'/public/favicon.ico')
|
53
|
+
puts ''
|
54
|
+
FileUtils.cp("#{factory_root_dir}/public/favicon.ico", "#{root_dir}/public/favicon.ico")
|
55
|
+
puts "#{root_dir}/public/favicon.ico"
|
56
|
+
end
|
57
|
+
puts 'DONE'
|
58
|
+
end
|
59
|
+
|
60
|
+
desc 'Clean assets folder'
|
61
|
+
task :clean do
|
62
|
+
print 'DESTROYING PUBLIC/ASSETS... '
|
63
|
+
FileUtils.rm_rf File.join(root_dir, '/public/assets')
|
64
|
+
puts 'DONE'
|
65
|
+
end
|
66
|
+
|
67
|
+
task :test do
|
68
|
+
puts 'TEST WORKED!'
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
ENV['RACK_ENV'] ||= 'development'
|
2
|
+
####################################################################################
|
3
|
+
require 'fanforce'
|
4
|
+
require 'active_support/all'
|
5
|
+
require 'sinatra/base'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'redis'
|
8
|
+
|
9
|
+
if ENV['RACK_ENV'] == 'development'
|
10
|
+
require_relative 'app_factory/sprockets/hacks'
|
11
|
+
require_relative 'app_factory/sprockets/compiler'
|
12
|
+
end
|
13
|
+
|
14
|
+
caller[0].split(':')[0] =~ /^(.+(config\.ru|Rakefile))$/ ? ROOT_DIR = File.dirname($1) : nil
|
15
|
+
|
16
|
+
module FanforceApp
|
17
|
+
|
18
|
+
def self.config(&block)
|
19
|
+
config = @@config ||= FanforceApp::SinatraConfig.new(ROOT_DIR)
|
20
|
+
if block.present?
|
21
|
+
block.call(config)
|
22
|
+
config.root_dir = File.dirname($1) if !config.root_dir and caller[0].split(':')[0] =~ /^(.+(config\.ru|Rakefile))$/
|
23
|
+
end
|
24
|
+
config
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.root
|
28
|
+
config.root_dir
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.dir_name
|
32
|
+
config.dir_name
|
33
|
+
end
|
34
|
+
|
35
|
+
def self._id
|
36
|
+
config._id
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.load_config
|
40
|
+
config.load
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.call(env)
|
44
|
+
if ENV['RACK_ENV'] == 'development' and env['PATH_INFO'] =~ /^\/assets\//
|
45
|
+
env['PATH_INFO'] = env['PATH_INFO'].gsub(/^\/assets/, '')
|
46
|
+
sprockets = SprocketsCompiler.setup(FanforceApp.config.root_dir)
|
47
|
+
return sprockets.index.call(env)
|
48
|
+
end
|
49
|
+
require_relative 'app_factory/_init_sinatra'
|
50
|
+
FanforceApp::Sinatra.new.call(env)
|
51
|
+
end
|
52
|
+
|
53
|
+
require_relative 'app_factory/config/sinatra_config'
|
54
|
+
require_relative 'app_factory/initializers/ff_globals'
|
55
|
+
end
|
56
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'sinatra/content_for'
|
2
|
+
require 'coffee-filter'
|
3
|
+
require 'rack/jsonr'
|
4
|
+
####################################################################################
|
5
|
+
|
6
|
+
class FanforceApp::Sinatra < Sinatra::Base
|
7
|
+
require_relative 'config/_error_handling'
|
8
|
+
require_relative 'config/helpers/assets'
|
9
|
+
require_relative 'config/helpers/json'
|
10
|
+
require_relative 'config/helpers/fanforce'
|
11
|
+
|
12
|
+
use Rack::JSONR, :method_override => :all
|
13
|
+
|
14
|
+
helpers Sinatra::AssetHelpers
|
15
|
+
helpers Sinatra::JSONHelpers
|
16
|
+
helpers Sinatra::FanforceHelpers
|
17
|
+
helpers Sinatra::ContentFor
|
18
|
+
|
19
|
+
def self.any(url,&block)
|
20
|
+
get(url,&block)
|
21
|
+
post(url,&block)
|
22
|
+
put(url,&block)
|
23
|
+
delete(url,&block)
|
24
|
+
end
|
25
|
+
|
26
|
+
def page(page, options={})
|
27
|
+
current_dir = File.expand_path('../', __FILE__)
|
28
|
+
if !File.exists?("#{settings.views}/#{page}.haml")
|
29
|
+
rel_path = Pathname.new(current_dir).relative_path_from(Pathname.new(settings.views))
|
30
|
+
page = :"#{rel_path}/views/#{page}"
|
31
|
+
end
|
32
|
+
|
33
|
+
if options[:layout] and FanforceApp.config.respond_to?(:"layout_for_#{page}") and FanforceApp.config.method(:"layout_for_#{page}").call
|
34
|
+
if File.exists?("#{settings.views}/../layouts/#{options[:layout]}.haml")
|
35
|
+
options[:layout] = :"../layouts/#{options[:layout]}"
|
36
|
+
else
|
37
|
+
rel_path = Pathname.new(current_dir).relative_path_from(Pathname.new(settings.views))
|
38
|
+
options[:layout] = :"#{rel_path}/layouts/#{options[:layout]}"
|
39
|
+
end
|
40
|
+
else
|
41
|
+
options[:layout] = false
|
42
|
+
end
|
43
|
+
haml page, options
|
44
|
+
end
|
45
|
+
|
46
|
+
configure do
|
47
|
+
FanforceApp.load_config
|
48
|
+
set :haml, {:escape_attrs => false}
|
49
|
+
set :static, true
|
50
|
+
set :protection, :except => [:frame_options, :json_csrf]
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|