deckr 0.1.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.
- data/Gemfile +7 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +9 -0
- data/bin/deckr +3 -0
- data/lib/deckr.rb +7 -0
- data/lib/deckr/cli.rb +22 -0
- data/lib/deckr/deck.rb +64 -0
- data/lib/deckr/package.rb +22 -0
- data/lib/deckr/resource.rb +37 -0
- data/lib/deckr/templates/Gemfile +5 -0
- data/lib/deckr/templates/config.ru +12 -0
- data/lib/deckr/templates/deck/GPL-license.txt +278 -0
- data/lib/deckr/templates/deck/MIT-license.txt +21 -0
- data/lib/deckr/templates/deck/README.md +64 -0
- data/lib/deckr/templates/deck/boilerplate.html +96 -0
- data/lib/deckr/templates/deck/core/deck.core.css +407 -0
- data/lib/deckr/templates/deck/core/deck.core.js +498 -0
- data/lib/deckr/templates/deck/core/deck.core.scss +450 -0
- data/lib/deckr/templates/deck/extensions/goto/deck.goto.css +41 -0
- data/lib/deckr/templates/deck/extensions/goto/deck.goto.html +7 -0
- data/lib/deckr/templates/deck/extensions/goto/deck.goto.js +170 -0
- data/lib/deckr/templates/deck/extensions/goto/deck.goto.scss +46 -0
- data/lib/deckr/templates/deck/extensions/hash/deck.hash.css +13 -0
- data/lib/deckr/templates/deck/extensions/hash/deck.hash.html +2 -0
- data/lib/deckr/templates/deck/extensions/hash/deck.hash.js +142 -0
- data/lib/deckr/templates/deck/extensions/hash/deck.hash.scss +15 -0
- data/lib/deckr/templates/deck/extensions/menu/deck.menu.css +47 -0
- data/lib/deckr/templates/deck/extensions/menu/deck.menu.js +187 -0
- data/lib/deckr/templates/deck/extensions/menu/deck.menu.scss +58 -0
- data/lib/deckr/templates/deck/extensions/navigation/deck.navigation.css +43 -0
- data/lib/deckr/templates/deck/extensions/navigation/deck.navigation.html +3 -0
- data/lib/deckr/templates/deck/extensions/navigation/deck.navigation.js +92 -0
- data/lib/deckr/templates/deck/extensions/navigation/deck.navigation.scss +56 -0
- data/lib/deckr/templates/deck/extensions/scale/deck.scale.css +28 -0
- data/lib/deckr/templates/deck/extensions/scale/deck.scale.js +170 -0
- data/lib/deckr/templates/deck/extensions/scale/deck.scale.scss +31 -0
- data/lib/deckr/templates/deck/extensions/status/deck.status.css +18 -0
- data/lib/deckr/templates/deck/extensions/status/deck.status.html +6 -0
- data/lib/deckr/templates/deck/extensions/status/deck.status.js +95 -0
- data/lib/deckr/templates/deck/extensions/status/deck.status.scss +22 -0
- data/lib/deckr/templates/deck/introduction/index.html +215 -0
- data/lib/deckr/templates/deck/jquery-1.7.2.min.js +4 -0
- data/lib/deckr/templates/deck/modernizr.custom.js +4 -0
- data/lib/deckr/templates/deck/test/fixtures/complex.html +24 -0
- data/lib/deckr/templates/deck/test/fixtures/empty.html +19 -0
- data/lib/deckr/templates/deck/test/fixtures/iframe_simple.html +10 -0
- data/lib/deckr/templates/deck/test/fixtures/iframes.html +32 -0
- data/lib/deckr/templates/deck/test/fixtures/nesteds.html +36 -0
- data/lib/deckr/templates/deck/test/fixtures/standard.html +42 -0
- data/lib/deckr/templates/deck/test/index.html +39 -0
- data/lib/deckr/templates/deck/test/lib/jasmine-html.js +190 -0
- data/lib/deckr/templates/deck/test/lib/jasmine-jquery.js +288 -0
- data/lib/deckr/templates/deck/test/lib/jasmine.css +166 -0
- data/lib/deckr/templates/deck/test/lib/jasmine.js +2477 -0
- data/lib/deckr/templates/deck/test/settings.js +3 -0
- data/lib/deckr/templates/deck/test/spec.core.js +436 -0
- data/lib/deckr/templates/deck/test/spec.goto.js +142 -0
- data/lib/deckr/templates/deck/test/spec.hash.js +81 -0
- data/lib/deckr/templates/deck/test/spec.menu.js +66 -0
- data/lib/deckr/templates/deck/test/spec.navigation.js +51 -0
- data/lib/deckr/templates/deck/test/spec.scale.js +57 -0
- data/lib/deckr/templates/deck/test/spec.status.js +58 -0
- data/lib/deckr/templates/deck/themes/style/neon.css +123 -0
- data/lib/deckr/templates/deck/themes/style/neon.scss +155 -0
- data/lib/deckr/templates/deck/themes/style/swiss.css +84 -0
- data/lib/deckr/templates/deck/themes/style/swiss.scss +107 -0
- data/lib/deckr/templates/deck/themes/style/web-2.0.css +214 -0
- data/lib/deckr/templates/deck/themes/style/web-2.0.scss +250 -0
- data/lib/deckr/templates/deck/themes/transition/fade.css +43 -0
- data/lib/deckr/templates/deck/themes/transition/fade.scss +69 -0
- data/lib/deckr/templates/deck/themes/transition/horizontal-slide.css +76 -0
- data/lib/deckr/templates/deck/themes/transition/horizontal-slide.scss +90 -0
- data/lib/deckr/templates/deck/themes/transition/vertical-slide.css +94 -0
- data/lib/deckr/templates/deck/themes/transition/vertical-slide.scss +112 -0
- data/lib/deckr/templates/views/index.slim +13 -0
- data/lib/deckr/templates/views/layout.slim +48 -0
- data/lib/deckr/version.rb +3 -0
- data/lib/rack/deckr.rb +31 -0
- data/lib/sinatra/deckr.rb +17 -0
- data/spec/deck_spec.rb +118 -0
- data/spec/fixtures/foo.txt +1 -0
- data/spec/fixtures/foo/bar.txt +1 -0
- data/spec/package_spec.rb +45 -0
- data/spec/rack/deckr_spec.rb +38 -0
- data/spec/resource_spec.rb +62 -0
- data/spec/sinatra/deckr_spec.rb +32 -0
- data/spec/spec_helper.rb +27 -0
- metadata +161 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
doctype html
|
2
|
+
html
|
3
|
+
head
|
4
|
+
meta charset="utf-8"
|
5
|
+
meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"
|
6
|
+
meta name="viewport" content="width=1024, user-scalable=no"
|
7
|
+
|
8
|
+
title = @title || "Presentation"
|
9
|
+
|
10
|
+
/ Required stylesheet
|
11
|
+
link rel="stylesheet" type="text/css" href="#{{deck.core.css.url}}"
|
12
|
+
|
13
|
+
/ Extension CSS files
|
14
|
+
- deck.extensions.each do |extension|
|
15
|
+
- if extension.css.exist?
|
16
|
+
link rel="stylesheet" type="text/css" href="#{{extension.css.url}}"
|
17
|
+
|
18
|
+
/ Style theme
|
19
|
+
- if deck.style
|
20
|
+
link rel="stylesheet" type="text/css" href="#{{deck.style.url}}"
|
21
|
+
|
22
|
+
/ Transition theme
|
23
|
+
- if deck.transition
|
24
|
+
link rel="stylesheet" type="text/css" href="#{{deck.transition.url}}"
|
25
|
+
|
26
|
+
/ Required Modernizr file
|
27
|
+
script type="text/javascript" src="#{{deck.resource('modernizr.custom.js').url}}"
|
28
|
+
|
29
|
+
body.deck-container
|
30
|
+
/ Your presentation
|
31
|
+
== yield
|
32
|
+
|
33
|
+
/ Extension snippets
|
34
|
+
- deck.extensions.each do |extension|
|
35
|
+
== extension.html.content
|
36
|
+
|
37
|
+
/ Required JS files
|
38
|
+
script type="text/javascript" src="#{{deck.resource('jquery-1.7.2.min.js').url}}"
|
39
|
+
script type="text/javascript" src="#{{deck.core.js.url}}"
|
40
|
+
|
41
|
+
/ Extension JS files
|
42
|
+
- deck.extensions.each do |extension|
|
43
|
+
- if extension.js.exist?
|
44
|
+
script type="text/javascript" src="#{{extension.js.url}}"
|
45
|
+
|
46
|
+
/ Initialize the deck
|
47
|
+
javascript:
|
48
|
+
jQuery(function($) { $.deck('.slide') });
|
data/lib/rack/deckr.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "deckr"
|
2
|
+
require "pathname"
|
3
|
+
|
4
|
+
module Rack
|
5
|
+
class Deckr
|
6
|
+
F = ::File
|
7
|
+
|
8
|
+
def initialize(app, opts={})
|
9
|
+
@app = app
|
10
|
+
@url = opts[:url] || "/deck"
|
11
|
+
@path = opts[:path] || F.join(Dir.pwd, "deck")
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
env["deckr.deck"] = ::Deckr::Deck.new(@url, @path)
|
16
|
+
|
17
|
+
path = env["PATH_INFO"]
|
18
|
+
|
19
|
+
return @app.call(env) unless path.start_with?(@url)
|
20
|
+
|
21
|
+
path = Pathname(path).relative_path_from(Pathname(@url))
|
22
|
+
path = F.expand_path(F.join(@path, path))
|
23
|
+
|
24
|
+
return @app.call(env) unless path.start_with?(@path) && F.file?(path)
|
25
|
+
|
26
|
+
file = Rack::File.new(@path)
|
27
|
+
file.path = path
|
28
|
+
file.serving(env)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/deck_spec.rb
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Deckr::Deck do
|
4
|
+
before do
|
5
|
+
@deck = Deckr::Deck.new("/deck", deck_path)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe ".new" do
|
9
|
+
subject { @deck }
|
10
|
+
its(:parent) { should be_nil }
|
11
|
+
its(:url) { should == "/deck" }
|
12
|
+
its(:path) { should == deck_path }
|
13
|
+
its(:name) { should == @deck.path }
|
14
|
+
its(:extensions) { should be_empty }
|
15
|
+
its(:style) { should be_nil }
|
16
|
+
its(:transition) { should be_nil }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#resource" do
|
20
|
+
subject { @deck.resource("foo") }
|
21
|
+
it { should be_kind_of(Deckr::Resource) }
|
22
|
+
its(:parent) { should == @deck }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#package" do
|
26
|
+
subject { @deck.package("foo") }
|
27
|
+
it { should be_kind_of(Deckr::Package) }
|
28
|
+
its(:parent) { should == @deck }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#core" do
|
32
|
+
subject { @deck.core }
|
33
|
+
it { should == @deck.package("core") }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#style" do
|
37
|
+
context "given a style name" do
|
38
|
+
subject { @deck.style "foo" }
|
39
|
+
it { should == @deck.resource("themes/style/foo.css") }
|
40
|
+
end
|
41
|
+
|
42
|
+
context "given nil" do
|
43
|
+
subject { @deck.style nil }
|
44
|
+
it { should == nil }
|
45
|
+
end
|
46
|
+
|
47
|
+
context "given false" do
|
48
|
+
subject { @deck.style false }
|
49
|
+
it { should == false }
|
50
|
+
end
|
51
|
+
|
52
|
+
context "given no arguments" do
|
53
|
+
it "returns a specified style" do
|
54
|
+
@deck.style "foo"
|
55
|
+
@deck.style.should == @deck.resource("themes/style/foo.css")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#transition" do
|
61
|
+
context "given a transition name" do
|
62
|
+
subject { @deck.transition "foo" }
|
63
|
+
it { should == @deck.resource("themes/transition/foo.css") }
|
64
|
+
end
|
65
|
+
|
66
|
+
context "given nil" do
|
67
|
+
subject { @deck.transition nil }
|
68
|
+
it { should == nil }
|
69
|
+
end
|
70
|
+
|
71
|
+
context "given false" do
|
72
|
+
subject { @deck.transition false }
|
73
|
+
it { should == false }
|
74
|
+
end
|
75
|
+
|
76
|
+
context "given no arguments" do
|
77
|
+
it "returns a specified transition" do
|
78
|
+
@deck.transition "foo"
|
79
|
+
@deck.transition.should == @deck.resource("themes/transition/foo.css")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#enable" do
|
85
|
+
before { @deck.enable "foo", "bar", "foo" }
|
86
|
+
subject { @deck.extensions }
|
87
|
+
it { should have(2).items }
|
88
|
+
its([0]) { should == @deck.package("extensions/foo") }
|
89
|
+
its([1]) { should == @deck.package("extensions/bar") }
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#disable" do
|
93
|
+
before do
|
94
|
+
@deck.enable "foo", "bar", "baz"
|
95
|
+
@deck.disable "foo", "baz"
|
96
|
+
end
|
97
|
+
subject { @deck.extensions }
|
98
|
+
it { should have(1).items }
|
99
|
+
its([0]) { should == @deck.package("extensions/bar") }
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#exist?" do
|
103
|
+
context "when directory exists" do
|
104
|
+
subject { @deck.exist? }
|
105
|
+
it { should be_true }
|
106
|
+
end
|
107
|
+
|
108
|
+
context "when directory doesn't exist" do
|
109
|
+
subject { Deckr::Package.new(fixtures, "bar").exist? }
|
110
|
+
it { should be_false }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "#content" do
|
115
|
+
subject { @deck.content }
|
116
|
+
it { should be_empty }
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
FOO
|
@@ -0,0 +1 @@
|
|
1
|
+
BAR
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Deckr::Package do
|
4
|
+
before do
|
5
|
+
@package = Deckr::Package.new(fixtures, "foo/bar/baz")
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#resource" do
|
9
|
+
subject { @package.resource("foo.txt") }
|
10
|
+
it { should be_kind_of(Deckr::Resource) }
|
11
|
+
its(:parent) { should == @package }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#js" do
|
15
|
+
subject { @package.js }
|
16
|
+
it { should == @package.resource("deck.baz.js") }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#css" do
|
20
|
+
subject { @package.css }
|
21
|
+
it { should == @package.resource("deck.baz.css") }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#html" do
|
25
|
+
subject { @package.html }
|
26
|
+
it { should == @package.resource("deck.baz.html") }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#exist?" do
|
30
|
+
context "when directory exists" do
|
31
|
+
subject { Deckr::Package.new(fixtures, "foo").exist? }
|
32
|
+
it { should be_true }
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when directory does't exist" do
|
36
|
+
subject { Deckr::Package.new(fixtures, "bar").exist? }
|
37
|
+
it { should be_false }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#content" do
|
42
|
+
subject { @package.content }
|
43
|
+
it { should be_empty }
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Rack::Deckr do
|
4
|
+
before do
|
5
|
+
p = deck_path
|
6
|
+
mock_app do
|
7
|
+
use Rack::Deckr, :url => "/hoge", :path => p
|
8
|
+
not_found { "chained" }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "env" do
|
13
|
+
before { get "/" }
|
14
|
+
subject { last_request.env["deckr.deck"] }
|
15
|
+
it { should be_kind_of(Deckr::Deck) }
|
16
|
+
its(:url) { should == "/hoge" }
|
17
|
+
its(:path) { should == deck_path }
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when requested file exists" do
|
21
|
+
before { get "/hoge/core/deck.core.js" }
|
22
|
+
subject { last_response }
|
23
|
+
its(:body) { should =~ /^\/\*!\nDeck JS - deck.core/m }
|
24
|
+
its(:body) { should =~ /\}\)\(jQuery, 'deck', document\);\n$/m }
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when requested file doesn't exist" do
|
28
|
+
before { get "/deck/foo" }
|
29
|
+
subject { last_response }
|
30
|
+
its(:body) { should == "chained" }
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when requested url isn't known" do
|
34
|
+
before { get "/hello" }
|
35
|
+
subject { last_response }
|
36
|
+
its(:body) { should == "chained" }
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Deckr::Resource do
|
4
|
+
before do
|
5
|
+
@resource = Deckr::Resource.new(fixtures, "foo.txt")
|
6
|
+
end
|
7
|
+
|
8
|
+
describe ".new" do
|
9
|
+
subject { @resource }
|
10
|
+
its(:parent) { should == fixtures }
|
11
|
+
its(:name) { should == "foo.txt" }
|
12
|
+
its(:url) { should == File.join(fixtures.url, "foo.txt") }
|
13
|
+
its(:path) { should == File.join(fixtures.path, "foo.txt") }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#exist?" do
|
17
|
+
context "when file exists" do
|
18
|
+
subject { @resource.exist? }
|
19
|
+
it { should be_true }
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when file does't exist" do
|
23
|
+
subject { Deckr::Resource.new(fixtures, "bar.txt").exist? }
|
24
|
+
it { should be_false }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#content" do
|
29
|
+
context "when file exists" do
|
30
|
+
subject { @resource.content }
|
31
|
+
it { should == File.read(@resource.path) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when file does't exist" do
|
35
|
+
subject { Deckr::Resource.new(fixtures, "bar.txt").content }
|
36
|
+
it { should be_empty }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#==" do
|
41
|
+
context "given object that does't respond to #parent, #url and #path" do
|
42
|
+
subject { @resource == Object.new }
|
43
|
+
it { should be_false }
|
44
|
+
end
|
45
|
+
|
46
|
+
context "given different resource" do
|
47
|
+
subject do
|
48
|
+
@resource ==
|
49
|
+
double(:parent => @resource.parent, :url => "foo", :path => "bar")
|
50
|
+
end
|
51
|
+
it { should be_false }
|
52
|
+
end
|
53
|
+
|
54
|
+
context "given same resource" do
|
55
|
+
subject do
|
56
|
+
@resource ==
|
57
|
+
double(:parent => @resource.parent, :url => @resource.url, :path => @resource.path)
|
58
|
+
end
|
59
|
+
it { should be_true }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Sinatra::Deckr do
|
4
|
+
context "when application uses Rack::Deckr" do
|
5
|
+
before do
|
6
|
+
mock_app do
|
7
|
+
register Sinatra::Deckr
|
8
|
+
use Rack::Deckr
|
9
|
+
get "/" do
|
10
|
+
"#{deck != nil && deck == request.env['deckr.deck']}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
get "/"
|
14
|
+
end
|
15
|
+
subject { last_response.body }
|
16
|
+
it { should == "true" }
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when application doesn't use Rack::Deckr" do
|
20
|
+
before do
|
21
|
+
mock_app do
|
22
|
+
register Sinatra::Deckr
|
23
|
+
get "/" do
|
24
|
+
"#{deck == nil}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
get "/"
|
28
|
+
end
|
29
|
+
subject { last_response.body }
|
30
|
+
it { should == "true" }
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "deckr"
|
2
|
+
require "rack/deckr"
|
3
|
+
require "sinatra/deckr"
|
4
|
+
|
5
|
+
require "rack/test"
|
6
|
+
|
7
|
+
module SpecHelper
|
8
|
+
attr_reader :app
|
9
|
+
|
10
|
+
def mock_app(base=Sinatra::Base, &block)
|
11
|
+
@app = Sinatra.new(base, &block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def deck_path
|
15
|
+
File.expand_path("../../lib/deckr/templates/deck", __FILE__)
|
16
|
+
end
|
17
|
+
|
18
|
+
def fixtures
|
19
|
+
@fixtures ||= double("fixtures",
|
20
|
+
:url => "/fixtures", :path => File.expand_path("../fixtures", __FILE__))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
RSpec.configure do |c|
|
25
|
+
c.include Rack::Test::Methods
|
26
|
+
c.include SpecHelper
|
27
|
+
end
|