From e5fe48990d9671a9de8ab2a118b871575e35bfa1 Mon Sep 17 00:00:00 2001 From: Jakub Stastny aka botanicus Date: Thu, 26 May 2011 12:10:16 +0200 Subject: [PATCH] Fixed the example. --- example/Gemfile | 7 ++++ example/Gemfile.lock | 26 +++++++++++++++ example/README.textile | 3 ++ example/app/posts.rb | 2 +- example/app/tags.rb | 8 ++--- example/boot.rb | 4 ++- .../posts/{ruby.html => 2010-09-14-ruby.html} | 1 - .../{node-js.html => 2010-09-16-node-js.html} | 1 - example/output/posts/2010-09-14-ruby.html | 24 ++++++++++++++ example/output/posts/2010-09-16-node-js.html | 32 +++++++++++++++++++ example/output/tags/development.html | 2 +- example/output/tags/node.html | 10 ++++++ example/output/tags/node.js | 10 ++++++ example/rules.rb | 2 +- example/tasks.rb | 10 ++++++ 15 files changed, 132 insertions(+), 10 deletions(-) create mode 100644 example/Gemfile create mode 100644 example/Gemfile.lock create mode 100644 example/README.textile rename example/content/posts/{ruby.html => 2010-09-14-ruby.html} (98%) rename example/content/posts/{node-js.html => 2010-09-16-node-js.html} (97%) create mode 100644 example/output/posts/2010-09-14-ruby.html create mode 100644 example/output/posts/2010-09-16-node-js.html create mode 100644 example/output/tags/node.html create mode 100644 example/output/tags/node.js diff --git a/example/Gemfile b/example/Gemfile new file mode 100644 index 0000000..473161c --- /dev/null +++ b/example/Gemfile @@ -0,0 +1,7 @@ +# encoding: utf-8 + +source :rubygems + +gem "ace", path: ".." +gem "nokogiri" +gem "nake", group: "bundle" diff --git a/example/Gemfile.lock b/example/Gemfile.lock new file mode 100644 index 0000000..c3f8ca4 --- /dev/null +++ b/example/Gemfile.lock @@ -0,0 +1,26 @@ +PATH + remote: .. + specs: + ace (0.3.2) + template-inheritance + +GEM + remote: http://rubygems.org/ + specs: + haml (3.1.1) + nake (0.0.8) + term-ansicolor + nokogiri (1.4.4) + template-inheritance (0.3) + haml + tilt + term-ansicolor (1.0.5) + tilt (1.3.1) + +PLATFORMS + ruby + +DEPENDENCIES + ace! + nake + nokogiri diff --git a/example/README.textile b/example/README.textile new file mode 100644 index 0000000..c808bc2 --- /dev/null +++ b/example/README.textile @@ -0,0 +1,3 @@ +h1. About + +This is a minimal example of a blog in Ace. If you want to see something real-world and probably more up to date, then check "sources":https://github.com/botanicus/blog.101ideas.cz of "my blog":http://blog.101ideas.cz. diff --git a/example/app/posts.rb b/example/app/posts.rb index c105623..3ca91ef 100644 --- a/example/app/posts.rb +++ b/example/app/posts.rb @@ -1,7 +1,7 @@ # encoding: utf-8 require "nokogiri" -require "ace/filters" +require "ace/filters/template" # Inheritted methods: # - content diff --git a/example/app/tags.rb b/example/app/tags.rb index e2d0168..224b64c 100644 --- a/example/app/tags.rb +++ b/example/app/tags.rb @@ -1,11 +1,11 @@ # encoding: utf-8 +# The class represents all the tags, whereas +# the instance represents each single tag. class Tag < Ace::Item before Ace::TemplateFilter, layout: "tag.html" -end -class TagPagesGenerator - def tags + def self.tags Post.instances.inject(Hash.new) do |buffer, post| if tags = post.metadata[:tags] tags.each do |tag| @@ -17,7 +17,7 @@ class TagPagesGenerator end end - def run + def self.generate self.tags.each do |tag_title, items| tag_name = tag_title.downcase.gsub(" ", "-") metadata = {title: tag_title, timestamp: Time.now} diff --git a/example/boot.rb b/example/boot.rb index c33c093..8560cdc 100755 --- a/example/boot.rb +++ b/example/boot.rb @@ -1,6 +1,8 @@ -#!/usr/bin/env ace +#!/usr/bin/env bundle exec ace # encoding: utf-8 +# Execute this file to generate the web. + Dir["app/**/*.rb"].each do |file| load file end diff --git a/example/content/posts/ruby.html b/example/content/posts/2010-09-14-ruby.html similarity index 98% rename from example/content/posts/ruby.html rename to example/content/posts/2010-09-14-ruby.html index 54905d3..d1684a1 100644 --- a/example/content/posts/ruby.html +++ b/example/content/posts/2010-09-14-ruby.html @@ -1,6 +1,5 @@ --- title: Ruby Programming Language -timestamp: 2010-09-14 tags: ["Development", "Ruby"] --- diff --git a/example/content/posts/node-js.html b/example/content/posts/2010-09-16-node-js.html similarity index 97% rename from example/content/posts/node-js.html rename to example/content/posts/2010-09-16-node-js.html index 7cf3eb3..0ac982a 100644 --- a/example/content/posts/node-js.html +++ b/example/content/posts/2010-09-16-node-js.html @@ -1,6 +1,5 @@ --- title: Node.js Asynchronous JavaScript Framework -timestamp: 2010-09-16 tags: ["Development", "JavaScript", "Node.js"] --- diff --git a/example/output/posts/2010-09-14-ruby.html b/example/output/posts/2010-09-14-ruby.html new file mode 100644 index 0000000..b4ae395 --- /dev/null +++ b/example/output/posts/2010-09-14-ruby.html @@ -0,0 +1,24 @@ + + + + +
+

