lib/middleman-torrent/extension.rb in middleman-torrent-0.0.3 vs lib/middleman-torrent/extension.rb in middleman-torrent-0.0.4
- old
+ new
@@ -8,21 +8,30 @@
def initialize(app, options_hash={}, &block)
super
require 'mktorrent'
end
+ # Expose configuration values
+ def after_configuration
+ app.set :torrent_tracker, options.tracker
+ app.set :torrent_file, options.file
+ app.set :torrent_name, options.name
+ app.set :torrent_private, options.private
+ end
+
# Create the torrent after the site is built
def after_build(builder)
torrent = Torrent.new options.tracker
torrent.defaultdir = options.name
torrent.set_private if options.private
# Move to build_dir so it's not added to the torrent
within_build_path do
app.sitemap.resources.each do |file|
- torrent.add_file file.path
- builder.say_status 'to torrent', file.path
+ # We decode the path because it can have spaces (%20) and stuff
+ torrent.add_file URI.decode(file.path)
+ builder.say_status 'to torrent', URI.decode(file.path)
end
torrent.write_torrent options.file
end