#!/usr/local/bin/ruby -rubygems %w(camping camping/session).each { |lib| require lib } Camping.goes :QuickPresent module QuickPresent TITLE = "QuickPresent" NOTES = true include Camping::Session def self.create Camping::Models::Session.create_schema end def get_line line, display = true f = File.new("notes.txt") notes = f.readlines f.close @state.lines = notes.length notes[line].strip =~ /^(\/|~)/ ? `mate #{notes[line].strip}` : `echo "#{notes[line].strip}" | qs` if display forward = notes.length - line backward = line - 2 notes[(backward > 0 ? backward : 0)..(forward > 4 ? line + 4 : line + forward)].map { |n| n.strip.sub "-", ""} end end module QuickPresent::Controllers class Index < R '/' def get @text = get_line @state.num ||= -1, false render :index end end class Help def get render :help end end class Goto < R '/goto/(-?\d)' def get distance @state.num += distance.to_i @text = get_line @state.num render :index end end class Next def get @text = get_line @state.num += 1 render :index end end class Reset def get @text = get_line @state.num = -1, false render :index end end class Previous def get @text = get_line @state.num -= 1 render :index end end class Style < R '/styles.css' def get @headers["Content-Type"] = "text/css; charset=utf-8" @body = %{ body { font-family: Verdana, Arial, sans-serif; text-align: center } h1 { color: #AAA } a { text-decoration: none } body a:hover { color: #444 } a.nav { color: #CCC; font-size: 130%; padding: 20px; } a.peek_-2 { color: #BBB } a.peek_-1 { color: #999 } a.peek_0 { color: #555; font-weight: bold } a.peek_1 { color: #999 } a.peek_2 { color: #BBB } a.peek_3 { color: #CCC } a.peek_4 { color: #DDD } p { padding-top: 40px; color: #888 } } end end end module QuickPresent::Views def layout html do head do title QuickPresent::TITLE link :rel => 'stylesheet', :type => 'text/css', :href => '/styles.css', :media => 'screen' end body do h1 QuickPresent::TITLE self << yield end end end def index case @state.num when -1: a "Start", :href => R(Next), :class => "nav" when 0: a "Next", :href => R(Next), :class => "nav" when @state.lines - 1 a "Prev", :href => R(Previous), :class => "nav" a "Reset", :href => R(Reset), :class => "nav" else a "Prev", :href => R(Previous), :class => "nav" a "Next", :href => R(Next), :class => "nav" end if QuickPresent::NOTES p { i = @state.num < 2 ? -@state.num : -2 @text.each do |line| a line, :href => R(Goto, i), :class => "peek_#{i}"; br; i += 1 end } end end def help p "QuickPresent is a small tool for slick and easy presenting using Quicksilver. You must have the Quicksilver 'Command Line Tool (qs)' plugin installed for this to work." p "Simply outline your presentation in a file called notes.txt in the same directory as quickpresent.rb. Each line represents a new slide, all spaces before and after each line will be stripped. Lines beginning with http:// or other protocols that your default browser recognizes will be opened. Absolute paths to files on your HD will also be opened by Quicksilver." p "Going to the 'reset' path in your browser will restart the presentation. Once you have started the presentation the quickest way to step through it is by refreshing your browser, usually 'Apple R'. You can skip ahead or behind by clicking on the slide text in the browser. You can change the TITLE constant in quickpresent.rb to change the ah... title." p "For the actual presentation it would be best not to mirror the displays, and make the screen being projected the primary display. This way you can have your notes and controls on a seperate screen. If you can't do this set the NOTES constant to false so the notes aren't displayed." end end