org2slides 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.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +38 -0
  5. data/README.MD +39 -0
  6. data/Rakefile +7 -0
  7. data/bin/org2slides +17 -0
  8. data/lib/org2slides.rb +286 -0
  9. data/org2slides.gemspec +27 -0
  10. data/templates/reveal_js_template/css/FMtZSYIYoYw.ttf +0 -0
  11. data/templates/reveal_js_template/css/LqowQDslGv4DmUBAfWa2Vw.ttf +0 -0
  12. data/templates/reveal_js_template/css/cDxXwCLxiixG1c.ttf +0 -0
  13. data/templates/reveal_js_template/css/google-fonts.css +24 -0
  14. data/templates/reveal_js_template/css/main.css +909 -0
  15. data/templates/reveal_js_template/css/print/paper.css +170 -0
  16. data/templates/reveal_js_template/css/print/pdf.css +158 -0
  17. data/templates/reveal_js_template/css/theme/beige.css +179 -0
  18. data/templates/reveal_js_template/css/theme/default.css +169 -0
  19. data/templates/reveal_js_template/css/theme/simple.css +164 -0
  20. data/templates/reveal_js_template/css/v0SdcGFAl2aezM9Vq_aFTQ.ttf +0 -0
  21. data/templates/reveal_js_template/images/gitorious-org.png +0 -0
  22. data/templates/reveal_js_template/index.html +231 -0
  23. data/templates/reveal_js_template/js/reveal.js +1131 -0
  24. data/templates/reveal_js_template/js/reveal.min.js +70 -0
  25. data/templates/reveal_js_template/lib/css/zenburn.css +115 -0
  26. data/templates/reveal_js_template/lib/font/league_gothic-webfont.eot +0 -0
  27. data/templates/reveal_js_template/lib/font/league_gothic-webfont.svg +230 -0
  28. data/templates/reveal_js_template/lib/font/league_gothic-webfont.ttf +0 -0
  29. data/templates/reveal_js_template/lib/font/league_gothic-webfont.woff +0 -0
  30. data/templates/reveal_js_template/lib/font/league_gothic_license +2 -0
  31. data/templates/reveal_js_template/lib/js/classList.js +2 -0
  32. data/templates/reveal_js_template/lib/js/data-markdown.js +27 -0
  33. data/templates/reveal_js_template/lib/js/head.min.js +8 -0
  34. data/templates/reveal_js_template/lib/js/highlight.js +5 -0
  35. data/templates/reveal_js_template/lib/js/html5shiv.js +7 -0
  36. data/templates/reveal_js_template/lib/js/showdown.js +1341 -0
  37. data/templates/reveal_js_template/package.json +20 -0
  38. data/todo.org +33 -0
  39. metadata +151 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cc9ee98ab1298e1ed3248b649f2ac695591ee3d7
