Browse files

Add target to state, JRuby runner, drop non-movie files

  • Loading branch information...
1 parent 319e1ab commit 47ca4cb1dbaa5e5b2f2f6f479c0ce976a528d26e @paulcbetts committed Jun 1, 2008
Showing with 27 additions and 3 deletions.
  1. +6 −0 Rakefile
  2. +14 −1 app/controllers/podcast.rb
  3. +1 −0 config/router.rb
  4. +5 −2 lib/main.rb
  5. +1 −0 lib/state.rb
View
6 Rakefile
@@ -189,6 +189,12 @@ task :run do
sh "ruby #{RootDir}/lib/main.rb --debug -r 10 -l #{RootDir}/spec -t #{RootDir}/output"
end
+desc "Run Yikes from the source directory using JRuby"
+task :jrun do
+ sh "mkdir -p #{RootDir}/output"
+ sh "jruby #{RootDir}/lib/main.rb --debug -r 10 -l #{RootDir}/spec -t #{RootDir}/output"
+end
+
# Default Actions
task :default => [
:updatepo,
View
15 app/controllers/podcast.rb
@@ -2,10 +2,23 @@
require 'builder/xmlmarkup'
class Podcast < Application
- def index;
+ def index
render podcast_xml, :layout => false
end
+ def send_file
+ target = Yikes.instance.state.target
+ p = Pathname.new(File.join(target, params["path"]))
+ return p.to_s
+ begin
+ return nil unless p.realpath.to_s.index(target) == 0
+ rescue
+ return nil
+ end
+ p.to_s
+ #send_file(File.open(p.to_s, 'r'))
+ end
+
private
def podcast_xml
app = Yikes.instance.state
View
1 config/router.rb
@@ -29,5 +29,6 @@
# Change this for your home page to be available at /
# r.match('/').to(:controller => 'whatever', :action =>'index')
r.match('/:action.:format').to(:controller => 'welcome')
+ r.match(/\/files\/(.*)/).to(:controller => "podcast", :action => "send_file", :path => "[1]")
r.match('/').to(:controller => 'welcome', :action =>'index')
end
View
7 lib/main.rb
@@ -27,7 +27,6 @@
require 'gettext'
require 'optparse'
require 'optparse/time'
-require 'highline'
require 'singleton'
require 'yaml'
require 'merb-core'
@@ -44,6 +43,8 @@
$logging_level = ($DEBUG ? Logger::DEBUG : Logger::ERROR)
+AllowedFiletypes = ['.avi', '.mov', '.mp4', '.wmv']
+
class Yikes < Logger::Application
include Singleton
include ApplicationState
@@ -132,6 +133,7 @@ def run
self.level = $logging_level
load_state(File.join(Platform.settings_dir, 'state.yaml'), results[:library])
+ state.target = results[:target]
# Actually do stuff
unless results[:background]
@@ -162,7 +164,8 @@ def run
end
def enqueue_files_to_encode(library, target)
- state.add_to_queue get_file_list(library).collect {|x| EncodingItem.new(library, x, target)}
+ fl = get_file_list(library).delete_if{|x| not AllowedFiletypes.include?(Pathname.new(x).extname.downcase)}
+ state.add_to_queue(fl.collect {|x| EncodingItem.new(library, x, target)})
end
def do_encode(library, target)
View
1 lib/state.rb
@@ -67,6 +67,7 @@ class State
attr_accessor :encoded_queue
attr_accessor :to_encode_queue
attr_accessor :library
+ attr_accessor :target
def initialize(library)
@encoded_queue = []

0 comments on commit 47ca4cb

Please sign in to comment.