showoff 0.15.1 → 0.15.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/showoff.rb +25 -20
- data/lib/showoff/version.rb +1 -1
- data/lib/showoff_utils.rb +47 -17
- data/public/css/showoff.css +0 -3
- 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: 4fcc16c52c78d5e9c2d0f6b8fed009584e8b4558
|
4
|
+
data.tar.gz: 43d18be95f74b4690bb096733d821a87a9e09cb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c671f6d44ce601953d7e2a1882535c5d0141459033801a2fbe869a0d1a7998f792e9faa486cdff2d8888575bc53872af56064d667e459952a4fcee2e0240f07
|
7
|
+
data.tar.gz: 8330b2398adb6bfaf6a51e8358c4f6095bffd489a1e57c825c7e7f4da7199b36900eb83fdb10296f0a6e47b618a808f485b0f09adf6a4ea6a5ef1806b9e06603
|
data/lib/showoff.rb
CHANGED
@@ -114,6 +114,14 @@ class ShowOff < Sinatra::Application
|
|
114
114
|
settings.showoff_config['locked'] ||= Array.new
|
115
115
|
end
|
116
116
|
|
117
|
+
# default code parsers (for executable code blocks)
|
118
|
+
settings.showoff_config['parsers'] ||= {}
|
119
|
+
settings.showoff_config['parsers']['perl'] ||= 'perl'
|
120
|
+
settings.showoff_config['parsers']['puppet'] ||= 'puppet apply --color=false'
|
121
|
+
settings.showoff_config['parsers']['python'] ||= 'python'
|
122
|
+
settings.showoff_config['parsers']['ruby'] ||= 'ruby'
|
123
|
+
settings.showoff_config['parsers']['shell'] ||= 'sh'
|
124
|
+
|
117
125
|
# default code validators
|
118
126
|
settings.showoff_config['validators'] ||= {}
|
119
127
|
settings.showoff_config['validators']['perl'] ||= 'perl -cw'
|
@@ -226,7 +234,7 @@ class ShowOff < Sinatra::Application
|
|
226
234
|
files = if File.directory? section
|
227
235
|
Dir.glob("#{section}/**/*").sort
|
228
236
|
else
|
229
|
-
|
237
|
+
Array(section)
|
230
238
|
end
|
231
239
|
@logger.debug files
|
232
240
|
files
|
@@ -1320,30 +1328,27 @@ class ShowOff < Sinatra::Application
|
|
1320
1328
|
get '/execute/:lang' do |lang|
|
1321
1329
|
return 'Run showoff with -x or --executecode to enable code execution' unless @execute
|
1322
1330
|
|
1323
|
-
code
|
1331
|
+
code = get_code_from_slide(params[:path], params[:index])
|
1332
|
+
parser = settings.showoff_config['parsers'][lang]
|
1333
|
+
|
1334
|
+
return "No parser for #{lang}" unless parser
|
1324
1335
|
|
1325
1336
|
require 'timeout'
|
1326
1337
|
require 'open3' # for 1.8 compatibility :/
|
1327
1338
|
begin
|
1328
1339
|
Timeout::timeout(settings.showoff_config['timeout']) do
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
stdout, err = Open3.capture2('perl', '-e', code)
|
1342
|
-
stdout
|
1343
|
-
when 'null'
|
1344
|
-
code
|
1345
|
-
else
|
1346
|
-
"No exec handler for #{lang}"
|
1340
|
+
# write out a tempfile to make it simpler for end users to add custom language parser
|
1341
|
+
Tempfile.open('showoff-execution') do |f|
|
1342
|
+
File.write(f.path, code)
|
1343
|
+
@logger.debug "Evaluating: #{parser} #{f.path}"
|
1344
|
+
output, status = Open3.capture2e("#{parser} #{f.path}")
|
1345
|
+
|
1346
|
+
unless status.success?
|
1347
|
+
@logger.warn "Command execution failed for #{params[:path]}[#{params[:index]}]"
|
1348
|
+
@logger.warn output
|
1349
|
+
end
|
1350
|
+
|
1351
|
+
output
|
1347
1352
|
end
|
1348
1353
|
end
|
1349
1354
|
rescue => e
|
data/lib/showoff/version.rb
CHANGED
data/lib/showoff_utils.rb
CHANGED
@@ -130,7 +130,7 @@ class ShowOffUtils
|
|
130
130
|
next
|
131
131
|
|
132
132
|
elsif validator
|
133
|
-
# write out a tempfile because many validators require files to with
|
133
|
+
# write out a tempfile because many validators require files to work with
|
134
134
|
Tempfile.open('showoff-validation') do |f|
|
135
135
|
File.write(f.path, code)
|
136
136
|
unless system("#{validator} #{f.path}", :out => File::NULL, :err => File::NULL)
|
@@ -409,27 +409,57 @@ class ShowOffUtils
|
|
409
409
|
logger.level = Logger::WARN
|
410
410
|
end
|
411
411
|
|
412
|
-
index
|
413
|
-
sections =
|
412
|
+
index = File.join(dir, ShowOffUtils.presentation_config_file)
|
413
|
+
sections = ["."] # default boring showoff.json
|
414
|
+
|
414
415
|
if File.exist?(index)
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
sections = data
|
421
|
-
end
|
422
|
-
sections = sections.map do |s|
|
423
|
-
if s.is_a? Hash
|
424
|
-
s['section']
|
416
|
+
begin
|
417
|
+
data = JSON.parse(File.read(index))
|
418
|
+
logger.debug data
|
419
|
+
if data.is_a?(Hash)
|
420
|
+
sections = data['sections'] if data.include? 'sections'
|
425
421
|
else
|
426
|
-
|
422
|
+
sections = data
|
423
|
+
end
|
424
|
+
|
425
|
+
# each entry in sections can be:
|
426
|
+
# - "filename.md"
|
427
|
+
# - { "section": "filename.md" }
|
428
|
+
# - { "section": [ "array.md, "of.md, "files.md"] }
|
429
|
+
# - { "include": "sections.json" }
|
430
|
+
sections = sections.map do |entry|
|
431
|
+
next entry if entry.is_a? String
|
432
|
+
next nil unless entry.is_a? Hash
|
433
|
+
|
434
|
+
next entry['section'] if entry.include? 'section'
|
435
|
+
|
436
|
+
section = nil
|
437
|
+
if entry.include? 'include'
|
438
|
+
file = entry['include']
|
439
|
+
path = File.dirname(file)
|
440
|
+
data = JSON.parse(File.read(file))
|
441
|
+
if data.is_a? Array
|
442
|
+
if path == '.'
|
443
|
+
section = data
|
444
|
+
else
|
445
|
+
section = data.map do |source|
|
446
|
+
"#{path}/#{source}"
|
447
|
+
end
|
448
|
+
end
|
449
|
+
end
|
450
|
+
end
|
451
|
+
|
452
|
+
section
|
427
453
|
end
|
454
|
+
rescue => e
|
455
|
+
logger.error "There was a problem with the presentation file #{index}"
|
456
|
+
logger.error e.message
|
457
|
+
logger.debug e.backtrace
|
458
|
+
sections = []
|
428
459
|
end
|
429
|
-
else
|
430
|
-
sections = ["."] # if there's no showoff.json file, make a boring one
|
431
460
|
end
|
432
|
-
|
461
|
+
|
462
|
+
sections.flatten.compact
|
433
463
|
end
|
434
464
|
|
435
465
|
def self.showoff_title(dir = '.')
|
data/public/css/showoff.css
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: showoff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Chacon
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-12-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|