4
+ data.tar.gz: 27c6e686cf855af5494229d79a44d6865396d3fe
5
+ SHA512:
6
+ metadata.gz: 90da62398212a7c9c17eec20235d4cf67a08d1f3a814bb0c37460fcce5f547e2e996e62782fe2749a577679654b1be8821231cc0dbfe699ee18a7f8cda114124
7
+ data.tar.gz: 57fdf48e7fc9c77c81617d2dd099d4830bd15c61663e0f1ec1b170f8cdf35838349ed6e386cb7c75f41ee916a43d46032851cf9f10d8aac846ef4debb22379a5
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ generated_slides
2
+ test.org
3
+ test.html
4
+ *_slides
5
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in .gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ org2slides (0.1.0)
5
+ nokogiri
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ activesupport (3.2.8)
11
+ i18n (~> 0.6)
12
+ multi_json (~> 1.0)
13
+ i18n (0.6.1)
14
+ mini_portile (0.6.2)
15
+ minitest (4.0.0)
16
+ multi_json (1.3.6)
17
+ nokogiri (1.6.6.2)
18
+ mini_portile (~> 0.6.0)
19
+ org-ruby (0.9.12)
20
+ rubypants (~> 0.2)
21
+ rubypants (0.2.0)
22
+ shoulda (3.1.1)
23
+ shoulda-context (~> 1.0)
24
+ shoulda-matchers (~> 1.2)
25
+ shoulda-context (1.0.0)
26
+ shoulda-matchers (1.3.0)
27
+ activesupport (>= 3.0.0)
28
+
29
+ PLATFORMS
30
+ java
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ minitest
35
+ org-ruby
36
+ org2slides!
37
+ shoulda
38
+ shoulda-context
data/README.MD ADDED
@@ -0,0 +1,39 @@
1
+
2
+ org2slides
3
+ ===
4
+
5
+ Turn .org orgmode files into html slides (via Reveal.js)
6
+
7
+
8
+ Dependencies
9
+ ===========
10
+
11
+ Ruby.
12
+
13
+
14
+ Install
15
+ =======
16
+
17
+ `gem install org2slides`
18
+
19
+
20
+ Usage
21
+ =====
22
+
23
+ `org2slides ORG_FILE_PATH`
24
+
25
+
26
+ Testing
27
+ =====
28
+
29
+ To hack on this and test the code, clone it, then run the following
30
+ whenever you need to do a smoketest:
31
+
32
+ ruby -Ilib bin/org2slides test.org && open test_generated_slides/index.html
33
+
34
+
35
+ License
36
+ =======
37
+
38
+ org2slides is free software licensed under the
39
+ [GNU Affero General Public License (AGPL)](http://www.gnu.org/licenses/agpl-3.0.html).
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |i|
5
+ i.test_files = FileList['test/test_*.rb']
6
+ #i.verbose = true
7
+ end
data/bin/org2slides ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "org2slides"
4
+
5
+ if ARGV.length != 1
6
+ puts "Usage: org2slides ORG_FILE_PATH"
7
+ exit 1
8
+ end
9
+
10
+ converter = OrgToSlides::Converter.new
11
+ htmldir_name = converter.convert(ARGV[0])
12
+
13
+ puts "\n\nSlides generated here:"
14
+ puts "#{htmldir_name}_generated_slides/index.html\n\n"
15
+
16
+ # TODO Param to display version (-v, --version)
17
+ #puts OrgToSlides::VERSION
data/lib/org2slides.rb ADDED
@@ -0,0 +1,286 @@
1
+ # -*- coding: utf-8 -*-
2
+ module OrgToSlides
3
+ VERSION = "0.2.0"
4
+
5
+
6
+ class Converter
7
+
8
+ def body(orgfile_path)
9
+ `cat #{orgfile_path}`
10
+ end
11
+
12
+ def title(orgfile_path)
13
+ `cat #{orgfile_path} | grep "#+TITLE:" `.gsub("#+TITLE:", "").strip
14
+ end
15
+
16
+ def layout(title, body)
17
+ <<MARKUP
18
+ <!doctype html>
19
+ <html lang="en">
20
+ <head>
21
+ <meta charset="utf-8">
22
+ <title>#{title}</title>
23
+ <meta name="apple-mobile-web-app-capable" content="yes">
24
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
25
+ <link href='http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
26
+ <link rel="stylesheet" href="css/main.css">
27
+ <link rel="stylesheet" href="css/theme/default.css">
28
+ <!-- For syntax highlighting -->
29
+ <link rel="stylesheet" href="lib/css/zenburn.css">
30
+ <script>
31
+ // If the query includes 'print-pdf' we'll use the PDF print sheet
32
+ document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
33
+ </script>
34
+ <!--[if lt IE 9]>
35
+ <script src="lib/js/html5shiv.js"></script>
36
+ <![endif]-->
37
+ </head>
38
+ <body>
39
+ <div class="reveal">
40
+ <!-- Used to fade in a background when a specific slide state is reached -->
41
+ <div class="state-background"></div>
42
+
43
+ <!-- Any section element inside of this container is displayed as a slide -->
44
+ <div class="slides">
45
+
46
+ #{body}
47
+
48
+ </div>
49
+
50
+ <!-- The navigational controls UI -->
51
+ <aside class="controls">
52
+ <a class="left" href="#">&#x25C4;</a>
53
+ <a class="right" href="#">&#x25BA;</a>
54
+ <a class="up" href="#">&#x25B2;</a>
55
+ <a class="down" href="#">&#x25BC;</a>
56
+ </aside>
57
+ <!-- Presentation progress bar -->
58
+ <div class="progress"><span></span></div>
59
+ </div>
60
+ <script src="lib/js/head.min.js"></script>
61
+ <script src="js/reveal.min.js"></script>
62
+ <script>
63
+ // Full list of configuration options available here:
64
+ // https://github.com/hakimel/reveal.js#configuration
65
+ Reveal.initialize({
66
+ controls: true,
67
+ progress: true,
68
+ history: true,
69
+ transition: Reveal.getQueryHash().transition || 'linear', // default/cube/page/concave/linear(2d)
70
+ // Optional libraries used to extend on reveal.js
71
+ dependencies: [
72
+ { src: 'lib/js/highlight.js', async: true, callback: function() { window.hljs.initHighlightingOnLoad(); } },
73
+ { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
74
+ { src: 'lib/js/showdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
75
+ { src: 'lib/js/data-markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
76
+ { src: 'socket.io/socket.io.js', async: true, condition: function() { return window.location.host === 'localhost:1947'; } },
77
+ { src: 'plugin/speakernotes/client.js', async: true, condition: function() { return window.location.host === 'localhost:1947'; } },
78
+ ]
79
+ });
80
+ </script>
81
+ </body>
82
+ </html>
83
+ MARKUP
84
+ end
85
+
86
+ def convert_old(orgfile_path)
87
+ title = "" # TODO derive title from filename and|or org contents
88
+ puts `org2html #{orgfile_path}`
89
+ htmlfile_path = orgfile_path.gsub(".org", ".html")
90
+ htmldir_name = orgfile_path.gsub(".org", "")
91
+ body = body(htmlfile_path)
92
+ body = transform_divs_into_sections(body)
93
+ body = slide_layout(title, body)
94
+
95
+ # TODO use path of this file to find dir of template dir where gem is actually located
96
+
97
+ gem_root_path = File.expand_path(File.dirname(__FILE__))+"/.."
98
+ `cp -r #{gem_root_path}/templates/reveal_js_template #{htmldir_name}_generated_slides`
99
+ File.open("#{htmldir_name}_generated_slides/index.html", 'w') { |file| file.write(body) }
100
+ `rm #{htmlfile_path}`
101
+ return htmldir_name
102
+ end
103
+
104
+ def ast_to_reveal_js_structure(ast)
105
+ slides = []
106
+
107
+ # TODO: run to_html on ruby parser ast first, or can we do it after?
108
+
109
+ ast.headlines.each do |h|
110
+ slide_title = h.body_lines[0].to_s
111
+ slide_body = h.body_lines[1..(h.body_lines.size-1)].map{|l| l.to_s}.join("\n")
112
+ slides << {:title => slide_title, :body => slide_body}
113
+ end
114
+
115
+ puts slides
116
+ end
117
+
118
+ def convert(orgfile_path)
119
+
120
+ org_body = contents = File.read(orgfile_path)
121
+ ast = Orgmode::Parser.new(org_body)
122
+ slide_markup_body = ast.to_revealjs_html
123
+
124
+ title = "" # TODO derive title from filename and|or org contents
125
+ full_body = layout(title, slide_markup_body)
126
+
127
+ #puts body
128
+
129
+ htmldir_name = orgfile_path.gsub(".org", "")
130
+ gem_root_path = File.expand_path(File.dirname(__FILE__))+"/.."
131
+ `cp -r #{gem_root_path}/templates/reveal_js_template #{htmldir_name}_generated_slides`
132
+ File.open("#{htmldir_name}_generated_slides/index.html", 'w') { |file| file.write(full_body) }
133
+ return htmldir_name
134
+ end
135
+
136
+ end
137
+ end
138
+
139
+
140
+
141
+ # For now, monkeypath in revealjs export into the org-ruby lib
142
+
143
+ require 'org-ruby'
144
+
145
+
146
+ module Orgmode
147
+ class Parser
148
+
149
+ @first_slide_done = false
150
+
151
+ def translate_to_slides(lines, output_buffer)
152
+ output_buffer.output_type = :start
153
+ lines.each do |line|
154
+ if (line.kind_of?(Headline))
155
+
156
+ if(!@first_slide_done)
157
+ @first_slide_done = true
158
+ else
159
+ output_buffer.insert_slide_stop
160
+ end
161
+
162
+ output_buffer.insert_slide_start
163
+ end
164
+ output_buffer.insert(line)
165
+ end
166
+ output_buffer.flush!
167
+ output_buffer.pop_mode while output_buffer.current_mode
168
+ output_buffer.output_footnotes!
169
+ output_buffer.output
170
+ end
171
+
172
+ def to_revealjs_html
173
+ mark_trees_for_export
174
+ export_options = {
175
+ :decorate_title => @in_buffer_settings["TITLE"],
176
+ :export_heading_number => export_heading_number?,
177
+ :export_todo => export_todo?,
178
+ :use_sub_superscripts => use_sub_superscripts?,
179
+ :export_footnotes => export_footnotes?,
180
+ :link_abbrevs => @link_abbrevs,
181
+ :skip_syntax_highlight => @parser_options[:skip_syntax_highlight],
182
+ :markup_file => @parser_options[:markup_file]
183
+ }
184
+ export_options[:skip_tables] = true if not export_tables?
185
+ output = ""
186
+ output_buffer = RevealJsHtmlBuffer.new(output, export_options)
187
+
188
+ if @in_buffer_settings["TITLE"]
189
+
190
+ # If we're given a new title, then just create a new line
191
+ # for that title.
192
+ title = Line.new(@in_buffer_settings["TITLE"], self, :title)
193
+ translate_to_slides([title], output_buffer)
194
+ end
195
+ translate_to_slides(@header_lines, output_buffer) unless skip_header_lines?
196
+
197
+ # If we've output anything at all, remove the :decorate_title option.
198
+ export_options.delete(:decorate_title) if (output.length > 0)
199
+ @headlines.each do |headline|
200
+ next if headline.export_state == :exclude
201
+ case headline.export_state
202
+ when :exclude
203
+ # NOTHING
204
+ when :headline_only
205
+ translate_to_slides(headline.body_lines[0, 1], output_buffer)
206
+ when :all
207
+ translate_to_slides(headline.body_lines, output_buffer)
208
+ end
209
+ end
210
+ output << "\n"
211
+
212
+ return output if @parser_options[:skip_rubypants_pass]
213
+
214
+ rp = RubyPants.new(output)
215
+
216
+ unclosed_html = rp.to_html
217
+ closed_html = unclosed_html << "END-SLIDE"
218
+ sectioned_html = closed_html.gsub("START-SLIDE", "\n<section>").gsub("END-SLIDE","\n</section>")
219
+ end
220
+ end
221
+
222
+
223
+ class RevealJsHtmlBuffer < HtmlOutputBuffer
224
+ def insert_slide_start
225
+ @buffer << "START-SLIDE"
226
+ end
227
+
228
+ def insert_slide_stop
229
+ @buffer << "END-SLIDE"
230
+ end
231
+
232
+ def insert(line)
233
+ # Prepares the output buffer to receive content from a line.
234
+ # As a side effect, this may flush the current accumulated text.
235
+ @logger.debug "Looking at #{line.paragraph_type}|#{line.assigned_paragraph_type}(#{current_mode}) : #{line.to_s}"
236
+
237
+ # We try to get the lang from #+BEGIN_SRC blocks
238
+ @block_lang = line.block_lang if line.begin_block?
239
+ unless should_accumulate_output?(line)
240
+ flush!
241
+ maintain_mode_stack(line)
242
+ end
243
+
244
+
245
+ # Adds the current line to the output buffer
246
+ case
247
+ when line.assigned_paragraph_type == :comment
248
+ # Don't add to buffer
249
+ when line.title?
250
+ @buffer << line.output_text
251
+ when line.raw_text?
252
+ @buffer << "\n" << line.output_text if line.raw_text_tag == @buffer_tag
253
+ when preserve_whitespace?
254
+ @buffer << "\n" << line.output_text unless line.block_type
255
+ when line.assigned_paragraph_type == :code
256
+ # If the line is contained within a code block but we should
257
+ # not preserve whitespaces, then we do nothing.
258
+ when (line.kind_of? Headline)
259
+ add_line_attributes line
260
+ @buffer << "\n" << line.output_text.strip
261
+ when ([:definition_term, :list_item, :table_row, :table_header,
262
+ :horizontal_rule].include? line.paragraph_type)
263
+ @buffer << "\n" << line.output_text.strip
264
+ when line.paragraph_type == :paragraph
265
+ @buffer << "\n"
266
+ buffer_indentation
267
+ @buffer << line.output_text.strip
268
+ end
269
+
270
+ if mode_is_code? current_mode and not line.block_type
271
+ # Determines the amount of whitespaces to be stripped at the
272
+ # beginning of each line in code block.
273
+ if line.paragraph_type != :blank
274
+ if @code_block_indent
275
+ @code_block_indent = [@code_block_indent, line.indent].min
276
+ else
277
+ @code_block_indent = line.indent
278
+ end
279
+ end
280
+ end
281
+
282
+ @output_type = line.assigned_paragraph_type || line.paragraph_type
283
+ end
284
+ end
285
+
286
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "org2slides"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "org2slides"
7
+ s.version = OrgToSlides::VERSION
8
+ s.authors = ["Thomas Kjeldahl Nilsson"]
9
+ s.email = ["thomas@kjeldahlnilsson.net"]
10
+ s.homepage = "https://kjeldahlnilsson.net"
11
+ s.summary = %q{Turn orgfiles into Reveal.js presentations}
12
+ s.description = %q{Turn orgfiles into Reveal.js presentations}
13
+
14
+ s.rubyforge_project = "org2slides"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_runtime_dependency "nokogiri"
22
+
23
+ s.add_development_dependency "minitest"
24
+ s.add_development_dependency "shoulda"
25
+ s.add_development_dependency "shoulda-context"
26
+ s.add_development_dependency "org-ruby"
27
+ end