slippery 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWFiYjgwMGViMWZkOGRjOGY1ODRhZTkzZjc2NWU3OWM3NDVmNGM2ZQ==
4
+ Yzk3NmU1ZGE3ZjY2MzM1OTRkOWQ3NDRlYzI0ZDkwOGEzOTYxMTgyOA==
5
5
  data.tar.gz: !binary |-
6
- OWFjYjk2MzlkNTExM2NlMWI5ZTE1ZGY4MDc5NTgzMGZiMzFiNWQxYQ==
6
+ MDI2MjA1M2FjN2Y4ZmY3Y2U1MDY2YWYzMTQ2NTFmZTU0NzZmMTE2MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTc0NGNhMTM5MWE4ZDA1ZDI3MWQ3YjU4ODMwMTJkMjgwYjYyNzRjMTc4OTNh
10
- NDFhZDI1YzA5YmI5OTJmNDk2MmI2ZWExNzg5MGM4ZTg4NDAyM2NjZWQxYjNk
11
- MDlkMjc0ZmRjMWJhYmVhOGZjZDI2ZWM2YWQ2NTQzNTc3YTBhYmM=
9
+ ZWFiMmQ4MmJmNTI0OThkNjkwMjNiMWE5NDJhNDIyNGI2ZGU0ZTlkM2I2NThl
10
+ NDUyYzM1NDNkOWMzMmRkNmU5ZmVkOWY3ZThlOWY4ZTNmNGY0ZGQyN2M3ZmZk
11
+ ZDdhNzE2MjZlZTg3ZmYyMmU3NzVjZDkwYTVjYjQ4NzJmZmYzNDQ=
12
12
  data.tar.gz: !binary |-
13
- YmY2NTNlNjlhOTRlMjA4YmEyMmY1MTNkZTIwZmRhNTYwNjNhMzc3YmMwNzcx
14
- ZmI2ZmJhMzNmOTU1NTYwN2IzMjAyMWQxY2EyMmM0YmQ0OWM0NjBiYzU1MWFl
15
- YTNjNWM2YzA5MWIwNjM3YTQwZDdlNGVmZTgxNmI2ZjBjZDhkYmM=
13
+ YTYxMjg0YWEwNzFhN2ZkZTQxMDU5MmVjNzc1N2Q3MTIxZjQ4YThlMmE0NDI1
14
+ YzA5NDBiMjM5ZjJhMzQxYTJhYTU1YjI1ZTUxODM5MWU1MTVlMTgwODkzYjU1
15
+ ODZhZjlkZGRmNWY4MWRjMzIyNjcwYjRlYmIxYjMxZDkyY2E3NTE=
data/Gemfile CHANGED
@@ -5,6 +5,6 @@ group :development do
5
5
  eval File.read('Gemfile.devtools')
6
6
  end
7
7
 
8
- gem 'hexp', path: '/home/arne/github/hexp'
8
+ #gem 'hexp', path: '/home/arne/github/hexp'
9
9
 
10
10
  gemspec
data/Gemfile.lock CHANGED
@@ -27,21 +27,12 @@ GIT
27
27
  PATH
28
28
  remote: .
29
29
  specs:
30
- slippery (0.0.3)
30
+ slippery (0.1.0)
31
31
  hexp (~> 0.0)
32
32
  kramdown (~> 1.1)
33
+ rake (~> 10.1)
33
34
  rb-inotify
34
35
 
35
- PATH
36
- remote: /home/arne/github/hexp
37
- specs:
38
- hexp (0.3.1)
39
- equalizer (~> 0.0)
40
- fzip (~> 0.1)
41
- ice_nine (~> 0.9)
42
- nokogiri (~> 1.6)
43
- sass (~> 3.2)
44
-
45
36
  GEM
46
37
  remote: https://rubygems.org/
47
38
  specs:
@@ -81,7 +72,6 @@ GEM
81
72
  ruby_parser (~> 3.1, > 3.1.0)
82
73
  sexp_processor (~> 4.0)
83
74
  formatador (0.2.4)
84
- fzip (0.2.0)
85
75
  guard (1.8.1)
86
76
  formatador (>= 0.2.4)
87
77
  listen (>= 1.0.0)
@@ -101,6 +91,11 @@ GEM
101
91
  guard-rubocop (0.2.0)
102
92
  guard (~> 1.8)
103
93
  rubocop (~> 0.9)
94
+ hexp (0.3.1)
95
+ equalizer (~> 0.0)
96
+ ice_nine (~> 0.9)
97
+ nokogiri (~> 1.6)
98
+ sass (~> 3.2)
104
99
  ice_nine (0.9.0)
