webby 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.3.0 / 2007-09-17
2
+
3
+ * Added support for CodeRay syntax highlighting
4
+
1
5
  == 0.2.0 / 2007-08-28
2
6
 
3
7
  * Updated rake tasks for website deployment
data/Manifest.txt CHANGED
@@ -19,6 +19,7 @@ data/content/css/blueprint/lib/reset.css
19
19
  data/content/css/blueprint/lib/typography.css
20
20
  data/content/css/blueprint/print.css
21
21
  data/content/css/blueprint/screen.css
22
+ data/content/css/coderay.css
22
23
  data/content/css/site.css
23
24
  data/content/index.txt
24
25
  data/layouts/default.rhtml
@@ -30,6 +31,7 @@ data/templates/page.erb
30
31
  lib/webby.rb
31
32
  lib/webby/auto_builder.rb
32
33
  lib/webby/builder.rb
34
+ lib/webby/coderay_filter.rb
33
35
  lib/webby/file.rb
34
36
  lib/webby/main.rb
35
37
  lib/webby/pages_db.rb
@@ -64,6 +66,8 @@ website/content/css/blueprint/screen.css
64
66
  website/content/css/site.css
65
67
  website/content/download.txt
66
68
  website/content/index.txt
69
+ website/content/manual.txt
70
+ website/content/tips_and_tricks.txt
67
71
  website/content/tutorial.txt
68
72
  website/layouts/default.rhtml
69
73
  website/tasks/create.rake
data/Rakefile CHANGED
@@ -27,7 +27,8 @@ PROJ.rdoc_exclude << '^(\.\/|\/)?website'
27
27
 
28
28
  PROJ.spec_opts << '--color'
29
29
 
30
- PROJ.dependencies << ['rspec', ">= #{Spec::VERSION::STRING}"]
31
- PROJ.dependencies << ['directory_watcher', ">= #{DirectoryWatcher::VERSION}"]
30
+ depend_on 'directory_watcher', '1.0.0'
31
+ depend_on 'hpricot'
32
+ depend_on 'rspec'
32
33
 
33
34
  # EOF
