Skip to content

Commit

Permalink
publish zine to manga download dir
Browse files Browse the repository at this point in the history
  • Loading branch information
jphager2 committed Nov 7, 2016
1 parent f8773b9 commit 64c3ac8
Show file tree
Hide file tree
Showing 274 changed files with 100 additions and 7 deletions.
1 change: 1 addition & 0 deletions .ruby-gemset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
my_manga_zine
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-2.1.5
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
source 'https://rubygems.org'

gem 'rpub'
source 'https://rubygems.org'

gem 'mangdown', '~> 0.13'
gem 'pg'
gem 'activerecord', '~> 4.0'
48 changes: 43 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,45 @@
GEM
remote: https://rubygems.org/
specs:
activemodel (4.2.7.1)
activesupport (= 4.2.7.1)
builder (~> 3.1)
activerecord (4.2.7.1)
activemodel (= 4.2.7.1)
activesupport (= 4.2.7.1)
arel (~> 6.0)
activesupport (4.2.7.1)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
builder (3.2.2)
commander (4.4.0)
highline (~> 1.7.2)
ethon (0.9.1)
ffi (>= 1.3.0)
ffi (1.9.14)
highline (1.7.8)
i18n (0.7.0)
json (1.8.3)
kramdown (1.12.0)
mangdown (0.14.0)
nokogiri (~> 1.6.0)
progress_bar (~> 1.0.3)
ruby-filemagic
rubyzip (~> 1.1.0)
typhoeus (~> 0.7.1)
mini_portile2 (2.1.0)
nokogiri (1.6.8)
minitest (5.9.1)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
pkg-config (1.1.7)
options (2.3.2)
pg (0.19.0)
progress_bar (1.0.5)
highline (~> 1.6)
options (~> 2.3.0)
rpub (0.5.0)
builder
commander
Expand All @@ -19,16 +48,25 @@ GEM
rubyzip
textstats
typogruby
rubypants (0.5.0)
rubyzip (1.2.0)
ruby-filemagic (0.7.1)
rubypants (0.6.0)
rubyzip (1.1.7)
textstats (0.0.2)
thread_safe (0.3.5)
typhoeus (0.7.3)
ethon (>= 0.7.4)
typogruby (1.0.18)
rubypants
tzinfo (1.2.2)
thread_safe (~> 0.1)

PLATFORMS
ruby

DEPENDENCIES
activerecord (~> 4.0)
mangdown (~> 0.13)
pg
rpub

BUNDLED WITH
Expand Down
5 changes: 5 additions & 0 deletions bin/my_manga_zine
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/Users/jph/.rvm/rubies/ruby-2.1.5/bin/ruby

require_relative '../lib/my_manga_zine'

MyManga::Zine.publish('zine')
47 changes: 45 additions & 2 deletions lib/my_manga_zine.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
require 'mangdown'
require_relative '../../my_manga/db/environment'
require_relative '../../my_manga/lib/my_manga'

module MyManga
module Zine
def self.publish
def self.publish(name)
Dir.mkdir('tmp') unless Dir.exist?('tmp')

zine = zine_content
serialized_name = []
zine.each do |chapter|
chapter.to_md.download_to(Dir.pwd + '/zine')
serialized_name << chapter.id
chapter.to_md.download_to(Dir.pwd + '/tmp')
MyManga.read!(chapter.manga, [chapter.number]) if read_on_publish?
end

serialized_name = serialized_name.join.to_i.to_s(32)

cbz("#{name}-#{serialized_name}")

utils.rm_r('tmp') if clean_up_files?

# Create an epub from the files (use rpub)
# Need to get the styles right
# (look at viewport, image dimensions, etc.)
Expand All @@ -35,6 +47,37 @@ def zine_content
[chapter.manga_id, chapter.number]
end
end

def cbz(dir)
pages = Dir['tmp/**/*.*']

Dir.mkdir(dir) unless Dir.exist?(dir)

pages.each do |page|
filename = File.basename(page)
utils.cp(page, File.join(MyManga.download_dir, dir, filename))
end

Mangdown::CBZ.one(dir)

utils.rm_r(dir) if clean_up_files?
end

def read_on_publish?
ENV['MY_MANGA_ZINE_NO_READ'].nil? && !debug?
end

def clean_up_files?
ENV['MY_MANGA_ZINE_CLEAN_UP'].nil? && !debug?
end

def debug?
ENV['DEBUG'] || $DEBUG
end

def utils
debug? ? FileUtils::Verbose : FileUtils
end
end
end
end
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00001.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00002.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00003.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00004.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00005.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00006.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00007.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00008.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00009.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00010.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00011.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00012.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00013.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00014.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00015.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00016.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00017.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00018.jpeg
Binary file added tmp/Kingdom 00463/Kingdom 463 - Page 00019.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00001.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00002.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00003.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00004.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00005.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00006.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00007.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00008.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00009.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00010.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00011.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00012.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00013.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00014.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00015.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00016.jpeg
Binary file added tmp/Kingdom 00464/Kingdom 464 - Page 00017.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00001.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00002.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00003.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00004.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00005.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00006.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00007.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00008.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00009.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00010.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00011.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00012.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00013.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00014.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00015.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00016.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00017.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00018.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00019.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00020.jpeg
Binary file added tmp/Nisekoi 00205/Nisekoi 205 - Page 00021.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00001.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00002.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00003.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00004.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00005.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00006.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00007.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00008.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00009.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00010.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00011.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00012.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00013.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00014.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00015.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00016.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00017.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00018.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00019.jpeg
Binary file added tmp/Nisekoi 00206/Nisekoi 206 - Page 00020.jpeg

0 comments on commit 64c3ac8

Please sign in to comment.