mkwebook 0.1.5 → 0.1.7
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/mkwebook/app.rb +4 -1
- data/lib/mkwebook/cli.rb +1 -0
- data/lib/mkwebook/ext/string.rb +4 -0
- data/lib/mkwebook/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f8fc12f211be95d5f471f231318136663987e920e2dfd1345118d68eb0bc420
|
|
4
|
+
data.tar.gz: ec4a088bd415a554c232a85692eba1e1983d4bf75941be8f5a8a76b6578f99b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ed276076ec77a9ed76386232f77282c350ae206fa2b7d477274dc3cfe460817fcf33c9f5e05c7ed4493333df001cfaa9f81dcfcc8bab524caeecadeb04c1037
|
|
7
|
+
data.tar.gz: 55830b7666568be18a1cdcce720d701c9e33a2121c4e568b1656fca303c71b82911dc3ecf4bd8d4233af64f85bb27b6e7b6c540f2963eec8ef627c300ea38d6e
|
data/Gemfile.lock
CHANGED
data/lib/mkwebook/app.rb
CHANGED
|
@@ -152,7 +152,7 @@ module Mkwebook
|
|
|
152
152
|
|
|
153
153
|
if page_link_selector = page_config[:page_link_selector]
|
|
154
154
|
page_links = page_elements.flat_map do |element|
|
|
155
|
-
element.css(page_link_selector).map { |a| a.evaluate('this.href') }
|
|
155
|
+
element.css(page_link_selector).map { |a| a.evaluate('this.href') rescue nil }.compact
|
|
156
156
|
end.uniq
|
|
157
157
|
@page_links[url] = page_links
|
|
158
158
|
end
|
|
@@ -170,6 +170,7 @@ module Mkwebook
|
|
|
170
170
|
element.css('a').each do |a|
|
|
171
171
|
u = a.evaluate('this.href') rescue nil
|
|
172
172
|
next unless u.present?
|
|
173
|
+
next unless u =~ /^https?:\/\//
|
|
173
174
|
href = u.normalize_uri('.html').relative_path_from(url.normalize_uri('.html'))
|
|
174
175
|
file = u.normalize_file_path('.html')
|
|
175
176
|
a.evaluate <<~JS
|
|
@@ -293,12 +294,14 @@ module Mkwebook
|
|
|
293
294
|
end
|
|
294
295
|
|
|
295
296
|
elements.uniq.compact.each do |element|
|
|
297
|
+
puts element if @cli_options[:print_entries]
|
|
296
298
|
name = element['name']
|
|
297
299
|
type = element['type']
|
|
298
300
|
path = element['path'].sub(%r{.*\.docset/Contents/Resources/Documents}, '')
|
|
299
301
|
db.execute('INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?, ?, ?);', [name, type, path])
|
|
300
302
|
end
|
|
301
303
|
|
|
304
|
+
|
|
302
305
|
plist_content = <<-PLIST
|
|
303
306
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
304
307
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
data/lib/mkwebook/cli.rb
CHANGED
|
@@ -33,6 +33,7 @@ module Mkwebook
|
|
|
33
33
|
|
|
34
34
|
option :limit, :type => :numeric, :aliases => '-l', :desc => 'Limit number of pages, specially for debugging'
|
|
35
35
|
option :list, :type => :boolean, :aliases => '-L', :desc => 'List all available Dash.app entry types'
|
|
36
|
+
option :print_entries, :type => :boolean, :aliases => '-p', :desc => 'Print extracted entries'
|
|
36
37
|
desc 'docset', 'Create docset'
|
|
37
38
|
def docset
|
|
38
39
|
if options[:list]
|
data/lib/mkwebook/ext/string.rb
CHANGED
|
@@ -16,6 +16,8 @@ class String
|
|
|
16
16
|
def normalize_file_path(force_extname = nil)
|
|
17
17
|
return self unless present?
|
|
18
18
|
uri = URI.parse(self)
|
|
19
|
+
return unless uri.scheme.in? %w(http https)
|
|
20
|
+
return unless uri.path.present?
|
|
19
21
|
file_path = uri.path[1..]
|
|
20
22
|
extname = force_extname || File.extname(file_path)
|
|
21
23
|
basename = File.basename(file_path, extname)
|
|
@@ -27,6 +29,8 @@ class String
|
|
|
27
29
|
def normalize_uri(force_extname = nil)
|
|
28
30
|
return self unless present?
|
|
29
31
|
uri = URI.parse(self)
|
|
32
|
+
return unless uri.scheme.in? %w(http https)
|
|
33
|
+
return unless uri.path.present?
|
|
30
34
|
file_path = uri.path[1..]
|
|
31
35
|
extname = force_extname || File.extname(file_path)
|
|
32
36
|
basename = File.basename(file_path, extname)
|
data/lib/mkwebook/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mkwebook
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Liu Xiang
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-12-
|
|
11
|
+
date: 2022-12-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|