105
100
  inflecto (0.0.2)
106
101
  kramdown (1.1.0)
@@ -200,7 +195,6 @@ DEPENDENCIES
200
195
  guard-mutant (~> 0.0.1)
201
196
  guard-rspec (~> 3.0.2)
202
197
  guard-rubocop (~> 0.2.0)
203
- hexp!
204
198
  jruby-openssl (~> 0.8.5)
205
199
  kramdown (~> 1.1.0)
206
200
  libnotify (~> 0.8.0)
data/lib/slippery.rb CHANGED
@@ -1,8 +1,11 @@
1
1
  require 'kramdown'
2
2
  require 'hexp'
3
+ require 'pathname'
3
4
 
4
5
  # Slippery namespace module
5
6
  module Slippery
7
+ ROOT = Pathname(__FILE__).dirname.parent
8
+
6
9
  def self.convert(element)
7
10
  Slippery::Converter.new.convert(element)
8
11
  end
@@ -36,6 +39,7 @@ require 'slippery/processors/add_google_font'
36
39
  require 'slippery/processors/graphviz_dot'
37
40
  require 'slippery/processors/hr_to_sections'
38
41
  require 'slippery/processors/self_contained'
42
+ require 'slippery/processors/add_highlight'
39
43
 
40
44
  require 'slippery/processors/impress_js/add_impress_js'
41
45
  require 'slippery/processors/impress_js/auto_offsets'
@@ -1,13 +1,12 @@
1
- require 'fileutils'
2
-
3
1
  # Manage the assets and their URI/path
4
2
  module Slippery
5
3
  module Assets
6
- ASSETS_PATH = '../../../assets/'
4
+ ASSETS_PATH = ROOT.join('assets')
7
5
 
8
6
  # Copies the assets locally
9
7
  def self.embed_locally
10
- FileUtils.cp_r(File.expand_path(ASSETS_PATH, __FILE__), './')
8
+ raise 'damn'
9
+ FileUtils.cp_r(ASSETS_PATH, './')
11
10
  end
12
11
 
13
12
  # returns a composer returning a URI for a given relative file path
@@ -4,7 +4,8 @@ module Slippery
4
4
 
5
5
  DEFAULT_OPTIONS = {
6
6
  type: :reveal_js,
7
- local: true
7
+ local: true,
8
+ history: true
8
9
  }.freeze
9
10
 
10
11
  def initialize(document, options = {})
