ace 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.textile CHANGED
@@ -5,3 +5,17 @@ Ace is a static page generator like "Nanoc":http://nanoc.stoneship.org, "Jekyll"
5
5
  Also, last but not least, Ace has a real template inheritance. Layouts are for kids, real men use template inheritance! What's the advantage? It's incredibly flexible.
6
6
 
7
7
  Check "Ace: Static Sites Generator":http://blog.101ideas.cz/posts/ace-static-site-generator.html for more information or you can take a look at "sources":https://github.com/botanicus/blog.101ideas.cz of "my blog":http://blog.101ideas.cz to have something to play with!
8
+
9
+ h1. Installation
10
+
11
+ If you want to use @ace-gen@:
12
+
13
+ <pre>
14
+ gem install ace --development
15
+ </pre>
16
+
17
+ Without @ace-gen@:
18
+
19
+ <pre>
20
+ gem install ace
21
+ </pre>
data/bin/ace-gen CHANGED
@@ -19,9 +19,14 @@ rescue LoadError
19
19
  abort "You have to install simple-templater first!"
20
20
  end
21
21
 
22
+ templater = SimpleTemplater.new(:ace)
23
+ generator = templater.find(:project)
24
+
25
+ if generator.nil?
26
+ abort "Generator not found!"
27
+ end
28
+
22
29
  begin
23
- templater = SimpleTemplater.new(:ace)
24
- generator = templater.find(:project)
25
30
  generator.run(ARGV)
26
31
  rescue SimpleTemplater::TargetAlreadyExist => exception
27
32
  abort exception.message
data/example/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ source :rubygems
4
+
5
+ gem "ace", path: ".."
6
+ gem "nokogiri"
7
+ gem "nake", group: "bundle"
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ ace (0.3.2)
5
+ template-inheritance
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ haml (3.1.1)
11
+ nake (0.0.8)
12
+ term-ansicolor
13
+ nokogiri (1.4.4)
14
+ template-inheritance (0.3)
15
+ haml
16
+ tilt
17
+ term-ansicolor (1.0.5)
18
+ tilt (1.3.1)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ ace!
25
+ nake
26
+ nokogiri
@@ -0,0 +1,3 @@
1
+ h1. About
2
+
3
+ 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.
data/example/app/posts.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require "nokogiri"
4
- require "ace/filters"
4
+ require "ace/filters/template"
5
5
 
6
6
  # Inheritted methods:
7
7
  # - content
data/example/app/tags.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  # encoding: utf-8
2
2
 
3
+ # The class represents all the tags, whereas
4
+ # the instance represents each single tag.
3
5
  class Tag < Ace::Item
4
6
  before Ace::TemplateFilter, layout: "tag.html"
5
- end
6
7
 
7
- class TagPagesGenerator
8
- def tags
8
+ def self.tags
9
9
  Post.instances.inject(Hash.new) do |buffer, post|
10
10
  if tags = post.metadata[:tags]
11
11
  tags.each do |tag|
@@ -17,7 +17,7 @@ class TagPagesGenerator
17
17
  end
18
18
  end
19
19
 
20
- def run
20
+ def self.generate
21
21
  self.tags.each do |tag_title, items|
22
22
  tag_name = tag_title.downcase.gsub(" ", "-")
23
23
  metadata = {title: tag_title, timestamp: Time.now}
data/example/boot.rb CHANGED
@@ -1,6 +1,8 @@
1
- #!/usr/bin/env ace
1
+ #!/usr/bin/env bundle exec ace
2
2
  # encoding: utf-8
3
3
 
4
+ # Execute this file to generate the web.
5
+
4
6
  Dir["app/**/*.rb"].each do |file|
5
7
  load file
6
8
  end
@@ -1,6 +1,5 @@
1
1
  ---
2
2
  title: Ruby Programming Language
3
- timestamp: 2010-09-14
4
3
  tags: ["Development", "Ruby"]
5
4
  ---
6
5
 
@@ -1,6 +1,5 @@
1
1
  ---
2
2
  title: Node.js Asynchronous JavaScript Framework
3
- timestamp: 2010-09-16
4
3
  tags: ["Development", "JavaScript", "Node.js"]
5
4
  ---
6
5
 
