Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Load in initial files
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Thomas committed May 18, 2008
0 parents commit ac49e25
Show file tree
Hide file tree
Showing 70 changed files with 5,874 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
29 changes: 29 additions & 0 deletions LICENSE
@@ -0,0 +1,29 @@
This source tree contains a mixture of original material and other people's work. In particular,
it contains Syntax Highlighting code from http://code.google.com/p/syntaxhighlighter/ and
the S5 package from http://meyerweb.com/eric/tools/s5/. Both of these packages carry their own licenses,
and the conditions in this file do not apply to these packages.

The following terms apply to the original code in this source tree:

Copyright (c) 2008 Dave Thomas

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
17 changes: 17 additions & 0 deletions README
@@ -0,0 +1,17 @@
This is a remarkably trivial package that makes simply HTML-based presentations from
a set up source files written using Textile. It's designed to help when creating
slides that contain lots of code, as it allows code to be embedded from external source files.
This means that the code that you embed can come from running (and tested) programs.

The code in the resulting slides is syntax highlighted, and is hyperlinked to the original
source file, allowing that file to be brought up in Textmate.

To get started

* make sure you have Ruby 1.8.6 installed, along with the Rake and redcloth gems
* type 'rake all' in the same directory as this README file
* open html/all.html


See the file LICENSE for details on how this all may be used.

41 changes: 41 additions & 0 deletions Rakefile
@@ -0,0 +1,41 @@
SLIDES_DIR = 'slides'
HTML_DIR = 'html'

Dir.chdir(SLIDES_DIR) { SRC = FileList['*.slides']; SRC.resolve }

OUTPUT = []

SRC.each do |file_name|
slide_file = File.join(SLIDES_DIR, file_name)
html_file = File.join(HTML_DIR, file_name.ext('.html'))
OUTPUT << html_file
desc "Build #{html_file} from #{slide_file}"
file html_file => slide_file do
sh "ruby bin/pressie.rb #{slide_file} > #{html_file}"
end
end

desc "Build the HTML slides from all the files slides/*.slides files"
task :default => OUTPUT

desc "Build all slides based on the contents of slides/table_of_contents.slides"
task :all => 'html/all.html'

task 'html/all.html' => 'tmp/almost_all.html' do
sh "ruby bin/postprocess_all.rb tmp/almost_all.html >html/all.html"
end

task 'tmp/almost_all.html' => 'tmp/almost_all.slides' do
sh "ruby bin/pressie.rb tmp/almost_all.slides >tmp/almost_all.html"
end

task 'tmp/almost_all.slides' => OUTPUT do
sh "ruby bin/build_all.rb slides/table_of_contents.slides tmp/almost_all.slides"
end

desc "Remove all work products—slides and temporary files"
task :clean do
FileUtils.rm OUTPUT, :force => true
FileUtils.rm "html/all.html", :force => true
FileUtils.rm FileList["tmp/*"], :force => true
end
27 changes: 27 additions & 0 deletions bin/build_all.rb
@@ -0,0 +1,27 @@
# We're passed a file containing hyperlinks to the HTML
# (ie, table_con_contents.slides)
# and contruct all.slides from it

BASE = File.join(File.dirname(__FILE__), "..")
HEADER = %{h1. Advanced Ruby\n\nbq. Chad Fowler and Dave Thomas\n\nh1. Contents\n\n}


contents = File.readlines(ARGV[0]).grep(/^\*.*:(.*)\.html/) { File.join(BASE, "slides", "#{$1}.slides") }.map {|name| File.read(name) }

File.open(ARGV[1], "w") do |op|
op.puts HEADER

op.puts %{<div style="font-size: 70%">\n\n}

contents.each do |content|
content =~ /h1.\s+(.*)/
STDERR.puts $1
op.puts "* #{$1}\n\n"
end

op.puts "</div>\n\n"

contents.each do |content|
op.puts content.sub(/h1/, 'h1(slide0)').sub(/__END__.*/m, '')
end
end
5 changes: 5 additions & 0 deletions bin/postprocess_all.rb
@@ -0,0 +1,5 @@
content = File.read(ARGV[0])

content = content.gsub(/<div class="slide">\s+<h1 class="slide0"/m, %{<div class="title slide">\n<h1})

puts content
7 changes: 7 additions & 0 deletions bin/pressie.rb
@@ -0,0 +1,7 @@
base = File.join(File.dirname(__FILE__), "..")
$: << File.join(base, "lib")

require 'rubygems'
require "pressie/pressie"

Pressie::process
11 changes: 11 additions & 0 deletions code/control/basic_continuation.rb
@@ -0,0 +1,11 @@
def open_box(continuation)
continuation.call if rand < 0.5
end

callcc do |continuation|
puts "opening box"
open_box(continuation)
puts "Phew--kitty's OK"
end

puts "closing box"
59 changes: 59 additions & 0 deletions code/control/cc_throw_catch.rb
@@ -0,0 +1,59 @@
#START:stack
class CatchStack
Frame = Struct.new(:symbol, :cc)

def stack
Thread.current[:catch_stack] ||= []
end

def wrap(symbol, cc)
stack << Frame.new(symbol, cc)
begin
yield
ensure
stack.pop
end
end

def find_continuation_for(symbol)
stack.pop until stack.empty? || stack.last.symbol == symbol
if stack.empty?
fail NameError, "uncaught throw `#{sym}'"
else
stack.pop.cc
end
end
end
#END:stack

