7 puts
"\n\nGenerating the website requires the newgem RubyGem"
8 puts
"Install: gem install newgem\n\n"
12 require 'syntax/convertors/html'
14 require File
.dirname(__FILE__
) + '/../lib/couch_object/version.rb'
16 version = CouchObject
::VERSION::STRING
17 download
= 'http://rubyforge.org/projects/couch_object'
22 return 'th' if (10..19).include?(self % 100)
35 return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
39 def convert_syntax(syntax
, source
)
40 return Syntax
::Convertors::HTML.for_syntax(syntax
).convert(source
).gsub(%r
!^
<pre
>|</pre
>$
!,'')
45 template
||= File
.join(File
.dirname(__FILE__
), '/../website/template.rhtml')
48 puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
52 template
= ERB
.new(File
.open(template
).read
)
56 File
.open(src
) do |fsrc
|
57 title_text
= fsrc
.readline
60 body_text
.gsub
!(%r
!<(pre
|code
)[^
>]*?syntax
=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
61 ident = syntax_items.length
62 element, syntax, source = $1, $2, $3
63 syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
64 "syntax-temp-#{ident}"
66 title
= RedCloth
.new(title_text
).to_html
.gsub(%r
!<.*?>!,'').strip
67 body
= RedCloth
.new(body_text
).to_html
68 body
.gsub
!(%r
!(?:<pre
><code
>)?syntax-temp-
(\d
+)(?:</code></pre
>)?!){ syntax_items
[$1.to_i
] }
74 $stdout << template
.result(binding
)