Permalink
Browse files

Add a couple of options, fix video export.

  • Loading branch information...
1 parent 1f604d4 commit 9f36c51a71fcdebd1bde1cdd6a395ae2e796c2f9 @dodecaphonic committed Jun 17, 2011
Showing with 18 additions and 7 deletions.
  1. +1 −1 bin/tumble_out
  2. +13 −3 lib/tumble_out/contentizer.rb
  3. +4 −3 lib/tumble_out/post.rb
View
@@ -57,5 +57,5 @@ if tumblog.nil?
exit
end
-contentizer = TumbleOut::Contentizer.new(tumblog, true)
+contentizer = TumbleOut::Contentizer.new(tumblog, show_progress: true, use_permalinks: permalinks)
contentizer.dump output_dir
@@ -2,21 +2,31 @@ module TumbleOut
class Contentizer
attr_reader :url
- def initialize(url, progress=false)
+ DEFAULTS = {
+ use_permalinks: false,
+ show_progress: false
+ }
+
+ def initialize(url, options={})
+ options = DEFAULTS.merge(options)
+
@url = url
@total_posts = nil
@chunk_size = 50
@posts = []
@done = false
- @show_progress = progress
+ @use_permalinks = options[:use_permalinks]
+ @show_progress = options[:show_progress]
end
def posts
$stderr.puts "Exporting..." if @show_progress
until @done
chunk = raw_posts(@posts.size)
- @posts += chunk.map { |rp| Post.new rp }
+ @posts += chunk.map { |rp|
+ Post.new rp, @use_permalinks
+ }
@done = @posts.size == @total_posts
$stderr.print "\r#{@posts.size} of #{@total_posts}" if @show_progress
View
@@ -14,7 +14,8 @@ def initialize(raw_post, use_permalink=false)
@title = nil
@body = nil
@slug = nil
- @topics = nil
+ @topics = nil
+ @private = false
@coder = HTMLEntities.new
parse raw_post
@@ -74,7 +75,7 @@ def parse_audio(post)
end
def parse_video(post)
- body = @coder.decode(post.search("video-source").
+ body = @coder.decode(post.search("video-player").first.
inner_html +
post.search("video-caption").
inner_html)
@@ -128,7 +129,7 @@ def parse_photo(post)
def create_front_matter
fm = "---\nlayout: post"
fm << "\ntitle: #{@title}" if @title
- fm << "\npermalink: #{@permalink}" if @permalink
+ fm << "\npermalink: #{@permalink}" if @use_permalink
fm << "\ntopics: " << @topics.join(" ") unless @topics.empty?
fm << "\n---"

0 comments on commit 9f36c51

Please sign in to comment.