neruda 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/pablo +71 -68
- data/lib/neruda.rb +17 -7
- data/lib/tasks/book.rake +6 -2
- data/lib/tasks/sinatra.rake +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c8fbbf1db41f23369213ab8927398003b6a7d44
|
4
|
+
data.tar.gz: c1d8aa69a1c92389b20aef6f7e4f5a892dc3fe9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5138eb7b6480997fb98bbc68dda232c5d9e5d9f59c5d8b86f1497f34173d191e8ab80440e676c616473aff485771b9ce97b87b005df321a97d6c84da8749965c
|
7
|
+
data.tar.gz: 331d2694272ae5d17859c27ed90579286b1bbcbb180fbd3615d94f91716f9fa5e27e1f8aa980ce1dfafa893f95e9e3355afde6190ad32d727beff7b43e44bd14
|
data/bin/pablo
CHANGED
@@ -24,6 +24,20 @@ module BundlerHelper
|
|
24
24
|
return cmd.join(' ') if use_system
|
25
25
|
exec(*cmd)
|
26
26
|
end
|
27
|
+
|
28
|
+
def capify
|
29
|
+
unless File.exist? 'Capfile'
|
30
|
+
STDERR.puts Rainbow('ERROR: Capfile does not exist.').red
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
|
34
|
+
capfile = File.new('Capfile', 'a')
|
35
|
+
capfile.write <<~EOF
|
36
|
+
neruda_spec = Gem::Specification.find_by_name 'neruda'
|
37
|
+
Dir.glob("\#{neruda_spec.gem_dir}/lib/tasks/*.rake").each { |r| import r }
|
38
|
+
Dir.glob("\#{neruda_spec.gem_dir}/lib/tasks/capistrano/*.rake").each { |r| import r }
|
39
|
+
EOF
|
40
|
+
end
|
27
41
|
end
|
28
42
|
|
29
43
|
# Methods used with pablo init method
|
@@ -125,6 +139,20 @@ module PabloInit
|
|
125
139
|
puts 'To complete this installation, you must now run: ' +
|
126
140
|
Rainbow('bundle install').yellow
|
127
141
|
end
|
142
|
+
|
143
|
+
def pablo_init
|
144
|
+
puts Rainbow('Creating main folders…').blue
|
145
|
+
init_path
|
146
|
+
puts Rainbow('Populating config file…').blue
|
147
|
+
init_config
|
148
|
+
puts Rainbow('Copying template files…').blue
|
149
|
+
init_assets
|
150
|
+
puts Rainbow('Installing rake files…').blue
|
151
|
+
init_rackup
|
152
|
+
puts ''
|
153
|
+
puts Rainbow('Neruda has been successfully installed.').green
|
154
|
+
init_bundler if bundler_is_present?
|
155
|
+
end
|
128
156
|
end
|
129
157
|
|
130
158
|
# Main pablo class
|
@@ -135,35 +163,35 @@ class Pablo
|
|
135
163
|
}
|
136
164
|
|
137
165
|
parse_options
|
166
|
+
route_command
|
167
|
+
end
|
138
168
|
|
139
|
-
|
169
|
+
def route_command
|
170
|
+
case ARGV[0]
|
171
|
+
when 'init'
|
140
172
|
pablo_init
|
141
173
|
|
142
|
-
|
174
|
+
when 'capify'
|
143
175
|
capify
|
144
176
|
|
145
|
-
|
177
|
+
when 'start', 'run'
|
146
178
|
start
|
147
179
|
|
148
|
-
|
180
|
+
when 'stop'
|
149
181
|
rake_or_bundle_run ['rake', 'sinatra:stop']
|
150
182
|
|
151
|
-
|
183
|
+
when 'compile'
|
152
184
|
rake_or_bundle_run ['rake', 'chapters:build_epubs'], true
|
153
185
|
rake_or_bundle_run ['rake', 'book:make']
|
154
186
|
|
155
|
-
|
187
|
+
when 'new'
|
156
188
|
new_chapter
|
157
189
|
|
158
|
-
|
190
|
+
when 'list'
|
159
191
|
list
|
160
192
|
|
161
|
-
|
162
|
-
|
163
|
-
unless File.exist? tiddly_file
|
164
|
-
FileUtils.copy File.join(__dir__, '../lib/tiddly.html'), tiddly_file
|
165
|
-
end
|
166
|
-
exec 'gio', 'open', tiddly_file
|
193
|
+
when 'board'
|
194
|
+
board
|
167
195
|
end
|
168
196
|
end
|
169
197
|
|
@@ -173,8 +201,8 @@ class Pablo
|
|
173
201
|
optparse = OptionParser.new do |opts|
|
174
202
|
opts.banner = <<~EOF
|
175
203
|
Usage:
|
176
|
-
pablo
|
177
|
-
pablo [
|
204
|
+
pablo -h
|
205
|
+
pablo [ -v ] command
|
178
206
|
|
179
207
|
EOF
|
180
208
|
opts.on('-v', '--verbose', 'Output more information') do
|
@@ -182,21 +210,7 @@ class Pablo
|
|
182
210
|
end
|
183
211
|
opts.on('-h', '--help', 'Display this screen') do
|
184
212
|
STDERR.puts opts
|
185
|
-
|
186
|
-
|
187
|
-
Commands:
|
188
|
-
init : Initialize your Neruda instance
|
189
|
-
start : Start the rack web server (default is thin)
|
190
|
-
stop : Stop the web server
|
191
|
-
compile: Generate the epubs files
|
192
|
-
list : List various book elements (chapters, characters, notes, sceneries)
|
193
|
-
board : Open your TiddlyWiki file located at ./private/notes/tiddly.html
|
194
|
-
|
195
|
-
Chapters related commands:
|
196
|
-
new [title] : Create a new chapter
|
197
|
-
|
198
|
-
EOF
|
199
|
-
exit
|
213
|
+
pablo_help
|
200
214
|
end
|
201
215
|
end
|
202
216
|
|
@@ -211,39 +225,24 @@ class Pablo
|
|
211
225
|
include BundlerHelper
|
212
226
|
include PabloInit
|
213
227
|
|
214
|
-
def
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
init_bundler if bundler_is_present?
|
233
|
-
end
|
234
|
-
|
235
|
-
def capify
|
236
|
-
unless File.exist? 'Capfile'
|
237
|
-
STDERR.puts Rainbow('ERROR: Capfile does not exist.').red
|
238
|
-
exit 1
|
239
|
-
end
|
240
|
-
|
241
|
-
capfile = File.new('Capfile', 'a')
|
242
|
-
capfile.write <<~EOF
|
243
|
-
neruda_spec = Gem::Specification.find_by_name 'neruda'
|
244
|
-
Dir.glob("\#{neruda_spec.gem_dir}/lib/tasks/*.rake").each { |r| import r }
|
245
|
-
Dir.glob("\#{neruda_spec.gem_dir}/lib/tasks/capistrano/*.rake").each { |r| import r }
|
246
|
-
EOF
|
228
|
+
def pablo_help
|
229
|
+
STDERR.puts <<~EOF
|
230
|
+
|
231
|
+
Book Commands:
|
232
|
+
new [title] Begin to write a new chapter
|
233
|
+
compile Generate the epubs files
|
234
|
+
list [elements] List various book elements
|
235
|
+
(chapters, characters, notes, sceneries)
|
236
|
+
board Open your TiddlyWiki file located
|
237
|
+
at ./private/notes/tiddly.html
|
238
|
+
|
239
|
+
System Commands
|
240
|
+
init Initialize your Neruda instance
|
241
|
+
(you just need to do it once).
|
242
|
+
start Start a test web server
|
243
|
+
stop Stop the web server
|
244
|
+
EOF
|
245
|
+
exit
|
247
246
|
end
|
248
247
|
|
249
248
|
def start
|
@@ -268,12 +267,16 @@ class Pablo
|
|
268
267
|
end
|
269
268
|
|
270
269
|
def list
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
270
|
+
list_type = ARGV[1] || 'chapters'
|
271
|
+
rake_or_bundle_run ['rake', "book:list[#{list_type}]"]
|
272
|
+
end
|
273
|
+
|
274
|
+
def board
|
275
|
+
tiddly_file = 'private/notes/tiddly.html'
|
276
|
+
unless File.exist? tiddly_file
|
277
|
+
FileUtils.copy File.join(__dir__, '../lib/tiddly.html'), tiddly_file
|
275
278
|
end
|
276
|
-
|
279
|
+
exec 'gio', 'open', tiddly_file
|
277
280
|
end
|
278
281
|
end
|
279
282
|
|
data/lib/neruda.rb
CHANGED
@@ -27,22 +27,29 @@ class Neruda::App < Sinatra::Base
|
|
27
27
|
include Neruda::Url
|
28
28
|
include Neruda::Chapter
|
29
29
|
|
30
|
+
def chdir
|
31
|
+
Dir.chdir settings.root if ENV['APP_ENV'] == 'production'
|
32
|
+
end
|
33
|
+
|
30
34
|
def find_slug
|
31
35
|
@slug = params[:chapter]
|
32
36
|
halt 404 if @slug.nil?
|
33
37
|
end
|
34
38
|
|
35
39
|
def find_file(kind = 'org')
|
36
|
-
|
40
|
+
if kind == 'epub'
|
41
|
+
f = File.join('private', 'epubs', "#{@slug}.epub")
|
42
|
+
elsif kind == 'chapters'
|
43
|
+
f = File.join('private', 'chapters', "#{@slug}.org")
|
44
|
+
else
|
45
|
+
f = File.join('private', "#{@slug}.#{kind}")
|
46
|
+
end
|
37
47
|
halt 404 unless File.exist? f
|
38
48
|
f
|
39
49
|
end
|
40
50
|
|
41
|
-
def find_chapter
|
42
|
-
@org_file = find_file
|
43
|
-
end
|
44
|
-
|
45
51
|
get '/epub/:chapter' do
|
52
|
+
chdir
|
46
53
|
find_slug
|
47
54
|
if @slug == 'all' && !Neruda::CONFIG['book_filename'].nil?
|
48
55
|
@slug = Neruda::CONFIG['book_filename']
|
@@ -54,8 +61,9 @@ class Neruda::App < Sinatra::Base
|
|
54
61
|
end
|
55
62
|
|
56
63
|
get '/chapter/:chapter' do
|
64
|
+
chdir
|
57
65
|
find_slug
|
58
|
-
|
66
|
+
@org_file = find_file('chapters')
|
59
67
|
@content = Orgmode::Parser.load @org_file
|
60
68
|
title # Force the early removal of the title
|
61
69
|
slim :chapter
|
@@ -70,11 +78,13 @@ class Neruda::App < Sinatra::Base
|
|
70
78
|
end
|
71
79
|
|
72
80
|
get '/' do
|
81
|
+
chdir
|
73
82
|
@slug = 'index'
|
74
83
|
text_content = ''
|
75
84
|
if File.exist? File.join('private', 'index.org')
|
76
|
-
|
85
|
+
@org_file = find_file
|
77
86
|
@content = Orgmode::Parser.load @org_file
|
87
|
+
title
|
78
88
|
text_content = @content.to_html
|
79
89
|
end
|
80
90
|
|
data/lib/tasks/book.rake
CHANGED
@@ -7,8 +7,12 @@ namespace :book do
|
|
7
7
|
desc 'List various book elements'
|
8
8
|
task :list, :list_type do |_, args|
|
9
9
|
list_type = args[:list_type]
|
10
|
-
|
11
|
-
|
10
|
+
unless ['chapters', 'characters',
|
11
|
+
'notes', 'sceneries'].include?(list_type)
|
12
|
+
STDERR.puts Rainbow("ERROR: #{list_type} is not a valid list type.").red
|
13
|
+
STDERR.puts 'Enter one of [chapters, characters, notes, sceneries].'
|
14
|
+
next
|
15
|
+
end
|
12
16
|
Dir.glob("private/#{list_type}/*.org") do |filename|
|
13
17
|
file_radix = File.basename(filename, '.org')
|
14
18
|
title = file_radix.split('_').map(&:capitalize).join(' ')
|
data/lib/tasks/sinatra.rake
CHANGED
@@ -21,7 +21,11 @@ namespace :sinatra do
|
|
21
21
|
cmd = ['rackup', "-E #{loc_env}", '-P', 'tmp/pids/neruda.pid']
|
22
22
|
cmd << '-D' if loc_env == 'production'
|
23
23
|
begin
|
24
|
-
|
24
|
+
if ENV['APP_ENV'].nil?
|
25
|
+
system({ 'APP_ENV' => loc_env }, cmd.join(' '))
|
26
|
+
else
|
27
|
+
sh(*cmd)
|
28
|
+
end
|
25
29
|
rescue Interrupt
|
26
30
|
puts Rainbow(' Kthxbye').blue
|
27
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neruda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Étienne Deparis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|