wagon serve seems to run okay (wip)
did
committed Mar 30, 2015
commit f918767c4276e74043cfe82934206f686d5c3a16
Showing 20
changed files with
379 additions
and 538 deletions
.gitignore
+4
-0
| @@ | @@ -26,3 +26,7 @@ spec/fixtures/default/log |
| /.sass-cache/ | |
| /tests | |
| + | |
| + | /deprecated |
| + | |
| + | dragonfly.log |
Gemfile
+4
-1
| @@ | @@ -13,9 +13,12 @@ gem 'rb-fsevent', '~> 0.9.1' |
| gem 'therubyracer' | |
| - | gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: '53a910eb6e', require: false |
| + | # gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: '53a910eb6e', require: false |
| gem 'locomotivecms_coal', github: 'locomotivecms/coal', ref: '6ae10e3684', require: false | |
| + | gem 'locomotivecms_steam', path: '../in_progress/steam', require: false |
| + | gem 'locomotivecms_common', path: '../in_progress/common', require: false |
| + | |
| group :test do | |
| gem 'pry' | |
locomotive/wagon.rb b/lib/locomotive/wagon.rb
+40
-54
| @@ | @@ -1,7 +1,3 @@ |
| - | require 'locomotive/wagon/version' |
| - | require 'locomotive/wagon/logger' |
| - | require 'locomotive/wagon/exceptions' |
| - | |
| module Locomotive | |
| module Wagon | |
| @@ | @@ -81,8 +77,7 @@ module Locomotive |
| use_listen = self.daemonize(path, server, use_listen) if options[:daemonize] | |
| - | # TODO |
| - | # Locomotive::Wagon::Listen.instance.start(reader) if use_listen |
| + | self.listen(path) if use_listen |
| server.start | |
| end | |
| @@ | @@ -203,29 +198,18 @@ module Locomotive |
| def self.require_steam(path, require_misc = true) | |
| require 'locomotive/steam' | |
| + | configure_logger(path) |
| + | |
| Locomotive::Steam.configure do |config| | |
| - | config.mode = :test |
| - | config.adapter = { name: :filesystem, path: path } |
| - | config.serve_assets = true |
| - | config.asset_path = File.expand_path(File.join(path, 'public')) |
| - | config.minify_assets = false |
| + | config.mode = :test |
| + | config.adapter = { name: :filesystem, path: path } |
| + | config.asset_path = File.expand_path(File.join(path, 'public')) |
| end | |
| - | Locomotive::Wagon::Logger.setup(path, false) |
| - | |
| if require_misc | |
| require 'bundler' | |
| Bundler.require 'misc' | |
| end | |
| - | |
| - | # logger = Locomotive::Wagon::Logger.instance.logger |
| - | # logger.info "YEAAH" |
| - | |
| - | Locomotive::Common.reset |
| - | Locomotive::Common.configure do |config| |
| - | config_file = File.expand_path(File.join(path, 'log', 'wagon.log')) |
| - | config.notifier = Locomotive::Common::Logger.setup(config_file) |
| - | end |
| end | |
| # # Load the Locomotive::Mounter lib and set it up (logger, ...etc). | |
| @@ | @@ -265,7 +249,6 @@ module Locomotive |
| def self.build_server(options) | |
| # TODO: new feature -> pick the right Rack handler (Thin, Puma, ...etc) | |
| - | |
| require 'locomotive/steam/server' | |
| require 'thin' | |
| @@ | @@ -277,41 +260,44 @@ module Locomotive |
| end | |
| def self.daemonize_server(server, path, use_listen) | |
| - | if options[:daemonize] |
| - | # very important to get the parent pid in order to differenciate the sub process from the parent one |
| - | parent_pid = Process.pid |
| - | |
| - | # The Daemons gem closes all file descriptors when it daemonizes the process. So any logfiles that were opened before the Daemons block will be closed inside the forked process. |
| - | # So, close the current logger and set it up again when daemonized. |
| - | Locomotive::Wagon::Logger.close |
| - | |
| - | server.log_file = File.join(File.expand_path(path), 'log', 'server.log') |
| - | server.pid_file = File.join(File.expand_path(path), 'log', 'server.pid') |
| - | server.daemonize |
| - | |
| - | use_listen = Process.pid != parent_pid && !options[:disable_listen] |
| - | |
| - | if Process.pid != parent_pid |
| - | # A "new logger" inside the daemon. |
| - | Locomotive::Wagon::Logger.setup(path, false) |
| - | # Locomotive::Mounter.logger = Locomotive::Wagon::Logger.instance.logger |
| - | Locomotive::Common.configure do |config| |
| - | config.notifier = Locomotive::Wagon::Logger.instance.logger |
| - | end |
| - | end |
| + | # very important to get the parent pid in order to differenciate the sub process from the parent one |
| + | parent_pid = Process.pid |
| + | |
| + | # The Daemons gem closes all file descriptors when it daemonizes the process. So any logfiles that were opened before the Daemons block will be closed inside the forked process. |
| + | # So, close the current logger and set it up again when daemonized. |
| + | # Locomotive::Wagon::Logger.close |
| + | Locomotive::Common::Logger.close |
| + | |
| + | server.log_file = File.join(File.expand_path(path), 'log', 'server.log') |
| + | server.pid_file = File.join(File.expand_path(path), 'log', 'server.pid') |
| + | server.daemonize |
| + | |
| + | # use_listen = Process.pid != parent_pid && !options[:disable_listen] # TO BE REMOVED |
| + | |
| + | if Process.pid != parent_pid |
| + | # A "new logger" inside the daemon. |
| + | configure_logger(path) |
| + | |
| + | use_listen |
| end | |
| end | |
| - | # def self.thin_server(reader, options) |
| - | # require 'locomotive/wagon/server' |
| - | # app = Locomotive::Wagon::Server.new(reader, options) |
| + | def self.listen(path) |
| + | require 'locomotive/wagon/listen' |
| + | require 'locomotive/steam/adapters/filesystem/simple_cache_store' |
| - | # # TODO: new feature -> pick the right Rack handler (Thin, Puma, ...etc) |
| - | # require 'thin' |
| - | # Thin::Server.new(options[:host], options[:port], { signals: true }, app).tap do |server| |
| - | # server.threaded = true |
| - | # end |
| - | # end |
| + | cache = Locomotive::Steam::Adapters::Filesystem::SimpleCacheStore.new |
| + | |
| + | Locomotive::Wagon::Listen.start(path, cache) |
| + | end |
| + | |
| + | def self.configure_logger(path) |
| + | Locomotive::Common.reset |
| + | Locomotive::Common.configure do |config| |
| + | notifier_file = File.expand_path(File.join(path, 'log', 'wagon.log')) |
| + | config.notifier = Locomotive::Common::Logger.setup(notifier_file) |
| + | end |
| + | end |
| def self.validate_resources(resources, writers_or_readers) | |
| return if resources.nil? | |
locomotive/wagon/exceptions.rb b/lib/locomotive/wagon/exceptions.rb
+0
-62
| @@ | @@ -1,62 +0,0 @@ |
| - | module Locomotive |
| - | module Wagon |
| - | |
| - | class DefaultException < ::Exception |
| - | |
| - | def initialize(message = nil, parent_exception = nil) |
| - | self.log_backtrace(parent_exception) if parent_exception |
| - | |
| - | super(message) |
| - | end |
| - | |
| - | protected |
| - | |
| - | def log_backtrace(parent_exception) |
| - | full_error_message = "#{parent_exception.message}\n\t" |
| - | full_error_message += parent_exception.backtrace.join("\n\t") |
| - | full_error_message += "\n\n" |
| - | Locomotive::Wagon::Logger.fatal full_error_message |
| - | end |
| - | |
| - | end |
| - | |
| - | class RendererException < DefaultException |
| - | |
| - | attr_accessor :name, :template, :liquid_context |
| - | |
| - | def initialize(exception, name, template, liquid_context) |
| - | self.name, self.template, self.liquid_context = name, template, liquid_context |
| - | |
| - | self.log_page_into_backtrace(exception) |
| - | |
| - | super(exception.message) |
| - | |
| - | self.set_backtrace(exception.backtrace) |
| - | end |
| - | |
| - | def log_page_into_backtrace(exception) |
| - | line = self.template.line_offset |
| - | line += (exception.respond_to?(:line) ? exception.line || 0 : 0) + 1 |
| - | |
| - | message = "#{self.template.filepath}:#{line}:in `#{self.name}'" |
| - | |
| - | Locomotive::Wagon::Logger.fatal "[ERROR] #{exception.message} - #{message}\n".red |
| - | |
| - | exception.backtrace.unshift message |
| - | end |
| - | |
| - | end |
| - | |
| - | class MounterException < DefaultException |
| - | end |
| - | |
| - | class GeneratorException < DefaultException |
| - | |
| - | def log_backtrace(parent_exception) |
| - | # Logger not initialized at this step |
| - | end |
| - | |
| - | end |
| - | |
| - | end |
| - | end |
locomotive/wagon/listen.rb b/lib/locomotive/wagon/listen.rb
+40
-31
| @@ | @@ -1,22 +1,21 @@ |
| require 'listen' | |
| module Locomotive::Wagon | |
| - | class Listen |
| - | attr_accessor :reader |
| + | class Listen < Struct.new(:path, :cache) |
| - | def self.instance |
| - | @@instance = new |
| + | def self.start(path, cache) |
| + | new(path, cache).tap { |instance| instance.apply_definitions } |
| end | |
| - | def start(reader) |
| - | @reader = reader |
| - | |
| + | def apply_definitions |
| self.definitions.each do |definition| | |
| self.apply(definition) | |
| end | |
| end | |
| + | protected |
| + | |
| def definitions | |
| [ | |
| ['config', /\.yml/, [:site, :content_types, :pages, :snippets, :content_entries, :translations]], | |
| @@ | @@ -27,39 +26,49 @@ module Locomotive::Wagon |
| ] | |
| end | |
| - | protected |
| - | |
| def apply(definition) | |
| - | reloader = Proc.new do |modified, added, removed| |
| - | resources = [*definition.last] |
| - | names = resources.map { |n| "\"#{n}\"" }.join(', ') |
| - | |
| - | unless resources.empty? |
| - | Locomotive::Wagon::Logger.info "* Reloaded #{names} at #{Time.now}" |
| - | |
| - | begin |
| - | reader.reload(resources) |
| - | rescue Exception => e |
| - | Locomotive::Wagon::MounterException.new('Unable to reload', e) |
| - | end |
| - | end |
| - | end |
| + | # reloader = Proc.new do |modified, added, removed| |
| + | # resources = |
| + | # names = resources.map { |n| "\"#{n}\"" }.join(', ') |
| - | filter = definition[1] |
| - | path = File.join(self.reader.mounting_point.path, definition.first) |
| - | path = File.expand_path(path) |
| + | # unless resources.empty? |
| + | # Locomotive::Common::Logger.info "service=listen resources=#{names} timestamp=#{Time.now}" |
| - | listener = ::Listen.to(path, only: filter, &reloader) |
| + | # begin |
| + | # reader.reload(resources) |
| + | # rescue Exception => e |
| + | # Locomotive::Common::DefaultException.new('Unable to reload', e) |
| + | # end |
| + | # end |
| + | # end |
| + | |
| + | reloader = build_reloader([*definition.last]) |
| + | filter = definition[1] |
| + | _path = File.expand_path(File.join(self.path, definition.first)) |
| + | |
| + | listener = ::Listen.to(_path, only: filter, &reloader) |
| # non blocking listener | |
| listener.start | |
| end | |
| - | def relative_path(path) |
| - | base_path = self.reader.mounting_point.path |
| - | relative_path = path.sub(base_path, '') |
| + | def build_reloader(resources) |
| + | Proc.new do |modified, added, removed| |
| + | resources.each do |resource| |
| + | Locomotive::Common::Logger.info "service=listen action=reload resource=#{resource} timestamp=#{Time.now}" |
| + | cache.delete(resource) |
| + | end |
| + | end |
| end | |
| + | # def relative_path(path) |
| + | # path.sub(site_path, '') |
| + | # end |
| + | |
| + | # def site_path |
| + | # self.adapter.site_path |
| + | # end |
| + | |
| end | |
| - | end |
| \ No newline at end of file | |
| + | end |
locomotive/wagon/logger.rb b/lib/locomotive/wagon/logger.rb
+0
-58
| @@ | @@ -1,58 +0,0 @@ |
| - | module Locomotive |
| - | module Wagon |
| - | |
| - | class Logger |
| - | |
| - | attr_accessor :logger, :logfile_path, :stdout |
| - | |
| - | def initialize |
| - | self.logger = nil |
| - | end |
| - | |
| - | # Setup the single instance of the ruby logger. |
| - | # |
| - | # @param [ String ] path The path to the log file (default: log/wagon.log) |
| - | # @param [ Boolean ] stdout Instead of having a file, log to the standard output |
| - | # |
| - | def setup(path, stdout = false) |
| - | require 'logger' |
| - | |
| - | self.stdout = stdout |
| - | |
| - | self.logfile_path = File.expand_path(File.join(path, 'log', 'wagon.log')) |
| - | FileUtils.mkdir_p(File.dirname(logfile_path)) |
| - | |
| - | out = self.stdout ? STDOUT : self.logfile_path |
| - | |
| - | self.logger = ::Logger.new(out).tap do |log| |
| - | log.level = ::Logger::DEBUG |
| - | log.formatter = proc do |severity, datetime, progname, msg| |
| - | "#{msg}\n" |
| - | end |
| - | end |
| - | end |
| - | |
| - | def self.instance |
| - | @@instance ||= self.new |
| - | end |
| - | |
| - | def self.setup(path, stdout = false) |
| - | self.instance.setup(path, stdout) |
| - | end |
| - | |
| - | def self.close |
| - | self.instance.logger.close |
| - | end |
| - | |
| - | class << self |
| - | %w(debug info warn error fatal unknown).each do |name| |
| - | define_method(name) do |message| |
| - | self.instance.logger.send(name.to_sym, message) |
| - | end |
| - | end |
| - | end |
| - | |
| - | end |
| - | |
| - | end |
| - | end |
| \ No newline at end of file | |
locomotive/wagon/misc.rb b/lib/locomotive/wagon/misc.rb
+8
-8
| @@ | @@ -1,9 +1,9 @@ |
| - | require 'locomotive/wagon/misc/core_ext.rb' |
| - | require 'locomotive/wagon/misc/will_paginate.rb' |
| - | require 'locomotive/wagon/misc/httparty.rb' |
| - | require 'locomotive/wagon/misc/dragonfly.rb' |
| + | # require 'locomotive/wagon/misc/core_ext.rb' |
| + | # require 'locomotive/wagon/misc/will_paginate.rb' |
| + | # require 'locomotive/wagon/misc/httparty.rb' |
| + | # require 'locomotive/wagon/misc/dragonfly.rb' |
| require 'locomotive/wagon/misc/i18n.rb' | |
| - | require 'locomotive/wagon/misc/mounter.rb' |
| - | require 'locomotive/wagon/misc/markdown.rb' |
| - | require 'locomotive/wagon/misc/haml.rb' |
| - | require 'locomotive/wagon/misc/better_errors.rb' |
| \ No newline at end of file | |
| + | # require 'locomotive/wagon/misc/mounter.rb' |
| + | # require 'locomotive/wagon/misc/markdown.rb' |
| + | # require 'locomotive/wagon/misc/haml.rb' |
| + | # require 'locomotive/wagon/misc/better_errors.rb' |
locomotive/wagon/misc/core_ext.rb b/lib/locomotive/wagon/misc/core_ext.rb
+61
-61
| @@ | @@ -1,62 +1,62 @@ |
| - | unless Hash.instance_methods.include?(:underscore_keys) |
| - | class Hash |
| - | |
| - | def underscore_keys |
| - | new_hash = {} |
| - | |
| - | self.each_pair do |key, value| |
| - | if value.respond_to?(:collect!) # Array |
| - | value.collect do |item| |
| - | if item.respond_to?(:each_pair) # Hash item within |
| - | item.underscore_keys |
| - | else |
| - | item |
| - | end |
| - | end |
| - | elsif value.respond_to?(:each_pair) # Hash |
| - | value = value.underscore_keys |
| - | end |
| - | |
| - | new_key = key.is_a?(String) ? key.underscore : key # only String keys |
| - | |
| - | new_hash[new_key] = value |
| - | end |
| - | |
| - | self.replace(new_hash) |
| - | end |
| - | |
| - | end |
| - | end |
| - | |
| - | unless String.instance_methods.include?(:to_bool) |
| - | class String |
| - | def to_bool |
| - | return true if self == true || self =~ (/(true|t|yes|y|1)$/i) |
| - | return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i) |
| - | raise ArgumentError.new("invalid value for Boolean: \"#{self}\"") |
| - | end |
| - | end |
| - | |
| - | class TrueClass |
| - | def to_bool; self; end |
| - | end |
| - | |
| - | class FalseClass |
| - | def to_bool; self; end |
| - | end |
| - | end |
| - | |
| - | unless Array.instance_methods.include?(:contains?) |
| - | class Array |
| - | def contains?(other); (self & other) == other; end |
| - | end |
| - | end |
| - | |
| - | unless Integer.instance_methods.include?(:to_datetime) |
| - | class Integer |
| - | def to_datetime |
| - | Time.at(self).to_datetime |
| - | end |
| - | end |
| - | end |
| + | # unless Hash.instance_methods.include?(:underscore_keys) |
| + | # class Hash |
| + | |
| + | # def underscore_keys |
| + | # new_hash = {} |
| + | |
| + | # self.each_pair do |key, value| |
| + | # if value.respond_to?(:collect!) # Array |
| + | # value.collect do |item| |
| + | # if item.respond_to?(:each_pair) # Hash item within |
| + | # item.underscore_keys |
| + | # else |
| + | # item |
| + | # end |
| + | # end |
| + | # elsif value.respond_to?(:each_pair) # Hash |
| + | # value = value.underscore_keys |
| + | # end |
| + | |
| + | # new_key = key.is_a?(String) ? key.underscore : key # only String keys |
| + | |
| + | # new_hash[new_key] = value |
| + | # end |
| + | |
| + | # self.replace(new_hash) |
| + | # end |
| + | |
| + | # end |
| + | # end |
| + | |
| + | # unless String.instance_methods.include?(:to_bool) |
| + | # class String |
| + | # def to_bool |
| + | # return true if self == true || self =~ (/(true|t|yes|y|1)$/i) |
| + | # return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i) |
| + | # raise ArgumentError.new("invalid value for Boolean: \"#{self}\"") |
| + | # end |
| + | # end |
| + | |
| + | # class TrueClass |
| + | # def to_bool; self; end |
| + | # end |
| + | |
| + | # class FalseClass |
| + | # def to_bool; self; end |
| + | # end |
| + | # end |
| + | |
| + | # unless Array.instance_methods.include?(:contains?) |
| + | # class Array |
| + | # def contains?(other); (self & other) == other; end |
| + | # end |
| + | # end |
| + | |
| + | # unless Integer.instance_methods.include?(:to_datetime) |
| + | # class Integer |
| + | # def to_datetime |
| + | # Time.at(self).to_datetime |
| + | # end |
| + | # end |
| + | # end |
locomotive/wagon/misc/dragonfly.rb b/lib/locomotive/wagon/misc/dragonfly.rb
+78
-78
| @@ | @@ -1,78 +1,78 @@ |
| - | module Locomotive |
| - | module Wagon |
| - | class Dragonfly |
| - | |
| - | attr_accessor :path, :enabled |
| - | |
| - | def enabled? |
| - | !!self.enabled |
| - | end |
| - | |
| - | def resize_url(source, resize_string) |
| - | _source = (case source |
| - | when String then source |
| - | when Hash then source['url'] || source[:url] |
| - | else |
| - | source.try(:url) |
| - | end) |
| - | |
| - | if _source.blank? |
| - | Locomotive::Wagon::Logger.error "Unable to resize on the fly: #{source.inspect}" |
| - | return |
| - | end |
| - | |
| - | return _source unless self.enabled? |
| - | |
| - | if _source =~ /^http/ |
| - | file = self.class.app.fetch_url(_source) |
| - | else |
| - | file = self.class.app.fetch_file(File.join(self.path, 'public', _source)) |
| - | end |
| - | |
| - | file.process(:thumb, resize_string).url |
| - | end |
| - | |
| - | def self.app |
| - | ::Dragonfly[:images] |
| - | end |
| - | |
| - | |
| - | def self.instance |
| - | @@instance ||= new |
| - | end |
| - | |
| - | def self.setup!(path) |
| - | self.instance.path = path |
| - | self.instance.enabled = false |
| - | |
| - | begin |
| - | require 'rack/cache' |
| - | require 'dragonfly' |
| - | |
| - | ## initialize Dragonfly ## |
| - | app = ::Dragonfly[:images].configure_with(:imagemagick) |
| - | |
| - | ## configure it ## |
| - | ::Dragonfly[:images].configure do |c| |
| - | convert = `which convert`.strip.presence || '/usr/bin/env convert' |
| - | c.convert_command = convert |
| - | c.identify_command = convert |
| - | |
| - | c.allow_fetch_url = true |
| - | c.allow_fetch_file = true |
| - | |
| - | c.url_format = '/images/dynamic/:job/:basename.:format' |
| - | end |
| - | |
| - | self.instance.enabled = true |
| - | rescue Exception => e |
| - | Locomotive::Wagon::Logger.warn %{ |
| - | [Dragonfly] !disabled! |
| - | [Dragonfly] If you want to take full benefits of all the features in the LocomotiveWagon, we recommend you to install ImageMagick and RMagick. Check out the documentation here: http://doc.locomotivecms.com/editor/installation. |
| - | } |
| - | end |
| - | end |
| - | |
| - | end |
| - | end |
| - | end |
| \ No newline at end of file | |
| + | # module Locomotive |
| + | # module Wagon |
| + | # class Dragonfly |
| + | |
| + | # attr_accessor :path, :enabled |
| + | |
| + | # def enabled? |
| + | # !!self.enabled |
| + | # end |
| + | |
| + | # def resize_url(source, resize_string) |
| + | # _source = (case source |
| + | # when String then source |
| + | # when Hash then source['url'] || source[:url] |
| + | # else |
| + | # source.try(:url) |
| + | # end) |
| + | |
| + | # if _source.blank? |
| + | # Locomotive::Wagon::Logger.error "Unable to resize on the fly: #{source.inspect}" |
| + | # return |
| + | # end |
| + | |
| + | # return _source unless self.enabled? |
| + | |
| + | # if _source =~ /^http/ |
| + | # file = self.class.app.fetch_url(_source) |
| + | # else |
| + | # file = self.class.app.fetch_file(File.join(self.path, 'public', _source)) |
| + | # end |
| + | |
| + | # file.process(:thumb, resize_string).url |
| + | # end |
| + | |
| + | # def self.app |
| + | # ::Dragonfly[:images] |
| + | # end |
| + | |
| + | |
| + | # def self.instance |
| + | # @@instance ||= new |
| + | # end |
| + | |
| + | # def self.setup!(path) |
| + | # self.instance.path = path |
| + | # self.instance.enabled = false |
| + | |
| + | # begin |
| + | # require 'rack/cache' |
| + | # require 'dragonfly' |
| + | |
| + | # ## initialize Dragonfly ## |
| + | # app = ::Dragonfly[:images].configure_with(:imagemagick) |
| + | |
| + | # ## configure it ## |
| + | # ::Dragonfly[:images].configure do |c| |
| + | # convert = `which convert`.strip.presence || '/usr/bin/env convert' |
| + | # c.convert_command = convert |
| + | # c.identify_command = convert |
| + | |
| + | # c.allow_fetch_url = true |
| + | # c.allow_fetch_file = true |
| + | |
| + | # c.url_format = '/images/dynamic/:job/:basename.:format' |
| + | # end |
| + | |
| + | # self.instance.enabled = true |
| + | # rescue Exception => e |
| + | # Locomotive::Wagon::Logger.warn %{ |
| + | # [Dragonfly] !disabled! |
| + | # [Dragonfly] If you want to take full benefits of all the features in the LocomotiveWagon, we recommend you to install ImageMagick and RMagick. Check out the documentation here: http://doc.locomotivecms.com/editor/installation. |
| + | # } |
| + | # end |
| + | # end |
| + | |
| + | # end |
| + | # end |
| + | # end |
locomotive/wagon/misc/haml.rb b/lib/locomotive/wagon/misc/haml.rb
+9
-9
| @@ | @@ -1,15 +1,15 @@ |
| - | module Haml::Filters |
| + | # module Haml::Filters |
| - | remove_filter("Markdown") #remove the existing Markdown filter |
| + | # remove_filter("Markdown") #remove the existing Markdown filter |
| - | module Markdown # the contents of this are as before, but without the lazy_require call |
| + | # module Markdown # the contents of this are as before, but without the lazy_require call |
| - | include Haml::Filters::Base |
| + | # include Haml::Filters::Base |
| - | def render text |
| - | Locomotive::Wagon::Markdown.render text |
| - | end |
| + | # def render text |
| + | # Locomotive::Wagon::Markdown.render text |
| + | # end |
| - | end |
| + | # end |
| - | end |
| \ No newline at end of file | |
| + | # end |
locomotive/wagon/misc/httparty.rb b/lib/locomotive/wagon/misc/httparty.rb
+36
-36
| @@ | @@ -1,48 +1,48 @@ |
| - | require 'uri' |
| + | # require 'uri' |
| - | module Locomotive |
| - | module Wagon |
| - | module Httparty |
| - | class Webservice |
| + | # module Locomotive |
| + | # module Wagon |
| + | # module Httparty |
| + | # class Webservice |
| - | include ::HTTParty |
| + | # include ::HTTParty |
| - | def self.consume(url, options = {}) |
| - | url = ::HTTParty.normalize_base_uri(url) |
| + | # def self.consume(url, options = {}) |
| + | # url = ::HTTParty.normalize_base_uri(url) |
| - | uri = URI.parse(url) |
| - | options[:base_uri] = "#{uri.scheme}://#{uri.host}" |
| - | options[:base_uri] += ":#{uri.port}" if uri.port != 80 |
| - | path = uri.request_uri |
| + | # uri = URI.parse(url) |
| + | # options[:base_uri] = "#{uri.scheme}://#{uri.host}" |
| + | # options[:base_uri] += ":#{uri.port}" if uri.port != 80 |
| + | # path = uri.request_uri |
| - | options.delete(:format) if options[:format] == 'default' |
| - | options[:format] = options[:format].gsub(/[\'\"]/, '').to_sym if options.has_key?(:format) |
| - | options[:headers] = { 'User-Agent' => 'LocomotiveCMS' } if options[:with_user_agent] |
| + | # options.delete(:format) if options[:format] == 'default' |
| + | # options[:format] = options[:format].gsub(/[\'\"]/, '').to_sym if options.has_key?(:format) |
| + | # options[:headers] = { 'User-Agent' => 'LocomotiveCMS' } if options[:with_user_agent] |
| - | username, password = options.delete(:username), options.delete(:password) |
| - | options[:basic_auth] = { username: username, password: password } if username |
| + | # username, password = options.delete(:username), options.delete(:password) |
| + | # options[:basic_auth] = { username: username, password: password } if username |
| - | path ||= '/' |
| + | # path ||= '/' |
| - | # Locomotive::Wagon::Logger.debug "[WebService] consuming #{path}, #{options.inspect}" |
| + | # # Locomotive::Wagon::Logger.debug "[WebService] consuming #{path}, #{options.inspect}" |
| - | response = self.get(path, options) |
| + | # response = self.get(path, options) |
| - | if response.code == 200 |
| - | _response = response.parsed_response |
| - | if _response.respond_to?(:underscore_keys) |
| - | _response.underscore_keys |
| - | else |
| - | _response.collect(&:underscore_keys) |
| - | end |
| - | else |
| - | Locomotive::Wagon::Logger.error "[WebService] consumed #{path}, #{options.inspect}, response = #{response.inspect}" |
| - | nil |
| - | end |
| + | # if response.code == 200 |
| + | # _response = response.parsed_response |
| + | # if _response.respond_to?(:underscore_keys) |
| + | # _response.underscore_keys |
| + | # else |
| + | # _response.collect(&:underscore_keys) |
| + | # end |
| + | # else |
| + | # Locomotive::Wagon::Logger.error "[WebService] consumed #{path}, #{options.inspect}, response = #{response.inspect}" |
| + | # nil |
| + | # end |
| - | end |
| + | # end |
| - | end |
| - | end |
| - | end |
| - | end |
| \ No newline at end of file | |
| + | # end |
| + | # end |
| + | # end |
| + | # end |
locomotive/wagon/misc/i18n.rb b/lib/locomotive/wagon/misc/i18n.rb
+2
-2
| @@ | @@ -1,2 +1,2 @@ |
| - | I18n.load_path = Dir[File.join(File.dirname(__FILE__), "/../../../../locales/*.yml")] |
| - | I18n.backend.reload! |
| \ No newline at end of file | |
| + | # I18n.load_path = Dir[File.join(File.dirname(__FILE__), "/../../../../locales/*.yml")] |
| + | # I18n.backend.reload! |
locomotive/wagon/misc/livereload.rb b/lib/locomotive/wagon/misc/livereload.rb
+3
-3
| @@ | @@ -8,7 +8,7 @@ module Guard |
| module UI | |
| class << self | |
| def method_missing(meth, *args) | |
| - | Locomotive::Wagon::Logger.send(meth, *args) |
| + | Locomotive::Common::Logger.send(meth, *args) |
| end | |
| end | |
| end | |
| @@ | @@ -32,7 +32,7 @@ module Locomotive |
| tcp_port = Locomotive::Wagon::TcpPort.new(options[:host], 35729) | |
| @port = tcp_port.first | |
| - | Locomotive::Wagon::Logger.debug "Run LiveReload on port '#{@port}'" |
| + | Locomotive::Common::Logger.debug "service=liveReload action=start port=#{@port}" |
| @livereload = Guard::LiveReload.new(options.merge(port: @port)) | |
| end | |
| @@ | @@ -40,4 +40,4 @@ module Locomotive |
| end | |
| end | |
| - | end |
| \ No newline at end of file | |
| + | end |
locomotive/wagon/misc/markdown.rb b/lib/locomotive/wagon/misc/markdown.rb
+23
-23
| @@ | @@ -1,27 +1,27 @@ |
| - | require 'redcarpet' |
| + | # require 'redcarpet' |
| - | module Locomotive |
| - | module Wagon |
| - | module Markdown |
| + | # module Locomotive |
| + | # module Wagon |
| + | # module Markdown |
| - | def self.render(text) |
| - | self.parser.render(text) |
| - | end |
| + | # def self.render(text) |
| + | # self.parser.render(text) |
| + | # end |
| - | def self.parser |
| - | @@markdown ||= Redcarpet::Markdown.new Redcarpet::Render::HTML, { |
| - | autolink: true, |
| - | fenced_code: true, |
| - | generate_toc: true, |
| - | gh_blockcode: true, |
| - | hard_wrap: true, |
| - | no_intraemphasis: true, |
| - | strikethrough: true, |
| - | tables: true, |
| - | xhtml: true |
| - | } |
| - | end |
| + | # def self.parser |
| + | # @@markdown ||= Redcarpet::Markdown.new Redcarpet::Render::HTML, { |
| + | # autolink: true, |
| + | # fenced_code: true, |
| + | # generate_toc: true, |
| + | # gh_blockcode: true, |
| + | # hard_wrap: true, |
| + | # no_intraemphasis: true, |
| + | # strikethrough: true, |
| + | # tables: true, |
| + | # xhtml: true |
| + | # } |
| + | # end |
| - | end |
| - | end |
| - | end |
| \ No newline at end of file | |
| + | # end |
| + | # end |
| + | # end |
locomotive/wagon/misc/mounter.rb b/lib/locomotive/wagon/misc/mounter.rb
+27
-27
| @@ | @@ -1,32 +1,32 @@ |
| - | module Locomotive |
| - | module Mounter |
| - | module Models |
| - | class Page |
| + | # module Locomotive |
| + | # module Mounter |
| + | # module Models |
| + | # class Page |
| - | def render(context) |
| - | self.parse(context).render(context) |
| - | end |
| + | # def render(context) |
| + | # self.parse(context).render(context) |
| + | # end |
| - | protected |
| + | # protected |
| - | def parse(context) |
| - | options = { |
| - | page: self, |
| - | mounting_point: context.registers[:mounting_point], |
| - | error_mode: :strict, |
| - | count_lines: true |
| - | } |
| + | # def parse(context) |
| + | # options = { |
| + | # page: self, |
| + | # mounting_point: context.registers[:mounting_point], |
| + | # error_mode: :strict, |
| + | # count_lines: true |
| + | # } |
| - | begin |
| - | template = ::Liquid::Template.parse(self.source, options) |
| - | rescue ::Liquid::SyntaxError => e |
| - | # do it again on the raw source instead so that the error line matches |
| - | # the source file. |
| - | ::Liquid::Template.parse(self.template.raw_source, options) |
| - | end |
| - | end |
| + | # begin |
| + | # template = ::Liquid::Template.parse(self.source, options) |
| + | # rescue ::Liquid::SyntaxError => e |
| + | # # do it again on the raw source instead so that the error line matches |
| + | # # the source file. |
| + | # ::Liquid::Template.parse(self.template.raw_source, options) |
| + | # end |
| + | # end |
| - | end |
| - | end |
| - | end |
| - | end |
| \ No newline at end of file | |
| + | # end |
| + | # end |
| + | # end |
| + | # end |
locomotive/wagon/misc/will_paginate.rb b/lib/locomotive/wagon/misc/will_paginate.rb
+14
-14
| @@ | @@ -1,16 +1,16 @@ |
| - | require 'will_paginate' |
| - | require 'will_paginate/collection' |
| + | # require 'will_paginate' |
| + | # require 'will_paginate/collection' |
| - | Array.class_eval do |
| - | def paginate(options = {}) |
| - | raise ArgumentError, "parameter hash expected (got #{options.inspect})" unless Hash === options |
| + | # Array.class_eval do |
| + | # def paginate(options = {}) |
| + | # raise ArgumentError, "parameter hash expected (got #{options.inspect})" unless Hash === options |
| - | WillPaginate::Collection.create( |
| - | options[:page] || 1, |
| - | options[:per_page] || 30, |
| - | options[:total_entries] || self.length |
| - | ) { |pager| |
| - | pager.replace self[pager.offset, pager.per_page].to_a |
| - | } |
| - | end |
| - | end |
| \ No newline at end of file | |
| + | # WillPaginate::Collection.create( |
| + | # options[:page] || 1, |
| + | # options[:per_page] || 30, |
| + | # options[:total_entries] || self.length |
| + | # ) { |pager| |
| + | # pager.replace self[pager.offset, pager.per_page].to_a |
| + | # } |
| + | # end |
| + | # end |
locomotive/wagon/standalone_server.rb b/lib/locomotive/wagon/standalone_server.rb
+22
-22
| @@ | @@ -1,28 +1,28 @@ |
| - | $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../..')) |
| + | # $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../..')) |
| - | require 'locomotive/wagon/logger' |
| - | require 'locomotive/wagon/version' |
| - | require 'locomotive/wagon/exceptions' |
| - | require 'locomotive/wagon/server' |
| - | require 'locomotive/mounter' |
| + | # require 'locomotive/wagon/logger' |
| + | # require 'locomotive/wagon/version' |
| + | # require 'locomotive/wagon/exceptions' |
| + | # require 'locomotive/wagon/server' |
| + | # require 'locomotive/mounter' |
| - | module Locomotive |
| - | module Wagon |
| - | class StandaloneServer < Server |
| + | # module Locomotive |
| + | # module Wagon |
| + | # class StandaloneServer < Server |
| - | def initialize(path) |
| - | Locomotive::Wagon::Logger.setup(path, false) |
| + | # def initialize(path) |
| + | # Locomotive::Wagon::Logger.setup(path, false) |
| - | # get the reader |
| - | reader = Locomotive::Mounter::Reader::FileSystem.instance |
| - | reader.run!(path: path) |
| - | reader |
| + | # # get the reader |
| + | # reader = Locomotive::Mounter::Reader::FileSystem.instance |
| + | # reader.run!(path: path) |
| + | # reader |
| - | Bundler.require 'misc' |
| + | # Bundler.require 'misc' |
| - | # run the rack app |
| - | super(reader, disable_listen: true) |
| - | end |
| - | end |
| - | end |
| - | end |
| \ No newline at end of file | |
| + | # # run the rack app |
| + | # super(reader, disable_listen: true) |
| + | # end |
| + | # end |
| + | # end |
| + | # end |
locomotivecms_wagon.gemspec
+7
-7
| @@ | @@ -18,16 +18,16 @@ Gem::Specification.new do |gem| |
| gem.require_paths = ['lib'] | |
| gem.executables = ['wagon'] | |
| - | gem.add_dependency 'thor' |
| - | gem.add_dependency 'thin', '~> 1.6.1' |
| - | gem.add_dependency 'better_errors', '~> 1.0.1' |
| - | gem.add_dependency 'rubyzip', '~> 1.1.0' |
| - | gem.add_dependency 'netrc', '~> 0.7.7' |
| + | gem.add_dependency 'thor', '~> 0.19.1' |
| + | gem.add_dependency 'thin', '~> 1.6.3' |
| + | gem.add_dependency 'better_errors', '~> 2.1.1' |
| + | gem.add_dependency 'rubyzip', '~> 1.1.7' |
| + | gem.add_dependency 'netrc', '~> 0.10.3' |
| - | gem.add_dependency 'listen', '~> 2.7.5' |
| + | gem.add_dependency 'listen', '~> 2.10.0' |
| gem.add_dependency 'rack-livereload', '~> 0.3.15' | |
| - | gem.add_dependency 'faker', '~> 0.9.5' |
| + | gem.add_dependency 'faker', '~> 1.4.3' |
| gem.add_development_dependency 'rake', '~> 10.0.4' | |
| gem.add_development_dependency 'rspec', '~> 2.6.0' | |
spec/fixtures/default/app/views/snippets/footer.liquid.haml
+1
-1
| @@ | @@ -3,4 +3,4 @@ |
| %p | |
| {{ 'powered_by' | translate }} <a href="http://www.locomotivecms.com">LocomotiveCMS</a>. Designed by <a href="http://www.sachagreif.com">Sacha Greif</a>. | |
| %p | |
| - | All photos are licensed under Creative Commons. (see original ones <a href='http://www.flickr.com/photos/38687875@N00/3391588262/'>here</a> or <a href='http://www.flickr.com/photos/cool_dry_place/55454498/'>here</a>). |
| \ No newline at end of file | |
| + | All photos are licensed under Creative Commons. (see original ones <a href='http://www.flickr.com/photos/38687875@N00/3391588262/'>here</a> or <a href='http://www.flickr.com/photos/cool_dry_place/55454498/'>here</a>). |
spec/unit/locomotive/wagon/liquid/drops/page_spec.rb
+0
-41
| @@ | @@ -1,41 +0,0 @@ |
| - | # encoding: utf-8 |
| - | |
| - | require 'locomotive/wagon/liquid' |
| - | |
| - | describe Locomotive::Wagon::Liquid::Drops::Page do |
| - | |
| - | let(:attributes) { { title: "Hello world" } } |
| - | let(:source) { Locomotive::Mounter::Models::Page.new(attributes) } |
| - | |
| - | subject { source.to_liquid } |
| - | |
| - | describe 'the title' do |
| - | |
| - | its(:title) { should eq "Hello world" } |
| - | |
| - | end |
| - | |
| - | describe 'with editable elements' do |
| - | |
| - | let(:text_a) { Locomotive::Mounter::Models::EditableElement.new(block: 'sidebar/header', slug: 'ads', content: 'foo' ) } |
| - | let(:text_b) { Locomotive::Mounter::Models::EditableElement.new(block: 'sidebar/footer', slug: 'ads', content: 'foo ter' ) } |
| - | let(:text_c) { Locomotive::Mounter::Models::EditableElement.new(block: '', slug: 'simple_text', content: 'bar' ) } |
| - | let(:text_d) { Locomotive::Mounter::Models::EditableElement.new(block: 'My footer/wrapper/inner', slug: 'text', content: 'hello world' ) } |
| - | let(:attributes) { { editable_elements: [text_a, text_b, text_c, text_d] } } |
| - | |
| - | its(:editable_elements) do |
| - | should eq({ |
| - | 'sidebar' => { |
| - | 'header' => { 'ads' => 'foo' }, |
| - | 'footer' => { 'ads' => 'foo ter' } |
| - | }, |
| - | 'simple_text' => 'bar', |
| - | 'my_footer' => { |
| - | 'wrapper' => { 'inner' => { 'text' => 'hello world' } } |
| - | } |
| - | }) |
| - | end |
| - | |
| - | end |
| - | |
| - | end |
| \ No newline at end of file | |