Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from jfoley/fix_generate
Fix deploy:generate task
- Loading branch information
Showing
5 changed files
with
93 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,82 +1,84 @@ | |||
require 'bundler'; Bundler.require | require 'bundler'; Bundler.require | ||
|
|
||
class Jqapi < Sinatra::Base | module Jqapi | ||
set :root, File.join(File.dirname(__FILE__), '..') | ASSET_PATHS = [ | ||
set :views, File.join(root, 'app/views') | 'app/assets/javascripts', | ||
set :sprockets, Sprockets::Environment.new(root) | 'app/assets/stylesheets', | ||
set :precompile, [/\w+\.(?!js|css).+/, /bundle.(css|js)$/] | 'app/assets/images', | ||
set :assets_prefix, 'assets' | 'vendor/assets/javascripts', | ||
set :assets_path, File.join(root, 'public', assets_prefix) | 'vendor/assets/stylesheets', | ||
|
'vendor/assets/images' | ||
asset_paths = [ | ].freeze | ||
'app/assets/javascripts', |
|
||
'app/assets/stylesheets', | class Server < Sinatra::Base | ||
'app/assets/images', | set :root, File.join(File.dirname(__FILE__), '..') | ||
'vendor/assets/javascripts', | set :views, File.join(root, 'app/views') | ||
'vendor/assets/stylesheets', | set :sprockets, Sprockets::Environment.new(root) | ||
'vendor/assets/images' | set :precompile, [/\w+\.(?!js|css).+/, /bundle.(css|js)$/] | ||
] | set :assets_prefix, 'assets' | ||
|
set :assets_path, File.join(root, 'public', assets_prefix) | ||
configure do |
|
||
asset_paths.each do |path| | configure do | ||
sprockets.append_path(File.join(root, path)) | ASSET_PATHS.each do |path| | ||
sprockets.append_path(File.join(root, path)) | |||
end | |||
end | end | ||
end | |||
|
|
||
before do | before do | ||
content_type :json | content_type :json | ||
end | end | ||
|
|||
get '/docs/categories.json' do | |||
serve_file('docs', 'categories.json') | |||
end | |||
|
|
||
get '/docs/index.json' do | get '/docs/categories.json' do | ||
serve_file('docs', 'index.json') | serve_file('docs', 'categories.json') | ||
end | end | ||
|
|
||
get '/docs/versions.json' do | get '/docs/index.json' do | ||
serve_file('docs', 'versions.json') | serve_file('docs', 'index.json') | ||
end | end | ||
|
|
||
get '/docs/entries/*.json' do | get '/docs/versions.json' do | ||
serve_file('docs/entries', "#{params[:splat][0]}.json") | serve_file('docs', 'versions.json') | ||
end | end | ||
|
|
||
get 'resources/*.png' do | get '/docs/entries/*.json' do | ||
content_type 'image/png' | serve_file('docs/entries', "#{params[:splat][0]}.json") | ||
serve_file('docs/resources', "#{params[:splat][0]}.png") | end | ||
end | |||
|
|
||
get 'resources/*.jpg' do | get 'resources/*.png' do | ||
content_type 'image/jpeg' | content_type 'image/png' | ||
serve_file('docs/resources', "#{params[:splat][0]}.jpg") | serve_file('docs/resources', "#{params[:splat][0]}.png") | ||
end | end | ||
|
|
||
get 'resources/*.gif' do | get 'resources/*.jpg' do | ||
content_type 'image/gif' | content_type 'image/jpeg' | ||
serve_file('docs/resources', "#{params[:splat][0]}.gif") | serve_file('docs/resources', "#{params[:splat][0]}.jpg") | ||
end | end | ||
|
|
||
get 'LICENSE' do | get 'resources/*.gif' do | ||
content_type 'text' | content_type 'image/gif' | ||
serve_file('', 'LICENSE') | serve_file('docs/resources', "#{params[:splat][0]}.gif") | ||
end | end | ||
|
|
||
get '/' do | get 'LICENSE' do | ||
content_type :html | content_type 'text' | ||
haml :index | serve_file('', 'LICENSE') | ||
end | end | ||
|
|||
get '/' do | |||
content_type :html | |||
haml :index | |||
end | |||
|
|
||
|
|
||
private | private | ||
def serve_file(path, filename) | def serve_file(path, filename) | ||
filepath = File.join(settings.root, path, filename) | filepath = File.join(settings.root, path, filename) | ||
|
|
||
if File.exists?(filepath) | if File.exists?(filepath) | ||
File.open(filepath).read | File.open(filepath).read | ||
else | else | ||
404 | 404 | ||
end | |||
end | end | ||
end | end | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,9 +1,9 @@ | |||
require "#{File.dirname(__FILE__)}/app/jqapi.rb" | require "#{File.dirname(__FILE__)}/app/jqapi.rb" | ||
|
|
||
map '/assets' do | map '/assets' do | ||
run Jqapi.sprockets | run Jqapi::Server.sprockets | ||
end | end | ||
|
|
||
map '/' do | map '/' do | ||
run Jqapi | run Jqapi::Server | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
# HORRIBLE HACK ALERT | |||
# This file is loaded and parsed every time thor is invoked | |||
# meaning all other .thor files are implicitly dependent on it. | |||
# Gross, but it works. | |||
|
|||
ROOT_DIR = File.join(File.dirname(__FILE__), '..') | |||
$LOAD_PATH.unshift(File.join(ROOT_DIR, 'app')) | |||
|
|||
require 'jqapi' |