@@ -0,0 +1,24 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html>
3
+ <head></head>
4
+ <body>
5
+ <div id='main'>
6
+ <h1>My Coooooool Bloogiiiiseeeeek!</h1>
7
+ <p class="excerpt">
8
+ 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.
9
+ </p>
10
+
11
+ <p>
12
+ 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.
13
+ </p>
14
+
15
+ <p>
16
+ 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.
17
+ </p>
18
+
19
+ <p>
20
+ <em>From <a href="http://en.wikipedia.org/wiki/Ruby_%28programming_language%29">Wikipedia.org</em>.
21
+ </p>
22
+ </div>
23
+ </body>
24
+ </html>
@@ -0,0 +1,32 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html>
3
+ <head></head>
4
+ <body>
5
+ <div id='main'>
6
+ <h1>My Coooooool Bloogiiiiseeeeek!</h1>
7
+ <p class="excerpt">
8
+ 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.
9
+ </p>
10
+
11
+ <p>
12
+ 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.
13
+ </p>
14
+
15
+ <pre>
16
+ var sys = require('sys'),
17
+ http = require('http');
18
+
19
+ http.createServer(function (request, response) {
20
+ response.writeHead(200, {'Content-Type': 'text/plain'});
21
+ response.end('Hello World\n');
22
+ }).listen(8000);
23
+
24
+ sys.puts('Server running at http://127.0.0.1:8000/');
25
+ </pre>
26
+
27
+ <p>
28
+ <em>From <a href="http://en.wikipedia.org/wiki/Node.js">Wikipedia.org</em>.
29
+ </p>
30
+ </div>
31
+ </body>
32
+ </html>
@@ -4,8 +4,8 @@
4
4
  <body>
5
5
  <div id='main'>
6
6
  <h1>My Coooooool Bloogiiiiseeeeek!</h1>
7
- Node.js Asynchronous JavaScript Framework
8
7
  Ruby Programming Language
8
+ Node.js Asynchronous JavaScript Framework
9
9
  </div>
10
10
  </body>
11
11
  </html>
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html>
3
+ <head></head>
4
+ <body>
5
+ <div id='main'>
6
+ <h1>My Coooooool Bloogiiiiseeeeek!</h1>
7
+ Node.js Asynchronous JavaScript Framework
8
+ </div>
9
+ </body>
10
+ </html>
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html>
3
+ <head></head>
4
+ <body>
5
+ <div id='main'>
6
+ <h1>My Coooooool Bloogiiiiseeeeek!</h1>
7
+ Node.js Asynchronous JavaScript Framework
8
+ </div>
9
+ </body>
10
+ </html>
data/example/rules.rb CHANGED
@@ -5,4 +5,4 @@ rule Post, "posts/*.html"
5
5
  rule Ace::Asset, "assets/**/*"
6
6
 
7
7
  # generators
8
- generator TagPagesGenerator#, "/tags/:slug"
8
+ generator Tag#, "/tags/:slug"
data/example/tasks.rb CHANGED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bundle exec nake
2
+ # encoding: utf-8
3
+
4
+ Task.new(:generate) do |task|
5
+ task.description = "Generate static HTML."
6
+
7
+ task.define do
8
+ sh "./boot.rb"
9
+ end
10
+ end
data/lib/ace.rb CHANGED
@@ -51,8 +51,14 @@ module Ace
51
51
  class Item
52
52
  def self.inherited(subclass)
53
53
  self.subclasses << subclass
54
- subclass.before_filters.push(*self.before_filters)
55
- subclass.after_filters.push(*self.after_filters)
54
+
55
+ self.before_filters.each do |instance|
56
+ subclass.before_filters << instance.dup
57
+ end
58
+
59
+ self.after_filters.each do |instance|
60
+ subclass.after_filters << instance.dup
61
+ end
56
62
  end
57
63
 
58
64
  def self.subclasses
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+
3
+ require "ace/filters"
4
+ require "nokogiri"
5
+
6
+ module Ace
7
+ class ImageThumbnailerFilter < Filter
8
+ def thumb_name(filename)
9
+ filename.gsub(/\.([^\.]*)$/, '_thumb.\1')
10
+ end
11
+
12
+ def thumbnail_nodeset(filename, doc)
13
+ a = Nokogiri::XML::Node.new 'a', doc
14
+ img = Nokogiri::XML::Node.new 'img', doc
15
+ a.set_attribute('href', filename)
16
+ img.set_attribute('src', thumb_name(filename))
17
+ img.parent = a
18
+ a
19
+ end
20
+
21
+ def make_thumbnail_image(filename, size)
22
+ size ||= 20 # default size
23
+ cmd = "convert content#{filename} -resize #{size} content#{thumb_name(filename)}"
24
+ warn "~ make thumbnail with '#{cmd}'"
25
+ system(cmd)
26
+ raise "Error when converting image 'content#{filename}'" if $?.to_i != 0
27
+ end
28
+
29
+ def call(item, content)
30
+ puts item.inspect
31
+ doc = Nokogiri::HTML(content)
32
+ doc.css("thumbnail").each do |thumb|
33
+ make_thumbnail_image thumb[:src], thumb[:size]
34
+ thumb.replace thumbnail_nodeset(thumb[:src], doc)
35
+ end
36
+ doc.to_s
37
+ end
38
+ end
39
+ end
@@ -16,12 +16,31 @@ module Ace
16
16
  end
