ficrip 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +38 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/ficrip +63 -0
- data/bin/setup +8 -0
- data/ficrip.gemspec +31 -0
- data/lib/ficrip/extensions.rb +16 -0
- data/lib/ficrip/process.rb +59 -0
- data/lib/ficrip/story.rb +139 -0
- data/lib/ficrip/version.rb +3 -0
- data/lib/ficrip.rb +4 -0
- metadata +203 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 274aeb5446a0a3d556d227c02e66fd394c0f7c73
|
4
|
+
data.tar.gz: 95c5d132493981015636a876efd8fc139a800e3a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e9be42f1da6348b7d24c348aae7e82864c3b8f1300041201c516ca1d007f2db82441a45c15560ed61b39329b728764e44181b290127dc4516b429761c085de09
|
7
|
+
data.tar.gz: 84b991e21709287b39ef532e611910615922c1709992914e6dd149c4dccfbdc224ba145a68cdfef16b384ec78d3f499c69dad41fb1590840caaacd7c06aedcfa
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Documentation cache and generated files:
|
17
|
+
/.yardoc/
|
18
|
+
/_yardoc/
|
19
|
+
/doc/
|
20
|
+
/rdoc/
|
21
|
+
|
22
|
+
## Environment normalization:
|
23
|
+
/.bundle/
|
24
|
+
/vendor/bundle
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at toroidalcode@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Katherine Whitlock
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Ficrip
|
2
|
+
Fanfiction.net to EPUB2/3 tool
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'ficrip'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install ficrip
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
TODO: Write usage instructions here
|
23
|
+
|
24
|
+
## Development
|
25
|
+
|
26
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
27
|
+
|
28
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/toroidal-code/ficrip. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
33
|
+
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
38
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ficrip"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/ficrip
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'slop'
|
5
|
+
require 'ruby-progressbar'
|
6
|
+
require 'ficrip'
|
7
|
+
|
8
|
+
opts = Slop.parse do |o|
|
9
|
+
o.banner = "usage: #{$0} [options] [<storyid/url>...]"
|
10
|
+
o.bool '--epub2', 'generate strict EPUB2 files instead of EPUB3 (e.g. for Google Play)'
|
11
|
+
o.bool '--verbose', 'enable verbose mode'
|
12
|
+
o.bool '-q', '--quiet', 'suppress output (quiet mode)'
|
13
|
+
o.on '-v', '--version', 'print the version' do
|
14
|
+
puts Ficrip::VERSION
|
15
|
+
exit
|
16
|
+
end
|
17
|
+
o.on '-h', '--help' do
|
18
|
+
puts o
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
if opts.args.empty?
|
24
|
+
puts opts
|
25
|
+
exit -1
|
26
|
+
end
|
27
|
+
|
28
|
+
storyids = opts.args.map do |a|
|
29
|
+
if a =~ Regexp.new('fanfiction.net/s/(\d+)', true)
|
30
|
+
Integer $1
|
31
|
+
else
|
32
|
+
begin
|
33
|
+
Integer a
|
34
|
+
rescue ArgumentError
|
35
|
+
$stderr.puts "Error! \"#{a}\" is not a valid fanfiction.net URL or StoryID"
|
36
|
+
$errored = true
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
exit -1 if $errored
|
42
|
+
|
43
|
+
storyids.each_with_index do |storyid, idx|
|
44
|
+
prefix = (storyids.count > 1) ? "(#{idx + 1}/#{storyids.count}): " : ''
|
45
|
+
progressbar = ProgressBar.create(format: prefix + "#{storyid}... Loading",
|
46
|
+
progress_mark: '#',
|
47
|
+
remainder_mark: '-')
|
48
|
+
|
49
|
+
fic = Ficrip.fetch storyid
|
50
|
+
|
51
|
+
author_title = "#{fic.author} - #{fic.title}"
|
52
|
+
|
53
|
+
progressbar.total = fic.chapters.count
|
54
|
+
progressbar.format = prefix + "#{author_title} | %a [%B] %p%% (%c/%C)"
|
55
|
+
|
56
|
+
epub = fic.bind(callback: lambda { progressbar.increment })
|
57
|
+
|
58
|
+
progressbar.format = prefix + "#{author_title}... Binding"
|
59
|
+
filename = File.join(Dir.pwd, "#{author_title}.epub")
|
60
|
+
epub.generate_epub filename
|
61
|
+
|
62
|
+
progressbar.format = prefix + "#{author_title}... Done!"
|
63
|
+
end
|
data/bin/setup
ADDED
data/ficrip.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ficrip/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'ficrip'
|
8
|
+
spec.version = Ficrip::VERSION
|
9
|
+
spec.license = 'MIT'
|
10
|
+
spec.summary = 'A fanfiction.net to EPUB2/3 tool.'
|
11
|
+
spec.author = 'Katherine Whitlock'
|
12
|
+
spec.email = 'toroidalcode@gmail.com'
|
13
|
+
spec.homepage = 'https://github.com/toroidal-code/ficrip'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = 'bin'
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_dependency 'nokogiri', '~> 1.6'
|
21
|
+
spec.add_dependency 'ruby-progressbar', '~> 1.8'
|
22
|
+
spec.add_dependency 'gepub', '0.7.0beta3'
|
23
|
+
spec.add_dependency 'slop', '~> 4.3'
|
24
|
+
spec.add_dependency 'contracts', '~> 0.14'
|
25
|
+
spec.add_dependency 'i18n_data', '~> 0.7'
|
26
|
+
spec.add_dependency 'fastimage', '~> 1.8'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
29
|
+
spec.add_development_dependency 'rake', '~> 11.2'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.5'
|
31
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Array
|
2
|
+
def find_with(str)
|
3
|
+
find { |i| i.start_with? str }.gsub(str, '').strip
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class String
|
8
|
+
def parse_int
|
9
|
+
gsub(/[^\d]/, '').to_i
|
10
|
+
end
|
11
|
+
|
12
|
+
def strip_heredoc
|
13
|
+
indent = scan(/^[ \t]*(?=\S)/).min.size || 0
|
14
|
+
gsub(/^[ \t]{#{indent}}/, '')
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'contracts'
|
2
|
+
require 'gepub'
|
3
|
+
require 'i18n_data'
|
4
|
+
require 'fastimage'
|
5
|
+
require 'open-uri'
|
6
|
+
require_relative 'extensions'
|
7
|
+
|
8
|
+
module Ficrip
|
9
|
+
include Contracts::Core
|
10
|
+
include Contracts::Builtin
|
11
|
+
|
12
|
+
Contract Integer => Story
|
13
|
+
def self.fetch(storyid)
|
14
|
+
base_url = "https://www.fanfiction.net/s/#{storyid}/"
|
15
|
+
primary_page = Nokogiri::HTML open(base_url)
|
16
|
+
|
17
|
+
title = primary_page.css('#profile_top > b').first.text
|
18
|
+
author = primary_page.css('#profile_top > a').first.text
|
19
|
+
|
20
|
+
Story.construct(title, author, base_url) do |s|
|
21
|
+
s.author_url = URI.join(base_url, primary_page.css('#profile_top > a').first['href'])
|
22
|
+
s.summary = primary_page.css('#profile_top > div').text
|
23
|
+
|
24
|
+
info = primary_page.css('#profile_top > span.xgray.xcontrast_txt').text.split(' - ')
|
25
|
+
|
26
|
+
s.rating = info.find_with 'Rated: Fiction'
|
27
|
+
s.language = info[1]
|
28
|
+
s.genres = info[2].split('/')
|
29
|
+
s.characters = info[3].strip
|
30
|
+
s.chapter_count = info.find_with('Chapters:').parse_int
|
31
|
+
s.word_count = info.find_with('Words:').parse_int
|
32
|
+
s.review_count = info.find_with('Reviews:').parse_int
|
33
|
+
s.favs_count = info.find_with('Favs:').parse_int
|
34
|
+
s.follows_count = info.find_with('Follows:').parse_int
|
35
|
+
s.updated_date = Date.parse info.find_with('Updated:')
|
36
|
+
s.published_date = Date.parse info.find_with('Published:')
|
37
|
+
s.info_id = info.find_with('id:').to_i
|
38
|
+
|
39
|
+
raise(Exception.new("Error! StoryID and parsed ID don't match.")) if s.info_id != storyid
|
40
|
+
|
41
|
+
cover_elem = primary_page.css('img.lazy.cimage').first
|
42
|
+
s.cover_url = URI.join(base_url, cover_elem['data-original']) if cover_elem
|
43
|
+
|
44
|
+
# Get the contents of the first chapter selector at the top of the page
|
45
|
+
chapter_select = primary_page.css('select#chap_select').first
|
46
|
+
if chapter_select
|
47
|
+
s.chapters = chapter_select.children.map(&:text)
|
48
|
+
else
|
49
|
+
s.chapters = "1. #{title}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
Contract Integer => GEPUB::Book
|
55
|
+
def self.get(storyid, version: 3)
|
56
|
+
fetch(storyid).bind(version)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/lib/ficrip/story.rb
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'contracts'
|
2
|
+
require 'open-uri'
|
3
|
+
require_relative 'extensions'
|
4
|
+
|
5
|
+
module Ficrip
|
6
|
+
class Story
|
7
|
+
include Contracts::Core
|
8
|
+
include Contracts::Builtin
|
9
|
+
|
10
|
+
attr_accessor :title, :author, :metadata
|
11
|
+
|
12
|
+
DOCTYPE = {
|
13
|
+
3 => '<!DOCTYPE html>',
|
14
|
+
2 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'
|
15
|
+
}
|
16
|
+
|
17
|
+
def initialize(title, author, url, metadata = {})
|
18
|
+
@title = title
|
19
|
+
@author = author
|
20
|
+
@url = url
|
21
|
+
@metadata = metadata
|
22
|
+
end
|
23
|
+
|
24
|
+
def construct
|
25
|
+
yield self
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.construct(title, author, url)
|
30
|
+
s = Story::new(title, author, url)
|
31
|
+
yield s
|
32
|
+
s
|
33
|
+
end
|
34
|
+
|
35
|
+
def method_missing(method_sym, *arguments, &block)
|
36
|
+
if method_sym != :title= && method_sym != :author= &&
|
37
|
+
method_sym.to_s.end_with?('=')
|
38
|
+
@metadata.send(:[]=, method_sym[0...-1].to_sym, *arguments, &block)
|
39
|
+
elsif @metadata.key?(method_sym) then
|
40
|
+
@metadata[method_sym]
|
41
|
+
else
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Contract Symbol, String => Story
|
47
|
+
def add_metadata(key, value)
|
48
|
+
@metadata[key] = value
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
# Contract { version: Maybe[Or[2, 3]] }
|
53
|
+
def bind(version: 3, callback: nil)
|
54
|
+
|
55
|
+
|
56
|
+
book = GEPUB::Book.new('OEPBS/package.opf', 'version' => version.to_f.to_s)
|
57
|
+
book.primary_identifier(@url, 'BookId', 'URL')
|
58
|
+
|
59
|
+
book.language = I18nData.language_code(@metadata[:language]).downcase
|
60
|
+
book.title = @title
|
61
|
+
book.creator = @author
|
62
|
+
|
63
|
+
# Cover if it exists
|
64
|
+
if @metadata.key? :cover_url
|
65
|
+
cover = open(@metadata[:cover_url], 'Referer' => @url)
|
66
|
+
cover_type = FastImage.type(cover)
|
67
|
+
book.add_item(format('img/cover_image.%s', cover_type), cover)
|
68
|
+
.cover_image
|
69
|
+
|
70
|
+
coverpage = <<-XHTML.strip_heredoc
|
71
|
+
<?xml version="1.0" encoding="utf-8"?>
|
72
|
+
#{DOCTYPE[version]}
|
73
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
74
|
+
<head>
|
75
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
76
|
+
<title>Cover</title>
|
77
|
+
<style type="text/css" title="override_css">
|
78
|
+
@page { padding: 0pt; margin:0pt }
|
79
|
+
body { text-align: center; padding:0pt; margin: 0pt; }
|
80
|
+
</style>
|
81
|
+
</head>
|
82
|
+
<body>
|
83
|
+
<div style="text-align: center;">
|
84
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"
|
85
|
+
width="100%" height="100%" preserveAspectRatio="xMidYMid meet">
|
86
|
+
<image width="100%" height="100%" xlink:href="cover_image.#{cover_type}"></image>
|
87
|
+
</svg>
|
88
|
+
</div>
|
89
|
+
</body>
|
90
|
+
</html>
|
91
|
+
XHTML
|
92
|
+
end
|
93
|
+
|
94
|
+
book.ordered do
|
95
|
+
book.add_item('img/coverpage.xhtml')
|
96
|
+
.add_content(StringIO.new(coverpage))
|
97
|
+
.toc_text(@title) if @metadata.key? :cover_url
|
98
|
+
|
99
|
+
unless @metadata[:chapters]
|
100
|
+
@metadata[:chapters] = @url
|
101
|
+
end
|
102
|
+
|
103
|
+
chapters.each do |chapter|
|
104
|
+
chapter_num, chapter_title = chapter.match(/^(\d+)\s*[-\\.)]?\s+(.*)/).captures
|
105
|
+
chapter_page = Nokogiri::HTML open(URI.join(@url, chapter_num))
|
106
|
+
|
107
|
+
storytext = chapter_page.css('#storytext').first
|
108
|
+
storytext.xpath('//@noshade').remove
|
109
|
+
storytext.xpath('//@size').remove
|
110
|
+
|
111
|
+
chapter_xhtml = <<-XHTML.strip_heredoc
|
112
|
+
<?xml version="1.0" encoding="utf-8"?>
|
113
|
+
#{DOCTYPE[version]}
|
114
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en">
|
115
|
+
<head>
|
116
|
+
<title>c#{chapter_num}</title>
|
117
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
118
|
+
</head>
|
119
|
+
<body>
|
120
|
+
#{'<section epub:type="chapter">' if version == 3}
|
121
|
+
<h1 style="text-align:center">#{chapter_title}</h1>
|
122
|
+
#{storytext.children.to_xhtml}
|
123
|
+
#{'</section>' if version == 3}
|
124
|
+
</body>
|
125
|
+
</html>
|
126
|
+
XHTML
|
127
|
+
|
128
|
+
book.add_item(format('text/chapter%03d.xhtml', chapter_num),
|
129
|
+
nil, "c#{chapter_num}")
|
130
|
+
.add_content(StringIO.new(Nokogiri::XML(chapter_xhtml){|c| c.noblanks}.to_xhtml(indent:2)))
|
131
|
+
.toc_text(chapter_title)
|
132
|
+
|
133
|
+
callback.call if callback
|
134
|
+
end
|
135
|
+
end
|
136
|
+
book
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
data/lib/ficrip.rb
ADDED
metadata
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ficrip
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Katherine Whitlock
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ruby-progressbar
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: gepub
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.7.0beta3
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.7.0beta3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: slop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: contracts
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.14'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.14'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: i18n_data
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.7'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: fastimage
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.8'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.8'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: bundler
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.12'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.12'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '11.2'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '11.2'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '3.5'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '3.5'
|
153
|
+
description:
|
154
|
+
email: toroidalcode@gmail.com
|
155
|
+
executables:
|
156
|
+
- console
|
157
|
+
- ficrip
|
158
|
+
- setup
|
159
|
+
extensions: []
|
160
|
+
extra_rdoc_files: []
|
161
|
+
files:
|
162
|
+
- ".gitignore"
|
163
|
+
- ".rspec"
|
164
|
+
- ".travis.yml"
|
165
|
+
- CODE_OF_CONDUCT.md
|
166
|
+
- Gemfile
|
167
|
+
- LICENSE
|
168
|
+
- README.md
|
169
|
+
- Rakefile
|
170
|
+
- bin/console
|
171
|
+
- bin/ficrip
|
172
|
+
- bin/setup
|
173
|
+
- ficrip.gemspec
|
174
|
+
- lib/ficrip.rb
|
175
|
+
- lib/ficrip/extensions.rb
|
176
|
+
- lib/ficrip/process.rb
|
177
|
+
- lib/ficrip/story.rb
|
178
|
+
- lib/ficrip/version.rb
|
179
|
+
homepage: https://github.com/toroidal-code/ficrip
|
180
|
+
licenses:
|
181
|
+
- MIT
|
182
|
+
metadata: {}
|
183
|
+
post_install_message:
|
184
|
+
rdoc_options: []
|
185
|
+
require_paths:
|
186
|
+
- lib
|
187
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - ">="
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '0'
|
197
|
+
requirements: []
|
198
|
+
rubyforge_project:
|
199
|
+
rubygems_version: 2.5.1
|
200
|
+
signing_key:
|
201
|
+
specification_version: 4
|
202
|
+
summary: A fanfiction.net to EPUB2/3 tool.
|
203
|
+
test_files: []
|