slider 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Slider
2
+
3
+ From Markdown to HTML presentation. Quick & easy.
4
+
5
+ ## Status
6
+
7
+ First prototype, few minutes after lunch :)
8
+
9
+ ## Install
10
+
11
+ gem install slider
12
+
13
+ ## How to
14
+
15
+ Create your slides using markdown in a file, e.g. my_slides.md and run
16
+
17
+ slider my_slides
18
+
19
+ new file will be created for you my_slides.html and a directory my_slides-artefacts with several javascript and css files.
20
+
21
+ ## Example
22
+
23
+ Sample slides are in examples directory.
24
+
25
+ ## Thanks
26
+
27
+ Thanks to the authors of software I use
28
+
29
+ * tmm1
30
+ * [Pygments.rd](https://github.com/tmm1/pygments.rb)
31
+ * gettalong
32
+ * [Kramdown](https://github.com/gettalong/kramdown)
33
+ * imakewebthings
34
+ * [deck.js](https://github.com/imakewebthings/deck.js)
data/bin/slider ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path('../../lib/', __FILE__)
4
+ $:.unshift(lib) unless $:.include?(lib)
5
+
6
+ require 'fileutils'
7
+ require 'slider'
8
+
9
+ input = (ARGV[0] ||= 'slides')
10
+ template = (ARGV[1] ||= 'basic')
11
+
12
+ document = Slider::Document.new(input, template)
13
+ slides = document.render
14
+
15
+ File.open("#{input}.html", "w") do |file|
16
+ file.write(slides)
17
+ end
18
+
19
+ unless File.exists?("#{input}-artefacts")
20
+ FileUtils.cp_r(File.expand_path("../../templates/#{template}", __FILE__), "#{input}-artefacts")
21
+ end
@@ -0,0 +1,20 @@
1
+ require 'erb'
2
+
3
+ module Slider
4
+
5
+ class Document
6
+
7
+ def initialize(name, template)
8
+ @name = name
9
+ @file = File.read("#{name}.md")
10
+ @template = ERB.new(File.read(File.expand_path(File.join('..', '..', '..', 'templates', "#{template}.erb"), __FILE__)))
11
+ end
12
+
13
+ def render
14
+ @content = Kramdown::Document.new(@file, :input => 'Slider').to_html
15
+ @template.result(binding)
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,30 @@
1
+ require 'kramdown'
2
+ require 'kramdown/parser/kramdown'
3
+ require 'pygments'
4
+
5
+ class Kramdown::Parser::Slider < Kramdown::Parser::Kramdown
6
+
7
+ def initialize(source, options)
8
+ super
9
+ @block_parsers.unshift(:syntax_tag)
10
+ @block_parsers.unshift(:slide_tag)
11
+ end
12
+
13
+ def parse_syntax_tag
14
+ match = /^```(\w+)\n(.*)\n```$/m.match(@src.matched)
15
+ @src.pos += @src.matched_size
16
+ code = Pygments.highlight(match[2], :lexer => match[1], :options => {
17
+ :encoding => 'utf-8'
18
+ })
19
+ @tree.children << Element.new(:raw, code)
20
+ end
21
+
22
+ def parse_slide_tag
23
+ @src.pos += @src.matched_size
24
+ @tree.children << Element.new(:raw, '</section><section class="slide">')
25
+ end
26
+
27
+ define_parser(:slide_tag, /^!SLIDE\w*$/, '')
28
+ define_parser(:syntax_tag, /^``` ?([^\r\n]+)?\r?\n(.+?)\r?\n```\r?$/m, '')
29
+
30
+ end
@@ -0,0 +1,5 @@
1
+ module Slider
2
+
3
+ VERSION = '0.1' unless const_defined?(:VERSION)
4
+
5
+ end
data/lib/slider.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'slider/version'
2
+
3
+ require 'slider/markdown'
4
+ require 'slider/document'
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: slider
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Marek Jelen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: kramdown
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: pygments.rb
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Yeah, once again!
47
+ email:
48
+ - mjelen@redhat.com
49
+ executables:
50
+ - slider
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - bin/slider
55
+ - lib/slider/markdown.rb
56
+ - lib/slider/document.rb
57
+ - lib/slider/version.rb
58
+ - lib/slider.rb
59
+ - README.md
60
+ homepage: http://github.com/marekjelen/slider
61
+ licenses: []
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 1.8.21
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: Slides with ease
84
+ test_files: []