diff options
author | Florian Frank <flori@ping.de> | 2009-08-24 16:44:34 +0200 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2009-08-24 16:44:34 +0200 |
commit | bcbd6f7ee4b0aaaa670198c197f181ac28cb6086 (patch) | |
tree | 26218fa15e2bed68b0cb3ff4eb86d849510f5db7 | |
download | json-bcbd6f7ee4b0aaaa670198c197f181ac28cb6086.tar.gz |
initial commit
-rw-r--r-- | Rakefile | 51 | ||||
-rw-r--r-- | author.incl | 2 | ||||
-rw-r--r-- | description.incl | 58 | ||||
-rw-r--r-- | doc/.keep | 0 | ||||
-rw-r--r-- | edit_json.png | bin | 0 -> 55917 bytes | |||
-rw-r--r-- | footer.incl | 7 | ||||
-rw-r--r-- | header.incl | 11 | ||||
-rw-r--r-- | headline.incl | 1 | ||||
-rw-r--r-- | index.html | 180 | ||||
-rw-r--r-- | index.tmpl | 12 | ||||
-rw-r--r-- | installation.incl | 17 | ||||
-rw-r--r-- | json.png | bin | 0 -> 5288 bytes | |||
-rw-r--r-- | license.incl | 5 | ||||
-rw-r--r-- | linkbox.incl | 10 | ||||
-rw-r--r-- | logo.incl | 1 | ||||
-rw-r--r-- | meta.json | 19 | ||||
-rw-r--r-- | screenshots.html | 107 | ||||
-rw-r--r-- | screenshots.tmpl | 21 | ||||
-rw-r--r-- | style.css | 93 | ||||
-rw-r--r-- | usage.incl | 56 |
20 files changed, 651 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..b3e03ac --- /dev/null +++ b/Rakefile @@ -0,0 +1,51 @@ +require 'flott' +require 'json' +include Flott + +$meta = JSON.parse(File.read('meta.json')) + +task :default => [:doc, :homepage] + +desc "Create the project documentation." +task :doc do + if File.directory?('doc') + sh 'git rm -r doc' + end + sh 'git commit -m "deleted documentation" doc' + sh 'git checkout master' + rm_rf 'doc' + sh 'rake doc' + sh 'git checkout gh-pages' + sh 'git add doc' + sh 'git commit -m "generated documentation" doc' +end + +desc "Compile the homepage." +task :compile_homepage do + env = Environment.new + env.update($meta) + for tmpl in Dir['*.tmpl'] + ext = File.extname(tmpl) + out_name = tmpl.sub(/#{ext}$/, '.html') + warn "Compiling '#{tmpl}' -> '#{out_name}'." + File.open(out_name, 'w') do |o| + env.output = o + fp = Parser.from_filename(tmpl) + fp.evaluate(env) + end + end +end + +desc "Check the homepage with tidy." +task :tidy_homepage do + sh "tidy -e *index.html" +end + +desc "Compile and check the homepage." +task :homepage => [ :compile_homepage, :tidy_homepage ] + +desc "Publish the homepage to rubyforge." +task :publish_rubyforge => :homepage do + sh "scp -r rubyforge_index.html rubyforge.org:/var/www/gforge-projects/#{$meta['project_unixname']}/index.html" +end + # vim: set et sw=2 ts=2: diff --git a/author.incl b/author.incl new file mode 100644 index 0000000..eed563c --- /dev/null +++ b/author.incl @@ -0,0 +1,2 @@ +<h2>Author</h2> +[=@author] <<a href="mailto:[=@author_email]">[=@author_email]</a>> diff --git a/description.incl b/description.incl new file mode 100644 index 0000000..762be2a --- /dev/null +++ b/description.incl @@ -0,0 +1,58 @@ +<h2>Description</h2> +<p> +This is a implementation of the JSON specification according to +<a href="http://www.ietf.org/rfc/rfc4627.txt">RFC 4627</a>. You can think of it as a low fat +alternative to XML, if you want to store data to disk or transmit it over a +network rather than use a verbose markup language. +</p> +<p> +Starting from version 1.0.0 on there +will be two variants available: +</p> +<ul> +<li>A pure ruby variant, that relies on the iconv and the stringscan + extensions, which are both part of the ruby standard library.</li> +<li> The quite a bit faster (see the <a href="doc/index.html">documentation</a>) C + extension variant, which is in parts implemented in C and comes with its own + unicode conversion functions and a parser + generated by the <a href="http://www.cs.queensu.ca/~thurston/ragel">Ragel + State Machine Compiler</a>.</li> +</ul> +<p> +Both variants of the JSON generator escape all non-ASCII an control +characters with \uXXXX escape sequences, and support UTF-16 surrogate pairs +in order to be able to generate the whole range of unicode code points. This +means that generated JSON text is encoded as UTF-8 (because ASCII is a subset +of UTF-8) and at the same time avoids decoding problems for receiving +endpoints, that don't expect UTF-8 encoded texts. On the negative side this +may lead to a bit longer strings than necessarry. +</p> +<p> +It's also easy to extend JSON data types for arbitrary Ruby classes (including +your own) like this: +</p> +<pre> +class Range + def to_json(*a) + { + 'json_class' => self.class.name, + 'data' => \[ first, last, exclude_end? ] + }.to_json(*a) + end + + def self.json_create(o) + new(*o\['data']) + end +end +</pre> +<p> +Now Range instances can be serialized/deserialized: +</p> +<pre> +JSON.parse((1..10).to_json) == (1..10) +</pre> +<p> +A lot of additional information about JSON can be found <a +href="http://www.json.org/">Douglas Crockford's JSON +site</a>. +</p> diff --git a/doc/.keep b/doc/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/doc/.keep diff --git a/edit_json.png b/edit_json.png Binary files differnew file mode 100644 index 0000000..cd1fa8a --- /dev/null +++ b/edit_json.png diff --git a/footer.incl b/footer.incl new file mode 100644 index 0000000..f6abde4 --- /dev/null +++ b/footer.incl @@ -0,0 +1,7 @@ + <p class="valid"> + <a href="http://validator.w3.org/check?uri=referer"><img + src="http://www.w3.org/Icons/valid-xhtml10" + alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a> + </p> + </body> +</html> diff --git a/header.incl b/header.incl new file mode 100644 index 0000000..b34c8cd --- /dev/null +++ b/header.incl @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<!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" xml:lang="en" lang="en"> + <head> + <link rel="stylesheet" href="style.css" type="text/css" /> + <title>[=@project_name]</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + </head> + <body> diff --git a/headline.incl b/headline.incl new file mode 100644 index 0000000..d2e0f50 --- /dev/null +++ b/headline.incl @@ -0,0 +1 @@ + <h1>[=@project_unixname] – [=@project_name]</h1> diff --git a/index.html b/index.html new file mode 100644 index 0000000..b6e65a8 --- /dev/null +++ b/index.html @@ -0,0 +1,180 @@ +<?xml version="1.0" encoding="utf-8"?> +<!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" xml:lang="en" lang="en"> + <head> + <link rel="stylesheet" href="style.css" type="text/css" /> + <title>JSON implementation for Ruby</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + </head> + <body> + + <ul id="linkbox"> + <li><a href="/index.html">Homepage</a></li> + <li><a href="http://github.com/flori/json/tree/master">Github Repository</a></li> + <li><a href="http://rubyforge.org/projects/json">Rubyforge Project</a></li> + <li><a href="http://rubyforge.org/frs/?group_id=953">Download</a></li> + <li><a href="doc/index.html">Documentation</a></li> + + <li><a href="screenshots.html">Screenshots</a></li> + + </ul> + + <img id="logo" src="json.png" alt="JaSON, the Argonaut" title="JaSON, the Argonaut" /> + + <div id="content"> + <h1>json – JSON implementation for Ruby</h1> + +<h2>Description</h2> +<p> +This is a implementation of the JSON specification according to +<a href="http://www.ietf.org/rfc/rfc4627.txt">RFC 4627</a>. You can think of it as a low fat +alternative to XML, if you want to store data to disk or transmit it over a +network rather than use a verbose markup language. +</p> +<p> +Starting from version 1.0.0 on there +will be two variants available: +</p> +<ul> +<li>A pure ruby variant, that relies on the iconv and the stringscan + extensions, which are both part of the ruby standard library.</li> +<li> The quite a bit faster (see the <a href="doc/index.html">documentation</a>) C + extension variant, which is in parts implemented in C and comes with its own + unicode conversion functions and a parser + generated by the <a href="http://www.cs.queensu.ca/~thurston/ragel">Ragel + State Machine Compiler</a>.</li> +</ul> +<p> +Both variants of the JSON generator escape all non-ASCII an control +characters with \uXXXX escape sequences, and support UTF-16 surrogate pairs +in order to be able to generate the whole range of unicode code points. This +means that generated JSON text is encoded as UTF-8 (because ASCII is a subset +of UTF-8) and at the same time avoids decoding problems for receiving +endpoints, that don't expect UTF-8 encoded texts. On the negative side this +may lead to a bit longer strings than necessarry. +</p> +<p> +It's also easy to extend JSON data types for arbitrary Ruby classes (including +your own) like this: +</p> +<pre> +class Range + def to_json(*a) + { + 'json_class' => self.class.name, + 'data' => [ first, last, exclude_end? ] + }.to_json(*a) + end + + def self.json_create(o) + new(*o['data']) + end +end +</pre> +<p> +Now Range instances can be serialized/deserialized: +</p> +<pre> +JSON.parse((1..10).to_json) == (1..10) +</pre> +<p> +A lot of additional information about JSON can be found <a +href="http://www.json.org/">Douglas Crockford's JSON +site</a>. +</p> + +<h2>Installation</h2> +<p> +The library can be installed via rubygems: +</p> +<pre> +# gem install json +</pre> +<p> +If you have to use the pure variant, you can use: +</p> +<pre> +# gem install json_pure +</pre> +<p> +The gem and the source archive can also be <a +href="http://rubyforge.org/frs/?group_id=953">downloaded</a> directly from rubyforge.org. +</p> + +<h2>Usage</h2> +<p> +If you require JSON like this: +</p> +<pre> +require 'json' +</pre> +<p> +JSON first tries to load the extension variant. If this fails, the pure variant +is loaded and used. +</p> +<p> +To determine, which variant is active you can use the follwing methods: +</p> +<ul> +<li>Ext variant: +<pre> +[ JSON.parser, JSON.generator ] # => [JSON::Ext::Parser, JSON::Ext::Generator] +</pre> +</li> +<li>Pure variant: +<pre> +[ JSON.parser, JSON.generator ] # => [JSON::Pure::Parser, JSON::Pure::Generator] +</pre> +</li> +</ul> +<p> +If you want to enforce loading of a special variant, use +</p> +<pre> +require 'json/ext' +</pre> +<p> +to load the extension variant. Or use +</p> +<pre> +require 'json/pure' +</pre> +<p> +to use the pure variant. +</p> +<p> +You can choose to load a set of common additions to ruby core's objects if you +</p> +<pre> + require 'json/add/core' +</pre> +<p> + To get the best compatibility to rails' JSON implementation, you can +</p> +<pre> + require 'json/add/rails' +</pre> +<p> + Both of the additions attempt to require 'json' (like above) first, if it has not been required yet. +</p> + +<h2>Author</h2> +Florian Frank <<a href="mailto:flori@ping.de">flori@ping.de</a>> + +<h2>License</h2> +<p> +This is software is distributed under the same license as Ruby itself. See <a +href="http://www.ruby-lang.org/en/LICENSE.txt">http://www.ruby-lang.org/en/LICENSE.txt</a>. +</p> + + </div> + <p class="valid"> + <a href="http://validator.w3.org/check?uri=referer"><img + src="http://www.w3.org/Icons/valid-xhtml10" + alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a> + </p> + </body> +</html> + diff --git a/index.tmpl b/index.tmpl new file mode 100644 index 0000000..10e3a11 --- /dev/null +++ b/index.tmpl @@ -0,0 +1,12 @@ +[^header.incl] +[^linkbox.incl] +[^logo.incl] + <div id="content"> +[^headline.incl] +[^description.incl] +[^installation.incl] +[^usage.incl] +[^author.incl] +[^license.incl] + </div> +[^footer.incl] diff --git a/installation.incl b/installation.incl new file mode 100644 index 0000000..ad3e55c --- /dev/null +++ b/installation.incl @@ -0,0 +1,17 @@ +<h2>Installation</h2> +<p> +The library can be installed via rubygems: +</p> +<pre> +# gem install [=@project_unixname] +</pre> +<p> +If you have to use the pure variant, you can use: +</p> +<pre> +# gem install [=@project_unixname]_pure +</pre> +<p> +The gem and the source archive can also be <a +href="[=@download_url]">downloaded</a> directly from rubyforge.org. +</p> diff --git a/json.png b/json.png Binary files differnew file mode 100644 index 0000000..09e8a71 --- /dev/null +++ b/json.png diff --git a/license.incl b/license.incl new file mode 100644 index 0000000..0e6071f --- /dev/null +++ b/license.incl @@ -0,0 +1,5 @@ +<h2>License</h2> +<p> +This is software is distributed under the same license as Ruby itself. See <a +href="http://www.ruby-lang.org/en/LICENSE.txt">http://www.ruby-lang.org/en/LICENSE.txt</a>. +</p> diff --git a/linkbox.incl b/linkbox.incl new file mode 100644 index 0000000..415c886 --- /dev/null +++ b/linkbox.incl @@ -0,0 +1,10 @@ + <ul id="linkbox"> + <li><a href="[=@homepage_url]/index.html">Homepage</a></li> + <li><a href="[=@github_url]">Github Repository</a></li> + <li><a href="[=@project_url]">Rubyforge Project</a></li> + <li><a href="[=@download_url]">Download</a></li> + <li><a href="[=@documentation_url]">Documentation</a></li> + [if defined?(@screenshots) and not @screenshots.empty?] + <li><a href="screenshots.html">Screenshots</a></li> + [end] + </ul> diff --git a/logo.incl b/logo.incl new file mode 100644 index 0000000..40255bf --- /dev/null +++ b/logo.incl @@ -0,0 +1 @@ + <img id="logo" src="json.png" alt="JaSON, the Argonaut" title="JaSON, the Argonaut" /> diff --git a/meta.json b/meta.json new file mode 100644 index 0000000..10f4a67 --- /dev/null +++ b/meta.json @@ -0,0 +1,19 @@ +{ + "author_email":"flori@ping.de", + "author":"Florian Frank", + "documentation_url":"doc/index.html", + "download_url":"http://rubyforge.org/frs/?group_id=953", + "github_url": "http:\/\/github.com\/flori\/json\/tree\/master", + "project_name":"JSON implementation for Ruby", + "project_unixname":"json", + "project_url":"http://rubyforge.org/projects/json", + "screenshots":["edit_json.png", + "diagrams/JSON_array.png", + "diagrams/JSON_float.png", + "diagrams/JSON_integer.png", + "diagrams/JSON_object.png", + "diagrams/JSON.png", + "diagrams/JSON_string.png", + "diagrams/JSON_value.png" + ] +} diff --git a/screenshots.html b/screenshots.html new file mode 100644 index 0000000..a189799 --- /dev/null +++ b/screenshots.html @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="utf-8"?> +<!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" xml:lang="en" lang="en"> + <head> + <link rel="stylesheet" href="style.css" type="text/css" /> + <title>JSON implementation for Ruby</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + </head> + <body> + + <ul id="linkbox"> + <li><a href="/index.html">Homepage</a></li> + <li><a href="http://github.com/flori/json/tree/master">Github Repository</a></li> + <li><a href="http://rubyforge.org/projects/json">Rubyforge Project</a></li> + <li><a href="http://rubyforge.org/frs/?group_id=953">Download</a></li> + <li><a href="doc/index.html">Documentation</a></li> + + <li><a href="screenshots.html">Screenshots</a></li> + + </ul> + + <img id="logo" src="json.png" alt="JaSON, the Argonaut" title="JaSON, the Argonaut" /> + + <div id="content"> + <h1>json – JSON implementation for Ruby</h1> + + <h2>Screenshots</h2> + <p>Here are some Screenshots from the graphical JSON Editor + <i>edit_json.rb</i>, that is included in the library package. To run it, a + working installation of <a + href="http://ruby-gnome2.sourceforge.jp/">Ruby GTK2</a> is necessary.</p> + + <div style="text-align: center"> + <a href="edit_json.png"> + <img src="edit_json.png" width="400" height="300" alt="Screenshot #1" /> + </a> + <br /> + <span class="caption">Screenshot #1 (Click to enlarge)</span> + </div> + + <div style="text-align: center"> + <a href="diagrams/JSON_array.png"> + <img src="diagrams/JSON_array.png" width="400" height="300" alt="Screenshot #2" /> + </a> + <br /> + <span class="caption">Screenshot #2 (Click to enlarge)</span> + </div> + + <div style="text-align: center"> + <a href="diagrams/JSON_float.png"> + <img src="diagrams/JSON_float.png" width="400" height="300" alt="Screenshot #3" /> + </a> + <br /> + <span class="caption">Screenshot #3 (Click to enlarge)</span> + </div> + + <div style="text-align: center"> + <a href="diagrams/JSON_integer.png"> + <img src="diagrams/JSON_integer.png" width="400" height="300" alt="Screenshot #4" /> + </a> + <br /> + <span class="caption">Screenshot #4 (Click to enlarge)</span> + </div> + + <div style="text-align: center"> + <a href="diagrams/JSON_object.png"> + <img src="diagrams/JSON_object.png" width="400" height="300" alt="Screenshot #5" /> + </a> + <br /> + <span class="caption">Screenshot #5 (Click to enlarge)</span> + </div> + + <div style="text-align: center"> + <a href="diagrams/JSON.png"> + <img src="diagrams/JSON.png" width="400" height="300" alt="Screenshot #6" /> + </a> + <br /> + <span class="caption">Screenshot #6 (Click to enlarge)</span> + </div> + + <div style="text-align: center"> + <a href="diagrams/JSON_string.png"> + <img src="diagrams/JSON_string.png" width="400" height="300" alt="Screenshot #7" /> + </a> + <br /> + <span class="caption">Screenshot #7 (Click to enlarge)</span> + </div> + + <div style="text-align: center"> + <a href="diagrams/JSON_value.png"> + <img src="diagrams/JSON_value.png" width="400" height="300" alt="Screenshot #8" /> + </a> + <br /> + <span class="caption">Screenshot #8 (Click to enlarge)</span> + </div> + + </div> + <p class="valid"> + <a href="http://validator.w3.org/check?uri=referer"><img + src="http://www.w3.org/Icons/valid-xhtml10" + alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a> + </p> + </body> +</html> + diff --git a/screenshots.tmpl b/screenshots.tmpl new file mode 100644 index 0000000..d688c8b --- /dev/null +++ b/screenshots.tmpl @@ -0,0 +1,21 @@ +[^header.incl] +[^linkbox.incl] +[^logo.incl] + <div id="content"> +[^headline.incl] + <h2>Screenshots</h2> + <p>Here are some Screenshots from the graphical JSON Editor + <i>edit_json.rb</i>, that is included in the library package. To run it, a + working installation of <a + href="http://ruby-gnome2.sourceforge.jp/">Ruby GTK2</a> is necessary.</p> + [@screenshots.each_with_index do |s,i|] + <div style="text-align: center"> + <a href="[=s]"> + <img src="[=s]" width="400" height="300" alt="Screenshot #[=i + 1]" /> + </a> + <br /> + <span class="caption">Screenshot #[=i + 1] (Click to enlarge)</span> + </div> + [end] + </div> +[^footer.incl] diff --git a/style.css b/style.css new file mode 100644 index 0000000..ef0eaa4 --- /dev/null +++ b/style.css @@ -0,0 +1,93 @@ +body { + color: black; + background-color: white; + font-family: 'Verdana', 'Arial', sans-serif; + padding: 15px; + margin: 0; + font-size: 100.01%; +} +img { + border: 0; +} +pre { + margin: 25px; + background-color: silver; + color: navy; + border: 1px dashed black; + padding: 5px; +} +a { + color: #af0000; + background-color: white; + text-decoration: none; +} +a:hover { + text-decoration: underline; +} +img#logo { + float: left; +} +p.valid { + float: right; +} +ul#linkbox { + font-size: 12px; + float: right; + width: 150px; + margin: 0; + padding: 0; + border: 1px solid silver; +} +ul#linkbox li { + list-style: none; + margin: 0; + padding: 2px; +} +ul#linkbox a { + display: block; + padding: 5px; + text-decoration: none; + font-weight: bold; +} +ul#linkbox a:link { + color: white; + text-decoration: none; + background-color: #af0000; +} +ul#linkbox a:visited { + color: white; + text-decoration: none; + background-color: #af0000; +} +ul#linkbox a:hover { + color: white; + text-decoration: underline; + background-color: #af0000; +} +ul#linkbox a:active { + color: white; + text-decoration: underline; + background-color: #af0000; +} +div#content { + margin-right: 150px; + padding: 0 10px; +} +div#content h1 { + color: #af0000; + background-color: white; + font-size: 20px; + padding: 18px 0 18px 0; + margin: 0 90px; +} +div#content h2 { + font-size: 16px; + margin-bottom: 16px; +} +div#content p { + font-size: 14px; + margin-top: 14px; +} +span.caption { + font-size:12px; +} diff --git a/usage.incl b/usage.incl new file mode 100644 index 0000000..1497346 --- /dev/null +++ b/usage.incl @@ -0,0 +1,56 @@ +<h2>Usage</h2> +<p> +If you require JSON like this: +</p> +<pre> +require 'json' +</pre> +<p> +JSON first tries to load the extension variant. If this fails, the pure variant +is loaded and used. +</p> +<p> +To determine, which variant is active you can use the follwing methods: +</p> +<ul> +<li>Ext variant: +<pre> +\[ JSON.parser, JSON.generator ] # => \[JSON::Ext::Parser, JSON::Ext::Generator] +</pre> +</li> +<li>Pure variant: +<pre> +\[ JSON.parser, JSON.generator ] # => \[JSON::Pure::Parser, JSON::Pure::Generator] +</pre> +</li> +</ul> +<p> +If you want to enforce loading of a special variant, use +</p> +<pre> +require 'json/ext' +</pre> +<p> +to load the extension variant. Or use +</p> +<pre> +require 'json/pure' +</pre> +<p> +to use the pure variant. +</p> +<p> +You can choose to load a set of common additions to ruby core's objects if you +</p> +<pre> + require 'json/add/core' +</pre> +<p> + To get the best compatibility to rails' JSON implementation, you can +</p> +<pre> + require 'json/add/rails' +</pre> +<p> + Both of the additions attempt to require 'json' (like above) first, if it has not been required yet. +</p> |