fnando-glue 0.0.2
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.markdown +58 -0
- data/Rakefile +75 -0
- data/bin/glue +24 -0
- data/glue.gemspec +44 -0
- data/lib/glue/capistrano.rb +5 -0
- data/lib/glue/generator.rb +67 -0
- data/lib/glue/helper.rb +14 -0
- data/lib/glue/rake.rb +10 -0
- data/lib/glue/template/helper.rb +34 -0
- data/lib/glue/template/meta.rb +22 -0
- data/lib/glue/template/parser.rb +97 -0
- data/lib/glue/template.rb +10 -0
- data/lib/glue.rb +22 -0
- data/lib/vendor/colorize-0.0.1/colorize.rb +80 -0
- data/templates/Rakefile +3 -0
- data/templates/_footer.haml +2 -0
- data/templates/helper.rb +5 -0
- data/templates/index.haml +15 -0
- data/templates/main.haml +15 -0
- data/templates/style.sass +14 -0
- metadata +117 -0
data/README.markdown
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
Glue
|
2
|
+
====
|
3
|
+
|
4
|
+
Glue is a simple and dumb static site generator.
|
5
|
+
Glue uses [Haml](http://haml-lang.com/) and [Sass](http://sass-lang.com/) for markup and styling.
|
6
|
+
You can also use Textile or Markdown for texts.
|
7
|
+
|
8
|
+
INSTALL
|
9
|
+
-------
|
10
|
+
|
11
|
+
sudo gem install fnando-glue --source=http://gems.github.com
|
12
|
+
|
13
|
+
Or
|
14
|
+
|
15
|
+
git clone git://github.com/fnando/glue.git
|
16
|
+
cd glue
|
17
|
+
rake gem:install
|
18
|
+
|
19
|
+
USAGE
|
20
|
+
-----
|
21
|
+
|
22
|
+
Just run `glue /some/path` to generate your site skeleton.
|
23
|
+
|
24
|
+
[TODO: Write more about it]
|
25
|
+
|
26
|
+
TODO
|
27
|
+
----
|
28
|
+
|
29
|
+
Write tests
|
30
|
+
|
31
|
+
MAINTAINER
|
32
|
+
----------
|
33
|
+
|
34
|
+
* Nando Vieira (<http://simplesideias.com.br>)
|
35
|
+
|
36
|
+
LICENSE:
|
37
|
+
--------
|
38
|
+
|
39
|
+
(The MIT License)
|
40
|
+
|
41
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
42
|
+
a copy of this software and associated documentation files (the
|
43
|
+
'Software'), to deal in the Software without restriction, including
|
44
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
45
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
46
|
+
permit persons to whom the Software is furnished to do so, subject to
|
47
|
+
the following conditions:
|
48
|
+
|
49
|
+
The above copyright notice and this permission notice shall be
|
50
|
+
included in all copies or substantial portions of the Software.
|
51
|
+
|
52
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
53
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
54
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
55
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
56
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
57
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
58
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require "rake"
|
2
|
+
require File.dirname(__FILE__) + "/lib/glue"
|
3
|
+
|
4
|
+
PKG_FILES = %w(Rakefile glue.gemspec README.markdown) + Dir["{bin,lib,templates}/**/*"]
|
5
|
+
|
6
|
+
spec = Gem::Specification.new do |s|
|
7
|
+
s.name = "glue"
|
8
|
+
s.version = Glue::VERSION
|
9
|
+
s.summary = "Glue is a simple and dumb static site generator."
|
10
|
+
s.authors = ["Nando Vieira"]
|
11
|
+
s.email = ["fnando.vieira@gmail.com"]
|
12
|
+
s.homepage = "http://github.com/fnando/glue"
|
13
|
+
s.has_rdoc = false
|
14
|
+
s.files = PKG_FILES
|
15
|
+
s.bindir = "bin"
|
16
|
+
s.executables = "glue"
|
17
|
+
|
18
|
+
s.add_dependency "main"
|
19
|
+
s.add_dependency "RedCloth"
|
20
|
+
s.add_dependency "rdiscount"
|
21
|
+
s.add_dependency "haml"
|
22
|
+
end
|
23
|
+
|
24
|
+
namespace :gem do
|
25
|
+
# Thanks to the Merb project for this code.
|
26
|
+
desc "Update Github Gemspec"
|
27
|
+
task :update_gemspec do
|
28
|
+
skip_fields = %w(new_platform original_platform specification_version loaded required_ruby_version rubygems_version platform )
|
29
|
+
|
30
|
+
result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
|
31
|
+
result << "# RUN : 'rake gem:update_gemspec'\n\n"
|
32
|
+
result << "Gem::Specification.new do |s|\n"
|
33
|
+
|
34
|
+
spec.instance_variables.each do |ivar|
|
35
|
+
value = spec.instance_variable_get(ivar)
|
36
|
+
name = ivar.split("@").last
|
37
|
+
next if name == "date"
|
38
|
+
|
39
|
+
next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
|
40
|
+
if name == "dependencies"
|
41
|
+
value.each do |d|
|
42
|
+
dep, *ver = d.to_s.split(" ")
|
43
|
+
result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "").gsub(", runtime", "")}\n"
|
44
|
+
end
|
45
|
+
else
|
46
|
+
case value
|
47
|
+
when Array
|
48
|
+
value = name != "files" ? value.inspect : value.inspect.split(",").join(",\n")
|
49
|
+
when FalseClass
|
50
|
+
when TrueClass
|
51
|
+
when Fixnum
|
52
|
+
when String
|
53
|
+
value = value.inspect
|
54
|
+
else
|
55
|
+
value = value.to_s.inspect
|
56
|
+
end
|
57
|
+
result << " s.#{name} = #{value}\n"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
result << "end"
|
62
|
+
File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Build gem"
|
66
|
+
task :build => [:update_gemspec] do
|
67
|
+
system "gem build #{spec.instance_variable_get('@name')}.gemspec"
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Install gem"
|
71
|
+
task :install => [:update_gemspec, :build] do
|
72
|
+
system "sudo gem install #{spec.instance_variable_get('@name')}"
|
73
|
+
system "rm *.gem"
|
74
|
+
end
|
75
|
+
end
|
data/bin/glue
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "main"
|
5
|
+
require File.dirname(__FILE__) + "/../lib/glue"
|
6
|
+
|
7
|
+
Main {
|
8
|
+
description <<-TXT
|
9
|
+
The 'glue' command generates a site skeleton.
|
10
|
+
|
11
|
+
VERSION: #{Glue::VERSION}
|
12
|
+
|
13
|
+
USAGE: glue help [command]
|
14
|
+
TXT
|
15
|
+
|
16
|
+
argument(:path) {
|
17
|
+
description "The output path"
|
18
|
+
required
|
19
|
+
validate {|path| !File.exists?(File.expand_path(path)) }
|
20
|
+
attr
|
21
|
+
}
|
22
|
+
|
23
|
+
run { Glue::Generator.generate!(:path => path) }
|
24
|
+
}
|
data/glue.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!
|
2
|
+
# RUN : 'rake gem:update_gemspec'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.required_rubygems_version = ">= 0"
|
6
|
+
s.has_rdoc = true
|
7
|
+
s.email = ["fnando.vieira@gmail.com"]
|
8
|
+
s.name = "glue"
|
9
|
+
s.homepage = "http://github.com/fnando/glue"
|
10
|
+
s.bindir = "bin"
|
11
|
+
s.executables = ["glue"]
|
12
|
+
s.summary = "Glue is a simple and dumb static site generator."
|
13
|
+
s.add_dependency "main", ">= 0"
|
14
|
+
s.add_dependency "RedCloth", ">= 0"
|
15
|
+
s.add_dependency "rdiscount", ">= 0"
|
16
|
+
s.add_dependency "haml", ">= 0"
|
17
|
+
s.version = "0.0.2"
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
s.files = ["Rakefile",
|
20
|
+
"glue.gemspec",
|
21
|
+
"README.markdown",
|
22
|
+
"bin/glue",
|
23
|
+
"lib/glue",
|
24
|
+
"lib/glue/capistrano.rb",
|
25
|
+
"lib/glue/generator.rb",
|
26
|
+
"lib/glue/helper.rb",
|
27
|
+
"lib/glue/rake.rb",
|
28
|
+
"lib/glue/template",
|
29
|
+
"lib/glue/template/helper.rb",
|
30
|
+
"lib/glue/template/meta.rb",
|
31
|
+
"lib/glue/template/parser.rb",
|
32
|
+
"lib/glue/template.rb",
|
33
|
+
"lib/glue.rb",
|
34
|
+
"lib/vendor",
|
35
|
+
"lib/vendor/colorize-0.0.1",
|
36
|
+
"lib/vendor/colorize-0.0.1/colorize.rb",
|
37
|
+
"templates/_footer.haml",
|
38
|
+
"templates/helper.rb",
|
39
|
+
"templates/index.haml",
|
40
|
+
"templates/main.haml",
|
41
|
+
"templates/Rakefile",
|
42
|
+
"templates/style.sass"]
|
43
|
+
s.authors = ["Nando Vieira"]
|
44
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Glue
|
2
|
+
module Generator
|
3
|
+
extend self
|
4
|
+
extend Glue::Helper
|
5
|
+
|
6
|
+
def generate!(options={})
|
7
|
+
templates = File.expand_path(File.dirname(__FILE__) + "/../../templates")
|
8
|
+
output = File.expand_path(options[:path])
|
9
|
+
|
10
|
+
# create root directory
|
11
|
+
run "creating #{Colorize.yellow(output, :style => :underscore)} directory" do
|
12
|
+
FileUtils.mkdir_p(output)
|
13
|
+
end
|
14
|
+
|
15
|
+
# create views directory
|
16
|
+
run %(creating #{Colorize.yellow("views/layouts")} directory) do
|
17
|
+
FileUtils.mkdir_p File.join(output, "views/layouts")
|
18
|
+
end
|
19
|
+
|
20
|
+
# create javascripts directory
|
21
|
+
run %(creating #{Colorize.yellow("public/javascripts")} directory) do
|
22
|
+
FileUtils.mkdir_p File.join(output, "public/javascripts")
|
23
|
+
end
|
24
|
+
|
25
|
+
# create config directory
|
26
|
+
run %(creating #{Colorize.yellow("config")} directory) do
|
27
|
+
FileUtils.mkdir_p File.join(output, "config")
|
28
|
+
end
|
29
|
+
|
30
|
+
# copy stylesheet file
|
31
|
+
run %( copying #{Colorize.yellow("views/stylesheets/style.sass")}) do
|
32
|
+
FileUtils.mkdir_p File.join(output, "views/stylesheets")
|
33
|
+
FileUtils.cp File.join(templates, "style.sass"), File.join(output, "views/stylesheets/style.sass")
|
34
|
+
end
|
35
|
+
|
36
|
+
# create images directory
|
37
|
+
run %(creating #{Colorize.yellow("public/images")} directory) do
|
38
|
+
FileUtils.mkdir_p File.join(output, "public/images")
|
39
|
+
end
|
40
|
+
|
41
|
+
# copy rake file
|
42
|
+
run %( copying #{Colorize.yellow("Rakefile")}) do
|
43
|
+
FileUtils.cp File.join(templates, "Rakefile"), File.join(output, "Rakefile")
|
44
|
+
end
|
45
|
+
|
46
|
+
# copy helper file
|
47
|
+
run %( copying #{Colorize.yellow("config/helper.rb")}) do
|
48
|
+
FileUtils.cp File.join(templates, "helper.rb"), File.join(output, "config/helper.rb")
|
49
|
+
end
|
50
|
+
|
51
|
+
# copy layout.haml
|
52
|
+
run %( copying #{Colorize.yellow("views/layouts/main.haml")}) do
|
53
|
+
FileUtils.cp File.join(templates, "main.haml"), File.join(output, "views/layouts/main.haml")
|
54
|
+
end
|
55
|
+
|
56
|
+
# copy index.haml
|
57
|
+
run %( copying #{Colorize.yellow("views/index.haml")}) do
|
58
|
+
FileUtils.cp File.join(templates, "index.haml"), File.join(output, "views/index.haml")
|
59
|
+
end
|
60
|
+
|
61
|
+
# copy _footer.haml
|
62
|
+
run %( copying #{Colorize.yellow("views/_footer.haml")}) do
|
63
|
+
FileUtils.cp File.join(templates, "_footer.haml"), File.join(output, "views/_footer.haml")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/glue/helper.rb
ADDED
data/lib/glue/rake.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Glue
|
2
|
+
module Template
|
3
|
+
class Helper
|
4
|
+
def markdown(text)
|
5
|
+
RDiscount.new(text).to_html
|
6
|
+
end
|
7
|
+
|
8
|
+
def textile(text)
|
9
|
+
RedCloth.new(text).to_html
|
10
|
+
end
|
11
|
+
|
12
|
+
def haml(text)
|
13
|
+
Haml::Engine.new(text).to_html(self)
|
14
|
+
end
|
15
|
+
|
16
|
+
def render(path)
|
17
|
+
parts = [GLUE_ROOT, "views", File.dirname(path), "_" + File.basename(path)]
|
18
|
+
parts.reject! {|p| p == "." }
|
19
|
+
|
20
|
+
path = File.join(*parts)
|
21
|
+
|
22
|
+
if File.exists?(file = "#{path}.haml")
|
23
|
+
haml File.read(file)
|
24
|
+
elsif File.exists?(file = "#{path}.markdown")
|
25
|
+
markdown File.read(file)
|
26
|
+
elsif File.exists?(file = "#{path}.textile")
|
27
|
+
textile File.read(file)
|
28
|
+
else
|
29
|
+
"Missing partial at <strong>#{path}</strong>"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Glue
|
2
|
+
module Template
|
3
|
+
class Meta
|
4
|
+
attr_accessor :metadata
|
5
|
+
attr_accessor :body
|
6
|
+
attr_accessor :content
|
7
|
+
|
8
|
+
def initialize(path)
|
9
|
+
self.metadata = {}
|
10
|
+
self.body = File.read(path)
|
11
|
+
process!
|
12
|
+
end
|
13
|
+
|
14
|
+
def process!
|
15
|
+
self.content = body.gsub /^\/ *(.*?): *(.*?) *$/sm do |m|
|
16
|
+
metadata[$1] = $2
|
17
|
+
""
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Glue
|
2
|
+
module Template
|
3
|
+
class Parser
|
4
|
+
attr_accessor :root
|
5
|
+
|
6
|
+
include Glue::Helper
|
7
|
+
|
8
|
+
def initialize(root)
|
9
|
+
@root = root
|
10
|
+
end
|
11
|
+
|
12
|
+
def run!
|
13
|
+
# load user helper file if exist
|
14
|
+
if File.exists?("#{root}/helper.rb")
|
15
|
+
require "#{root}/helper.rb"
|
16
|
+
Glue::Template::Helper.__send__ :include, ::Helper
|
17
|
+
end
|
18
|
+
|
19
|
+
# process all stylesheets
|
20
|
+
Dir["#{root}/views/stylesheets/**/*.sass"].each do |path|
|
21
|
+
run "processing #{Colorize.yellow(path)}" do
|
22
|
+
render_sass path
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# process all templates
|
27
|
+
Dir["#{root}/views/**/*.haml"].each do |path|
|
28
|
+
# layout files should be skipped
|
29
|
+
next if path =~ /#{Regexp.escape("#{root}/views/layouts/")}/
|
30
|
+
|
31
|
+
# partial files should be skipped
|
32
|
+
next if path =~ /_.*?\.haml$/
|
33
|
+
|
34
|
+
run "processing #{Colorize.yellow(path)}" do
|
35
|
+
render_haml(path)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def render_haml(path)
|
41
|
+
# extract metadata from file
|
42
|
+
meta = Glue::Template::Meta.new(path)
|
43
|
+
|
44
|
+
# instantiate template helper
|
45
|
+
helper = Glue::Template::Helper.new
|
46
|
+
|
47
|
+
# instantiate and process haml for page
|
48
|
+
haml = Haml::Engine.new(meta.content)
|
49
|
+
content_for_layout = haml.to_html(helper)
|
50
|
+
|
51
|
+
# instantiate haml for layout
|
52
|
+
layout = File.read("#{root}/views/layouts/#{meta.metadata["layout"]}.haml")
|
53
|
+
haml = Haml::Engine.new(layout)
|
54
|
+
vars = meta.metadata.merge({
|
55
|
+
:content_for_layout => content_for_layout,
|
56
|
+
:glue_version => Glue::VERSION
|
57
|
+
})
|
58
|
+
|
59
|
+
# retrieve relative file path and set target
|
60
|
+
relative_path = path.sub("#{root}/views/", "").gsub(/\.haml$/, ".html")
|
61
|
+
target = File.join(root, "public", relative_path)
|
62
|
+
|
63
|
+
# create directories if necessary
|
64
|
+
FileUtils.mkdir_p File.dirname(target)
|
65
|
+
|
66
|
+
# retrieve parsed content
|
67
|
+
full_page = haml.to_html(helper, vars)
|
68
|
+
|
69
|
+
# save processed page
|
70
|
+
File.open(target, "w+") do |f|
|
71
|
+
f << full_page
|
72
|
+
end
|
73
|
+
|
74
|
+
# save as index page
|
75
|
+
if meta.metadata["index"] == "true"
|
76
|
+
index_path = File.join(root, "public", "index.html")
|
77
|
+
|
78
|
+
File.open(index_path, "w+") do |f|
|
79
|
+
f << full_page
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def render_sass(path)
|
85
|
+
name = File.basename(path).gsub(/\.sass$/, "")
|
86
|
+
sass = Sass::Engine.new(File.read(path))
|
87
|
+
output = "#{root}/public/stylesheets/#{name}.css"
|
88
|
+
|
89
|
+
FileUtils.mkdir_p File.dirname(output)
|
90
|
+
|
91
|
+
File.open(output, "w+") do |file|
|
92
|
+
file << sass.render
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
data/lib/glue.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Glue
|
2
|
+
VERSION = "0.0.2"
|
3
|
+
end
|
4
|
+
|
5
|
+
# add glue lib to load path
|
6
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
7
|
+
|
8
|
+
require "FileUtils" unless defined?(FileUtils)
|
9
|
+
require "ostruct"
|
10
|
+
require "open-uri"
|
11
|
+
require "RedCloth"
|
12
|
+
require "rdiscount"
|
13
|
+
require "haml"
|
14
|
+
require "sass"
|
15
|
+
require "vendor/colorize-0.0.1/colorize"
|
16
|
+
|
17
|
+
require "glue/helper"
|
18
|
+
require "glue/generator"
|
19
|
+
require "glue/template"
|
20
|
+
require "glue/template/parser"
|
21
|
+
require "glue/template/meta"
|
22
|
+
require "glue/template/helper"
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Colorize
|
2
|
+
extend self
|
3
|
+
|
4
|
+
VERSION = "0.0.1"
|
5
|
+
|
6
|
+
COLORS = {
|
7
|
+
:black => "30",
|
8
|
+
:blue => "34",
|
9
|
+
:cyan => "36",
|
10
|
+
:gray => "30",
|
11
|
+
:green => "32",
|
12
|
+
:purple => "35",
|
13
|
+
:red => "31",
|
14
|
+
:white => "37",
|
15
|
+
:yellow => "33"
|
16
|
+
}
|
17
|
+
|
18
|
+
BGCOLORS = {
|
19
|
+
:black => "40",
|
20
|
+
:blue => "44",
|
21
|
+
:cyan => "46",
|
22
|
+
:gray => "47",
|
23
|
+
:green => "42",
|
24
|
+
:purple => "45",
|
25
|
+
:red => "41",
|
26
|
+
:white => "47",
|
27
|
+
:yellow => "43"
|
28
|
+
}
|
29
|
+
|
30
|
+
STYLES = {
|
31
|
+
:highlight => "1",
|
32
|
+
:blink => "5",
|
33
|
+
:underscore => "4"
|
34
|
+
}
|
35
|
+
|
36
|
+
def puts(string, options={})
|
37
|
+
Kernel.puts apply(string, options)
|
38
|
+
end
|
39
|
+
|
40
|
+
def apply(string, options={})
|
41
|
+
options = {
|
42
|
+
:style => []
|
43
|
+
}.merge(options)
|
44
|
+
|
45
|
+
options[:style] = [options[:style]].flatten
|
46
|
+
|
47
|
+
colors = []
|
48
|
+
|
49
|
+
options[:color] = options[:color].to_sym if options[:color]
|
50
|
+
options[:bgcolor] = options[:bgcolor].to_sym if options[:bgcolor]
|
51
|
+
|
52
|
+
colors << COLORS[options[:color]] if options[:color]
|
53
|
+
colors << BGCOLORS[options[:bgcolor]] if options[:bgcolor]
|
54
|
+
|
55
|
+
options[:style] << :highlight if [options[:color], options[:bgcolor]].include?(:white)
|
56
|
+
|
57
|
+
options[:style].each do |option|
|
58
|
+
colors << STYLES[option.to_sym]
|
59
|
+
end
|
60
|
+
|
61
|
+
colors.uniq!
|
62
|
+
colors.compact!
|
63
|
+
|
64
|
+
if ENV["COLORIZE"] == "0"
|
65
|
+
string
|
66
|
+
else
|
67
|
+
%(\e[#{colors.join(";")}m#{string}\e[0m)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def method_missing(color_name, *args)
|
72
|
+
if COLORS.keys.include?(color_name.to_sym)
|
73
|
+
string = args.shift
|
74
|
+
options = args.pop || {}
|
75
|
+
apply string, {:color => color_name}.merge(options)
|
76
|
+
else
|
77
|
+
super
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/templates/Rakefile
ADDED
data/templates/helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
/ title: Welcome to your page!
|
2
|
+
/ description: Generated by Glue. Check it out at http://github.com/fnando/glue
|
3
|
+
/ keywords: Glue, Ruby, Site Generator
|
4
|
+
/ layout: main
|
5
|
+
/ id: index
|
6
|
+
|
7
|
+
%h1 Welcome to your site!
|
8
|
+
|
9
|
+
= markdown("This paragraph was written using [Markdown](http://en.wikipedia.org/wiki/Markdown)")
|
10
|
+
|
11
|
+
= textile('This paragraph was written using "Textile":http://en.wikipedia.org/wiki/Textile_(markup_language)')
|
12
|
+
|
13
|
+
= reversed("This paragraph was written using a custom helper!")
|
14
|
+
|
15
|
+
= render("footer")
|
data/templates/main.haml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
!!! 1.1
|
2
|
+
|
3
|
+
%html
|
4
|
+
%head
|
5
|
+
%title= title
|
6
|
+
%meta{"name" => "description", "content" => description}
|
7
|
+
%meta{"name" => "keywords", "content" => keywords}
|
8
|
+
%meta{"name" => "generator", "content" => "Glue #{glue_version}"}
|
9
|
+
%meta{"http-equiv" => "content-type", "content" => "text/html; charset=UTF-8"}
|
10
|
+
%link{"rel" => "shortcut icon", "href" => "/favicon.ico", "type" => "image/x-icon"}
|
11
|
+
%link{"rel" => "stylesheet", "href" => "/stylesheets/style.css", "type" => "text/css"}
|
12
|
+
|
13
|
+
%body{"id" => id}
|
14
|
+
#page
|
15
|
+
= content_for_layout
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fnando-glue
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nando Vieira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-16 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: main
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: RedCloth
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rdiscount
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: haml
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- fnando.vieira@gmail.com
|
58
|
+
executables:
|
59
|
+
- glue
|
60
|
+
extensions: []
|
61
|
+
|
62
|
+
extra_rdoc_files: []
|
63
|
+
|
64
|
+
files:
|
65
|
+
- Rakefile
|
66
|
+
- glue.gemspec
|
67
|
+
- README.markdown
|
68
|
+
- bin/glue
|
69
|
+
- lib/glue
|
70
|
+
- lib/glue/capistrano.rb
|
71
|
+
- lib/glue/generator.rb
|
72
|
+
- lib/glue/helper.rb
|
73
|
+
- lib/glue/rake.rb
|
74
|
+
- lib/glue/template
|
75
|
+
- lib/glue/template/helper.rb
|
76
|
+
- lib/glue/template/meta.rb
|
77
|
+
- lib/glue/template/parser.rb
|
78
|
+
- lib/glue/template.rb
|
79
|
+
- lib/glue.rb
|
80
|
+
- lib/vendor
|
81
|
+
- lib/vendor/colorize-0.0.1
|
82
|
+
- lib/vendor/colorize-0.0.1/colorize.rb
|
83
|
+
- templates/_footer.haml
|
84
|
+
- templates/helper.rb
|
85
|
+
- templates/index.haml
|
86
|
+
- templates/main.haml
|
87
|
+
- templates/Rakefile
|
88
|
+
- templates/style.sass
|
89
|
+
has_rdoc: true
|
90
|
+
homepage: http://github.com/fnando/glue
|
91
|
+
licenses:
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "0"
|
102
|
+
version:
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: "0"
|
108
|
+
version:
|
109
|
+
requirements: []
|
110
|
+
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 1.3.5
|
113
|
+
signing_key:
|
114
|
+
specification_version: 2
|
115
|
+
summary: Glue is a simple and dumb static site generator.
|
116
|
+
test_files: []
|
117
|
+
|