class Parade::Server

Public Class Methods

new(app=nil) click to toggle source
Calls superclass method
# File lib/parade/server.rb, line 71
def initialize(app=nil)
  super(app)
  require_ruby_files
end
plugin_commands() click to toggle source
# File lib/parade/server.rb, line 67
def self.plugin_commands
  @plugin_commands ||= []
end
plugin_javascript_files() click to toggle source

@return the javascript files that have been registered by plugins

# File lib/parade/server.rb, line 51
def self.plugin_javascript_files
  @javscript_files ||= []
end
plugin_stylesheet_files() click to toggle source
# File lib/parade/server.rb, line 59
def self.plugin_stylesheet_files
  @css_files ||= []
end
public_path() click to toggle source
# File lib/parade/server.rb, line 17
def self.public_path
  File.dirname(__FILE__) + '/../public'
end
register(server_module) click to toggle source

Includes the specified module into the server to grant the server additional functionality.

# File lib/parade/server.rb, line 37
def self.register(server_module)
  include server_module
end
register_command(input,description) click to toggle source
# File lib/parade/server.rb, line 63
def self.register_command(input,description)
  plugin_commands.push OpenStruct.new(:input => input,:description => description)
end
register_javascript(js_file) click to toggle source

Register a javascript file that will be loaded after the code javscript

# File lib/parade/server.rb, line 44
def self.register_javascript(js_file)
  plugin_javascript_files.push js_file
end
register_stylesheet(css_file) click to toggle source
# File lib/parade/server.rb, line 55
def self.register_stylesheet(css_file)
  plugin_stylesheet_files.push css_file
end
views_path() click to toggle source
# File lib/parade/server.rb, line 13
def self.views_path
  File.dirname(__FILE__) + '/../views'
end

Public Instance Methods

css(*filepaths) click to toggle source

A shortcut to define a CSS resource file within a view template

# File lib/parade/server.rb, line 101
def css(*filepaths)
  filepaths.map do |filepath|
    css_path = File.join(presentation_path_prefix,"css",filepath)
    %{<link rel="stylesheet" href="#{css_path}" type="text/css"/>}
  end.join("\n")
end
custom_css_files() click to toggle source

Create resources links to all the CSS files found at the root of presentation directory.

# File lib/parade/server.rb, line 131
def custom_css_files
  custom_resource "css" do |path|
    css path
  end
end
custom_js_files() click to toggle source

Create resources links to all the Javascript files found at the root of presentation directory.

# File lib/parade/server.rb, line 163
def custom_js_files
  custom_resource "js" do |path|
    js path
  end
end
custom_resource(resource_extension) { |relative_path| ... } click to toggle source
# File lib/parade/server.rb, line 118
def custom_resource(resource_extension)
  load_presentation.resources.map do |resource_path|
    Dir.glob("#{resource_path}/*.#{resource_extension}").map do |path|
      relative_path = path.sub(settings.presentation_directory,'')
      yield relative_path if block_given?
    end.join("\n")
  end.join("\n")
end
js(*filepaths) click to toggle source

A shortcut to define a Javascript resource file within a view template

# File lib/parade/server.rb, line 111
def js(*filepaths)
  filepaths.map do |filepath|
    js_path = File.join(presentation_path_prefix,"js",filepath)
    %{<script type="text/javascript" src="#{js_path}"></script>}
  end.join("\n")
end
load_presentation() click to toggle source
# File lib/parade/server.rb, line 84
def load_presentation
  root_node = Parsers::PresentationDirectoryParser.parse settings.presentation_directory,
    :root_path => settings.presentation_directory, :parade_file => presentation_files

  root_node.add_post_renderer Renderers::UpdateImagePaths.new :root_path => settings.presentation_directory
  root_node
end
pause_message() click to toggle source
# File lib/parade/server.rb, line 190
def pause_message
  presentation.pause_message
end
plugin_commands() click to toggle source
# File lib/parade/server.rb, line 169
def plugin_commands
  self.class.plugin_commands
end
plugin_css_files() click to toggle source
# File lib/parade/server.rb, line 137
def plugin_css_files
  self.class.plugin_stylesheet_files.map do |path|
    content = File.read(path)
    erb :inline_css, locals: { content: content }
  end.join("\n")
end
plugin_js_files() click to toggle source
# File lib/parade/server.rb, line 152
def plugin_js_files
  self.class.plugin_javascript_files.map do |path|
    content = File.read(path)
    erb :inline_js, locals: { content: content }
  end.join("\n")
end
presentation() click to toggle source
# File lib/parade/server.rb, line 173
def presentation
  load_presentation
end
presentation_files() click to toggle source
# File lib/parade/server.rb, line 80
def presentation_files
  (Array(settings.presentation_file) + settings.default_presentation_files).compact.uniq
end
presentation_path_prefix() click to toggle source
# File lib/parade/server.rb, line 94
def presentation_path_prefix
  env['SCRIPT_NAME'].to_s
end
require_ruby_files() click to toggle source
# File lib/parade/server.rb, line 76
def require_ruby_files
  Dir.glob("#{settings.presentation_directory}/*.rb").map { |path| require path }
end
slides(options = {}) click to toggle source
# File lib/parade/server.rb, line 181
def slides(options = {})
  options = { presentation_path_prefix: presentation_path_prefix }
  presentation.to_html(options)
end
theme_css() click to toggle source

This helper method is called within the header to return the theme specified by the top level section of the preseation

# File lib/parade/server.rb, line 148
def theme_css
  css("themes/#{load_presentation.theme}.css") if load_presentation.theme
end
title() click to toggle source
# File lib/parade/server.rb, line 177
def title
  presentation.title
end