parade 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +21 -0
- data/README.md +542 -0
- data/Rakefile +15 -0
- data/bin/parade +138 -0
- data/lib/parade.rb +43 -0
- data/lib/parade/commands/commands.rb +84 -0
- data/lib/parade/commands/generate_outline.rb +34 -0
- data/lib/parade/commands/generate_presentation.rb +34 -0
- data/lib/parade/commands/generate_rackup.rb +32 -0
- data/lib/parade/commands/html_output.rb +47 -0
- data/lib/parade/commands/render_from_template.rb +50 -0
- data/lib/parade/commands/static_html.rb +38 -0
- data/lib/parade/commands/static_pdf.rb +39 -0
- data/lib/parade/commands/unknown.rb +23 -0
- data/lib/parade/features/live_ruby.rb +18 -0
- data/lib/parade/features/pdf_presentation.rb +24 -0
- data/lib/parade/features/preshow.rb +11 -0
- data/lib/parade/helpers/encode_image.rb +24 -0
- data/lib/parade/helpers/template_generator.rb +130 -0
- data/lib/parade/metadata.rb +73 -0
- data/lib/parade/metadata/assignment.rb +38 -0
- data/lib/parade/metadata/css_classes.rb +22 -0
- data/lib/parade/metadata/html_id.rb +35 -0
- data/lib/parade/metadata/template.rb +31 -0
- data/lib/parade/parsers/dsl.rb +138 -0
- data/lib/parade/parsers/dsl_file_parser.rb +17 -0
- data/lib/parade/parsers/json_file_parser.rb +67 -0
- data/lib/parade/parsers/markdown_image_paths.rb +44 -0
- data/lib/parade/parsers/markdown_slide_splitter.rb +63 -0
- data/lib/parade/parsers/presentation_directory_parser.rb +36 -0
- data/lib/parade/parsers/presentation_file_parser.rb +27 -0
- data/lib/parade/parsers/presentation_filepath_parser.rb +35 -0
- data/lib/parade/parsers/slides_file_content_parser.rb +27 -0
- data/lib/parade/renderers/columns_renderer.rb +68 -0
- data/lib/parade/renderers/command_line_renderer.rb +142 -0
- data/lib/parade/renderers/html_with_pygments.rb +42 -0
- data/lib/parade/renderers/inline_images.rb +31 -0
- data/lib/parade/renderers/special_paragraph_renderer.rb +23 -0
- data/lib/parade/renderers/update_image_paths.rb +75 -0
- data/lib/parade/section.rb +183 -0
- data/lib/parade/server.rb +139 -0
- data/lib/parade/slide.rb +128 -0
- data/lib/parade/version.rb +3 -0
- data/lib/public/css/960.css +653 -0
- data/lib/public/css/fg.menu.css +114 -0
- data/lib/public/css/ghf_marked.css +180 -0
- data/lib/public/css/jquery-terminal.css +73 -0
- data/lib/public/css/onepage.css +62 -0
- data/lib/public/css/parade.css +450 -0
- data/lib/public/css/pdf.css +13 -0
- data/lib/public/css/reset.css +53 -0
- data/lib/public/css/spinner_bar.gif +0 -0
- data/lib/public/css/theme/images/ui-bg_diagonals-small_100_f0efea_40x40.png +0 -0
- data/lib/public/css/theme/images/ui-bg_flat_35_f0f0f0_40x100.png +0 -0
- data/lib/public/css/theme/images/ui-bg_glass_55_fcf0ba_1x400.png +0 -0
- data/lib/public/css/theme/images/ui-bg_glow-ball_25_2e2e28_600x600.png +0 -0
- data/lib/public/css/theme/images/ui-bg_highlight-soft_100_f0efea_1x100.png +0 -0
- data/lib/public/css/theme/images/ui-bg_highlight-soft_25_327E04_1x100.png +0 -0
- data/lib/public/css/theme/images/ui-bg_highlight-soft_25_5A9D1A_1x100.png +0 -0
- data/lib/public/css/theme/images/ui-bg_highlight-soft_95_ffedad_1x100.png +0 -0
- data/lib/public/css/theme/images/ui-bg_inset-soft_22_3b3b35_1x100.png +0 -0
- data/lib/public/css/theme/images/ui-icons_808080_256x240.png +0 -0
- data/lib/public/css/theme/images/ui-icons_8DC262_256x240.png +0 -0
- data/lib/public/css/theme/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/public/css/theme/images/ui-icons_e7e6e4_256x240.png +0 -0
- data/lib/public/css/theme/images/ui-icons_eeeeee_256x240.png +0 -0
- data/lib/public/css/theme/images/ui-icons_ffffff_256x240.png +0 -0
- data/lib/public/css/theme/ui.accordion.css +9 -0
- data/lib/public/css/theme/ui.all.css +2 -0
- data/lib/public/css/theme/ui.base.css +9 -0
- data/lib/public/css/theme/ui.core.css +37 -0
- data/lib/public/css/theme/ui.datepicker.css +62 -0
- data/lib/public/css/theme/ui.dialog.css +13 -0
- data/lib/public/css/theme/ui.progressbar.css +4 -0
- data/lib/public/css/theme/ui.resizable.css +13 -0
- data/lib/public/css/theme/ui.slider.css +17 -0
- data/lib/public/css/theme/ui.tabs.css +9 -0
- data/lib/public/css/theme/ui.theme.css +245 -0
- data/lib/public/favicon.ico +0 -0
- data/lib/public/js/coffee-script.js +8 -0
- data/lib/public/js/fg.menu.js +645 -0
- data/lib/public/js/jTypeWriter.js +26 -0
- data/lib/public/js/jquery-1.4.2.js +6240 -0
- data/lib/public/js/jquery-print.js +109 -0
- data/lib/public/js/jquery-pubsub.js +27 -0
- data/lib/public/js/jquery-terminal.js +2712 -0
- data/lib/public/js/jquery.batchImageLoad.js +56 -0
- data/lib/public/js/jquery.cycle.all.js +1284 -0
- data/lib/public/js/keyboard.js +733 -0
- data/lib/public/js/parade-code-execution.js +122 -0
- data/lib/public/js/parade-command-input.js +16 -0
- data/lib/public/js/parade-command-visor.js +92 -0
- data/lib/public/js/parade-keyboard-input.js +54 -0
- data/lib/public/js/parade.js +675 -0
- data/lib/public/js/spine.js +904 -0
- data/lib/templates/config.ru.erb +4 -0
- data/lib/templates/showoff.erb +27 -0
- data/lib/templates/slides.md.erb +25 -0
- data/lib/views/header.erb +73 -0
- data/lib/views/index.erb +53 -0
- data/lib/views/inline_css.erb +3 -0
- data/lib/views/inline_js.erb +3 -0
- data/lib/views/onepage.erb +17 -0
- data/lib/views/pdf.erb +17 -0
- data/lib/views/slide.erb +5 -0
- metadata +317 -0
data/Rakefile
ADDED
data/bin/parade
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require 'parade'
|
5
|
+
require 'parade/version'
|
6
|
+
require 'parade/commands/commands'
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
require 'gli'
|
10
|
+
|
11
|
+
include GLI
|
12
|
+
|
13
|
+
version Parade::VERSION
|
14
|
+
|
15
|
+
desc 'Generate assets (e.g. sections or slides) for your presentation'
|
16
|
+
arg_name 'asset_name'
|
17
|
+
long_desc "#{Parade::Commands.generators.map {|k,v| "#{k} - #{v.description}" }.join("\n\n")}"
|
18
|
+
command [:g,:gen,:generate] do |c|
|
19
|
+
|
20
|
+
c.desc "Force creation of the asset, even if one already exists with a similar name"
|
21
|
+
c.switch [:f, :force]
|
22
|
+
|
23
|
+
c.action do |global,local,args|
|
24
|
+
|
25
|
+
asset_name = args.shift
|
26
|
+
key_value_args = args.map {|arg| key, value = arg.split(/:|=/) ; [ key, value ] }.flatten
|
27
|
+
parsed_arguments = Hash[*key_value_args]
|
28
|
+
all_parameters = global.merge(local).merge(parsed_arguments)
|
29
|
+
|
30
|
+
Parade::Commands.execute(:generator,asset_name,all_parameters) if asset_name
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Serves the parade presentation in the specified (or current) directory'
|
36
|
+
arg_name "[pres_dir]"
|
37
|
+
default_value "."
|
38
|
+
command [:s,:serve,:server] do |c|
|
39
|
+
|
40
|
+
c.desc 'Show verbose messaging'
|
41
|
+
c.switch :verbose
|
42
|
+
|
43
|
+
c.desc 'Port on which to run'
|
44
|
+
c.default_value "9090"
|
45
|
+
c.flag [:p,:port]
|
46
|
+
|
47
|
+
c.desc 'Host or ip to run on'
|
48
|
+
c.default_value "localhost"
|
49
|
+
c.flag [:h,:host]
|
50
|
+
|
51
|
+
c.action do |global_options,options,args|
|
52
|
+
|
53
|
+
url = "http://#{options[:h]}:#{options[:p].to_i}"
|
54
|
+
puts "
|
55
|
+
-------------------------
|
56
|
+
|
57
|
+
Your Parade presentation is now starting up.
|
58
|
+
|
59
|
+
To view it plainly, visit [ #{url} ]
|
60
|
+
|
61
|
+
-------------------------
|
62
|
+
|
63
|
+
"
|
64
|
+
presentation_filepath = args[0]
|
65
|
+
|
66
|
+
unless File.directory?(presentation_filepath)
|
67
|
+
filename = File.basename(presentation_filepath)
|
68
|
+
presentation_filepath = File.dirname(presentation_filepath)
|
69
|
+
end
|
70
|
+
|
71
|
+
Parade::Server.run! :host => options[:h],
|
72
|
+
:port => options[:p].to_i,
|
73
|
+
:presentation_directory => presentation_filepath,
|
74
|
+
:presentation_file => filename,
|
75
|
+
:verbose => options[:verbose]
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
desc 'Output the presentation in a particular format'
|
81
|
+
arg_name 'format_type'
|
82
|
+
arg_name '[pres_dir]'
|
83
|
+
long_desc "#{Parade::Commands.statics.map {|k,v| "#{k} - #{v.description}" }.join("\n\n")}"
|
84
|
+
command [:static] do |c|
|
85
|
+
|
86
|
+
c.desc "Force creation of the asset, even if one already exists with a similar name"
|
87
|
+
c.switch [:f, :force]
|
88
|
+
|
89
|
+
c.action do |global,local,args|
|
90
|
+
|
91
|
+
format_type = args.shift
|
92
|
+
presentation_filepath = args.shift || "."
|
93
|
+
|
94
|
+
unless File.directory?(presentation_filepath)
|
95
|
+
filename = File.basename(presentation_filepath)
|
96
|
+
presentation_filepath = File.dirname(presentation_filepath)
|
97
|
+
end
|
98
|
+
|
99
|
+
key_value_args = args.map {|arg| key, value = arg.split(/:|=/) ; [ key, value ] }.flatten
|
100
|
+
parsed_arguments = Hash[*key_value_args]
|
101
|
+
all_parameters = global.merge(local).merge(parsed_arguments)
|
102
|
+
|
103
|
+
all_parameters.merge!('filepath' => presentation_filepath, 'parade_file' => filename)
|
104
|
+
Parade::Commands.execute(:static,format_type,all_parameters) if format_type
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
pre do |global,command,options,args|
|
110
|
+
# Pre logic here
|
111
|
+
# Return true to proceed; false to abourt and not call the
|
112
|
+
# chosen command
|
113
|
+
true
|
114
|
+
end
|
115
|
+
|
116
|
+
post do |global,command,options,args|
|
117
|
+
# Post logic here
|
118
|
+
end
|
119
|
+
|
120
|
+
on_error do |exception|
|
121
|
+
# Error logic here
|
122
|
+
# return false to skip default error handling
|
123
|
+
true
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
# To allow an easier command-line to launch parade, the following format
|
128
|
+
#
|
129
|
+
# `parade` is converted to `parade server .`
|
130
|
+
# `parade [directoryname] is convereted `parade server [directoryname]`
|
131
|
+
#
|
132
|
+
|
133
|
+
parameters = ARGV
|
134
|
+
|
135
|
+
parameters = [ "server", "." ] if parameters.empty?
|
136
|
+
parameters.unshift "server" if parameters.count == 1
|
137
|
+
|
138
|
+
exit GLI.run(parameters)
|
data/lib/parade.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'json'
|
4
|
+
require 'nokogiri'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'logger'
|
7
|
+
require 'tilt'
|
8
|
+
require 'css_parser'
|
9
|
+
|
10
|
+
begin
|
11
|
+
require 'RMagick'
|
12
|
+
rescue LoadError
|
13
|
+
$stderr.puts %{
|
14
|
+
--------------------------------------------------------------------------------
|
15
|
+
Please install RMagick:
|
16
|
+
|
17
|
+
$ gem install rmagick
|
18
|
+
|
19
|
+
RMagick is required for:
|
20
|
+
|
21
|
+
* Static output to ensure images are included with the documents
|
22
|
+
* Web rendering, auto-re-sizing of images
|
23
|
+
--------------------------------------------------------------------------------
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
begin
|
28
|
+
require 'pdfkit'
|
29
|
+
rescue LoadError
|
30
|
+
$stderr.puts %{
|
31
|
+
--------------------------------------------------------------------------------
|
32
|
+
Please install PDFKit and wkhtmltopdf-binary:
|
33
|
+
|
34
|
+
$ gem install pdfkit
|
35
|
+
$ gem install wkhtmltopdf-binary
|
36
|
+
|
37
|
+
PDFKit and wkhtmltopdf-binary are required to provide PDF output
|
38
|
+
--------------------------------------------------------------------------------
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
require_relative 'parade/helpers/encode_image'
|
43
|
+
require_relative 'parade/server'
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require_relative 'render_from_template'
|
2
|
+
|
3
|
+
require_relative 'static_html'
|
4
|
+
require_relative 'static_pdf'
|
5
|
+
require_relative 'unknown'
|
6
|
+
require_relative 'generate_presentation'
|
7
|
+
require_relative 'generate_outline'
|
8
|
+
require_relative 'generate_rackup'
|
9
|
+
|
10
|
+
|
11
|
+
module Parade
|
12
|
+
|
13
|
+
#
|
14
|
+
# Commands is a module that contains commands to be used through the
|
15
|
+
# bin/parade utility. This module defines a number of helper methods to
|
16
|
+
# define generator and static content output formats.
|
17
|
+
#
|
18
|
+
module Commands
|
19
|
+
|
20
|
+
# @return [Hash] an empty command hash with the default, when a command is
|
21
|
+
# not found, to return the Unknown command.
|
22
|
+
def self.commands_with_unknown_default
|
23
|
+
command_hash = {}
|
24
|
+
command_hash.default = Unknown.new
|
25
|
+
command_hash
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Hash] a hash that contains all the avaliable static output commands
|
29
|
+
def self.statics
|
30
|
+
@statics ||= commands_with_unknown_default
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [Hash] a hash that contains all the avaliable generator commands
|
34
|
+
def self.generators
|
35
|
+
@generators ||= commands_with_unknown_default
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# @param [String,Symbol] type the type of command (e.g. statics or generators)
|
40
|
+
# @param [String] name the name which the command can be accessed
|
41
|
+
# @param [Object#description,Object#generate] command the command itself, which
|
42
|
+
# adheres to the two methods {#description} and {#generate}
|
43
|
+
#
|
44
|
+
def self.commands(type,name,command=nil)
|
45
|
+
command_set = send(type)
|
46
|
+
if command
|
47
|
+
command_set[name] = command
|
48
|
+
else
|
49
|
+
command_set[name]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Find or create a static output command. Creates a static output entry
|
54
|
+
# if the command is provided.
|
55
|
+
def self.static(name,command=nil)
|
56
|
+
commands :statics, name, command
|
57
|
+
end
|
58
|
+
|
59
|
+
# Find or create a generator command. Creates a static output entry if the
|
60
|
+
# command is provided.
|
61
|
+
def self.generator(name,command=nil)
|
62
|
+
commands :generators, name, command
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# @param [String,Symbol] type the typw of command (e.g. statics or generators)
|
67
|
+
# @param [String] name the name of the command to be found of the specified type
|
68
|
+
# @param [Hash] options a Hash of options that help instruct the execution
|
69
|
+
# process.
|
70
|
+
#
|
71
|
+
def self.execute(type,name,options)
|
72
|
+
puts "Generating #{type} #{name} with #{options}"
|
73
|
+
send(type,name).generate(options)
|
74
|
+
end
|
75
|
+
|
76
|
+
static "html", StaticHtml.new
|
77
|
+
static "pdf", StaticPdf.new
|
78
|
+
|
79
|
+
generator "presentation", GeneratePresentation.new
|
80
|
+
generator "outline", GenerateOutline.new
|
81
|
+
generator "rackup", GenerateRackup.new
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Parade
|
2
|
+
module Commands
|
3
|
+
|
4
|
+
#
|
5
|
+
# Generate a parade outline presentation file.
|
6
|
+
#
|
7
|
+
class GenerateOutline
|
8
|
+
include RenderFromTemplate
|
9
|
+
|
10
|
+
def description
|
11
|
+
"A generic presentation file (i.e. #{default_outline_filename})"
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate(options)
|
15
|
+
outline_filename = options['outline'] || default_outline_filename
|
16
|
+
create_file_with_contents outline_filename, outline_template(options), options
|
17
|
+
end
|
18
|
+
|
19
|
+
def default_outline_filename
|
20
|
+
"parade"
|
21
|
+
end
|
22
|
+
|
23
|
+
def outline_template(options)
|
24
|
+
template_options = { 'erb_template_file' => File.join(default_template_path, "#{default_outline_filename}.erb"),
|
25
|
+
'title' => 'My Presentation',
|
26
|
+
'description' => 'The importance of unicorns!' }.merge(options)
|
27
|
+
|
28
|
+
render_template template_options
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Parade
|
2
|
+
module Commands
|
3
|
+
|
4
|
+
#
|
5
|
+
# Generates a presentation directory and the presentation outline if it
|
6
|
+
# does not already exist.
|
7
|
+
#
|
8
|
+
class GeneratePresentation
|
9
|
+
include RenderFromTemplate
|
10
|
+
|
11
|
+
def description
|
12
|
+
"A presentation folder with outline file"
|
13
|
+
end
|
14
|
+
|
15
|
+
def generate(options)
|
16
|
+
|
17
|
+
directory = options['dir'] || default_presentation_dirname
|
18
|
+
Dir.mkdir(directory) unless File.exists?(directory)
|
19
|
+
|
20
|
+
Dir.chdir(directory) do
|
21
|
+
outline_generator = GenerateOutline.new
|
22
|
+
outline_generator.generate(options)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def default_presentation_dirname
|
28
|
+
"presentation"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Parade
|
2
|
+
module Commands
|
3
|
+
|
4
|
+
#
|
5
|
+
# Generates the a Rackup `config.ru` file to allow for presentations to
|
6
|
+
# be deployed to locations like Heroku.
|
7
|
+
#
|
8
|
+
class GenerateRackup
|
9
|
+
include RenderFromTemplate
|
10
|
+
|
11
|
+
def description
|
12
|
+
"A default rackup file (i.e. #{rackup_filename})"
|
13
|
+
end
|
14
|
+
|
15
|
+
def generate(options)
|
16
|
+
create_file_with_contents rackup_filename, rackup_template(options), options
|
17
|
+
end
|
18
|
+
|
19
|
+
def rackup_filename
|
20
|
+
"config.ru"
|
21
|
+
end
|
22
|
+
|
23
|
+
def rackup_template(options)
|
24
|
+
template_options = { 'erb_template_file' => File.join(default_template_path, "#{rackup_filename}.erb") }.merge(options)
|
25
|
+
|
26
|
+
render_template template_options
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require_relative '../renderers/inline_images'
|
2
|
+
|
3
|
+
module Parade
|
4
|
+
module Commands
|
5
|
+
|
6
|
+
#
|
7
|
+
# HtmlOuput creates an HTML representation of the presentation and returns
|
8
|
+
# it from the generate method. This is to be consumed by other commands
|
9
|
+
# that my use this output to be saved or manipulated.
|
10
|
+
#
|
11
|
+
# @see StaticHtml
|
12
|
+
# @see StaticPdf
|
13
|
+
#
|
14
|
+
class HtmlOutput
|
15
|
+
include RenderFromTemplate
|
16
|
+
|
17
|
+
def description
|
18
|
+
"This method returns HTML output"
|
19
|
+
end
|
20
|
+
|
21
|
+
def generate(options)
|
22
|
+
filepath = options['filepath']
|
23
|
+
|
24
|
+
return unless File.exists? filepath
|
25
|
+
|
26
|
+
if File.directory? filepath
|
27
|
+
root_path = filepath
|
28
|
+
root_node = Parsers::PresentationDirectoryParser.parse filepath, :root_path => ".",
|
29
|
+
:parade_file => (Array(options['parade_file']) + [ "parade", "parade.json" ]).compact.uniq
|
30
|
+
else
|
31
|
+
root_path = File.dirname filepath
|
32
|
+
root_node = Parsers::PresentationFileParser.parse filepath, :root_path => root_path
|
33
|
+
end
|
34
|
+
|
35
|
+
root_node.add_post_renderer Renderers::InlineImages
|
36
|
+
|
37
|
+
template_options = { 'erb_template_file' => File.join(default_view_path, "#{options['template']}.erb"),
|
38
|
+
'custom_asset_path' => root_path,
|
39
|
+
'slides' => root_node.to_html }
|
40
|
+
|
41
|
+
render_template template_options
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative '../helpers/template_generator'
|
2
|
+
|
3
|
+
module Parade
|
4
|
+
module Commands
|
5
|
+
|
6
|
+
#
|
7
|
+
# A module that shares common methods and information.
|
8
|
+
#
|
9
|
+
module RenderFromTemplate
|
10
|
+
|
11
|
+
# @return [String] the filepath to the templates directory within this project.
|
12
|
+
def default_template_path
|
13
|
+
File.join File.dirname(__FILE__), "..", "..", "templates"
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# @see HtmlOutput
|
18
|
+
# @see StaticPdf
|
19
|
+
# @return [String] the filepath to the views directory within this project
|
20
|
+
def default_view_path
|
21
|
+
File.join File.dirname(__FILE__), "..", "..", "views"
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# @param [Hash] options parameters that will help create the template
|
26
|
+
#
|
27
|
+
# @return [String] the string contents from the rendered template.
|
28
|
+
def render_template(options)
|
29
|
+
template = TemplateGenerator.new options
|
30
|
+
template.render
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# @param [String] filename the file name to save the file
|
35
|
+
# @param [String] contents the contents to write to the file
|
36
|
+
# @param [Hash] options a hash of options which may influence whether
|
37
|
+
# the file should be saved or overwritten.
|
38
|
+
#
|
39
|
+
def create_file_with_contents(filename,contents,options)
|
40
|
+
return if (File.exists?(filename) and not options.key?(:force))
|
41
|
+
File.open(filename,'w+') do |file|
|
42
|
+
file.puts contents
|
43
|
+
end
|
44
|
+
true
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|