rename the assets_path configuration property into asset_path + add more options for the Steam cli

did committed Mar 18, 2015
commit 7c0db3065048021c9eb89fa89fcac8bfd268aeff
Showing 7 changed files with 27 additions and 13 deletions
bin/steam.rb +19 -5
@@ @@ -8,6 +8,8 @@ Bundler.require
require 'thin'
require 'optparse'
+ server_options = { address: 'localhost', port: 8080 }
+
options = {
adapter: {
name: :filesystem,
@@ @@ -22,7 +24,7 @@ OptionParser.new do |opts|
# Filesystem adapter
opts.on('-p', '--path PATH', 'Serve a Wagon site from a path in your filesystem') do |path|
options[:adapter][:path] = File.expand_path(path)
- options[:assets_path] = File.expand_path(File.join(path, 'public'))
+ options[:asset_path] = File.expand_path(File.join(path, 'public'))
options[:database] = options[:hosts] = nil
end
@@ @@ -38,7 +40,17 @@ OptionParser.new do |opts|
# Assets path
opts.on('-a', '--assets-path ASSETS_PATH', 'Tell Steam where to find the assets (if local)') do |path|
- options[:assets_path] = path
+ options[:asset_path] = path
+ end
+
+ # Asset host
+ opts.on('-h', '--asset-host HOST', 'Required if the assets are stored on Amazon S3 or through a CDN') do |host|
+ options[:asset_host]
+ end
+
+ # TCP port
+ opts.on('-p', '--port PORT', 'Run the HTTP server on the specified port (by default: 8080') do |port|
+ server_options[:port] = port
end
# Logger
@@ @@ -60,8 +72,10 @@ require_relative '../lib/locomotive/steam/server'
Locomotive::Steam.configure do |config|
config.mode = :test
config.adapter = options[:adapter]
- config.serve_assets = options[:assets_path].present?
- config.assets_path = options[:assets_path]
+ config.serve_assets = options[:asset_path].present?
+ config.asset_path = options[:asset_path]
+ config.asset_host = options[:asset_host]
+ config.mounted_on = options[:mounted_on]
config.minify_assets = false
end
@@ @@ -73,7 +87,7 @@ end
app = Locomotive::Steam::Server.to_app
# Note: alt thin settings (Threaded)
- server = Thin::Server.new('localhost', '8080', app)
+ server = Thin::Server.new(server_options[:address], server_options[:port], app)
server.threaded = true
server.start
# FIXME: Rack::Handler::Thin.run app (not threaded)
locomotive/steam/configuration.rb b/lib/locomotive/steam/configuration.rb +1 -1
@@ @@ -64,7 +64,7 @@ module Locomotive
#
# default: nil
#
- attr_accessor :assets_path
+ attr_accessor :asset_path
# If java is installed and if this option is enabled,
# then YUI::JavaScriptCompressor and YUI::CssCompressor are used to minify the css and the javascript.
locomotive/steam/server.rb b/lib/locomotive/steam/server.rb +2 -2
@@ @@ -27,11 +27,11 @@ module Locomotive::Steam
if configuration.serve_assets
use ::Rack::Static, {
- root: configuration.assets_path,
+ root: configuration.asset_path,
urls: ['/images', '/fonts', '/samples', '/media', '/sites']
}
use Middlewares::DynamicAssets, {
- root: configuration.assets_path,
+ root: configuration.asset_path,
minify: configuration.minify_assets
}
end
locomotive/steam/services.rb b/lib/locomotive/steam/services.rb +1 -1
@@ @@ -64,7 +64,7 @@ module Locomotive
end
register :image_resizer do
- Steam::ImageResizerService.new(::Dragonfly.app(:steam), configuration.assets_path)
+ Steam::ImageResizerService.new(::Dragonfly.app(:steam), configuration.asset_path)
end
register :translator do
locomotive/steam/services/image_resizer_service.rb b/lib/locomotive/steam/services/image_resizer_service.rb +2 -2
@@ @@ -1,7 +1,7 @@
module Locomotive
module Steam
- class ImageResizerService < Struct.new(:resizer, :assets_path)
+ class ImageResizerService < Struct.new(:resizer, :asset_path)
IsHTTP = /^https?:\/\//o
@@ @@ -29,7 +29,7 @@ module Locomotive
resizer.fetch_url(url_or_path)
else
path = url_or_path.sub(/(\?.*)$/, '')
- resizer.fetch_file(File.join(assets_path || '', 'public', path))
+ resizer.fetch_file(File.join(asset_path || '', 'public', path))
end
end
spec/support/helpers.rb +1 -1
@@ @@ -26,7 +26,7 @@ module Spec
config.mode = :test
config.adapter = { name: :filesystem, path: default_fixture_site_path }
# config.adapter = { name: :'mongoDB', database: 'steam_test', hosts: ['127.0.0.1'] }
- config.assets_path = File.expand_path(File.join(default_fixture_site_path, 'public'))
+ config.asset_path = File.expand_path(File.join(default_fixture_site_path, 'public'))
config.serve_assets = true
config.minify_assets = true
end
spec/unit/configuration_spec.rb +1 -1
@@ @@ -8,7 +8,7 @@ describe Locomotive::Steam::Configuration do
it { expect(subject.mode).to eq(:production) }
it { expect(subject.serve_assets).to eq(true) }
- it { expect(subject.assets_path).to eq(nil) }
+ it { expect(subject.asset_path).to eq(nil) }
end