#START:CC
module CC
CATCH_STACK = CatchStack.new

def self.catch(sym)
callcc do |cc|
CATCH_STACK.wrap(sym, cc) do
yield
end
end
end

def self.throw(sym, value=nil)
cc = CATCH_STACK.find_continuation_for(sym)
cc.call(value)
end
end
#END:CC

#START:body
def test_method
CC.throw(:x, "thrown X") if rand < 0.5
end

result = CC.catch(:x) do
test_method
"normal exit"
end

puts "Result is #{result}"
#END:body
8 changes: 8 additions & 0 deletions code/control/closure_continuation.rb
@@ -0,0 +1,8 @@
def create_continuation(arg)
callcc { |continuation| return continuation }
puts "Back in method: arg = #{arg}"
exit
end

cont_one = create_continuation(123)
cont_one.call #=> Back in method: arg = 123
12 changes: 12 additions & 0 deletions code/control/closure_continuation_2.rb
@@ -0,0 +1,12 @@
def create_continuation(arg)
callcc { |continuation| return continuation }
puts "Back in method: arg = #{arg}"
end

cont_one = create_continuation(123)
cont_one.call

### Results in:
#
# Back in method: arg = 123
# closure_continuation_2.rb:8: undefined method `call' for nil:NilClass
115 changes: 115 additions & 0 deletions dp.SyntaxHighlighter/CSS.html
@@ -0,0 +1,115 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Test.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>dp.SyntaxHighlighter Tests</title>
<link type="text/css" rel="stylesheet" href="Styles/SyntaxHighlighter.css"></link>
<link href="Styles/TestPages.css" rel="stylesheet" type="text/css">
</head>

<body>

<h1>dp.SyntaxHighlighter 1.5.0 Tests and Samples</h1>
<p><a href="http://code.google.com/p/syntaxhighlighter/">http://code.google.com/p/syntaxhighlighter/</a></p>

<h2><!-- InstanceBeginEditable name="Title" -->CSS<!-- InstanceEndEditable --></h2>

<div class="layout">

<div class="column1">
<h3>Languages:</h3>
<ol>
<li><a href="CSharp.html">C#</a></li>
<li><a href="CSS.html">CSS</a></li>
<li><a href="Cpp.html">C++</a></li>
<li><a href="Delphi.html">Delphi</a></li>
<li><a href="Java.html">Java</a></li>
<li><a href="JavaScript.html">JavaScript</a></li>
<li><a href="PHP.html">PHP</a></li>
<li><a href="Python.html">Python</a></li>
<li><a href="Ruby.html">Ruby</a></li>
<li><a href="SQL.html">SQL</a></li>
<li><a href="VB.html">Visual Basic</a></li>
<li><a href="XML.html">XML / HTML</a></li>
</ol>
<h3>Features:</h3>
<ol>
<li><a href="SmartTabs.html">Smart tabs</a></li>
<li><a href="FirstLine.html">First line</a> </li>
<li><a href="CollapseCode.html">Expand code</a></li>
<li><a href="ShowColumns.html">Show columns</a></li>
<li><a href="NoGutter.html">No gutter</a></li>
<li><a href="NoControls.html">No controls</a></li>
</ol>
</div>

<div class="column2">
Text body before.
<hr/>
<!-- InstanceBeginEditable name="Code" -->
<pre name="code" class="css">
/* Main style for the table */

.dp-highlighter
{
font-family: "Courier New", Courier, mono;
font-size: 12px;
text-align: left;
border: 1px solid #2B91AF;
background-color: #fff;
width: 99%;
overflow: auto;
line-height: 100% !important;
margin: 18px 0px 18px 0px;
}

.dp-highlighter ol
{
margin: 0px 0px 0px 45px;
padding: 0px;
color: #2B91AF;
}

.dp-highlighter ol li
{
border-left: 3px solid #6CE26C;
border-bottom: 1px solid #eee;
background-color: #fff;
padding-left: 10px;
}

.dp-highlighter ol li.alt
{
background-color: #f8f8f8;
}
</pre>
<!-- InstanceEndEditable -->
<hr/>
Text body after.
</div>
</div>

<div class="footer">
Copyright 2004-2007 Alex Gorbatchev.<br/>
</div>

<script class="javascript" src="Scripts/shCore.js"></script>
<script class="javascript" src="Scripts/shBrushCSharp.js"></script>
<script class="javascript" src="Scripts/shBrushPhp.js"></script>
<script class="javascript" src="Scripts/shBrushJScript.js"></script>
<script class="javascript" src="Scripts/shBrushJava.js"></script>
<script class="javascript" src="Scripts/shBrushVb.js"></script>
<script class="javascript" src="Scripts/shBrushSql.js"></script>
<script class="javascript" src="Scripts/shBrushXml.js"></script>
<script class="javascript" src="Scripts/shBrushDelphi.js"></script>
<script class="javascript" src="Scripts/shBrushPython.js"></script>
<script class="javascript" src="Scripts/shBrushRuby.js"></script>
<script class="javascript" src="Scripts/shBrushCss.js"></script>
<script class="javascript" src="Scripts/shBrushCpp.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'Scripts/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>

</body>
<!-- InstanceEnd --></html>

0 comments on commit ac49e25

Please sign in to comment.