My Coooooool Bloogiiiiseeeeek!

+

+ Ruby is a dynamic, reflective, general purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto. It was influenced primarily by Perl, Smalltalk, Eiffel, and Lisp. +

+ +

+ Ruby supports multiple programming paradigms, including functional, object oriented, imperative and reflective. It also has a dynamic type system and automatic memory management; it is therefore similar in varying respects to Python, Perl, Lisp, Dylan, Pike, and CLU. +

+ +

+ The standard 1.8.7 implementation is written in C, as a single-pass interpreted language. There is currently no specification of the Ruby language, so the original implementation is considered to be the de facto reference. As of 2010[update], there are a number of complete or upcoming alternative implementations of the Ruby language, including YARV, JRuby, Rubinius, IronRuby, MacRuby, and HotRuby, each of which takes a different approach, with IronRuby, JRuby and MacRuby providing just-in-time compilation and MacRuby also providing ahead-of-time compilation. The official 1.9 branch uses YARV, as will 2.0 (development), and will eventually supersede the slower Ruby MRI. +

+ +

+ From Wikipedia.org. +

+
+ + diff --git a/example/output/posts/2010-09-16-node-js.html b/example/output/posts/2010-09-16-node-js.html new file mode 100644 index 0000000..2826ee2 --- /dev/null +++ b/example/output/posts/2010-09-16-node-js.html @@ -0,0 +1,32 @@ + + + + +
+

My Coooooool Bloogiiiiseeeeek!

+

+ Node.js is an evented I/O framework for the V8 JavaScript engine. It is intended for writing scalable network programs such as web servers. +

+ +

+ Node.js is similar in purpose to Twisted for Python, Perl Object Environment for Perl, and EventMachine for Ruby. Unlike most JavaScript, it is not executed in a web browser, but it is rather related to server-side JavaScript. Node.js implements some CommonJS specifications[1]. Node.js includes a REPL environment for interactive testing. +

+ +
+      var sys = require('sys'),
+          http = require('http');
+      
+      http.createServer(function (request, response) {
+          response.writeHead(200, {'Content-Type': 'text/plain'});
+          response.end('Hello World\n');
+      }).listen(8000);
+      
+      sys.puts('Server running at http://127.0.0.1:8000/');
+      
+ +

+ From Wikipedia.org. +

+
+ + diff --git a/example/output/tags/development.html b/example/output/tags/development.html index 4bd304b..71d18a4 100644 --- a/example/output/tags/development.html +++ b/example/output/tags/development.html @@ -4,8 +4,8 @@

My Coooooool Bloogiiiiseeeeek!

- Node.js Asynchronous JavaScript Framework Ruby Programming Language + Node.js Asynchronous JavaScript Framework
diff --git a/example/output/tags/node.html b/example/output/tags/node.html new file mode 100644 index 0000000..b6c4df9 --- /dev/null +++ b/example/output/tags/node.html @@ -0,0 +1,10 @@ + + + + +
+

My Coooooool Bloogiiiiseeeeek!

+ Node.js Asynchronous JavaScript Framework +
+ + diff --git a/example/output/tags/node.js b/example/output/tags/node.js new file mode 100644 index 0000000..b6c4df9 --- /dev/null +++ b/example/output/tags/node.js @@ -0,0 +1,10 @@ + + + + +
+

My Coooooool Bloogiiiiseeeeek!

+ Node.js Asynchronous JavaScript Framework +
+ + diff --git a/example/rules.rb b/example/rules.rb index 9b2b107..a9d068b 100644 --- a/example/rules.rb +++ b/example/rules.rb @@ -5,4 +5,4 @@ rule Post, "posts/*.html" rule Ace::Asset, "assets/**/*" # generators -generator TagPagesGenerator#, "/tags/:slug" +generator Tag#, "/tags/:slug" diff --git a/example/tasks.rb b/example/tasks.rb index e69de29..9722d3b 100755 --- a/example/tasks.rb +++ b/example/tasks.rb @@ -0,0 +1,10 @@ +#!/usr/bin/env bundle exec nake +# encoding: utf-8 + +Task.new(:generate) do |task| + task.description = "Generate static HTML." + + task.define do + sh "./boot.rb" + end +end