prez 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/prez +9 -0
- data/lib/prez/assets.rb +83 -0
- data/lib/prez/build.rb +61 -0
- data/lib/prez/cli.rb +35 -0
- data/lib/prez/files.rb +55 -0
- data/lib/prez/version.rb +9 -0
- data/lib/prez.rb +1 -0
- data/templates/new.prez.tt +10 -0
- data/vendor/javascripts/jquery.js +9205 -0
- data/vendor/javascripts/prez.js +53 -0
- data/vendor/stylesheets/prez.css +46 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2249ace5ffb8f6605523aa4604763b57445b4bd3
|
4
|
+
data.tar.gz: 7dba78c2ade67bd68bab76e895057aae7fb8cfed
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e4dc2afb90be92edde3071a9dfef2901fbe7a6e629f3353dec14581b6b11b2e656f0d5b48b40a396e1f0c92a06a1f2e84773a7183cff69bc56fd0d22de98726
|
7
|
+
data.tar.gz: a4888d107c8efb98b12d363a5204ccfe26d838a730a2fb71e48c6d37a7bc9654a35ab11fa24e27f853a563e8a678e210c593c9a321efaa7293f6e7552caf0f5b
|
data/bin/prez
ADDED
data/lib/prez/assets.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require "prez/files"
|
2
|
+
require "sass"
|
3
|
+
require "uglifier"
|
4
|
+
|
5
|
+
module Prez
|
6
|
+
module Assets
|
7
|
+
class Tagged
|
8
|
+
attr_reader :name, :contents
|
9
|
+
|
10
|
+
def initialize(name, options = {})
|
11
|
+
@name = name
|
12
|
+
@contents = Prez::Files.contents name, extension
|
13
|
+
@dev = options.fetch :dev, false
|
14
|
+
end
|
15
|
+
|
16
|
+
def dev?
|
17
|
+
@dev
|
18
|
+
end
|
19
|
+
|
20
|
+
def minified_contents
|
21
|
+
minify contents
|
22
|
+
end
|
23
|
+
|
24
|
+
def minify(contents)
|
25
|
+
contents
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_tag
|
29
|
+
if dev?
|
30
|
+
"#{open}\n#{contents}#{close}"
|
31
|
+
else
|
32
|
+
"#{open}#{minified_contents}#{close}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Javascript < Prez::Assets::Tagged
|
38
|
+
def extension
|
39
|
+
"js"
|
40
|
+
end
|
41
|
+
|
42
|
+
def open
|
43
|
+
%{<script type="text/javascript">}
|
44
|
+
end
|
45
|
+
|
46
|
+
def close
|
47
|
+
%{</script>}
|
48
|
+
end
|
49
|
+
|
50
|
+
def minify(contents)
|
51
|
+
Uglifier.compile contents
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class Stylesheet < Prez::Assets::Tagged
|
56
|
+
def extension
|
57
|
+
"css"
|
58
|
+
end
|
59
|
+
|
60
|
+
def open
|
61
|
+
%{<style type="text/css">}
|
62
|
+
end
|
63
|
+
|
64
|
+
def close
|
65
|
+
%{</style>}
|
66
|
+
end
|
67
|
+
|
68
|
+
def minify(contents)
|
69
|
+
Sass::Engine.new(contents, syntax: :scss, style: :compressed).render
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class << self
|
74
|
+
def javascript(name, options = {})
|
75
|
+
Prez::Assets::Javascript.new(name, options).to_tag
|
76
|
+
end
|
77
|
+
|
78
|
+
def stylesheet(name, options = {})
|
79
|
+
Prez::Assets::Stylesheet.new(name, options).to_tag
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/prez/build.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require "prez/assets"
|
2
|
+
require "thor/actions"
|
3
|
+
require "thor/error"
|
4
|
+
require "thor/group"
|
5
|
+
|
6
|
+
module Prez
|
7
|
+
class Build < Thor::Group
|
8
|
+
include Thor::Actions
|
9
|
+
argument :name, type: :string
|
10
|
+
|
11
|
+
def check_file!
|
12
|
+
if File.exists? name
|
13
|
+
@filename = name
|
14
|
+
elsif File.exists? "#{name}.prez"
|
15
|
+
@filename = "#{name}.prez"
|
16
|
+
else
|
17
|
+
raise Thor::Error.new(set_color("Missing prez file '#{name}'", :red, :bold))
|
18
|
+
end
|
19
|
+
|
20
|
+
if filename =~ /\.html$/
|
21
|
+
raise Thor::Error.new(set_color("Prez file cannot be html file: '#{name}'", :red, :bold))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def generate_html
|
26
|
+
template filename, html_filename
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def base_name
|
32
|
+
filename.sub /\.prez$/, ""
|
33
|
+
end
|
34
|
+
|
35
|
+
def filename
|
36
|
+
@filename
|
37
|
+
end
|
38
|
+
|
39
|
+
def html_filename
|
40
|
+
"#{base_name}.html"
|
41
|
+
end
|
42
|
+
|
43
|
+
def javascript(name)
|
44
|
+
Prez::Assets.javascript name
|
45
|
+
rescue Prez::Files::MissingError
|
46
|
+
raise Thor::Error.new(set_color("Could not find file: '#{name}.js'", :red, :bold))
|
47
|
+
end
|
48
|
+
|
49
|
+
def stylesheet(name)
|
50
|
+
Prez::Assets.stylesheet name
|
51
|
+
rescue Prez::Files::MissingError
|
52
|
+
raise Thor::Error.new(set_color("Could not find file: '#{name}.css'", :red, :bold))
|
53
|
+
end
|
54
|
+
|
55
|
+
class << self
|
56
|
+
def source_root
|
57
|
+
File.expand_path "."
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/prez/cli.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require "prez/build"
|
2
|
+
require "prez/version"
|
3
|
+
require "thor"
|
4
|
+
require "thor/actions"
|
5
|
+
|
6
|
+
module Prez
|
7
|
+
class CLI < Thor
|
8
|
+
include Thor::Actions
|
9
|
+
register Prez::Build, "build", "build NAME", "Builds the single html presentation from the prez file"
|
10
|
+
|
11
|
+
map "-v" => "version"
|
12
|
+
|
13
|
+
desc "new NAME", "Generates a new presentation"
|
14
|
+
def new(name)
|
15
|
+
template "new.prez.tt", "#{name}.prez"
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "version", "Show the prez version"
|
19
|
+
long_desc "
|
20
|
+
This can be optionally used as 'prez -v'"
|
21
|
+
def version
|
22
|
+
say Prez::Version
|
23
|
+
end
|
24
|
+
|
25
|
+
class << self
|
26
|
+
def exit_on_failure?
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
def source_root
|
31
|
+
File.absolute_path File.expand_path("../../../templates", __FILE__)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/prez/files.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module Prez
|
2
|
+
module Files
|
3
|
+
class MissingError < StandardError
|
4
|
+
def initialize(name, extension)
|
5
|
+
super "Could not find file name '#{name}' with extension '#{extension}'"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class Paths
|
10
|
+
attr_reader :extension, :paths
|
11
|
+
|
12
|
+
def initialize(extension, dirname)
|
13
|
+
@extension = extension
|
14
|
+
|
15
|
+
@paths = [].tap do |paths|
|
16
|
+
paths << File.expand_path(".")
|
17
|
+
paths << File.expand_path(File.join(".", dirname))
|
18
|
+
paths << File.expand_path(File.join("../../../vendor", dirname), __FILE__)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def find(name)
|
23
|
+
paths.each do |path|
|
24
|
+
file = File.join path, "#{name}.#{extension}"
|
25
|
+
|
26
|
+
if File.exists?(file)
|
27
|
+
return file
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
raise Prez::Files::MissingError.new(name, extension)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class << self
|
36
|
+
SEARCH_PATHS = {
|
37
|
+
"js" => Prez::Files::Paths.new("js", "javascripts"),
|
38
|
+
"css" => Prez::Files::Paths.new("css", "stylesheets")
|
39
|
+
}
|
40
|
+
|
41
|
+
def contents(name, extension)
|
42
|
+
file = find name, extension
|
43
|
+
File.read file
|
44
|
+
end
|
45
|
+
|
46
|
+
def find(name, extension)
|
47
|
+
unless SEARCH_PATHS[extension]
|
48
|
+
raise Prez::Files::MissingError.new(name, extension)
|
49
|
+
end
|
50
|
+
|
51
|
+
SEARCH_PATHS[extension].find name
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/prez/version.rb
ADDED
data/lib/prez.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "prez/version"
|