@@ -19,8 +20,8 @@ module Slippery
19
20
  impress_js: [
20
21
  Processors::HrToSections.new(H[:div, class: 'step']),
21
22
  Processors::ImpressJs::AddImpressJs.new(Assets::path_composer(@options[:local]), js_options),
22
- Processors::ImpressJs::AutoOffsets.new,
23
- ],
23
+ (Processors::ImpressJs::AutoOffsets.new unless @options.fetch(:manual_offsets, false)),
24
+ ].compact,
24
25
  reveal_js: [
25
26
  Processors::HrToSections.new(H[:section]),
26
27
  Processors::RevealJs::AddRevealJs.new(Assets::path_composer(@options[:local]), js_options),
@@ -0,0 +1,23 @@
1
+ module Slippery
2
+ module Processors
3
+ class AddHighlight
4
+
5
+ DEFAULT_STYLE = :default
6
+ DEFAULT_VERSION = '8.0'
7
+
8
+ def initialize(style = DEFAULT_STYLE, version = DEFAULT_VERSION)
9
+ @style = style
10
+ @version = version
11
+ end
12
+
13
+ def call(doc)
14
+ doc.rewrite 'head' do |head|
15
+ head <<= H[:link, rel: "stylesheet", href: "http://yandex.st/highlightjs/#{@version}/styles/#{@style}.min.css"]
16
+ head <<= H[:script, src: "http://yandex.st/highlightjs/#{@version}/highlight.min.js"]
17
+ head <<= H[:script, 'hljs.initHighlightingOnLoad();']
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -22,7 +22,7 @@ module Slippery
22
22
  def call(doc)
23
23
  doc.replace('body') do |body|
24
24
  include_local_javascript(body, @path_composer.call('impress.js/js/impress.js'))
25
- .set_attributes({id: 'impress'}.merge(data_attributes(attributes)))
25
+ .set_attrs({id: 'impress'}.merge(data_attributes(attributes)))
26
26
  .add H[:script, 'impress().init();']
27
27
  end
28
28
  end
@@ -10,7 +10,7 @@ module Slippery
10
10
  def call(doc)
11
11
  doc.replace('.step') do |step|
12
12
  ['data-x', 'data-y'].each_with_index do |axis, idx|
13
- if step.attr?(axis)
13
+ if step.has_attr?(axis)
14
14
  @position[idx] = step[axis].to_i
15
15
  else
16
16
  @position[idx] += @offsets[idx]
@@ -26,11 +26,11 @@ module Slippery
26
26
  presentations.map {|path| [ path.basename(path.extname), path ] }
27
27
  end
28
28
 
29
- def markdown_to_hexp(infile)
29
+ def markdown_to_hexp(infile, options = {})
30
30
  doc = Slippery::Document.new(infile.read)
31
- doc = Slippery::Presentation.new(doc, options)
31
+ doc = Slippery::Presentation.new(doc, @options.merge(options))
32
32
 
33
- doc.process(*processors)
33
+ doc.process(*processors.reject {|pr| options[:skip_self_contained] && pr == Slippery::Processors::SelfContained})
34
34
  end
35
35
 
36
36
  def processor(selector, &blk)
@@ -45,6 +45,16 @@ module Slippery
45
45
  processors << Slippery::Processors::SelfContained
46
46
  end
47
47
 
48
+ def title(title)
49
+ processor 'head' do |head|
50
+ head <<= H[:title, title]
51
+ end
52
+ end
53
+
54
+ def add_highlighting(style = Slippery::Processors::AddHighlight::DEFAULT_STYLE, version = Slippery::Processors::AddHighlight::DEFAULT_VERSION)
55
+ processors << Slippery::Processors::AddHighlight.new(style, version)
56
+ end
57
+
48
58
  def define
49
59
  namespace @name do
50
60
  desc "build all"
@@ -61,14 +71,17 @@ module Slippery
61
71
 
62
72
  namespace :watch do
63
73
  presentation_names.each do |name, path|
74
+ files = markdown_to_hexp(path, skip_self_contained: true).select('link,script').map {|link| link.attr('href') || link.attr('src')}.compact
75
+ files = files.select {|f| File.exist?(f)}
76
+
64
77
  desc "watch #{name} for changes"
65
- WatchTask.new(name, [path.to_s]) do
78
+ WatchTask.new(name, [path.to_s, *files]) do
66
79
  dest = Tempfile.new("#{name}.html")
67
80
  File.open("#{name}.html") { |src| FileUtils.copy_stream(src, dest) }
68
81
  dest.close
69
82
  Rake::Task["#{@name}:build:#{name}"].execute
70
83
  puts "="*60
71
- print `diff -u #{dest.path} #{name}.html` if File.exist? "#{name}.html"
84
+ print `diff -u #{dest.path} #{name}.html | cut -c1-150` if File.exist? "#{name}.html"
72
85
  end
73
86
  end
74
87
  end
@@ -1,3 +1,3 @@
1
1
  module Slippery
2
- VERSION = '0.0.3'
2
+ VERSION = '0.1.0'
3
3
  end
data/slippery.gemspec CHANGED
@@ -17,11 +17,11 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = `git ls-files -- spec`.split($/)
18
18
  gem.extra_rdoc_files = %w[README.md LICENSE]
19
19
 
20
- gem.add_runtime_dependency 'hexp' , '~> 0.0'
21
- gem.add_runtime_dependency 'kramdown' , '~> 1.1'
20
+ gem.add_runtime_dependency 'hexp' , '~> 0.0'
21
+ gem.add_runtime_dependency 'kramdown' , '~> 1.1'
22
22
  gem.add_runtime_dependency 'rb-inotify'
23
+ gem.add_runtime_dependency 'rake' , '~> 10.1'
23
24
 
24
- gem.add_development_dependency 'rake', '~> 10.1'
25
25
  gem.add_development_dependency 'rspec', '~> 2.14'
26
26
  gem.add_development_dependency 'rubygems-tasks'
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slippery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arne Brasseur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-23 00:00:00.000000000 Z
11
+ date: 2014-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  prerelease: false
@@ -60,7 +60,7 @@ dependencies:
60
60
  - - ~>
61
61
  - !ruby/object:Gem::Version
62
62
  version: '10.1'
63
- type: :development
63
+ type: :runtime
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
@@ -182,6 +182,7 @@ files:
182
182
  - lib/slippery/presentation.rb
183
183
  - lib/slippery/processor_helpers.rb
184
184
  - lib/slippery/processors/add_google_font.rb
185
+ - lib/slippery/processors/add_highlight.rb
185
186
  - lib/slippery/processors/graphviz_dot.rb
186
187
  - lib/slippery/processors/hr_to_sections.rb
187
188
  - lib/slippery/processors/impress_js/add_impress_js.rb