lib/parade/server.rb in parade-0.9.0 vs lib/parade/server.rb in parade-0.9.1
- old
+ new
@@ -1,42 +1,84 @@
require_relative 'section'
require_relative "parsers/dsl"
require_relative 'renderers/update_image_paths'
-require_relative 'features/live_ruby'
-require_relative 'features/pdf_presentation'
-require_relative 'features/preshow'
-
require_relative 'slide_post_renderers'
require_relative 'slide_pre_renderers'
module Parade
class Server < Sinatra::Application
- def initialize(app=nil)
- super(app)
- require_ruby_files
+
+ def self.views_path
+ File.dirname(__FILE__) + '/../views'
end
- def require_ruby_files
- Dir.glob("#{settings.presentation_directory}/*.rb").map { |path| require path }
+ def self.public_path
+ File.dirname(__FILE__) + '/../public'
end
- set :views, File.dirname(__FILE__) + '/../views'
- set :public_folder, File.dirname(__FILE__) + '/../public'
-
+ set :views, views_path
+ set :public_folder, public_path
set :verbose, false
set :presentation_directory do
File.expand_path Dir.pwd
end
set :presentation_file, 'parade'
-
set :default_presentation_files, [ 'parade', 'parade.json' ]
+
+ #
+ # Includes the specified module into the server to grant the server additional
+ # functionality.
+ #
+ def self.register(server_module)
+ include server_module
+ end
+
+ #
+ # Register a javascript file that will be loaded after the code javscript
+ #
+ def self.register_javascript(js_file)
+ plugin_javascript_files.push js_file
+ end
+
+ #
+ # @return the javascript files that have been registered by plugins
+ #
+ def self.plugin_javascript_files
+ @javscript_files ||= []
+ end
+
+ def self.register_stylesheet(css_file)
+ plugin_stylesheet_files.push css_file
+ end
+
+ def self.plugin_stylesheet_files
+ @css_files ||= []
+ end
+
+ def self.register_command(input,description)
+ plugin_commands.push OpenStruct.new(:input => input,:description => description)
+ end
+
+ def self.plugin_commands
+ @plugin_commands ||= []
+ end
+
+ def initialize(app=nil)
+ super(app)
+ require_ruby_files
+ end
+
+ def require_ruby_files
+ Dir.glob("#{settings.presentation_directory}/*.rb").map { |path| require path }
+ end
+
def presentation_files
(Array(settings.presentation_file) + settings.default_presentation_files).compact.uniq
end
def load_presentation
@@ -80,20 +122,36 @@
custom_resource "css" do |path|
css path
end
end
+ def plugin_css_files
+ self.class.plugin_stylesheet_files.map do |path|
+ "<style>\n#{File.read(path)}\n</style>"
+ end.join("\n")
+ end
+
+ def plugin_js_files
+ self.class.plugin_javascript_files.map do |path|
+ "<script type='text/javascript'>#{File.read(path)}</script>"
+ end.join("\n")
+ end
+
#
# Create resources links to all the Javascript files found at the root of
# presentation directory.
#
def custom_js_files
custom_resource "js" do |path|
js path
end
end
+ def plugin_commands
+ self.class.plugin_commands
+ end
+
def presentation
load_presentation
end
def title
@@ -132,12 +190,8 @@
get "/onepage" do
erb :onepage
end
- include LiveRuby
- include PDFPresentation
- include Preshow
-
end
-end
+end
\ No newline at end of file