laze 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.rdoc +150 -0
- data/Rakefile +76 -0
- data/VERSION.yml +5 -0
- data/bin/laze +126 -0
- data/examples/website/includes/tagline.html +1 -0
- data/examples/website/input/contact/email.md +6 -0
- data/examples/website/input/css/screen.css +5 -0
- data/examples/website/input/css/test.less +6 -0
- data/examples/website/input/img/ruby.gif +0 -0
- data/examples/website/input/img/test.jpg +0 -0
- data/examples/website/input/img/test.png +0 -0
- data/examples/website/input/index.md +13 -0
- data/examples/website/input/js/foo.js +1 -0
- data/examples/website/input/js/lib.js +5 -0
- data/examples/website/layouts/default.html +15 -0
- data/examples/website/layouts/subpage.html +5 -0
- data/examples/website/laze.yml +1 -0
- data/features/create_sites.feature +73 -0
- data/features/plugins.feature +49 -0
- data/features/site_data.feature +26 -0
- data/features/step_definitions/laze_steps.rb +77 -0
- data/features/support/env.rb +17 -0
- data/lib/laze.rb +64 -0
- data/lib/laze/asset.rb +7 -0
- data/lib/laze/core_extensions.rb +15 -0
- data/lib/laze/item.rb +59 -0
- data/lib/laze/javascript.rb +5 -0
- data/lib/laze/layout.rb +105 -0
- data/lib/laze/page.rb +33 -0
- data/lib/laze/plugins.rb +56 -0
- data/lib/laze/plugins/cache_buster.rb +49 -0
- data/lib/laze/plugins/css_imports.rb +42 -0
- data/lib/laze/plugins/cssmin.rb +31 -0
- data/lib/laze/plugins/image_check.rb +28 -0
- data/lib/laze/plugins/image_optimizer.rb +52 -0
- data/lib/laze/plugins/js_requires.rb +63 -0
- data/lib/laze/plugins/jsmin.rb +31 -0
- data/lib/laze/plugins/less.rb +35 -0
- data/lib/laze/plugins/robots.rb +28 -0
- data/lib/laze/plugins/sitemap.rb +63 -0
- data/lib/laze/renderer.rb +47 -0
- data/lib/laze/renderers/javascript_renderer.rb +16 -0
- data/lib/laze/renderers/page_renderer.rb +40 -0
- data/lib/laze/renderers/stylesheet_renderer.rb +16 -0
- data/lib/laze/secretary.rb +74 -0
- data/lib/laze/section.rb +39 -0
- data/lib/laze/store.rb +51 -0
- data/lib/laze/stores/filesystem.rb +127 -0
- data/lib/laze/stylesheet.rb +6 -0
- data/lib/laze/target.rb +56 -0
- data/lib/laze/targets/filesystem.rb +41 -0
- data/test/helper.rb +12 -0
- data/test/test_assets.rb +28 -0
- data/test/test_core_extensions.rb +19 -0
- data/test/test_item.rb +59 -0
- data/test/test_layout.rb +47 -0
- data/test/test_renderer.rb +71 -0
- data/test/test_renderers.rb +40 -0
- data/test/test_secretary.rb +48 -0
- data/test/test_store.rb +18 -0
- data/test/test_target.rb +84 -0
- metadata +207 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Arjan van der Gaag
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
= Laze
|
2
|
+
|
3
|
+
Laze is a simple static website generator, inspired by the likes of jekyll,
|
4
|
+
bonsai, nanoc, webby and many others. It's main purpose is to convert a bunch
|
5
|
+
of text files into a working website.
|
6
|
+
|
7
|
+
Laze is currently in development. Use at your own risk.
|
8
|
+
|
9
|
+
== Installation
|
10
|
+
|
11
|
+
This project has not yet been released as a Ruby gem. For now, install it
|
12
|
+
by cloning its git repository or downloading the source from its github
|
13
|
+
project page. Copy all source files to some location on your hard drive.
|
14
|
+
Then you can run Laze like so:
|
15
|
+
|
16
|
+
/path/to/laze/bin/laze
|
17
|
+
|
18
|
+
...where /path/to/laze is where you saved Laze on your disk.
|
19
|
+
|
20
|
+
== Usage
|
21
|
+
|
22
|
+
You run Laze from the command line in your project directory. See
|
23
|
+
<tt>laze --help</tt> for more information.
|
24
|
+
|
25
|
+
== Why use a static site generator?
|
26
|
+
|
27
|
+
A static site generator can help you automate some of the processes used when
|
28
|
+
creating static websites. It is not a Content Management System, it is just
|
29
|
+
a way to transform simple text files into web pages.
|
30
|
+
|
31
|
+
Static site generators usually use separate files for HTML boilerplate code,
|
32
|
+
like a header and footer, and the actual content of the site, like its text
|
33
|
+
pages. Laze is no different.
|
34
|
+
|
35
|
+
Then, by running Laze you apply the boilerplate code to your content files
|
36
|
+
and transform them into HTML files. This has several benefits:
|
37
|
+
|
38
|
+
* Consistent page layouts
|
39
|
+
* DRY: change the lay-out of many pages by changing a single layout file
|
40
|
+
* Transformations: write content using Markdown or another text filter
|
41
|
+
* Secure: since the output is only static HTML files, there are no moving
|
42
|
+
parts on your server. There are no server errors and no security attacks.
|
43
|
+
* Fast: again, without moving parts on the server, your website will be
|
44
|
+
the quickest it can ever be.
|
45
|
+
|
46
|
+
Laze adds some other tricks to make creating websites a little easier.
|
47
|
+
|
48
|
+
Note: because there are no moving parts on your web server, but only static
|
49
|
+
HTML files, it is tricky to set up dynamic features such as a contact form
|
50
|
+
or a weblog commenting system. Be sure to weigh your options carefully.
|
51
|
+
|
52
|
+
== Why use Laze?
|
53
|
+
|
54
|
+
The main reason for using Laze to generate your sites is that it makes your
|
55
|
+
website easy to maintain, easy to develop and because it optimizes your
|
56
|
+
website for you.
|
57
|
+
|
58
|
+
Various plugin, included by default, help you create a great website
|
59
|
+
|
60
|
+
* Check for missing images in your stylesheets
|
61
|
+
* Use Less CSS to write better CSS
|
62
|
+
* Automatically minify CSS and Javascript code
|
63
|
+
* Automatically concatenate CSS and Javascript files to reduce HTTP requests
|
64
|
+
* Automatically generate sitemaps for your site
|
65
|
+
|
66
|
+
The notable downside of Laze is that it does not help you generate a blog.
|
67
|
+
That is not to say that you cannot blog using Laze, just that Laze does not
|
68
|
+
relieve any pain.
|
69
|
+
|
70
|
+
== Project setup
|
71
|
+
|
72
|
+
A typical Laze project looks like this:
|
73
|
+
|
74
|
+
[project root directory]
|
75
|
+
|- input
|
76
|
+
| `- index.html
|
77
|
+
|- layouts
|
78
|
+
| `- default.html
|
79
|
+
|- includes
|
80
|
+
`- output
|
81
|
+
|
82
|
+
The input directory holds all your content. Your final website will be
|
83
|
+
generated in the output directory. The end result will look very much like
|
84
|
+
what's in the input directory.
|
85
|
+
|
86
|
+
The layouts directory holds files that can be wrapped around your content
|
87
|
+
files. The includes directory holds files that any content file can include
|
88
|
+
somewhere on its page.
|
89
|
+
|
90
|
+
=== Transformation
|
91
|
+
|
92
|
+
Here's the transformation process:
|
93
|
+
|
94
|
+
1. Scan the input directory for all files and directories.
|
95
|
+
2. Copy everything from /input over to /output...
|
96
|
+
3. ...but when the file is an HTML page, apply a text filter and layout to it
|
97
|
+
4. ...and when the file is a CSS file, expand and minify it
|
98
|
+
5. ...and when the file is a Javascript file, concatenate and minify it
|
99
|
+
|
100
|
+
=== More information
|
101
|
+
|
102
|
+
* Liquid is supported in all HTML files (http://www.liquidmarkup.org)
|
103
|
+
* Less is supported in all CSS files ending in +.less+ (http://lesscss.org/)
|
104
|
+
* Markdown is supported in all HTML files
|
105
|
+
(http://daringfireball.net/projects/markdown/)
|
106
|
+
* pngcrush (http://pmt.sourceforge.net/pngcrush/) and jpegtran
|
107
|
+
(http://jpegclub.org/) are used to optimize images.
|
108
|
+
|
109
|
+
Furthermore, Laze depends on the following third-party Ruby gems:
|
110
|
+
|
111
|
+
* liquid
|
112
|
+
* rdiscount
|
113
|
+
* redcloth
|
114
|
+
|
115
|
+
It could optionally use the following Ruby gems:
|
116
|
+
|
117
|
+
* jsmin
|
118
|
+
* cssmin
|
119
|
+
* directory_watcher
|
120
|
+
* webrick
|
121
|
+
* less
|
122
|
+
|
123
|
+
== Bugs, issues and to do's
|
124
|
+
|
125
|
+
There's still a lot to do. Please file bug reports or feature requests at the
|
126
|
+
github project site (http://github.com/avdgaag/laze).
|
127
|
+
|
128
|
+
== Credits
|
129
|
+
|
130
|
+
Author:: Arjan van der Gaag
|
131
|
+
E-mail:: arjan@arjanvandergaag.nl
|
132
|
+
Website:: http://avdgaag.github.com
|
133
|
+
Project website:: http://avdgaag.github.com/laze
|
134
|
+
Project documentation:: http:://avdgaag.github.com/laze/rdoc
|
135
|
+
Project source:: http://github.com/avdgaag/laze
|
136
|
+
|
137
|
+
== Note on Patches/Pull Requests
|
138
|
+
|
139
|
+
* Fork the project.
|
140
|
+
* Make your feature addition or bug fix.
|
141
|
+
* Add tests for it. This is important so I don't break it in a
|
142
|
+
future version unintentionally.
|
143
|
+
* Commit, do not mess with rakefile, version, or history.
|
144
|
+
(if you want to have your own version, that is fine but
|
145
|
+
bump version in a commit by itself I can ignore when I pull)
|
146
|
+
* Send me a pull request. Bonus points for topic branches.
|
147
|
+
|
148
|
+
== Copyright
|
149
|
+
|
150
|
+
Copyright (c) 2009 Arjan van der Gaag. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "laze"
|
8
|
+
gem.summary = %Q{A simple static site manager}
|
9
|
+
gem.description = <<-EOF
|
10
|
+
Laze is a simple static website generator, inspired by the likes of
|
11
|
+
jekyll, bonsai, nanoc, webby and many others. It's main purpose is to
|
12
|
+
convert a bunch of text files into a working website.
|
13
|
+
EOF
|
14
|
+
gem.email = "info@agwebdesign.nl"
|
15
|
+
gem.homepage = "http://github.com/avdgaag/laze"
|
16
|
+
gem.authors = ["Arjan van der Gaag"]
|
17
|
+
gem.add_development_dependency("thoughtbot-shoulda")
|
18
|
+
gem.add_dependency('liquid')
|
19
|
+
gem.add_dependency('rdiscount')
|
20
|
+
gem.add_dependency('RedCloth')
|
21
|
+
gem.add_dependency('jsmin')
|
22
|
+
gem.add_dependency('cssmin')
|
23
|
+
gem.add_dependency('directory_watcher')
|
24
|
+
gem.add_dependency('less')
|
25
|
+
end
|
26
|
+
Jeweler::GemcutterTasks.new
|
27
|
+
rescue LoadError
|
28
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
29
|
+
end
|
30
|
+
|
31
|
+
require 'rake/testtask'
|
32
|
+
Rake::TestTask.new(:test) do |test|
|
33
|
+
test.libs << 'lib' << 'test'
|
34
|
+
test.pattern = 'test/**/test_*.rb'
|
35
|
+
test.verbose = true
|
36
|
+
end
|
37
|
+
|
38
|
+
begin
|
39
|
+
require 'rcov/rcovtask'
|
40
|
+
Rcov::RcovTask.new do |test|
|
41
|
+
test.libs << 'test'
|
42
|
+
test.pattern = 'test/**/test_*.rb'
|
43
|
+
test.verbose = true
|
44
|
+
end
|
45
|
+
rescue LoadError
|
46
|
+
task :rcov do
|
47
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
task :test => :check_dependencies
|
52
|
+
|
53
|
+
task :default => :test
|
54
|
+
|
55
|
+
require 'rake/rdoctask'
|
56
|
+
Rake::RDocTask.new do |rdoc|
|
57
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
58
|
+
|
59
|
+
rdoc.rdoc_dir = 'rdoc'
|
60
|
+
rdoc.title = "laze #{version}"
|
61
|
+
rdoc.rdoc_files.include('README*')
|
62
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
63
|
+
end
|
64
|
+
|
65
|
+
begin
|
66
|
+
require 'cucumber/rake/task'
|
67
|
+
|
68
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
69
|
+
t.cucumber_opts = "--format progress"
|
70
|
+
end
|
71
|
+
rescue LoadError
|
72
|
+
desc 'Cucumber rake task not available'
|
73
|
+
task :features do
|
74
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
75
|
+
end
|
76
|
+
end
|
data/VERSION.yml
ADDED
data/bin/laze
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
3
|
+
|
4
|
+
help = <<HELP
|
5
|
+
Laze is a simple static website manager.
|
6
|
+
USAGE: laze [-admflvh] [target_dir] [source_dir]
|
7
|
+
HELP
|
8
|
+
|
9
|
+
require 'laze'
|
10
|
+
require 'optparse'
|
11
|
+
|
12
|
+
options = {}
|
13
|
+
|
14
|
+
o = OptionParser.new do |opts|
|
15
|
+
opts.banner = help
|
16
|
+
opts.separator ''
|
17
|
+
opts.separator 'Specify configuration in ./laze.yml or ovverride using these options:'
|
18
|
+
|
19
|
+
opts.on '-d', '--domain [URL]', 'Domain name for this site' do |url|
|
20
|
+
options[:domain] = url
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on '-s', '--[no-]server', 'Start web server on port 4545' do |s|
|
24
|
+
options[:server] = s
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on '-a', '--[no-]auto', 'Auto-regenerate the website' do |a|
|
28
|
+
options[:auto] = a
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on '-m', '--[no-]minify', 'Enable minification for .js and .css files' do |m|
|
32
|
+
options[:minify_js] = m
|
33
|
+
options[:minify_css] = m
|
34
|
+
end
|
35
|
+
|
36
|
+
opts.on '-f', '--logfile FILE', 'Write log messages to a file' do |filename|
|
37
|
+
options[:logfile] = filename
|
38
|
+
end
|
39
|
+
|
40
|
+
opts.on '-l', '--loglevel LEVEL', 'Filter log messages by level' do |level|
|
41
|
+
options[:loglevel] = level
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.separator ''
|
45
|
+
opts.separator 'Common options:'
|
46
|
+
|
47
|
+
opts.on '-v', '--version', 'Display current version' do
|
48
|
+
puts 'Laze ' + Laze.version
|
49
|
+
exit 0
|
50
|
+
end
|
51
|
+
|
52
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
53
|
+
puts opts
|
54
|
+
exit
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
begin
|
59
|
+
o.parse!
|
60
|
+
rescue OptionParser::InvalidOption => e
|
61
|
+
puts e
|
62
|
+
puts o
|
63
|
+
exit 1
|
64
|
+
end
|
65
|
+
|
66
|
+
case ARGV.size
|
67
|
+
when 0:
|
68
|
+
# ...
|
69
|
+
when 1:
|
70
|
+
options[:directory] = ARGV[0]
|
71
|
+
when 2:
|
72
|
+
options[:directory] = ARGV[0]
|
73
|
+
options[:source] = ARGV[1]
|
74
|
+
else
|
75
|
+
puts 'Invalid options. Run `laze --help` for more information.'
|
76
|
+
exit 1
|
77
|
+
end
|
78
|
+
|
79
|
+
secretary = Laze::Secretary.new(options)
|
80
|
+
|
81
|
+
if options[:auto]
|
82
|
+
require 'directory_watcher'
|
83
|
+
puts 'Auto-regenerating enabled'
|
84
|
+
dw = DirectoryWatcher.new(secretary.options[:source])
|
85
|
+
dw.interval = 1
|
86
|
+
dw.glob = Dir.chdir(secretary.options[:source]) do
|
87
|
+
dirs = Dir['*'].select { |x| File.directory?(x) }
|
88
|
+
dirs -= [secretary.options[:directory]]
|
89
|
+
dirs = dirs.map { |x| "#{x}/**/*" }
|
90
|
+
dirs += ['*']
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
dw.add_observer do |*args|
|
95
|
+
puts "#{args.size} files changed; regenerating..."
|
96
|
+
secretary.run
|
97
|
+
end
|
98
|
+
|
99
|
+
dw.start
|
100
|
+
|
101
|
+
loop { sleep 1000 } unless options[:server]
|
102
|
+
else
|
103
|
+
secretary.run
|
104
|
+
end
|
105
|
+
|
106
|
+
if options[:server]
|
107
|
+
require 'webrick'
|
108
|
+
include WEBrick
|
109
|
+
|
110
|
+
FileUtils.mkdir_p(secretary.options[:directory])
|
111
|
+
|
112
|
+
mime_types = WEBrick::HTTPUtils::DefaultMimeTypes
|
113
|
+
mime_types.store 'js', 'application/javascript'
|
114
|
+
|
115
|
+
s = HTTPServer.new(
|
116
|
+
:Port => 4545,
|
117
|
+
:DocumentRoot => secretary.options[:directory],
|
118
|
+
:MimeTypes => mime_types
|
119
|
+
)
|
120
|
+
t = Thread.new {
|
121
|
+
s.start
|
122
|
+
}
|
123
|
+
|
124
|
+
trap("INT") { s.shutdown }
|
125
|
+
t.join()
|
126
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
This is an example of Laze, the static site generator.
|
Binary file
|
Binary file
|
Binary file
|