magic_reveal 2.4.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d5c1f685fc06356224773be6c761b559d20dcb7
4
+ data.tar.gz: f6061b79e83be0baf5637ee4957045881c3bf3cf
5
+ SHA512:
6
+ metadata.gz: e638920d89ab90ffcea767da5676b43c77954a93ee68bd42ad3ff86ff501319a91b60ca693e37e7b3ae9cac918d9f40d7b4e02e01c532eb0527a92bc1a921a2f
7
+ data.tar.gz: 4ba1e2768b60d18b3a54ad24cc8ab858ba4db57d210a61f039c78a46de6d2c527d94e90403a7e27a16a41c466952a12e684ffe657a92488a16d0ae3679f6f5ac
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ tags
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.9.2
5
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in magic-reveal.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard :rspec, :cli => "--color --order default --format progress" do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Christian Höltje
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # Magic Reveal
2
+
3
+ Magic Reveal makes creating presentations easy and fun.
4
+
5
+ See it in action at the [demo/tutorial](http://docwhat.github.io/magic_reveal/)
6
+
7
+ [![Build Status](https://secure.travis-ci.org/docwhat/magic_reveal.png?branch=master)](http://travis-ci.org/docwhat/magic_reveal)
8
+ [![Dependencies](https://gemnasium.com/docwhat/magic_reveal.png?branch=master)](https://gemnasium.com/docwhat/magic_reveal)
9
+ [![Coverage Status](https://coveralls.io/repos/docwhat/magic_reveal/badge.png?branch=master)](https://coveralls.io/r/docwhat/magic_reveal)
10
+
11
+ ## Installation
12
+
13
+ Use `gem` to install magic_reveal:
14
+
15
+ $ gem install magic_reveal
16
+
17
+ The version numbers are the based on the versions of
18
+ [reveal.js](https://github.com/hakimel/reveal.js). The last number is
19
+ the revision specific to Magic Reveal.
20
+
21
+ ### Requirements
22
+
23
+ * Ruby 1.9.2 or newer
24
+ * A recent version of [Bundler](http://bundler.io/)
25
+
26
+ <br/>
27
+ Magic Reveal *may* work on non-posix systems, but I make no promises. Pull Requests are
28
+ welcome.
29
+
30
+ ## Usage
31
+
32
+ To get started:
33
+
34
+ $ magic-reveal new my-presentation
35
+ $ cd my-presentation
36
+ $ vim slides.md
37
+
38
+ Feel free to replace [vim](http://vim.org/) with the editor of your choice.
39
+
40
+ ### Viewing the presentation
41
+
42
+ $ rackup
43
+
44
+ Then open your browser to [`http://localhost:9292`](http://localhost:9292).
45
+
46
+ ### The format of slides.md
47
+
48
+ Magic Reveal uses [github-flavored
49
+ markdown](https://help.github.com/articles/github-flavored-markdown)
50
+ as much as practical.
51
+
52
+ #### External code files
53
+
54
+ If you want your source code to be in files outside your `slides.md`, no problem!
55
+
56
+ To load source from `example.rb`, for example, then use `@@source = <filename>`
57
+ as the body of the code section.
58
+
59
+ For example:
60
+
61
+ ```
62
+ `@@source = example.rb`
63
+ ```
64
+
65
+ This works with triple back-quote blocks and four-space indented blocks sections as well.
66
+
67
+ ## Development
68
+
69
+ There is a full [RSpec](http://rspec.info/) test suite. Make sure you
70
+ write tests before you continue.
71
+
72
+ For the places where I don't have tests because I couldn't figure it out,
73
+ please help!
74
+
75
+ ### Future plans
76
+
77
+ * Generate static sites via the `magic-reveal` command line tool
78
+ * A configuration file, for using plugins, etc.
79
+
80
+ ## Contributing
81
+
82
+ (because you know it could be better)
83
+
84
+ 1. [Fork it](https://github.com/docwhat/magic_reveal)
85
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
86
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
87
+ 4. Push to the branch (`git push origin my-new-feature`)
88
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "rspec/core/rake_task"
2
+
3
+ task :default => :spec
4
+
5
+ namespace :gem do
6
+ require "bundler/gem_tasks"
7
+ end
8
+
9
+ RSpec::Core::RakeTask.new(:spec)
10
+
data/bin/magic-reveal ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path('../../lib', __FILE__)
4
+
5
+ require 'magic_reveal/cli'
6
+
7
+ MagicReveal::Cli.run
@@ -0,0 +1,50 @@
1
+ require 'redcarpet'
2
+ require 'sinatra/base'
3
+ require 'magic_reveal/slide_renderer'
4
+ require 'magic_reveal/index_libber'
5
+
6
+ begin
7
+ require 'better_errors'
8
+ HAS_BETTER_ERRORS = true
9
+ rescue LoadError
10
+ HAS_BETTER_ERRORS = false
11
+ end
12
+
13
+ module MagicReveal
14
+ class App < Sinatra::Base
15
+ if HAS_BETTER_ERRORS
16
+ configure :development do
17
+ use BetterErrors::Middleware
18
+ BetterErrors.application_root = File.expand_path('../../..', __FILE__)
19
+ end
20
+ end
21
+
22
+ set :public_folder, File.expand_path('reveal.js', Dir.getwd)
23
+
24
+ helpers do
25
+ def markdown
26
+ @markdown ||= Redcarpet::Markdown.new(
27
+ MagicReveal::SlideRenderer.new,
28
+ :space_after_headers => true,
29
+ :filter_html => true,
30
+ :fenced_code_blocks => true,
31
+ :no_intra_emphasis => true,
32
+ )
33
+ end
34
+
35
+ def index_html_path
36
+ @index_html_path ||= Pathname.pwd + 'reveal.js' + 'index.html'
37
+ end
38
+ end
39
+
40
+ get '/' do
41
+ slides = markdown.render File.read('slides.md')
42
+ libber = MagicReveal::IndexLibber.new index_html_path.read
43
+ libber.update_author MagicReveal::Identifier.name
44
+ libber.update_description "A Magical Presentiation"
45
+ libber.update_slides slides
46
+ libber.to_s
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,30 @@
1
+ module MagicReveal
2
+ class Cli
3
+ class Options
4
+ attr_accessor(
5
+ :command,
6
+ :project,
7
+ )
8
+
9
+ def program_name
10
+ @program_name ||= File.basename($0)
11
+ end
12
+
13
+ def parse args
14
+ case args.first
15
+ when 'new'
16
+ if args.length != 2
17
+ @command = :help
18
+ else
19
+ @command = :new
20
+ @project = args[1]
21
+ end
22
+ when 'help'
23
+ @command = :help
24
+ else
25
+ @command = :help
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,43 @@
1
+ require 'forwardable'
2
+
3
+ require 'magic_reveal/cli/options'
4
+ require 'magic_reveal/creator'
5
+
6
+ module MagicReveal
7
+ class Cli
8
+ extend Forwardable
9
+
10
+ def_delegator :options, :program_name
11
+ def_delegator :options, :command
12
+ def_delegator :options, :project
13
+
14
+ attr_writer :creator
15
+
16
+ # Helper method
17
+ def self.run args=ARGV
18
+ self.new.run args
19
+ end
20
+
21
+ # Action Classes
22
+ def creator
23
+ @creator ||= Creator.new(Dir.getwd)
24
+ end
25
+
26
+ def options
27
+ @options ||= Options.new
28
+ end
29
+
30
+ def run args=ARGV
31
+ options.parse args
32
+
33
+ case command
34
+ when :new
35
+ creator.create_project(project)
36
+ else
37
+ puts "Usage: #{program_name}"
38
+ puts
39
+ puts "This isn't written yet."
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,51 @@
1
+ require 'magic_reveal'
2
+ require 'net/https'
3
+ require 'archive/zip'
4
+ require 'pathname'
5
+ require 'fileutils'
6
+
7
+ module MagicReveal
8
+ # Fetchs a github zip file and unpacks it for use.
9
+ class Conductor
10
+ attr_reader :url, :enable_warnings
11
+
12
+ def initialize url=nil
13
+ self.url = url unless url.nil?
14
+ end
15
+
16
+ def url= url
17
+ @url = URI.parse url
18
+ end
19
+
20
+ def fetch save_path, limit = 5
21
+ raise TooManyRedirects if limit <= 0
22
+ save_path = Pathname.new save_path
23
+
24
+ request = Net::HTTP::Get.new url.path
25
+ response = Net::HTTP.start(url.host, url.port, use_ssl: url.scheme == 'https') { |http| http.request(request) }
26
+
27
+ case response
28
+ when Net::HTTPSuccess then
29
+ save_path.open('w') { |fp| fp.write response.body }
30
+ when Net::HTTPRedirection then
31
+ self.url = response['location']
32
+ warn "redirected to #{url}" if enable_warnings
33
+ fetch(save_path, limit - 1)
34
+ else
35
+ raise Error, "Huh? #{response.value}"
36
+ end
37
+ end
38
+
39
+ def unpack zip_file, directory
40
+ directory = Pathname.new directory
41
+ raise Error, "Directory '#{directory}' already exists." if directory.exist?
42
+
43
+ Archive::Zip.extract zip_file.to_s, directory.to_s
44
+
45
+ # Unwrap the outer-most unzipped directory.
46
+ wrapper_dir = directory.children.first
47
+ wrapper_dir.children.each { |c| c.rename(directory + c.basename) }
48
+ wrapper_dir.rmdir
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,49 @@
1
+ require 'fileutils'
2
+ require 'pathname'
3
+
4
+ require 'magic_reveal/version'
5
+ require 'magic_reveal/reveal_js_fetcher'
6
+
7
+ module MagicReveal
8
+ class Creator
9
+ attr_reader :directory
10
+ attr_writer :reveal_js_fetcher, :template_slides, :template_config_ru
11
+
12
+ def initialize(directory)
13
+ @directory = Pathname.new directory
14
+ end
15
+
16
+ def reveal_js_fetcher
17
+ @reveal_js_fetcher ||= RevealJsFetcher.new
18
+ end
19
+
20
+ def template_slides
21
+ @template_slides ||= Pathname.new(__FILE__).dirname.dirname.dirname + 'README.md'
22
+ end
23
+
24
+ def template_config_ru
25
+ @template_config_ru ||= Pathname.new(__FILE__).dirname + 'template-config.ru'
26
+ end
27
+
28
+ def create_project(project)
29
+ top_dir = directory + project
30
+ reveal_dir = top_dir + 'reveal.js'
31
+ gemfile = top_dir + 'Gemfile'
32
+
33
+ top_dir.mkdir
34
+
35
+ reveal_js_fetcher.save_to(reveal_dir)
36
+ FileUtils.copy_file template_slides.to_s, (top_dir + 'slides.md').to_s
37
+ FileUtils.copy_file template_config_ru.to_s, (top_dir + 'config.ru').to_s
38
+ gemfile.open('w') do |f|
39
+ f.puts "source 'https://rubygems.org'"
40
+ f.puts
41
+ f.puts "gem 'magic_reveal', '~> #{VERSION}'"
42
+ end
43
+
44
+ Dir.chdir(top_dir.to_s) do
45
+ system 'bundle install'
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,30 @@
1
+ require 'sys/admin'
2
+
3
+ module MagicReveal
4
+ class Identifier
5
+ attr_accessor :sys_admin
6
+
7
+ def initialize sys_admin=nil
8
+ @sys_admin = sys_admin || Sys::Admin
9
+ end
10
+
11
+ # Alias to make life easier.
12
+ def self.name
13
+ new.name
14
+ end
15
+
16
+ def name
17
+ login = sys_admin.get_login
18
+ user = sys_admin.get_user login
19
+
20
+ return user.full_name if user.respond_to? :full_name
21
+ gecos = user.gecos
22
+ name = gecos.split(/\s*,\s*/).first
23
+ if name.nil? || name.empty?
24
+ return login
25
+ else
26
+ return name
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,37 @@
1
+ require 'pathname'
2
+ require 'nokogiri'
3
+ require 'magic_reveal/identifier'
4
+
5
+ module MagicReveal
6
+ # Mad Libs with Reveal.JS's index.html
7
+ class IndexLibber
8
+ attr_reader :html
9
+
10
+ def initialize html_text
11
+ @html = Nokogiri::HTML(html_text, &:noblanks)
12
+ end
13
+
14
+ def update_author author
15
+ if meta = html.at_xpath("//meta[@name='author']")
16
+ meta.set_attribute('content', author)
17
+ end
18
+ end
19
+
20
+ def update_description description
21
+ if meta = html.at_xpath("//meta[@name='description']")
22
+ meta.set_attribute('content', description)
23
+ end
24
+ end
25
+
26
+ def update_slides slides_text
27
+ slides = Nokogiri::HTML(slides_text).css('section')
28
+ if container = html.at_css('div.reveal div.slides')
29
+ container.children = slides
30
+ end
31
+ end
32
+
33
+ def to_s
34
+ html.to_html
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,31 @@
1
+ require 'magic_reveal/version'
2
+ require 'magic_reveal/conductor'
3
+
4
+ module MagicReveal
5
+ class RevealJsFetcher
6
+ attr_reader :version
7
+ attr_writer :conductor
8
+
9
+ def initialize(version=REVEAL_JS_VERSION)
10
+ @version = version
11
+ end
12
+
13
+ def zip_url
14
+ "https://github.com/hakimel/reveal.js/archive/#{@version}.zip"
15
+ end
16
+
17
+ def conductor
18
+ @conductor ||= Conductor.new zip_url
19
+ end
20
+
21
+ def save_to(reveal_dir)
22
+ reveal_dir = Pathname.new reveal_dir
23
+
24
+ Dir.mktmpdir do |tmpdir|
25
+ zipfile = tmpdir + "fetching-#{REVEAL_JS_VERSION}.zip"
26
+ conductor.fetch(zipfile)
27
+ conductor.unpack(zipfile, reveal_dir)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,59 @@
1
+ require 'redcarpet'
2
+ require 'cgi'
3
+
4
+ require 'magic_reveal/version'
5
+
6
+ module MagicReveal
7
+ class SlideRenderer < Redcarpet::Render::HTML
8
+ include Redcarpet::Render::SmartyPants
9
+ attr_accessor :has_shown_slides
10
+
11
+ def initialize
12
+ super(no_styles: true)
13
+ end
14
+
15
+ def doc_header
16
+ @has_shown_slides = false
17
+ "<!-- generated by magic_reveal v#{VERSION} on #{Time.now} -->"
18
+ end
19
+
20
+ def doc_footer
21
+ has_shown_slides ? '</section>' : ''
22
+ end
23
+
24
+ def header(text, header_level)
25
+ output = []
26
+ if has_shown_slides
27
+ output << "</section>"
28
+ else
29
+ @has_shown_slides = true
30
+ end
31
+ output << "<section>"
32
+ output << "<h#{header_level}>#{text}</h#{header_level}>"
33
+ output.join("\n")
34
+ end
35
+
36
+ def prepare_code(code)
37
+ if code =~ %r{\A\s*@@source\s*=\s*(.*)\s*\Z}
38
+ File.read($1)
39
+ else
40
+ code
41
+ end
42
+ end
43
+
44
+ def block_code(code, language)
45
+ output = []
46
+ if language
47
+ output << "<pre class=\"#{language}\">"
48
+ else
49
+ output << "<pre>"
50
+ end
51
+ output << "<code>"
52
+
53
+ output << CGI::escapeHTML(prepare_code code)
54
+ output << "</code>"
55
+ output << "</pre>"
56
+ output.join("")
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,2 @@
1
+ require 'magic_reveal/app'
2
+ run MagicReveal::App
@@ -0,0 +1,4 @@
1
+ module MagicReveal
2
+ REVEAL_JS_VERSION = "2.4.0"
3
+ VERSION = "#{REVEAL_JS_VERSION}.1"
4
+ end
@@ -0,0 +1,7 @@
1
+ require "magic_reveal/version"
2
+
3
+ module MagicReveal
4
+ class Error < StandardError; end
5
+ class TooManyRedirects < Error; end
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,45 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'magic_reveal/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "magic_reveal"
8
+ spec.version = MagicReveal::VERSION
9
+ spec.authors = ["Christian Höltje"]
10
+ spec.email = ["docwhat@gerf.org"]
11
+ spec.description = %q{Create presentations with markdown and ease!}
12
+ spec.summary = %q{Create presentations using markdown and reveal.js}
13
+ spec.homepage = "https://github.com/docwhat/magic_reveal"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.required_ruby_version = '>= 1.9.2'
22
+
23
+ spec.add_dependency "sinatra", "~> 1.4"
24
+ spec.add_dependency "redcarpet", "~> 3.0"
25
+ spec.add_dependency "archive-zip", "~> 0.6"
26
+ spec.add_dependency "sys-admin", "~> 1.6"
27
+ spec.add_dependency "nokogiri", "~> 1.5"
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.3"
30
+ spec.add_development_dependency "rake"
31
+ spec.add_development_dependency "guard-rspec", "~> 3.0"
32
+ spec.add_development_dependency "rspec", "~> 2.14"
33
+ spec.add_development_dependency "coveralls", "~> 0.6"
34
+ spec.add_development_dependency "better_errors"
35
+ spec.add_development_dependency "binding_of_caller"
36
+
37
+ #For detecting changes in the filesystem
38
+ spec.add_development_dependency 'rb-inotify'
39
+ spec.add_development_dependency 'rb-fsevent'
40
+ spec.add_development_dependency 'rb-fchange'
41
+
42
+ #For displaying notices
43
+ spec.add_development_dependency 'terminal-notifier-guard'
44
+ spec.add_development_dependency 'libnotify'
45
+ end
Binary file
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+ require 'magic_reveal/app'
3
+
4
+ describe MagicReveal::App do
5
+ # I'm not sure how to test this...
6
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+ require 'magic_reveal/cli/options'
3
+
4
+ describe MagicReveal::Cli::Options do
5
+ describe ".parse" do
6
+ before { subject.parse args }
7
+
8
+ context "given 'new <project>'" do
9
+ let(:args) { %w{new someproject} }
10
+
11
+ its(:command) { should be(:new) }
12
+ its(:project) { should eq('someproject') }
13
+ end
14
+
15
+ context "given 'new <project> extrajunk'" do
16
+ let(:args) { %w{new someproject extrajunk} }
17
+
18
+ its(:command) { should be(:help) }
19
+ its(:project) { should be_nil }
20
+ end
21
+
22
+ context "given 'help'" do
23
+ let(:args) { %w{help} }
24
+
25
+ its(:command) { should be(:help) }
26
+ end
27
+
28
+ context "given no arguments" do
29
+ let(:args) { [] }
30
+
31
+ its(:command) { should be(:help) }
32
+ end
33
+ end
34
+ end