17
17
 
18
18
  def initialize(options = Hash.new)
19
- @path = options[:layout]
19
+ @layout = options[:layout] if options.has_key?(:layout)
20
20
  end
21
21
 
22
22
  def call(item, content)
23
- if @path.nil?
24
- @path = item.original_path.sub("content/", "")
23
+ path = @layout || item.original_path.sub(/content\//, "") # We remove content/, because content is in TI paths.
24
+ if path.nil?
25
+ raise <<-EOF.gsub(/ {10}/m, "")
26
+ You have to specify output_path of #{self.inspect}
27
+
28
+ Usage:
29
+
30
+ class Post < Ace::Item
31
+ before Ace::TemplateFilter, layout: "posts.html"
32
+ end
33
+
34
+ # OR:
35
+
36
+ class Post < Ace::Item
37
+ before Ace::TemplateFilter
38
+
39
+ # And have #original_path set up (Ace does it by default,
40
+ # but if you are using some custom code it might not work
41
+ # out of the box).
42
+ end
43
+ EOF
25
44
  end
26
45
 
27
46
  parts = item.output_path.split(".")
@@ -33,7 +52,7 @@ module Ace
33
52
  raise "Template can be named either with one suffix as template.haml or with two of them as template.html.haml resp. template.xml.haml."
34
53
  end
35
54
 
36
- template = TemplateInheritance::Template.new(@path, Scope.new)
55
+ template = TemplateInheritance::Template.new(path, Scope.new)
37
56
  return template.render(item: item)
38
57
  end
39
58
  end
data/lib/ace/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Ace
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.3"
5
5
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: ace
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.2
5
+ version: 0.3.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - "Jakub \xC5\xA0\xC5\xA5astn\xC3\xBD aka Botanicus"
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain:
12
- date: 2011-05-26 00:00:00 +02:00
12
+ date: 2011-06-05 00:00:00 +02:00
13
13
  default_executable: ace
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -53,6 +53,9 @@ files:
53
53
  - ace.pre.gemspec
54
54
  - bin/ace
55
55
  - bin/ace-gen
56
+ - example/Gemfile
57
+ - example/Gemfile.lock
58
+ - example/README.textile
56
59
  - example/app/posts.rb
57
60
  - example/app/tags.rb
58
61
  - example/boot.rb
@@ -61,19 +64,23 @@ files:
61
64
  - example/content/assets/js/application.js
62
65
  - example/content/index.html.haml
63
66
  - example/content/posts.json.rb
64
- - example/content/posts/node-js.html
65
- - example/content/posts/ruby.html
67
+ - example/content/posts/2010-09-14-ruby.html
68
+ - example/content/posts/2010-09-16-node-js.html
66
69
  - example/layouts/base.html.haml
67
70
  - example/layouts/post.html.haml
68
71
  - example/layouts/tag.html.haml
69
72
  - example/lib/initializer.rb
70
73
  - example/output/assets/css/style.css
71
74
  - example/output/assets/js/application.js
75
+ - example/output/posts/2010-09-14-ruby.html
76
+ - example/output/posts/2010-09-16-node-js.html
72
77
  - example/output/posts/node-js.html
73
78
  - example/output/posts/ruby.html
74
79
  - example/output/posts/test.html
75
80
  - example/output/tags/development.html
76
81
  - example/output/tags/javascript.html
82
+ - example/output/tags/node.html
83
+ - example/output/tags/node.js
77
84
  - example/output/tags/node.js.html
78
85
  - example/output/tags/ruby.html
79
86
  - example/rules.rb
@@ -82,6 +89,7 @@ files:
82
89
  - lib/ace/dsl.rb
83
90
  - lib/ace/filters.rb
84
91
  - lib/ace/filters/haml.rb
92
+ - lib/ace/filters/image_thumbnailer.rb
85
93
  - lib/ace/filters/layout.rb
86
94
  - lib/ace/filters/pygments.rb
87
95
  - lib/ace/filters/sass.rb