slideshift 0.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.
- data/bin/slideshift +8 -0
- data/lib/slideshift/tool/cli/default.conf +2 -0
- data/lib/slideshift/tool/cli/main.rb +98 -0
- data/lib/slideshift/tool/config.rb +45 -0
- data/lib/slideshift/tool/presentation.rb +36 -0
- data/lib/slideshift/tool/render/asciidoc.rb +1 -0
- data/lib/slideshift/tool/render/markdown.rb +60 -0
- data/lib/slideshift/tool/render/textile.rb +1 -0
- data/lib/slideshift/tool/server/server.rb +43 -0
- data/lib/slideshift/tool/template.erb +96 -0
- data/lib/slideshift/tool/version.rb +7 -0
- data/lib/slideshift/tool.rb +9 -0
- metadata +172 -0
data/bin/slideshift
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
require 'thor'
|
5
|
+
|
6
|
+
require 'faraday'
|
7
|
+
require 'yajl'
|
8
|
+
|
9
|
+
module Slideshift::Tool
|
10
|
+
module Cli
|
11
|
+
|
12
|
+
class Main < Thor
|
13
|
+
|
14
|
+
include Thor::Actions
|
15
|
+
|
16
|
+
def initialize(*args)
|
17
|
+
super(*args)
|
18
|
+
|
19
|
+
Slideshift::Tool.config.read(File.expand_path('../default.conf', __FILE__))
|
20
|
+
|
21
|
+
Slideshift::Tool.config.read('~/.slideshift.conf') if File.exists?('~/.slideshift.conf')
|
22
|
+
Slideshift::Tool.config.read('./slideshift.conf') if File.exists?('./slideshift.conf')
|
23
|
+
|
24
|
+
Slideshift::Tool.config
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'server', 'Starts local server to present the presentation'
|
28
|
+
option :port, :desc => 'Port to bind local server', :aliases => '-P', :required => false, :default => 8000
|
29
|
+
def server
|
30
|
+
presentation = Slideshift::Tool::Presentation.new
|
31
|
+
presentation.load
|
32
|
+
server = Slideshift::Tool::Server::Server.new(presentation)
|
33
|
+
server.start
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'upload', 'Upload the presentation to be available online'
|
37
|
+
def upload
|
38
|
+
|
39
|
+
say 'Uploading new presentation to SlideShift ...'
|
40
|
+
|
41
|
+
`tar czf presentation.tar.gz .`
|
42
|
+
|
43
|
+
http = Faraday.new(:url => Slideshift::Tool.config['service']['url']) do |builder|
|
44
|
+
builder.use Faraday::Response::Logger # log the request to STDOUT
|
45
|
+
builder.use Faraday::Adapter::NetHttp # make http requests with Net::HTTP
|
46
|
+
|
47
|
+
builder.request :multipart
|
48
|
+
builder.request :url_encoded
|
49
|
+
end
|
50
|
+
|
51
|
+
if Slideshift::Tool.config['service']['id']
|
52
|
+
say 'Presentation ID found, updating ...'
|
53
|
+
type = :update
|
54
|
+
else
|
55
|
+
say 'Creating new presentation ...'
|
56
|
+
type = :create
|
57
|
+
end
|
58
|
+
|
59
|
+
if type == :create
|
60
|
+
name = ask 'Name of your presentation:'
|
61
|
+
response = http.put do |req|
|
62
|
+
req.url = '/api/presentation'
|
63
|
+
req.headers['X-Api-Key'] = Slideshift::Tool.config['service']['key']
|
64
|
+
req.body = Yajl::Encoder.encode({ :name => name })
|
65
|
+
end
|
66
|
+
id = response.body
|
67
|
+
else
|
68
|
+
id = Slideshift::Tool.config['service']['id']
|
69
|
+
end
|
70
|
+
|
71
|
+
http.put do |req|
|
72
|
+
req.url File.join('/api/presentation', id)
|
73
|
+
req.headers['X-Api-Key'] = Slideshift::Tool.config['service']['key']
|
74
|
+
req.headers['Content-Type'] = 'application/x-gzip'
|
75
|
+
req.body = File.read('presentation.tar.gz')
|
76
|
+
end
|
77
|
+
|
78
|
+
FileUtils.rm('presentation.tar.gz')
|
79
|
+
|
80
|
+
if type == :create
|
81
|
+
Slideshift::Tool.config.service.id = id
|
82
|
+
conf = File.exists?('./slideshift.conf') ? File.read('./slideshift.conf') : ''
|
83
|
+
unless conf.index(id)
|
84
|
+
conf << "\nservice.id = '#{id}'\n"
|
85
|
+
File.open('./slideshift.conf', 'w') do |file|
|
86
|
+
file.write(conf)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
say "You presentation id: #{id}"
|
92
|
+
say "Presentation can be accessed directly: #{Slideshift::Tool.config['service']['url']}/presentation/#{id}"
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Slideshift
|
4
|
+
|
5
|
+
module Tool
|
6
|
+
|
7
|
+
def self.config
|
8
|
+
@config ||= Config.new
|
9
|
+
end
|
10
|
+
|
11
|
+
class Config
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@config = {}
|
15
|
+
end
|
16
|
+
|
17
|
+
def read(file)
|
18
|
+
ERB.new("<% #{File.read(file)} %>").result(binding)
|
19
|
+
end
|
20
|
+
|
21
|
+
def [](name)
|
22
|
+
@config[name.to_s.to_sym]
|
23
|
+
end
|
24
|
+
|
25
|
+
def []=(name, value)
|
26
|
+
@config[name.to_s.to_sym] = value
|
27
|
+
end
|
28
|
+
|
29
|
+
def method_missing(name, *args)
|
30
|
+
if name =~ /=$/
|
31
|
+
@config[name.to_s.sub('=', '').to_sym] = args.first
|
32
|
+
else
|
33
|
+
@config[name] ||= self.class.new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def inspect
|
38
|
+
@config.inspect
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Slideshift::Tool
|
4
|
+
|
5
|
+
class Presentation
|
6
|
+
|
7
|
+
def initialize(dir = ".", static = '/static')
|
8
|
+
@dir = dir
|
9
|
+
@static = static
|
10
|
+
@render = Render::Markdown.new(@dir)
|
11
|
+
end
|
12
|
+
|
13
|
+
def static(file)
|
14
|
+
File.join(@static, file)
|
15
|
+
end
|
16
|
+
|
17
|
+
def load
|
18
|
+
template = File.read(File.expand_path("../template.erb", __FILE__))
|
19
|
+
template = File.read("#{@dir}/template.erb") if File.exists?("#{@dir}/template.erb")
|
20
|
+
@template = ERB.new(template)
|
21
|
+
@render.load
|
22
|
+
end
|
23
|
+
|
24
|
+
def render
|
25
|
+
@template.result(binding)
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def presentation
|
31
|
+
@render.render
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# ToDo: implement
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'kramdown'
|
2
|
+
require 'kramdown/parser/kramdown'
|
3
|
+
require 'pygments'
|
4
|
+
|
5
|
+
|
6
|
+
# ToDo: clean up!
|
7
|
+
class Kramdown::Parser::Slider < Kramdown::Parser::Kramdown
|
8
|
+
|
9
|
+
def initialize(source, options)
|
10
|
+
super
|
11
|
+
@block_parsers.unshift(:syntax_tag)
|
12
|
+
@block_parsers.unshift(:slide_tag)
|
13
|
+
end
|
14
|
+
|
15
|
+
def parse_syntax_tag
|
16
|
+
match = /^```(\w+)\n(.*)\n```$/m.match(@src.matched)
|
17
|
+
@src.pos += @src.matched_size
|
18
|
+
code = Pygments.highlight(match[2], :lexer => match[1], :options => {
|
19
|
+
:encoding => 'utf-8'
|
20
|
+
})
|
21
|
+
@tree.children << Element.new(:raw, code)
|
22
|
+
end
|
23
|
+
|
24
|
+
def parse_slide_tag
|
25
|
+
@src.pos += @src.matched_size
|
26
|
+
@tree.children << Element.new(:raw, '</section><section class="slide">')
|
27
|
+
end
|
28
|
+
|
29
|
+
define_parser(:slide_tag, /^!SLIDE\w*$/, '')
|
30
|
+
define_parser(:syntax_tag, /^``` ?([^\r\n]+)?\r?\n(.+?)\r?\n```\r?$/m, '')
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
module Slideshift::Tool
|
35
|
+
module Render
|
36
|
+
|
37
|
+
class Markdown
|
38
|
+
|
39
|
+
def initialize(dir)
|
40
|
+
@dir = dir
|
41
|
+
end
|
42
|
+
|
43
|
+
def load
|
44
|
+
file = "#{@dir}/presentation.md"
|
45
|
+
unless File.exists?(file)
|
46
|
+
puts "Error: Source file (#{file}) does not exists!"
|
47
|
+
exit(1)
|
48
|
+
end
|
49
|
+
@source = File.read(file)
|
50
|
+
self
|
51
|
+
end
|
52
|
+
|
53
|
+
def render
|
54
|
+
Kramdown::Document.new(@source, :input => 'Slider').to_html
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# ToDo: implement
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'webrick'
|
2
|
+
|
3
|
+
require 'slideshift/static'
|
4
|
+
|
5
|
+
module Slideshift::Tool::Server
|
6
|
+
|
7
|
+
class Server
|
8
|
+
|
9
|
+
def initialize(presentation)
|
10
|
+
@presentation = presentation
|
11
|
+
end
|
12
|
+
|
13
|
+
def start
|
14
|
+
|
15
|
+
@server = WEBrick::HTTPServer.new(:Port => Slideshift::Tool.config['server']['port'])
|
16
|
+
|
17
|
+
@server.mount_proc('/') do |req, res|
|
18
|
+
file = nil
|
19
|
+
|
20
|
+
local_file = File.join(Dir.getwd, req.path)
|
21
|
+
file = local_file if File.exists?(local_file) && File.file?(local_file)
|
22
|
+
|
23
|
+
static_file = File.join(Slideshift::Static.path, '..', req.path)
|
24
|
+
puts static_file
|
25
|
+
file = static_file if File.exists?(static_file) && File.file?(static_file)
|
26
|
+
|
27
|
+
if file
|
28
|
+
res.body = File.read(file)
|
29
|
+
else
|
30
|
+
@presentation.load
|
31
|
+
res.body = @presentation.render
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
trap('INT') { @server.shutdown }
|
36
|
+
|
37
|
+
@server.start
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
|
5
|
+
<meta charset="utf-8">
|
6
|
+
<meta name="viewport" content="width=1024, user-scalable=no">
|
7
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
8
|
+
|
9
|
+
<title>Slideshift</title>
|
10
|
+
|
11
|
+
<script type="text/javascript" src="<%= static('jquery.js') %>"></script>
|
12
|
+
<script type="text/javascript" src="<%= static('modernizr.js') %>"></script>
|
13
|
+
|
14
|
+
<script type="text/javascript" src="<%= static('deck.js/deck.core.js') %>"></script>
|
15
|
+
<link rel="stylesheet" type="text/css" href="<%= static('deck.js/deck.core.css') %>">
|
16
|
+
|
17
|
+
<link rel="stylesheet" type="text/css" href="<%= static('deck.js/swiss.css') %>">
|
18
|
+
<link rel="stylesheet" type="text/css" href="<%= static('deck.js/horizontal-slide.css') %>">
|
19
|
+
|
20
|
+
<script type="text/javascript" src="<%= static('deck.js/deck.menu.js') %>"></script>
|
21
|
+
<link rel="stylesheet" type="text/css" href="<%= static('deck.js/deck.menu.css') %>">
|
22
|
+
|
23
|
+
<script type="text/javascript" src="<%= static('deck.js/deck.status.js') %>"></script>
|
24
|
+
<link rel="stylesheet" type="text/css" href="<%= static('deck.js/deck.status.css') %>">
|
25
|
+
|
26
|
+
<script type="text/javascript" src="<%= static('deck.js/deck.hash.js') %>"></script>
|
27
|
+
<link rel="stylesheet" type="text/css" href="<%= static('deck.js/deck.hash.css') %>">
|
28
|
+
|
29
|
+
<link rel="stylesheet" type="text/css" href="<%= static('railscasts.css') %>">
|
30
|
+
|
31
|
+
</head>
|
32
|
+
<body class="deck-container">
|
33
|
+
|
34
|
+
<section class="slide">
|
35
|
+
<%= presentation %>
|
36
|
+
</section>
|
37
|
+
|
38
|
+
<a href="#" title="Permalink to this slide" class="deck-permalink">#</a>
|
39
|
+
|
40
|
+
<p class="deck-status">
|
41
|
+
<span class="deck-status-current"></span>
|
42
|
+
/
|
43
|
+
<span class="deck-status-total"></span>
|
44
|
+
</p>
|
45
|
+
|
46
|
+
<script type="text/javascript">
|
47
|
+
|
48
|
+
function openControlWindow() {
|
49
|
+
window.controlWindow = window.open('/#controlWindow', 'control');
|
50
|
+
window.moveToSlide = function (id) {
|
51
|
+
$.deck('go', id);
|
52
|
+
};
|
53
|
+
}
|
54
|
+
|
55
|
+
function controlWindow() {
|
56
|
+
$.deck('showMenu');
|
57
|
+
console.log(window.parent);
|
58
|
+
$(document).bind('deck.change', function (event, from, to) {
|
59
|
+
window.opener.moveToSlide(to);
|
60
|
+
});
|
61
|
+
}
|
62
|
+
|
63
|
+
function presentationWindow() {
|
64
|
+
$(document).bind('keypress', function (e) {
|
65
|
+
// 'c' pressed
|
66
|
+
if (e.charCode == 99) {
|
67
|
+
openControlWindow();
|
68
|
+
}
|
69
|
+
});
|
70
|
+
}
|
71
|
+
|
72
|
+
$(function () {
|
73
|
+
|
74
|
+
$.deck('.slide');
|
75
|
+
|
76
|
+
$.extend(true, $.deck.defaults, {
|
77
|
+
classes:{
|
78
|
+
menu:'deck-menu'
|
79
|
+
},
|
80
|
+
keys:{
|
81
|
+
menu:77 // 'm'
|
82
|
+
}
|
83
|
+
});
|
84
|
+
|
85
|
+
if (window.location.hash == '#controlWindow') {
|
86
|
+
controlWindow();
|
87
|
+
} else {
|
88
|
+
presentationWindow();
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
});
|
93
|
+
</script>
|
94
|
+
|
95
|
+
</body>
|
96
|
+
</html>
|
metadata
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slideshift
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Marek Jelen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: slideshift-static
|
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: kramdown
|
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
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: thor
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: sinatra
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: pygments.rb
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: faraday
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: yajl-ruby
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: SlideShift is modern presentation system
|
127
|
+
email:
|
128
|
+
- marek@jelen.biz
|
129
|
+
executables:
|
130
|
+
- slideshift
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- bin/slideshift
|
135
|
+
- lib/slideshift/tool/cli/default.conf
|
136
|
+
- lib/slideshift/tool/cli/main.rb
|
137
|
+
- lib/slideshift/tool/config.rb
|
138
|
+
- lib/slideshift/tool/presentation.rb
|
139
|
+
- lib/slideshift/tool/render/asciidoc.rb
|
140
|
+
- lib/slideshift/tool/render/markdown.rb
|
141
|
+
- lib/slideshift/tool/render/textile.rb
|
142
|
+
- lib/slideshift/tool/server/server.rb
|
143
|
+
- lib/slideshift/tool/template.erb
|
144
|
+
- lib/slideshift/tool/version.rb
|
145
|
+
- lib/slideshift/tool.rb
|
146
|
+
homepage: http://github.com/marekjelen/slideshift-tool
|
147
|
+
licenses:
|
148
|
+
- Apache2
|
149
|
+
post_install_message:
|
150
|
+
rdoc_options: []
|
151
|
+
require_paths:
|
152
|
+
- lib
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ! '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
none: false
|
161
|
+
requirements:
|
162
|
+
- - ! '>='
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: 1.3.6
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 1.8.24
|
168
|
+
signing_key:
|
169
|
+
specification_version: 3
|
170
|
+
summary: SlideShift CLI tool
|
171
|
+
test_files: []
|
172
|
+
has_rdoc:
|