Navigation Menu

Skip to content

Commit

Permalink
Added website
Browse files Browse the repository at this point in the history
  • Loading branch information
drnic committed Feb 18, 2008
1 parent 2b66c7a commit 3bf6456
Show file tree
Hide file tree
Showing 8 changed files with 721 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/website.yml.sample
@@ -0,0 +1,2 @@
host: nicwilliams@rubyforge.org
remote_dir: /var/www/gforge-projects/jsunittest
75 changes: 75 additions & 0 deletions script/txt2html
@@ -0,0 +1,75 @@
#!/usr/bin/env ruby

require 'rubygems'
begin
require 'newgem'
rescue LoadError
puts "\n\nGenerating the website requires the newgem RubyGem"
puts "Install: gem install newgem\n\n"
exit(1)
end
require 'redcloth'
require 'syntax/convertors/html'
require 'erb'
ENV['rakefile_just_config'] = "true"
load File.dirname(__FILE__) + '/../Rakefile'

version = APP_VERSION
download = 'http://rubyforge.org/projects/jsunittest'

class Fixnum
def ordinal
# teens
return 'th' if (10..19).include?(self % 100)
# others
case self % 10
when 1: return 'st'
when 2: return 'nd'
when 3: return 'rd'
else return 'th'
end
end
end

class Time
def pretty
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
end
end

def convert_syntax(syntax, source)
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
end

if ARGV.length >= 1
src, template = ARGV
template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')

else
puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
exit!
end

template = ERB.new(File.open(template).read)

title = nil
body = nil
File.open(src) do |fsrc|
title_text = fsrc.readline
body_text = fsrc.read
syntax_items = []
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
ident = syntax_items.length
element, syntax, source = $1, $2, $3
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
"syntax-temp-#{ident}"
}
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
body = RedCloth.new(body_text).to_html
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
end
stat = File.stat(src)
created = stat.ctime
modified = stat.mtime

$stdout << template.result(binding)
35 changes: 35 additions & 0 deletions tasks/website.rake
@@ -0,0 +1,35 @@
require 'yaml'

def website_config
unless @website_config
begin
@website_config = YAML.load(File.read(File.expand_path(File.dirname(__FILE__) + "/../config/website.yml")))
rescue
puts <<-EOS
To upload your website to a host, you need to configure
config/website.yml. See config/website.yml.sample for
an example.
EOS
exit
end
end
@website_config
end

desc 'Generate website files'
task :website_generate => [:ruby_env, :dist] do
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
end
end

desc 'Upload website files to rubyforge'
task :website_upload do
host = website_config["host"] # "#{rubyforge_username}@rubyforge.org"
remote_dir = website_config["remote_dir"] # "/var/www/gforge-projects/#{PATH}/"
local_dir = 'website'
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
end

desc 'Generate and upload website files'
task :website => [:website_generate, :website_upload]
97 changes: 97 additions & 0 deletions website/index.html
@@ -0,0 +1,97 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
jsunittest
</title>
<script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>

<script type="text/javascript">
window.onload = function() {
settings = {
tl: { radius: 10 },
tr: { radius: 10 },
bl: { radius: 10 },
br: { radius: 10 },
antiAlias: true,
autoPad: true,
validTags: ["div"]
}
var versionBox = new curvyCorners(settings, document.getElementById("version"));
versionBox.applyCornersToAll();
}
</script>
</head>
<body>
<div id="main">

<h1>jsunittest</h1>
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/jsunittest"; return false'>
<p>Get Version</p>
<a href="http://rubyforge.org/projects/jsunittest" class="numbers">0.5.0</a>
</div>
<h2>What</h2>


<p>This JavaScript project &#8230;</p>


<h2>Downloading</h2>


<p><a href="dist/jsunittest.js">jsunittest.js</a></p>


<h2>The basics</h2>


<h2>Demonstration of usage</h2>


<h2>Forum</h2>


<p><a href="http://groups.google.com/group/jsunittest">http://groups.google.com/group/jsunittest</a></p>


<p><span class="caps">TODO</span> &#8211; create Google Group &#8211; jsunittest</p>


<h2>How to submit patches</h2>


<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people&#8217;s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>


<p>The trunk repository is <code>svn://rubyforge.org/var/svn/jsunittest/trunk</code> for anonymous access.</p>


<p>OR</p>


<p>The source project is a <a href="http://git.or.cz/">Git</a> repository. See Dr Nic Williams&#8217;s <a href="http://github.com/nicwilliams/jsunittest/tree/master">master branch</a> for clone/checkout details.</p>


<h2>License</h2>


<p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>


<h2>Contact</h2>


<p>Comments are welcome. Send an email to <a href="mailto:drnicwilliams@gmail.com">Dr Nic Williams</a> via the <a href="http://groups.google.com/group/jsunittest">forum</a></p>
<p class="coda">
<a href="drnicwilliams@gmail.com">Dr Nic Williams</a>, 18th February 2008<br>
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
</p>
</div>

<!-- insert site tracking codes here, like Google Urchin -->

</body>
</html>
43 changes: 43 additions & 0 deletions website/index.txt
@@ -0,0 +1,43 @@
h1. jsunittest

h2. What

This JavaScript project ...

h2. Downloading

<a href="dist/jsunittest.js">jsunittest.js</a>


h2. The basics


h2. Demonstration of usage



h2. Forum

"http://groups.google.com/group/jsunittest":http://groups.google.com/group/jsunittest

TODO - create Google Group - jsunittest

h2. How to submit patches

Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.

The trunk repository is <code>svn://rubyforge.org/var/svn/jsunittest/trunk</code> for anonymous access.

OR

The source project is a "Git":http://git.or.cz/ repository. See Dr Nic Williams's "master branch":http://github.com/nicwilliams/jsunittest/tree/master for clone/checkout details.


h2. License

This code is free to use under the terms of the MIT license.

h2. Contact

Comments are welcome. Send an email to "Dr Nic Williams":mailto:drnicwilliams@gmail.com via the "forum":http://groups.google.com/group/jsunittest

0 comments on commit 3bf6456

Please sign in to comment.