images_to_scrapbox 0.1.6 → 0.2.0
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/lib/cli.rb +3 -1
- data/lib/images_to_scrapbox/version.rb +1 -1
- data/lib/images_to_scrapbox.rb +23 -5
- 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: 6d5894439756b0ad31499cd09903e2906352ec3fce3e19626490f4c703e68a47
|
|
4
|
+
data.tar.gz: c47956dfea4dae4fe2ca2a91ad63815ab74db8455eacdbdba37069bbba3355af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 868ddcfd5f9a2378013010962f8071d8d421104a35c4c0c92079a7cdba7c413efa1a565ddbf7c1e39dc10dc25904bb327b2b8a7b4bf9a1a70c612179bc9bc564
|
|
7
|
+
data.tar.gz: e636881b58590cfd19f294376857d3fe97cbca511215057c669f265686bd4369da2fd1bf79956125b7d57813951aa92f35f572d2ab840acbab3bac80001bb88e
|
data/lib/cli.rb
CHANGED
|
@@ -25,7 +25,7 @@ module ImagesToScrapbox
|
|
|
25
25
|
class_option :unique, :type => :boolean, :aliases => '-u',
|
|
26
26
|
:default => true, :desc => 'unique files'
|
|
27
27
|
class_option :sort, :type => :string, :aliases => '-s',
|
|
28
|
-
:default => "
|
|
28
|
+
:default => "numbers", :desc => 'sort files by `none`, `names`, or `numbers`'
|
|
29
29
|
class_option :ascending, :type => :boolean, :aliases => '-a',
|
|
30
30
|
:default => true, :desc => "sort in ascending order, or descending"
|
|
31
31
|
|
|
@@ -37,6 +37,8 @@ module ImagesToScrapbox
|
|
|
37
37
|
:default => "mtime", :desc => "file timestamp: `atime`, `ctime`, or `mtime`"
|
|
38
38
|
method_option :toc, type: :boolean, aliases: '-t',
|
|
39
39
|
:default => true, desc: 'creates table-of-contents'
|
|
40
|
+
method_option :whole, type: :boolean, aliases: '-w',
|
|
41
|
+
:default => true, desc: 'creates a page occipied by whole images'
|
|
40
42
|
|
|
41
43
|
desc 'convert FILES [options]', 'Convert images files to scrapbox-json'
|
|
42
44
|
def convert(*globs)
|
data/lib/images_to_scrapbox.rb
CHANGED
|
@@ -52,9 +52,9 @@ module ImagesToScrapbox
|
|
|
52
52
|
when "numbers"
|
|
53
53
|
@@converters.sort_by!{ |e|
|
|
54
54
|
File.basename(e.image_name, File.extname(e.image_name)).
|
|
55
|
-
|
|
55
|
+
match(%r!(\d+)\Z!).to_a[1].to_i }
|
|
56
56
|
else
|
|
57
|
-
raise Thor::Error, "Unknown sort type: #{
|
|
57
|
+
raise Thor::Error, "Unknown sort type: #{options[:sort]}"
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
unless options[:ascending]
|
|
@@ -79,6 +79,10 @@ module ImagesToScrapbox
|
|
|
79
79
|
pages.concat Converter.toc_page
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
+
if options[:whole]
|
|
83
|
+
pages.concat Converter.whole_page(options)
|
|
84
|
+
end
|
|
85
|
+
|
|
82
86
|
result={
|
|
83
87
|
"pages": pages
|
|
84
88
|
}
|
|
@@ -87,7 +91,7 @@ module ImagesToScrapbox
|
|
|
87
91
|
|
|
88
92
|
end
|
|
89
93
|
|
|
90
|
-
attr_reader :image_name, :image_path, :page_title
|
|
94
|
+
attr_reader :image_name, :image_path, :image_url, :page_title
|
|
91
95
|
def initialize(path)
|
|
92
96
|
@image_name=path
|
|
93
97
|
@image_path=File.expand_path(path)
|
|
@@ -96,12 +100,26 @@ module ImagesToScrapbox
|
|
|
96
100
|
def Converter.toc_page()
|
|
97
101
|
tocpage=SbPage.new()
|
|
98
102
|
tocpage.set_page_title(@@converted_on)
|
|
99
|
-
@@converters.map do |
|
|
100
|
-
tocpage.push_text("
|
|
103
|
+
@@converters.map do |c|
|
|
104
|
+
tocpage.push_text("["+c.page_title+"]")
|
|
101
105
|
end
|
|
102
106
|
tocpage.get_page
|
|
103
107
|
end
|
|
104
108
|
|
|
109
|
+
def Converter.whole_page(options)
|
|
110
|
+
wholepage=SbPage.new()
|
|
111
|
+
wholepage.set_page_title("Whole_images_"+@@converted_on)
|
|
112
|
+
@@converters.map do |c|
|
|
113
|
+
wholepage.push_text("[[["+c.page_title+"]]]")
|
|
114
|
+
unless c.image_url.empty?
|
|
115
|
+
wholepage.push_text( options[:larger] ? "[["+c.image_url+"]]" : "["+c.image_url+"]")
|
|
116
|
+
wholepage.push_empty_text()
|
|
117
|
+
end
|
|
118
|
+
wholepage.push_empty_text()
|
|
119
|
+
end
|
|
120
|
+
wholepage.get_page
|
|
121
|
+
end
|
|
122
|
+
|
|
105
123
|
def start(options)
|
|
106
124
|
|
|
107
125
|
timestamp=""
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: images_to_scrapbox
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hiroharu Sugawara
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-01-
|
|
11
|
+
date: 2018-01-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|