codex 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +8 -0
- data/LICENSE.txt +29 -0
- data/Manifest.txt +95 -0
- data/PostInstall.txt +5 -0
- data/README.txt +31 -0
- data/Rakefile +4 -0
- data/app_generators/codex/USAGE +5 -0
- data/app_generators/codex/codex_generator.rb +106 -0
- data/app_generators/codex/templates/Rakefile +54 -0
- data/app_generators/codex/templates/bin/build_all.rb +47 -0
- data/app_generators/codex/templates/bin/postprocess_all.rb +5 -0
- data/app_generators/codex/templates/bin/pressie.rb +7 -0
- data/app_generators/codex/templates/code/control/basic_continuation.rb +11 -0
- data/app_generators/codex/templates/code/control/cc_throw_catch.rb +59 -0
- data/app_generators/codex/templates/code/control/closure_continuation.rb +8 -0
- data/app_generators/codex/templates/code/control/closure_continuation_2.rb +12 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/CSS.html +115 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/CSharp.html +134 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/CollapseCode.html +90 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Cpp.html +190 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/CrashTest.html +108 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Delphi.html +112 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/FirstLine.html +90 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Index.html +80 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Java.html +122 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/JavaScript.html +112 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/NoControls.html +89 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/NoGutter.html +89 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/PHP.html +102 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Python.html +121 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Ruby.html +131 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/SQL.html +98 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/clipboard.swf +0 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushCSharp.js +32 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushCpp.js +73 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushCss.js +52 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushDelphi.js +34 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushJScript.js +22 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushJava.js +28 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushPhp.js +60 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushPython.js +30 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushRuby.js +28 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushSql.js +42 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushVb.js +29 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushXml.js +70 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shCore.js +414 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shCore.uncompressed.js +674 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/ShowColumns.html +89 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/SmartTabs.html +88 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Styles/SyntaxHighlighter.css +158 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Styles/TestPages.css +63 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/Templates/Test.dwt +80 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/VB.html +115 -0
- data/app_generators/codex/templates/dp.SyntaxHighlighter/XML.html +136 -0
- data/app_generators/codex/templates/html/all.html +0 -0
- data/app_generators/codex/templates/readme.txt +4 -0
- data/app_generators/codex/templates/slides/basics.slides +37 -0
- data/app_generators/codex/templates/slides/building.slides +27 -0
- data/app_generators/codex/templates/slides/example.slides +80 -0
- data/app_generators/codex/templates/slides/including_code.slides +80 -0
- data/app_generators/codex/templates/slides/metadata.yml +4 -0
- data/app_generators/codex/templates/slides/table_of_contents.slides +14 -0
- data/app_generators/codex/templates/ui/default/blank.gif +0 -0
- data/app_generators/codex/templates/ui/default/bodybg.gif +0 -0
- data/app_generators/codex/templates/ui/default/framing.css +23 -0
- data/app_generators/codex/templates/ui/default/iepngfix.htc +42 -0
- data/app_generators/codex/templates/ui/default/opera.css +7 -0
- data/app_generators/codex/templates/ui/default/outline.css +15 -0
- data/app_generators/codex/templates/ui/default/pretty.css +86 -0
- data/app_generators/codex/templates/ui/default/print.css +1 -0
- data/app_generators/codex/templates/ui/default/s5-core.css +9 -0
- data/app_generators/codex/templates/ui/default/slides.css +3 -0
- data/app_generators/codex/templates/ui/default/slides.js +553 -0
- data/bin/codex +17 -0
- data/codex.gemspec +30 -0
- data/config/hoe.rb +75 -0
- data/config/requirements.rb +15 -0
- data/lib/codex.rb +7 -0
- data/lib/codex/content.rb +160 -0
- data/lib/codex/pressie.rb +108 -0
- data/lib/codex/version.rb +9 -0
- data/lib/stylesheets/pressie.css +196 -0
- data/lib/stylesheets/print.css +149 -0
- data/lib/stylesheets/ruby.png +0 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +9 -0
- data/test/test_codex.rb +11 -0
- data/test/test_codex_generator.rb +78 -0
- data/test/test_generator_helper.rb +29 -0
- data/test/test_helper.rb +2 -0
- metadata +163 -0
data/bin/codex
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubigen'
|
5
|
+
|
6
|
+
if %w(-v --version).include? ARGV.first
|
7
|
+
require 'codex/version'
|
8
|
+
puts "#{File.basename($0)} #{Codex::VERSION::STRING}"
|
9
|
+
exit(0)
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rubigen/scripts/generate'
|
13
|
+
source = RubiGen::PathSource.new(:application,
|
14
|
+
File.join(File.dirname(__FILE__), "../app_generators"))
|
15
|
+
RubiGen::Base.reset_sources
|
16
|
+
RubiGen::Base.append_sources source
|
17
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'codex')
|
data/codex.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{codex}
|
3
|
+
s.version = "1.0.2"
|
4
|
+
|
5
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Dave Thomas"]
|
9
|
+
s.date = %q{2008-05-19}
|
10
|
+
s.default_executable = %q{codex}
|
11
|
+
s.description = %q{Simple tool for creating source-code intensive presentations and courses}
|
12
|
+
s.email = ["dave@pragprog.com"]
|
13
|
+
s.executables = ["codex"]
|
14
|
+
s.extra_rdoc_files = ["History.txt", "LICENSE.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "app_generators/codex/templates/readme.txt"]
|
15
|
+
s.files = ["History.txt", "LICENSE.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "Rakefile", "app_generators/codex/USAGE", "app_generators/codex/codex_generator.rb", "app_generators/codex/templates/Rakefile", "app_generators/codex/templates/bin/build_all.rb", "app_generators/codex/templates/bin/postprocess_all.rb", "app_generators/codex/templates/bin/pressie.rb", "app_generators/codex/templates/code/control/basic_continuation.rb", "app_generators/codex/templates/code/control/cc_throw_catch.rb", "app_generators/codex/templates/code/control/closure_continuation.rb", "app_generators/codex/templates/code/control/closure_continuation_2.rb", "app_generators/codex/templates/dp.SyntaxHighlighter/CSS.html", "app_generators/codex/templates/dp.SyntaxHighlighter/CSharp.html", "app_generators/codex/templates/dp.SyntaxHighlighter/CollapseCode.html", "app_generators/codex/templates/dp.SyntaxHighlighter/Cpp.html", "app_generators/codex/templates/dp.SyntaxHighlighter/CrashTest.html", "app_generators/codex/templates/dp.SyntaxHighlighter/Delphi.html", "app_generators/codex/templates/dp.SyntaxHighlighter/FirstLine.html", "app_generators/codex/templates/dp.SyntaxHighlighter/Index.html", "app_generators/codex/templates/dp.SyntaxHighlighter/Java.html", "app_generators/codex/templates/dp.SyntaxHighlighter/JavaScript.html", "app_generators/codex/templates/dp.SyntaxHighlighter/NoControls.html", "app_generators/codex/templates/dp.SyntaxHighlighter/NoGutter.html", "app_generators/codex/templates/dp.SyntaxHighlighter/PHP.html", "app_generators/codex/templates/dp.SyntaxHighlighter/Python.html", "app_generators/codex/templates/dp.SyntaxHighlighter/Ruby.html", "app_generators/codex/templates/dp.SyntaxHighlighter/SQL.html", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/clipboard.swf", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushCSharp.js", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushCpp.js", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushCss.js", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushDelphi.js", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushJScript.js", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushJava.js", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushPhp.js", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushPython.js", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushRuby.js", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushSql.js", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushVb.js", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shBrushXml.js", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shCore.js", "app_generators/codex/templates/dp.SyntaxHighlighter/Scripts/shCore.uncompressed.js", "app_generators/codex/templates/dp.SyntaxHighlighter/ShowColumns.html", "app_generators/codex/templates/dp.SyntaxHighlighter/SmartTabs.html", "app_generators/codex/templates/dp.SyntaxHighlighter/Styles/SyntaxHighlighter.css", "app_generators/codex/templates/dp.SyntaxHighlighter/Styles/TestPages.css", "app_generators/codex/templates/dp.SyntaxHighlighter/Templates/Test.dwt", "app_generators/codex/templates/dp.SyntaxHighlighter/VB.html", "app_generators/codex/templates/dp.SyntaxHighlighter/XML.html", "app_generators/codex/templates/html/all.html", "app_generators/codex/templates/readme.txt", "app_generators/codex/templates/slides/basics.slides", "app_generators/codex/templates/slides/building.slides", "app_generators/codex/templates/slides/example.slides", "app_generators/codex/templates/slides/including_code.slides", "app_generators/codex/templates/slides/metadata.yml", "app_generators/codex/templates/slides/table_of_contents.slides", "app_generators/codex/templates/ui/default/blank.gif", "app_generators/codex/templates/ui/default/bodybg.gif", "app_generators/codex/templates/ui/default/framing.css", "app_generators/codex/templates/ui/default/iepngfix.htc", "app_generators/codex/templates/ui/default/opera.css", "app_generators/codex/templates/ui/default/outline.css", "app_generators/codex/templates/ui/default/pretty.css", "app_generators/codex/templates/ui/default/print.css", "app_generators/codex/templates/ui/default/s5-core.css", "app_generators/codex/templates/ui/default/slides.css", "app_generators/codex/templates/ui/default/slides.js", "bin/codex", "codex.gemspec", "config/hoe.rb", "config/requirements.rb", "lib/codex.rb", "lib/codex/content.rb", "lib/codex/pressie.rb", "lib/codex/version.rb", "lib/stylesheets/pressie.css", "lib/stylesheets/print.css", "lib/stylesheets/ruby.png", "script/console", "script/destroy", "script/generate", "setup.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "test/test_codex.rb", "test/test_codex_generator.rb", "test/test_generator_helper.rb", "test/test_helper.rb"]
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.homepage = %q{http://codex.rubyforge.org}
|
18
|
+
s.post_install_message = %q{
|
19
|
+
To create new presentations:
|
20
|
+
|
21
|
+
codex path/to/presentation/folder
|
22
|
+
|
23
|
+
}
|
24
|
+
s.rdoc_options = ["--main", "README.txt"]
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
s.rubyforge_project = %q{codex}
|
27
|
+
s.rubygems_version = %q{1.1.1}
|
28
|
+
s.summary = %q{Simple tool for creating source-code intensive presentations and courses}
|
29
|
+
s.test_files = ["test/test_codex.rb", "test/test_codex_generator.rb", "test/test_generator_helper.rb", "test/test_helper.rb"]
|
30
|
+
end
|
data/config/hoe.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'codex/version'
|
2
|
+
|
3
|
+
AUTHOR = 'Dave Thomas' # can also be an array of Authors
|
4
|
+
EMAIL = "dave@pragprog.com"
|
5
|
+
DESCRIPTION = "Simple tool for creating source-code intensive presentations and courses"
|
6
|
+
GEM_NAME = 'codex' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = 'codex' # The unix name for your project
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
EXTRA_DEPENDENCIES = [
|
11
|
+
['rake', '>= 0.8.1'],
|
12
|
+
['RedCloth', '>= 3.0.4'],
|
13
|
+
['rubigen', '>=1.3.2']
|
14
|
+
] # An array of rubygem dependencies [name, version]
|
15
|
+
|
16
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
17
|
+
@config = nil
|
18
|
+
RUBYFORGE_USERNAME = "unknown"
|
19
|
+
def rubyforge_username
|
20
|
+
unless @config
|
21
|
+
begin
|
22
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
23
|
+
rescue
|
24
|
+
puts <<-EOS
|
25
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
26
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
27
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
28
|
+
EOS
|
29
|
+
exit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
REV = nil
|
37
|
+
# UNCOMMENT IF REQUIRED:
|
38
|
+
# REV = YAML.load(`svn info`)['Revision']
|
39
|
+
VERS = Codex::VERSION::STRING + (REV ? ".#{REV}" : "")
|
40
|
+
RDOC_OPTS = ['--quiet', '--title', 'codex documentation',
|
41
|
+
"--opname", "index.html",
|
42
|
+
"--line-numbers",
|
43
|
+
"--main", "README",
|
44
|
+
"--inline-source"]
|
45
|
+
|
46
|
+
class Hoe
|
47
|
+
def extra_deps
|
48
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
49
|
+
@extra_deps
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Generate all the Rake tasks
|
54
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
55
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
56
|
+
p.developer(AUTHOR, EMAIL)
|
57
|
+
p.description = DESCRIPTION
|
58
|
+
p.summary = DESCRIPTION
|
59
|
+
p.url = HOMEPATH
|
60
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
61
|
+
p.test_globs = ["test/**/test_*.rb"]
|
62
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
63
|
+
|
64
|
+
# == Optional
|
65
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
66
|
+
#p.extra_deps = EXTRA_DEPENDENCIES
|
67
|
+
|
68
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
69
|
+
end
|
70
|
+
|
71
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
72
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
73
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
74
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
75
|
+
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
data/lib/codex.rb
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'redcloth'
|
2
|
+
|
3
|
+
class Codex::Content
|
4
|
+
|
5
|
+
# Wrap the parameters to :code
|
6
|
+
#
|
7
|
+
# :code file.rb[:part class=xxx]
|
8
|
+
class Descriptor
|
9
|
+
attr_reader :file_name, :part
|
10
|
+
attr_reader :css_class
|
11
|
+
attr_reader :lang
|
12
|
+
|
13
|
+
def initialize(string)
|
14
|
+
@css_class = "code-normal"
|
15
|
+
@lang = "ruby"
|
16
|
+
|
17
|
+
if string && string =~ /(.*?)\[(.*)\]/
|
18
|
+
@file_name = $1
|
19
|
+
parse_params($2.dup)
|
20
|
+
else
|
21
|
+
@file_name = string
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def parse_params(params)
|
26
|
+
params.split.each do |param|
|
27
|
+
if param =~ /(.*?)=(.*)/
|
28
|
+
case $1
|
29
|
+
when "class"
|
30
|
+
@css_class = $2
|
31
|
+
when "lang"
|
32
|
+
@lang = $2
|
33
|
+
else
|
34
|
+
fail "Unknown parameter #{$1} in '#{params}'"
|
35
|
+
end
|
36
|
+
else
|
37
|
+
@part = param
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
START_SLIDE = %{<div class="slide">\n}
|
45
|
+
END_SLIDE = %{</div>\n}
|
46
|
+
BETWEEN_SLIDES = END_SLIDE + "\n" + START_SLIDE
|
47
|
+
|
48
|
+
CODE_PATTERN = /^:code\s+(.+)/
|
49
|
+
|
50
|
+
# Temporarily prepended to lines of incldued code to stop them being processed
|
51
|
+
# as Textfile
|
52
|
+
|
53
|
+
INCLUDED_CODE_PREFIX = "XXX\001"
|
54
|
+
INCLUDED_CODE_PREFIX_REGEXP = /#{INCLUDED_CODE_PREFIX}/mo
|
55
|
+
|
56
|
+
|
57
|
+
def initialize(original)
|
58
|
+
@original = original.sub(/__END__.*/m, '').gsub(/__SKIP__.*?__ENDSKIP__/m, '')
|
59
|
+
end
|
60
|
+
|
61
|
+
def to_html
|
62
|
+
textile = preprocess_inlinecode(@original)
|
63
|
+
textile = preprocess_code(textile)
|
64
|
+
content = split_into_slides(textile)
|
65
|
+
html = RedCloth.new(content).to_html
|
66
|
+
remove_code_escaping_from(html)
|
67
|
+
end
|
68
|
+
|
69
|
+
# look for :code filename[part] and substitute in the appropriate part
|
70
|
+
# of the given file. Do in two steps because the regexp engine isn;t reentrant
|
71
|
+
def preprocess_code(text)
|
72
|
+
chunks = {}
|
73
|
+
text.scan(CODE_PATTERN) do |file,|
|
74
|
+
desc = Descriptor.new(file)
|
75
|
+
chunks[file] = find_content_from(desc)
|
76
|
+
end
|
77
|
+
text.gsub(CODE_PATTERN) { file = $1.dup; format_code(Descriptor.new(file), chunks[file]) }
|
78
|
+
end
|
79
|
+
|
80
|
+
# Look for :inlinecode /.../:endinlinecode and substitute in as if it came from a file
|
81
|
+
def preprocess_inlinecode(text)
|
82
|
+
state = :copying
|
83
|
+
result = []
|
84
|
+
text.split(/\n/).each do |line|
|
85
|
+
case state
|
86
|
+
when :copying
|
87
|
+
if line =~ /^:inlinecode(.*)/
|
88
|
+
args = $1.strip
|
89
|
+
desc = Descriptor.new("--[#{args}]")
|
90
|
+
result << %{<div class="#{desc.css_class}">\n}
|
91
|
+
result << %{\n<pre name="code" class="#{desc.lang}:nogutter:nocontrols">\n}
|
92
|
+
state = :incode
|
93
|
+
else
|
94
|
+
result << line
|
95
|
+
end
|
96
|
+
when :incode
|
97
|
+
if line =~ /^:endinlinecode/
|
98
|
+
result << "</pre></div>\n\n"
|
99
|
+
state = :copying
|
100
|
+
else
|
101
|
+
result << INCLUDED_CODE_PREFIX + line
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
result.join("\n")
|
107
|
+
end
|
108
|
+
|
109
|
+
def split_into_slides(textile)
|
110
|
+
result = []
|
111
|
+
slides = textile.split(/^h1/).each do |slide|
|
112
|
+
unless slide.empty?
|
113
|
+
result << START_SLIDE << "\nh1" << slide << END_SLIDE
|
114
|
+
end
|
115
|
+
end
|
116
|
+
result.join
|
117
|
+
end
|
118
|
+
|
119
|
+
def find_content_from(desc)
|
120
|
+
begin
|
121
|
+
content = File.read(desc.file_name)
|
122
|
+
rescue Exception => e
|
123
|
+
STDERR.puts e.message
|
124
|
+
exit 2
|
125
|
+
end
|
126
|
+
|
127
|
+
find_part_in(content, desc.part)
|
128
|
+
end
|
129
|
+
|
130
|
+
def find_part_in(content, part_name)
|
131
|
+
result = []
|
132
|
+
state = part_name ? :skipping : :normal
|
133
|
+
content.each_line do |line|
|
134
|
+
if line.sub!(/(START|END):(\w+)/, '')
|
135
|
+
if $2 == part_name
|
136
|
+
if $1 == "START"
|
137
|
+
state = :normal
|
138
|
+
else
|
139
|
+
state = :skipping
|
140
|
+
end
|
141
|
+
end
|
142
|
+
next
|
143
|
+
end
|
144
|
+
result << line unless state == :skipping
|
145
|
+
end
|
146
|
+
result.join
|
147
|
+
end
|
148
|
+
|
149
|
+
def format_code(desc, code)
|
150
|
+
code = code.gsub(/^/m, INCLUDED_CODE_PREFIX)
|
151
|
+
%{<div class="#{desc.css_class}">\n} +
|
152
|
+
%{\n<pre name="code" class="#{desc.lang}:nogutter:nocontrols">#{code}} +
|
153
|
+
%{</pre></div>} +
|
154
|
+
%{<div class="codeurl"><a href="txmt://open?url=file://#{File.expand_path(desc.file_name)}">#{desc.file_name}</a></div>\n\n}
|
155
|
+
end
|
156
|
+
|
157
|
+
def remove_code_escaping_from(html)
|
158
|
+
html.gsub(INCLUDED_CODE_PREFIX_REGEXP, '')
|
159
|
+
end
|
160
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
S5_HEAD = %{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
7
|
+
|
8
|
+
<head>
|
9
|
+
<title>&title;</title>
|
10
|
+
<!-- metadata -->
|
11
|
+
<meta name="generator" content="S5" />
|
12
|
+
<meta name="version" content="S5 1.1" />
|
13
|
+
<meta name="presdate" content="&date" />
|
14
|
+
<meta name="author" content="&author;" />
|
15
|
+
<meta name="organization" content="&organization;" />
|
16
|
+
<meta name="company" content="&company;" />
|
17
|
+
<!-- configuration parameters -->
|
18
|
+
<meta name="defaultView" content="slideshow" />
|
19
|
+
<meta name="controlVis" content="hidden" />
|
20
|
+
<!-- style sheet links -->
|
21
|
+
<link rel="stylesheet" href="../ui/default/slides.css" type="text/css" media="projection" id="slideProj" />
|
22
|
+
<link rel="stylesheet" href="../ui/default/outline.css" type="text/css" media="screen" id="outlineStyle" />
|
23
|
+
<link rel="stylesheet" href="../lib/stylesheets/print.css" type="text/css" media="print" id="slidePrint" />
|
24
|
+
<link rel="stylesheet" href="../ui/default/opera.css" type="text/css" media="projection" id="operaFix" />
|
25
|
+
|
26
|
+
<link rel="stylesheet" href="../lib/stylesheets/pressie.css" type="text/css" />
|
27
|
+
|
28
|
+
<!-- S5 JS -->
|
29
|
+
<script src="../ui/default/slides.js" type="text/javascript"></script>
|
30
|
+
|
31
|
+
<!-- Syntax Highlighter -->
|
32
|
+
<link rel="stylesheet" href="../dp.SyntaxHighlighter/Styles/SyntaxHighlighter.css"></link>
|
33
|
+
|
34
|
+
</head>
|
35
|
+
<body>
|
36
|
+
|
37
|
+
<div class="layout">
|
38
|
+
<div id="controls"><!-- DO NOT EDIT --></div>
|
39
|
+
<div id="currentSlide"><!-- DO NOT EDIT --></div>
|
40
|
+
<div id="header"></div>
|
41
|
+
<div id="footer">
|
42
|
+
<h2>Copyright © ©right;</h2>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
</div>
|
46
|
+
|
47
|
+
|
48
|
+
<div class="presentation">
|
49
|
+
}
|
50
|
+
|
51
|
+
S5_TAIL = %{
|
52
|
+
<!-- Syntax Highlighter -->
|
53
|
+
<script language="javascript" src="../dp.SyntaxHighlighter/Scripts/shCore.js"></script>
|
54
|
+
<script language="javascript" src="../dp.SyntaxHighlighter/Scripts/shBrushCpp.js"></script>
|
55
|
+
<script language="javascript" src="../dp.SyntaxHighlighter/Scripts/shBrushRuby.js"></script>
|
56
|
+
<script language="javascript" src="../dp.SyntaxHighlighter/Scripts/shBrushXml.js"></script>
|
57
|
+
<script language="javascript">
|
58
|
+
dp.SyntaxHighlighter.ClipboardSwf = '/flash/clipboard.swf';
|
59
|
+
dp.SyntaxHighlighter.HighlightAll('code');
|
60
|
+
</script>
|
61
|
+
</div>
|
62
|
+
</body>
|
63
|
+
</html>
|
64
|
+
}
|
65
|
+
|
66
|
+
|
67
|
+
module Codex
|
68
|
+
class Pressie
|
69
|
+
|
70
|
+
def self.process
|
71
|
+
new.process
|
72
|
+
end
|
73
|
+
|
74
|
+
def process
|
75
|
+
metadata_name = ARGV.shift || usage("Missing metadata file name")
|
76
|
+
load_metadata(metadata_name)
|
77
|
+
input_name = ARGV.shift || usage("Missing input file name")
|
78
|
+
content = Content.new(File.read(input_name)) rescue usage($!.message)
|
79
|
+
header = substitute_metadata_into(S5_HEAD)
|
80
|
+
puts header, content.to_html, S5_TAIL
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def usage(msg = nil)
|
87
|
+
STDERR.puts "pressie.rb <metadatafile> <inputfile>"
|
88
|
+
if msg
|
89
|
+
STDERR.puts
|
90
|
+
STDERR.puts msg
|
91
|
+
end
|
92
|
+
exit 1
|
93
|
+
end
|
94
|
+
|
95
|
+
def load_metadata(file_name)
|
96
|
+
@metadata = YAML.load_file(file_name)
|
97
|
+
end
|
98
|
+
|
99
|
+
def substitute_metadata_into(text)
|
100
|
+
text = text.dup
|
101
|
+
%w{author company organization date copyright title}.each do |key|
|
102
|
+
text.gsub!(/&#{key};/, @metadata[key]) if @metadata.has_key?(key)
|
103
|
+
end
|
104
|
+
text
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
code {
|
2
|
+
font-family: Monaco;
|
3
|
+
}
|
4
|
+
|
5
|
+
|
6
|
+
div.slide code {
|
7
|
+
font-weight: normal;
|
8
|
+
font-size: 85%;
|
9
|
+
color: #228;
|
10
|
+
}
|
11
|
+
|
12
|
+
div.dp-highlighter
|
13
|
+
{
|
14
|
+
font-family: "Gill Sans", "Consolas", "Courier New", Courier, mono;
|
15
|
+
font-size: 100%;
|
16
|
+
background-color: white;
|
17
|
+
overflow: auto;
|
18
|
+
/* margin: 18px 0px 18px 0px; */
|
19
|
+
padding-top: 1px; /* adds a little border on top when controls are hidden */
|
20
|
+
margin-bottom: 0px;
|
21
|
+
border: 2px solid;
|
22
|
+
}
|
23
|
+
|
24
|
+
div.dp-highlighter ol
|
25
|
+
{
|
26
|
+
margin-top: 1px;
|
27
|
+
margin-bottom: 10px;
|
28
|
+
padding: 0px;
|
29
|
+
}
|
30
|
+
|
31
|
+
div.dp-highlighter ol li
|
32
|
+
{
|
33
|
+
background-color: white;
|
34
|
+
}
|
35
|
+
|
36
|
+
div.dp-highlighter .keyword {
|
37
|
+
font-weight: normal;
|
38
|
+
color: #33b;
|
39
|
+
}
|
40
|
+
|
41
|
+
div.dp-highlighter .variable {
|
42
|
+
font-weight: normal;
|
43
|
+
}
|
44
|
+
|
45
|
+
div.dp-highlighter .string {
|
46
|
+
color: #22c;
|
47
|
+
font-style: italic;
|
48
|
+
}
|
49
|
+
|
50
|
+
.dp-cpp span.datatypes {
|
51
|
+
font-weight: normal;
|
52
|
+
}
|
53
|
+
|
54
|
+
div.codeurl {
|
55
|
+
margin-top: 0.5em;
|
56
|
+
margin-bottom: 1.5em;
|
57
|
+
padding-right: 1em;
|
58
|
+
text-align: right;
|
59
|
+
font-size: 50%;
|
60
|
+
}
|
61
|
+
|
62
|
+
div.slide ul {
|
63
|
+
margin-left: 0pt;
|
64
|
+
}
|
65
|
+
|
66
|
+
div.slide td {
|
67
|
+
padding: 0.3em 1em;
|
68
|
+
}
|
69
|
+
|
70
|
+
div.slide th {
|
71
|
+
background: #337;
|
72
|
+
color: white;
|
73
|
+
font-weight: bold;
|
74
|
+
padding: 0.2em 0em 0.2em 0em;
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
body {
|
79
|
+
background: white;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
div#header {
|
86
|
+
background: white;
|
87
|
+
display: none;
|
88
|
+
}
|
89
|
+
|
90
|
+
div#footer {
|
91
|
+
background: white;
|
92
|
+
font-size: 50%;
|
93
|
+
height: 1em;
|
94
|
+
}
|
95
|
+
|
96
|
+
div#footer h2 {
|
97
|
+
font-weight: normal;
|
98
|
+
font-size: 60%;
|
99
|
+
}
|
100
|
+
|
101
|
+
div.slide h1 {
|
102
|
+
background: white;
|
103
|
+
color: #993333;
|
104
|
+
left: 1em;
|
105
|
+
top: 0.5em;
|
106
|
+
width: 95%;
|
107
|
+
padding: 0em 0em 0em 0em;
|
108
|
+
border-bottom: 6px solid #ffaaaa;
|
109
|
+
text-transform: none;
|
110
|
+
}
|
111
|
+
|
112
|
+
|
113
|
+
div.slide h1.exercise {
|
114
|
+
background: white;
|
115
|
+
color: #339933;
|
116
|
+
left: 1em;
|
117
|
+
top: 0.5em;
|
118
|
+
width: 95%;
|
119
|
+
padding: 0em 0em 0em 0em;
|
120
|
+
border-bottom: 6px solid #aaffaa;
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
div#slide0, div.title {
|
125
|
+
height: 100%;
|
126
|
+
background-image: url(ruby.png);
|
127
|
+
background-repeat: no-repeat;
|
128
|
+
background-position: bottom right;
|
129
|
+
}
|
130
|
+
|
131
|
+
div#slide0 h1, div.title h1 {
|
132
|
+
color: #993333;
|
133
|
+
background:transparent none repeat scroll 0%;
|
134
|
+
font-family:Helvetica,sans-serif;
|
135
|
+
font-size:2em;
|
136
|
+
font-size-adjust:none;
|
137
|
+
font-stretch:normal;
|
138
|
+
font-style:normal;
|
139
|
+
font-variant:normal;
|
140
|
+
font-weight:bold;
|
141
|
+
line-height:normal;
|
142
|
+
margin:10% 0pt 0pt;
|
143
|
+
padding:0pt;
|
144
|
+
position:static;
|
145
|
+
white-space:normal;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
/* code layout */
|
150
|
+
div.code-large {
|
151
|
+
font-size: 150% !important;
|
152
|
+
line-height: 1.6em !important;
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
div.code-normal {
|
157
|
+
font-size: 90% !important;
|
158
|
+
line-height: 2em !important;
|
159
|
+
}
|
160
|
+
|
161
|
+
div.code-normal li {
|
162
|
+
margin-top: 0.6em;
|
163
|
+
}
|
164
|
+
|
165
|
+
div.code-small {
|
166
|
+
font-size: 75% !important;
|
167
|
+
line-height: 2em !important;
|
168
|
+
}
|
169
|
+
|
170
|
+
div.code-small li {
|
171
|
+
margin-top: 0.6em;
|
172
|
+
}
|
173
|
+
|
174
|
+
div.code-tiny {
|
175
|
+
font-size: 50% !important;
|
176
|
+
line-height: 2em !important;
|
177
|
+
}
|
178
|
+
|
179
|
+
div.code-tiny li {
|
180
|
+
margin-top: 0.6em;
|
181
|
+
}
|
182
|
+
|
183
|
+
div.code-supertiny {
|
184
|
+
font-size: 33% !important;
|
185
|
+
line-height: 2em !important;
|
186
|
+
}
|
187
|
+
|
188
|
+
div.code-supertiny li {
|
189
|
+
margin-top: 0.6em;
|
190
|
+
}
|
191
|
+
|
192
|
+
.caption {
|
193
|
+
color: #448;
|
194
|
+
font-family: Gil Sans;
|
195
|
+
font-size: 70%;
|
196
|
+
}
|