@@ -0,0 +1,111 @@
1
+ .CodeRay {
2
+ padding: 0.5em;
3
+ margin-bottom: 1.3em;
4
+ background-color: #eee;
5
+ border: 1px solid black;
6
+ font: 1.1em Monaco, 'Courier New', 'Terminal', monospace;
7
+ color: #100;
8
+ }
9
+ .CodeRay pre {
10
+ padding: 0px;
11
+ margin: 0px;
12
+ overflow: auto;
13
+ background-color: transparent;
14
+ border: none;
15
+ }
16
+
17
+ div.CodeRay { }
18
+
19
+ span.CodeRay { white-space: pre; border: 0px; padding: 2px }
20
+
21
+ table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px }
22
+ table.CodeRay td { padding: 2px 4px; vertical-align: top }
23
+
24
+ .CodeRay .line_numbers, .CodeRay .no {
25
+ background-color: #def;
26
+ color: gray;
27
+ text-align: right;
28
+ }
29
+ .CodeRay .line_numbers tt { font-weight: bold }
30
+ .CodeRay .no { padding: 0px 4px }
31
+
32
+ ol.CodeRay { font-size: 10pt }
33
+ ol.CodeRay li { white-space: pre }
34
+
35
+ .CodeRay .debug { color:white ! important; background:blue ! important; }
36
+
37
+ .CodeRay .af { color:#00C }
38
+ .CodeRay .an { color:#007 }
39
+ .CodeRay .av { color:#700 }
40
+ .CodeRay .aw { color:#C00 }
41
+ .CodeRay .bi { color:#509; font-weight:bold }
42
+ .CodeRay .c { color:#666; }
43
+
44
+ .CodeRay .ch { color:#04D }
45
+ .CodeRay .ch .k { color:#04D }
46
+ .CodeRay .ch .dl { color:#039 }
47
+
48
+ .CodeRay .cl { color:#B06; font-weight:bold }
49
+ .CodeRay .co { color:#036; font-weight:bold }
50
+ .CodeRay .cr { color:#0A0 }
51
+ .CodeRay .cv { color:#369 }
52
+ .CodeRay .df { color:#099; font-weight:bold }
53
+ .CodeRay .di { color:#088; font-weight:bold }
54
+ .CodeRay .dl { color:black }
55
+ .CodeRay .do { color:#970 }
56
+ .CodeRay .ds { color:#D42; font-weight:bold }
57
+ .CodeRay .e { color:#666; font-weight:bold }
58
+ .CodeRay .en { color:#800; font-weight:bold }
59
+ .CodeRay .er { color:#F00; background-color:#FAA }
60
+ .CodeRay .ex { color:#F00; font-weight:bold }
61
+ .CodeRay .fl { color:#60E; font-weight:bold }
62
+ .CodeRay .fu { color:#06B; font-weight:bold }
63
+ .CodeRay .gv { color:#d70; font-weight:bold }
64
+ .CodeRay .hx { color:#058; font-weight:bold }
65
+ .CodeRay .i { color:#00D; font-weight:bold }
66
+ .CodeRay .ic { color:#B44; font-weight:bold }
67
+
68
+ .CodeRay .il { background: #eee }
69
+ .CodeRay .il .il { background: #ddd }
70
+ .CodeRay .il .il .il { background: #ccc }
71
+ .CodeRay .il .idl { font-weight: bold; color: #888 }
72
+
73
+ .CodeRay .in { color:#B2B; font-weight:bold }
74
+ .CodeRay .iv { color:#33B }
75
+ .CodeRay .la { color:#970; font-weight:bold }
76
+ .CodeRay .lv { color:#963 }
77
+ .CodeRay .oc { color:#40E; font-weight:bold }
78
+ .CodeRay .of { color:#000; font-weight:bold }
79
+ .CodeRay .op { }
80
+ .CodeRay .pc { color:#038; font-weight:bold }
81
+ .CodeRay .pd { color:#369; font-weight:bold }
82
+ .CodeRay .pp { color:#579 }
83
+ .CodeRay .pt { color:#339; font-weight:bold }
84
+ .CodeRay .r { color:#080; font-weight:bold }
85
+
86
+ .CodeRay .rx { background-color:#fff0ff }
87
+ .CodeRay .rx .k { color:#808 }
88
+ .CodeRay .rx .dl { color:#404 }
89
+ .CodeRay .rx .mod { color:#C2C }
90
+ .CodeRay .rx .fu { color:#404; font-weight: bold }
91
+
92
+ .CodeRay .s { background-color:#fff0f0 }
93
+ .CodeRay .s .s { background-color:#ffe0e0 }
94
+ .CodeRay .s .s .s { background-color:#ffd0d0 }
95
+ .CodeRay .s .k { color:#D20 }
96
+ .CodeRay .s .dl { color:#710 }
97
+
98
+ .CodeRay .sh { background-color:#f0fff0 }
99
+ .CodeRay .sh .k { color:#2B2 }
100
+ .CodeRay .sh .dl { color:#161 }
101
+
102
+ .CodeRay .sy { color:#A60 }
103
+ .CodeRay .sy .k { color:#A60 }
104
+ .CodeRay .sy .dl { color:#630 }
105
+
106
+ .CodeRay .ta { color:#070 }
107
+ .CodeRay .tf { color:#070; font-weight:bold }
108
+ .CodeRay .ts { color:#D70; font-weight:bold }
109
+ .CodeRay .ty { color:#339; font-weight:bold }
110
+ .CodeRay .v { color:#036 }
111
+ .CodeRay .xt { color:#444 }
@@ -15,6 +15,9 @@ filter: erb
15
15
  <link rel="stylesheet" href="css/blueprint/screen.css" type="text/css" media="screen, projection" />
16
16
  <link rel="stylesheet" href="css/blueprint/print.css" type="text/css" media="print" />
17
17
 
18
+ <!-- CodeRay syntax highlighting CSS -->
19
+ <link rel="stylesheet" href="css/coderay.css" type="text/css" />
20
+
18
21
  <!-- Homepage CSS -->
19
22
  <link rel="stylesheet" href="css/site.css" type="text/css" media="screen, projection" />
20
23
  </head>
@@ -0,0 +1,79 @@
1
+ # $Id: coderay_filter.rb 24 2007-09-17 22:22:06Z tim_pease $
2
+
3
+ require 'enumerator'
4
+ require 'hpricot'
5
+ try_require 'coderay'
6
+
7
+ module Webby
8
+
9
+ # The CodeRayFilter applies syntax highlighting to source code embedded in a
10
+ # webpage. The CodeRay highlighting engine is used for the HTML markup of
11
+ # the source code. A set of <coderay>...</coderay> tags is used to denote
12
+ # which sections of the page should be highlighted.
13
+ #
14
+ # Options can be passed to the CodeRay engine via attributes in the
15
+ # <coderay> tag.
16
+ #
17
+ # <coderay lang="ruby" line_numbers="inline">
18
+ # # Initializer for the class.
19
+ # def initialize( string )
20
+ # @str = stirng
21
+ # end
22
+ # </coderay>
23
+ #
24
+ # The supported CodeRay options are the following:
25
+ #
26
+ # line_numbers : include line nubers in 'table', 'linline',
27
+ # or 'list'
28
+ # line_number_start : where to start with line number counting
29
+ # bold_every : make every n-th number appear bold
30
+ # tab_width : convert tab characters to n spaces
31
+ #
32
+ class CodeRayFilter
33
+
34
+ # call-seq:
35
+ # CodeRayFilter.new( string )
36
+ #
37
+ # Creates a new CodeRay filter that will operate on the given _string_.
38
+ #
39
+ def initialize( str )
40
+ @str = str
41
+ end
42
+
43
+ # call-seq:
44
+ # to_html => string
45
+ #
46
+ # Process the original text string passed to the filter when it was
47
+ # created and output HTML formatted text. Any text between
48
+ # <coderay>...</coderay> tags will have syntax highlighting applied to the
49
+ # text via the CodeRay gem.
50
+ #
51
+ def to_html
52
+ doc = Hpricot(@str)
53
+ doc.search('//coderay') do |cr|
54
+ text = cr.inner_html.strip
55
+ lang = (cr['lang'] || 'ruby').to_sym
56
+
57
+ opts = {}
58
+ %w(line_numbers to_sym
59
+ line_number_start to_i
60
+ bold_every to_i
61
+ tab_width to_i).each_slice(2) do |key,convert|
62
+ next if cr[key].nil?
63
+ opts[key.to_sym] = cr[key].send(convert)
64
+ end
65
+
66
+ #cr.swap(CodeRay.scan(text, lang).html(opts).div)
67
+ out = "<div class=\"CodeRay\"><pre>\n"
68
+ out << CodeRay.scan(text, lang).html(opts)
69
+ out << "\n</pre></div>"
70
+ cr.swap out
71
+ end
72
+
73
+ doc.to_html
74
+ end
75
+
76
+ end # class CodeRayFilter
77
+ end # module Webby
78
+
79
+ # EOF
@@ -1,7 +1,6 @@
1
- # $Id: renderer.rb 19 2007-08-28 22:48:24Z tim_pease $
1
+ # $Id: renderer.rb 22 2007-09-17 20:36:39Z tim_pease $
2
2
 
3
3
  require 'erb'
4
-
5
4
  try_require 'bluecloth'
6
5
  try_require 'redcloth'
7
6
 
@@ -85,6 +84,15 @@ class Renderer
85
84
  str
86
85
  end
87
86
 
87
+ #
88
+ #
89
+ def coderay_filter( str )
90
+ CodeRayFilter.new(str).to_html
91
+ rescue NameError
92
+ $stderr.puts "ERROR: coderay filter failed (CodeRay not installed?)"
93
+ exit
94
+ end
95
+
88
96
  # Render text via ERB using the built in ERB library.
89
97
  #
90
98
  def erb_filter( str )
data/lib/webby.rb CHANGED
@@ -1,8 +1,8 @@
1
- # $Id: webby.rb 19 2007-08-28 22:48:24Z tim_pease $
1
+ # $Id: webby.rb 25 2007-09-17 22:46:55Z tim_pease $
2
2
 
3
3
  module Webby
4
4
 
5
- VERSION = '0.2.0' # :nodoc:
5
+ VERSION = '0.3.0' # :nodoc:
6
6
 
7
7
  # Path to the Webby package
8
8
  PATH = ::File.expand_path(::File.join(::File.dirname(__FILE__), '..'))
data/tasks/setup.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: setup.rb 13 2007-08-23 22:18:00Z tim_pease $
1
+ # $Id: setup.rb 22 2007-09-17 20:36:39Z tim_pease $
2
2
 
3
3
  require 'rubygems'
4
4
  require 'ostruct'
@@ -106,4 +106,15 @@ def paragraphs_of(path, *paragraphs)
106
106
  File.read(path).delete("\r").split(/\n\n+/).values_at(*paragraphs)
107
107
  end
108
108
 
109
+ # Adds the given gem _name_ to the current project's dependency list. An
110
+ # optional gem _version_ can be given. If omitted, the newest gem version
111
+ # will be used.
112
+ #
113
+ def depend_on( name, version = nil )
114
+ spec = Gem.source_index.find_name(name).last
115
+ version = spec.version.to_s if version.nil? and !spec.nil?
116
+
117
+ PROJ.dependencies << (version.nil? ? [name] : [name, ">= #{version}"])
118
+ end
119
+
109
120
  # EOF
@@ -12,7 +12,7 @@ body { margin: 1.0em 0 }
12
12
  #footer hr { margin-bottom: 0.5em }
13
13
  #footer p { text-align: right }
14
14
 
15
- .code {
15
+ pre.code {
16
16
  padding: 0.5em;
17
17
  margin-bottom: 1.3em;
18
18
  color: #fff;
@@ -0,0 +1,10 @@
1
+ ---
2
+ title: Manual
3
+ created_at: Wed Aug 29 08:57:00 -0600 2007
4
+ filter:
5
+ - coderay
6
+ - textile
7
+ ---
8
+ h2. To-Do
9
+
10
+ The Webby user's manual goes here.
@@ -0,0 +1,54 @@
1
+ ---
2
+ title: Tips & Tricks
3
+ created_at: Wed Aug 29 08:57:11 -0600 2007
4
+ filter:
5
+ - erb
6
+ - coderay
7
+ - textile
8
+ ---
9
+ h2. To-Do
10
+
11
+ The Webby tips & tricks page goes here.
12
+
13
+ <notextile>
14
+ <coderay line_numbers="inline">
15
+ # call-seq:
16
+ # render_page => string
17
+ #
18
+ # Apply the desired filters to the page. The filters to apply are
19
+ # determined from the page's meta-data.
20
+ #
21
+ def render_page
22
+ ary = []
23
+ str = ::Webby::File.read(@page.path)
24
+
25
+ str << "and some more text"
26
+
27
+ @page.filter.to_a.each do |filter|
28
+ str = self.send(filter + '_filter', str)
29
+ end
30
+
31
+ str
32
+ end
33
+ </coderay>
34
+ </notextile>
35
+
36
+ And some more text.
37
+
38
+ <pre class="code">
39
+ ---
40
+ title: Home Page
41
+ filter:
42
+ - erb
43
+ - textile
44
+ ---
45
+ h2. <%= @page.title %>
46
+
47
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc congue ipsum
48
+ vestibulum libero. Aenean vitae justo. Nam eget tellus. Etiam convallis, est
49
+ eu lobortis mattis, lectus tellus tempus felis, a ultricies erat ipsum at
50
+ metus.
51
+
52
+ h3. Litora Sociis
53
+ ...
54
+ </pre>
@@ -8,13 +8,16 @@ filter: erb
8
8
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">
9
9
  <head>
10
10
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
11
- <title>Webby :: <%= @page.title %></title>
12
- <meta name="author" content="<%= @page.author %>" />
11
+ <title>Webby :: <%= h(@page.title) %></title>
12
+ <meta name="author" content="<%= h(@page.author) %>" />
13
13
 
14
14
  <!--- Blueprint CSS Framework -->
15
15
  <link rel="stylesheet" href="css/blueprint/screen.css" type="text/css" media="screen, projection" />
16
16
  <link rel="stylesheet" href="css/blueprint/print.css" type="text/css" media="print" />
17
17
 
18
+ <!-- CodeRay text highlighting CSS -->
19
+ <link rel="stylesheet" href="css/coderay.css" type="text/css" media="all" />
20
+
18
21
  <!-- Homepage CSS -->
19
22
  <link rel="stylesheet" href="css/site.css" type="text/css" media="screen, projection" />
20
23
  </head>
@@ -23,7 +26,7 @@ filter: erb
23
26
  <div class="container">
24
27
 
25
28
  <div class="column span-11 prepend-1 append-2 first last" id="header">
26
- <h1>Webby &#9775; <%= @page.title %></h1>
29
+ <h1>Webby &#9775; <%= h(@page.title) %></h1>
27
30
  <hr />
28
31
  <ul id="navigation"
29
32
  ><li><a href="index.html">Home</a>&#8766;</li
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: webby
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.0
7
- date: 2007-08-28 00:00:00 -06:00
6
+ version: 0.3.0
7
+ date: 2007-09-17 00:00:00 -06:00
8
8
  summary: static website creation and management
9
9
  require_paths:
10
10
  - lib
@@ -50,6 +50,7 @@ files:
50
50
  - data/content/css/blueprint/lib/typography.css
51
51
  - data/content/css/blueprint/print.css
52
52
  - data/content/css/blueprint/screen.css
53
+ - data/content/css/coderay.css
53
54
  - data/content/css/site.css
54
55
  - data/content/index.txt
55
56
  - data/layouts/default.rhtml
@@ -61,6 +62,7 @@ files:
61
62
  - lib/webby.rb
62
63
  - lib/webby/auto_builder.rb
63
64
  - lib/webby/builder.rb
65
+ - lib/webby/coderay_filter.rb
64
66
  - lib/webby/file.rb
65
67
  - lib/webby/main.rb
66
68
  - lib/webby/pages_db.rb
@@ -95,6 +97,8 @@ files:
95
97
  - website/content/css/site.css
96
98
  - website/content/download.txt
97
99
  - website/content/index.txt
100
+ - website/content/manual.txt
101
+ - website/content/tips_and_tricks.txt
98
102
  - website/content/tutorial.txt
99
103
  - website/layouts/default.rhtml
100
104
  - website/tasks/create.rake
@@ -119,22 +123,31 @@ requirements: []
119
123
 
120
124
  dependencies:
121
125
  - !ruby/object:Gem::Dependency
122
- name: rspec
126
+ name: directory_watcher
123
127
  version_requirement:
124
128
  version_requirements: !ruby/object:Gem::Version::Requirement
125
129
  requirements:
126
130
  - - ">="
127
131
  - !ruby/object:Gem::Version
128
- version: 1.0.5
132
+ version: 1.0.0
129
133
  version:
130
134
  - !ruby/object:Gem::Dependency
131
- name: directory_watcher
135
+ name: hpricot
132
136
  version_requirement:
133
137
  version_requirements: !ruby/object:Gem::Version::Requirement
134
138
  requirements:
135
139
  - - ">="
136
140
  - !ruby/object:Gem::Version
137
- version: 1.0.0
141
+ version: "0.6"
142
+ version:
143
+ - !ruby/object:Gem::Dependency
144
+ name: rspec
145
+ version_requirement:
146
+ version_requirements: !ruby/object:Gem::Version::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: 1.0.5
138
151
  version:
139
152
  - !ruby/object:Gem::Dependency
140
153
  name: rake