hydeweb 0.0.8.pre2 → 0.1.0
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/{CHANGELOG → HISTORY.md} +6 -0
- data/Rakefile +2 -52
- data/bin/hyde +3 -23
- data/bin/hyde01 +7 -0
- data/data/new_site/README.md +1 -1
- data/data/new_site/hyde.conf +9 -6
- data/lib/hyde/cli/helpers.rb +40 -0
- data/lib/hyde/cli.rb +86 -0
- data/lib/hyde/config.rb +37 -0
- data/lib/hyde/helpers.rb +6 -47
- data/lib/hyde/layout.rb +17 -9
- data/lib/hyde/meta.rb +5 -21
- data/lib/hyde/page.rb +207 -159
- data/lib/hyde/partial.rb +10 -5
- data/lib/hyde/project.rb +58 -208
- data/lib/hyde/server.rb +57 -0
- data/lib/hyde.rb +28 -51
- data/test/fixture/extensions/extensions/a/a.rb +1 -0
- data/test/fixture/extensions/hyde.conf +8 -0
- data/test/fixture/extensions/site/index.haml +1 -0
- data/test/fixture/fail_type/control/about/index.html +2 -0
- data/test/fixture/fail_type/control/about/us.html +2 -0
- data/test/fixture/fail_type/control/index.html +1 -0
- data/test/fixture/fail_type/hyde.conf +8 -0
- data/test/fixture/fail_type/site/index.haml +4 -0
- data/test/fixture/nested_layout/control/index.html +2 -0
- data/test/fixture/nested_layout/hyde.conf +8 -0
- data/test/fixture/nested_layout/layouts/default.haml +2 -0
- data/test/{fixtures/content_for/site/default.html.haml → fixture/nested_layout/layouts/post.haml} +1 -0
- data/test/fixture/nested_layout/site/index.haml +4 -0
- data/test/fixture/one/control/about/index.css +2 -0
- data/test/fixture/one/control/cheers.html +5 -0
- data/test/fixture/one/control/css/style.css +2 -0
- data/test/fixture/one/control/hello.html +5 -0
- data/test/fixture/one/control/hi.html +1 -0
- data/test/fixture/one/control/index.html +7 -0
- data/test/fixture/one/hyde.conf +9 -0
- data/test/fixture/one/layouts/default.haml +4 -0
- data/test/fixture/one/partials/menu.haml +3 -0
- data/test/fixture/one/site/about/index.scss +1 -0
- data/test/fixture/one/site/cheers.html.haml +1 -0
- data/test/fixture/one/site/css/style.scss +2 -0
- data/test/fixture/one/site/hello.haml +1 -0
- data/test/fixture/one/site/hi.html +1 -0
- data/test/fixture/one/site/index.haml +7 -0
- data/test/fixture/parent/control/about/index.html +2 -0
- data/test/fixture/parent/control/about/us.html +2 -0
- data/test/fixture/parent/control/index.html +1 -0
- data/test/fixture/parent/hyde.conf +8 -0
- data/test/fixture/parent/site/about/index.haml +3 -0
- data/test/fixture/parent/site/about/us.haml +3 -0
- data/test/fixture/parent/site/index.haml +3 -0
- data/test/fixture/sort/hyde.conf +8 -0
- data/test/fixture/sort/site/about/hardy.haml +4 -0
- data/test/fixture/sort/site/about/intrepid.haml +4 -0
- data/test/fixture/sort/site/about.haml +3 -0
- data/test/fixture/subclass/control/index.html +1 -0
- data/test/fixture/subclass/extensions/a/a.rb +12 -0
- data/test/fixture/subclass/hyde.conf +8 -0
- data/test/fixture/subclass/layouts/default.haml +1 -0
- data/test/fixture/subclass/layouts/post.haml +1 -0
- data/test/fixture/subclass/site/index.haml +4 -0
- data/test/helper.rb +15 -21
- data/test/unit/extensions_test.rb +16 -0
- data/test/unit/fixture_test.rb +77 -0
- data/test/unit/hyde_test.rb +30 -0
- metadata +107 -153
- data/.yardopts +0 -5
- data/LICENSE +0 -20
- data/VERSION +0 -1
- data/data/new_site/.gitignore +0 -24
- data/data/pages/404.html +0 -3
- data/hydeweb.gemspec +0 -159
- data/lib/hyde/clicommand.rb +0 -60
- data/lib/hyde/clicommands.rb +0 -128
- data/lib/hyde/ostruct.rb +0 -13
- data/lib/hyde/page_factory.rb +0 -90
- data/lib/hyde/renderer.rb +0 -133
- data/lib/hyde/renderers.rb +0 -100
- data/lib/hyde/sinatra/init.rb +0 -64
- data/lib/hyde/utils.rb +0 -43
- data/lib/hyde_misc/console.rb +0 -4
- data/manual/Extending/ExtendingHyde.md +0 -118
- data/manual/Hyde.md +0 -63
- data/manual/Introduction/Configuration.md +0 -70
- data/manual/Introduction/GettingStarted.md +0 -64
- data/manual/Introduction/Installation.md +0 -16
- data/manual/Introduction/Layouts.md +0 -14
- data/manual/Introduction/Metadata.md +0 -94
- data/manual/Introduction/Partials.md +0 -73
- data/manual/Introduction/TemplateLanguages.md +0 -59
- data/manual/Tips/Tips.md +0 -42
- data/test/fixtures/content_for/_config.yml +0 -8
- data/test/fixtures/content_for/layouts/cf-args.haml +0 -2
- data/test/fixtures/content_for/layouts/cf.haml +0 -14
- data/test/fixtures/content_for/layouts/default.haml +0 -4
- data/test/fixtures/content_for/layouts/shared/test.haml +0 -4
- data/test/fixtures/content_for/site/cf-args-default.haml +0 -2
- data/test/fixtures/content_for/site/cf-args.haml +0 -5
- data/test/fixtures/content_for/site/cf.haml +0 -6
- data/test/fixtures/content_for/site/cf2.haml +0 -3
- data/test/fixtures/content_for/site/index.html.haml +0 -9
- data/test/fixtures/content_for/site/var.html.haml +0 -5
- data/test/fixtures/content_for/www_control/cf-args-default.html +0 -1
- data/test/fixtures/content_for/www_control/cf-args.html +0 -2
- data/test/fixtures/content_for/www_control/cf.html +0 -17
- data/test/fixtures/content_for/www_control/cf2.html +0 -19
- data/test/fixtures/content_for/www_control/default.html +0 -2
- data/test/fixtures/content_for/www_control/index.html +0 -10
- data/test/fixtures/content_for/www_control/var.html +0 -2
- data/test/fixtures/custom/_config.yml +0 -8
- data/test/fixtures/custom/extensions/custom/custom.rb +0 -9
- data/test/fixtures/custom/layouts/default.haml +0 -8
- data/test/fixtures/custom/layouts/erbtest.erb +0 -2
- data/test/fixtures/custom/layouts/shared/sidebar.haml +0 -4
- data/test/fixtures/custom/site/about/index.html +0 -1
- data/test/fixtures/custom/site/assets/common.css.less +0 -1
- data/test/fixtures/custom/site/assets/style.css.less +0 -3
- data/test/fixtures/custom/site/foo.html.haml +0 -3
- data/test/fixtures/custom/site/index.html.haml +0 -6
- data/test/fixtures/custom/site/layout_test.html.haml +0 -6
- data/test/fixtures/custom/site/lol.html.erb +0 -7
- data/test/fixtures/custom/site/markdown.html.md +0 -8
- data/test/fixtures/custom/site/yes.html +0 -2
- data/test/fixtures/custom/www_control/about/index.html +0 -1
- data/test/fixtures/custom/www_control/assets/common.css +0 -1
- data/test/fixtures/custom/www_control/assets/style.css +0 -6
- data/test/fixtures/custom/www_control/foo.html +0 -1
- data/test/fixtures/custom/www_control/index.html +0 -16
- data/test/fixtures/custom/www_control/layout_test.html +0 -16
- data/test/fixtures/custom/www_control/lol.html +0 -5
- data/test/fixtures/custom/www_control/markdown.html +0 -17
- data/test/fixtures/custom/www_control/yes.html +0 -2
- data/test/fixtures/default/_config.yml +0 -8
- data/test/fixtures/default/extensions/custom/custom.rb +0 -2
- data/test/fixtures/default/layouts/default.haml +0 -5
- data/test/fixtures/default/site/about/index.html +0 -1
- data/test/fixtures/default/site/foo.html.haml +0 -3
- data/test/fixtures/default/site/index.html.haml +0 -6
- data/test/fixtures/default/site/layout_test.html.haml +0 -6
- data/test/fixtures/default/site/yes.html +0 -2
- data/test/fixtures/default/www_control/about/index.html +0 -1
- data/test/fixtures/default/www_control/foo.html +0 -1
- data/test/fixtures/default/www_control/index.html +0 -9
- data/test/fixtures/default/www_control/layout_test.html +0 -9
- data/test/fixtures/default/www_control/yes.html +0 -2
- data/test/test_all_fixtures.rb +0 -51
- data/test/test_build.rb +0 -20
- data/test/test_hyde.rb +0 -75
- data/test/test_page.rb +0 -26
- data/test/test_utils.rb +0 -22
data/{CHANGELOG → HISTORY.md}
RENAMED
data/Rakefile
CHANGED
|
@@ -1,55 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Jeweler::Tasks.new do |s|
|
|
4
|
-
s.name = "hydeweb"
|
|
5
|
-
s.authors = ["Rico Sta. Cruz", "Sinefunc, Inc."]
|
|
6
|
-
s.email = "rico@sinefunc.com"
|
|
7
|
-
s.summary = "Website preprocessor"
|
|
8
|
-
s.homepage = "http://github.com/sinefunc/hyde"
|
|
9
|
-
s.description = "Website preprocessor"
|
|
10
|
-
s.add_dependency('sinatra', '>= 1.0.0')
|
|
11
|
-
s.add_dependency('less', '>= 1.2.21')
|
|
12
|
-
s.add_dependency('haml', '>= 2.2.20')
|
|
13
|
-
end
|
|
14
|
-
Jeweler::GemcutterTasks.new
|
|
15
|
-
rescue LoadError
|
|
16
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
|
1
|
+
task :test do
|
|
2
|
+
Dir['test/**/*_test.rb'].each { |f| load f }
|
|
17
3
|
end
|
|
18
4
|
|
|
19
|
-
require 'rake/testtask'
|
|
20
|
-
Rake::TestTask.new(:test) do |test|
|
|
21
|
-
test.libs << 'lib' << 'test'
|
|
22
|
-
test.pattern = 'test/**/test_*.rb'
|
|
23
|
-
test.verbose = true
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
begin
|
|
27
|
-
require 'rcov/rcovtask'
|
|
28
|
-
Rcov::RcovTask.new do |test|
|
|
29
|
-
test.libs << 'test'
|
|
30
|
-
test.pattern = 'test/**/test_*.rb'
|
|
31
|
-
test.verbose = true
|
|
32
|
-
end
|
|
33
|
-
rescue LoadError
|
|
34
|
-
task :rcov do
|
|
35
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
task :test => :check_dependencies
|
|
40
|
-
|
|
41
5
|
task :default => :test
|
|
42
|
-
|
|
43
|
-
require 'rake/rdoctask'
|
|
44
|
-
Rake::RDocTask.new do |rdoc|
|
|
45
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
46
|
-
|
|
47
|
-
rdoc.rdoc_dir = 'rdoc'
|
|
48
|
-
rdoc.title = "Hyde #{version}"
|
|
49
|
-
rdoc.rdoc_files.include('README*')
|
|
50
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
task :autotest do
|
|
54
|
-
system "rstakeout 'rake test' **/*.rb"
|
|
55
|
-
end
|
data/bin/hyde
CHANGED
|
@@ -1,27 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
$:.unshift lib_path
|
|
2
|
+
$:.push File.expand_path('../../lib', __FILE__)
|
|
4
3
|
|
|
5
|
-
require 'optparse'
|
|
6
|
-
require 'rubygems'
|
|
7
4
|
require 'hyde'
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
$project = Hyde::Project.new
|
|
12
|
-
|
|
13
|
-
rescue Hyde::IncompatibleError => e
|
|
14
|
-
$stderr << e.message << "\n"
|
|
15
|
-
exit
|
|
16
|
-
|
|
17
|
-
rescue Hyde::NoRootError; end
|
|
18
|
-
|
|
19
|
-
if ARGV.size == 0
|
|
20
|
-
Hyde::CLICommands::Help.run
|
|
21
|
-
exit
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Can error
|
|
25
|
-
controller = Hyde::CLICommands.get_controller ARGV[0]
|
|
26
|
-
params = ARGV[1..-1]
|
|
27
|
-
controller.run(*params)
|
|
6
|
+
hydefile = Hyde::CLI.find_in_project('hyde.conf')
|
|
7
|
+
Hyde::CLI.run! :file => hydefile
|
data/bin/hyde01
ADDED
data/data/new_site/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Instructions
|
|
|
8
8
|
------------
|
|
9
9
|
|
|
10
10
|
1. Make sure Ruby (>= v1.8) is installed.
|
|
11
|
-
2. Install the hydeweb gem: `gem install hydeweb --pre`
|
|
11
|
+
2. Install the hydeweb gem: `gem install hydeweb --pre -v "~> 0.1"`
|
|
12
12
|
3. Build the site HTML files by typing: `hyde build`
|
|
13
13
|
|
|
14
14
|
You may also type `hyde start` to serve the files in a local web server.
|
data/data/new_site/hyde.conf
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# This is a Hyde site.
|
|
2
2
|
# Install the `hydeweb` Ruby gem and type `hyde` for help.
|
|
3
3
|
|
|
4
|
-
hyde_requirement: 0.
|
|
4
|
+
hyde_requirement: 0.1
|
|
5
5
|
|
|
6
6
|
# Path options
|
|
7
7
|
# -------------
|
|
@@ -24,9 +24,12 @@ output_path: public
|
|
|
24
24
|
# Any files matching these in the site_path will be excluded.
|
|
25
25
|
ignore:
|
|
26
26
|
- **/*~
|
|
27
|
+
- **/_*.scss
|
|
28
|
+
|
|
29
|
+
# Specify engine options here. These are optional.
|
|
30
|
+
tilt_options:
|
|
31
|
+
haml:
|
|
32
|
+
:escape_html: true
|
|
33
|
+
scss:
|
|
34
|
+
:load_paths: [ 'site/css' ]
|
|
27
35
|
|
|
28
|
-
# Put any custom gems here.
|
|
29
|
-
# gems:
|
|
30
|
-
# - hyde-rst
|
|
31
|
-
# - hyde-minify
|
|
32
|
-
# - hyde-zip
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
class Hyde
|
|
2
|
+
class CLI
|
|
3
|
+
module Helpers
|
|
4
|
+
def say_info(str)
|
|
5
|
+
say_status '*', str, 30
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def say_status(what, cmd, color=32)
|
|
9
|
+
c1 = "\033[0;#{color}m"
|
|
10
|
+
c0 = "\033[0;m"
|
|
11
|
+
puts "#{c1}%10s#{c0} %s" % [ what, cmd ]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def no_project
|
|
15
|
+
"No project file here."
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def project
|
|
19
|
+
@project ||= begin
|
|
20
|
+
pass no_project unless @hydefile
|
|
21
|
+
Dir.chdir File.dirname(@hydefile)
|
|
22
|
+
|
|
23
|
+
begin
|
|
24
|
+
project = Hyde::Project.new
|
|
25
|
+
pass no_project unless project.config_file?
|
|
26
|
+
rescue LegacyError
|
|
27
|
+
err "This is a legacy Hyde project."
|
|
28
|
+
err "To force it, try editing `hyde.conf` and upgrade the version line to `hyde_requirement: 0.1`."
|
|
29
|
+
pass
|
|
30
|
+
rescue VersionError => e
|
|
31
|
+
err e.message
|
|
32
|
+
pass
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
project
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
data/lib/hyde/cli.rb
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
class Hyde
|
|
2
|
+
class CLI < Shake
|
|
3
|
+
autoload :Helpers, "#{PREFIX}/hyde/cli/helpers"
|
|
4
|
+
|
|
5
|
+
extend Helpers
|
|
6
|
+
include Defaults
|
|
7
|
+
|
|
8
|
+
task(:create) do
|
|
9
|
+
wrong_usage unless params.size == 1
|
|
10
|
+
|
|
11
|
+
template = File.expand_path('../../../data/new_site', __FILE__)
|
|
12
|
+
target = params.first
|
|
13
|
+
|
|
14
|
+
pass "Error: target directory already exists." if File.directory?(target)
|
|
15
|
+
|
|
16
|
+
puts "Creating files in #{target}:"
|
|
17
|
+
puts
|
|
18
|
+
|
|
19
|
+
FileUtils.cp_r template, target
|
|
20
|
+
Dir[File.join(target, '**', '*')].sort.each do |f|
|
|
21
|
+
say_status :create, f if File.file?(f)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
puts ""
|
|
25
|
+
puts "Done! You've created a new project in #{target}."
|
|
26
|
+
puts "Get started now:"
|
|
27
|
+
puts ""
|
|
28
|
+
puts " $ cd #{target}"
|
|
29
|
+
puts " $ #{executable} start"
|
|
30
|
+
puts ""
|
|
31
|
+
puts "Or build the HTML files:"
|
|
32
|
+
puts ""
|
|
33
|
+
puts " $ #{executable} build"
|
|
34
|
+
puts ""
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
task.description = "Starts a new Hyde project"
|
|
38
|
+
task.usage = "create NAME"
|
|
39
|
+
|
|
40
|
+
task(:build) do
|
|
41
|
+
pre = project.config.output_path
|
|
42
|
+
|
|
43
|
+
begin
|
|
44
|
+
project.pages.each { |page|
|
|
45
|
+
handler = ''
|
|
46
|
+
handler = "(#{page.tilt_engine_name})" if page.tilt?
|
|
47
|
+
puts ("\033[0;33m*\033[0;32m #{pre}\033[0;m%-50s%s" % [ page.path, handler ]).strip
|
|
48
|
+
page.write
|
|
49
|
+
}
|
|
50
|
+
rescue NoGemError => e
|
|
51
|
+
err "Error: #{e.message}"
|
|
52
|
+
ensure
|
|
53
|
+
project.build_cleanup
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
task.description = "Builds the current project"
|
|
58
|
+
|
|
59
|
+
task(:start) do
|
|
60
|
+
port = (params.extract('-p') || 4833).to_i
|
|
61
|
+
host = (params.extract('-o') || '0.0.0.0')
|
|
62
|
+
|
|
63
|
+
require 'hyde/server'
|
|
64
|
+
|
|
65
|
+
Hyde::Server.run! :Host => host, :Port => port
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
task.description = "Starts the server"
|
|
69
|
+
|
|
70
|
+
task(:version) do
|
|
71
|
+
puts "Hyde #{Hyde::VERSION}"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
task.description = "Shows the current version"
|
|
75
|
+
|
|
76
|
+
def self.run!(options={})
|
|
77
|
+
@hydefile = options[:file]
|
|
78
|
+
return invoke(:version) if ARGV == ['-v']
|
|
79
|
+
return invoke(:version) if ARGV == ['--version']
|
|
80
|
+
|
|
81
|
+
begin
|
|
82
|
+
super *[]
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
data/lib/hyde/config.rb
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
class Hyde
|
|
2
|
+
class Config < OpenStruct
|
|
3
|
+
DEFAULTS = {
|
|
4
|
+
:site_path => '.',
|
|
5
|
+
:layouts_path => 'layouts',
|
|
6
|
+
:extensions_path => nil,
|
|
7
|
+
:partials_path => 'partials',
|
|
8
|
+
:output_path => 'public'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
def self.load(config_file)
|
|
12
|
+
new(YAML::load_file(config_file)) rescue new
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def initialize(options={})
|
|
16
|
+
super DEFAULTS.merge(options)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Returns tilt options for a given file.
|
|
20
|
+
# @example tilt_options('index.haml') # { :escape_html => ... }
|
|
21
|
+
def tilt_options_for(file)
|
|
22
|
+
tilt_options file.split('.').last.downcase
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Returns tilt options for a given engine.
|
|
26
|
+
# @example tilt_options('haml') # { :escape_html => ... }
|
|
27
|
+
def tilt_options(what)
|
|
28
|
+
@tilt_options ||= begin
|
|
29
|
+
o = @table[:tilt_options] || Hash.new
|
|
30
|
+
o['haml'] ||= { :escape_html => true }
|
|
31
|
+
o
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
@tilt_options[what.to_s]
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/hyde/helpers.rb
CHANGED
|
@@ -1,49 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
p.referrer = (referrer || self)
|
|
7
|
-
p.render locals
|
|
8
|
-
|
|
9
|
-
rescue ::Hyde::NotFound
|
|
10
|
-
"<!-- Can't find #{partial_path.to_s} -->"
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def content_for(key, &block)
|
|
15
|
-
content_block[key.to_sym] = block
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def has_content?(key)
|
|
19
|
-
content_block.keys.include? key.to_sym
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def yield_content(key, *args, &default_block)
|
|
23
|
-
block = content_block[key.to_sym]
|
|
24
|
-
|
|
25
|
-
if respond_to?(:block_is_haml?) && block_is_haml?(block)
|
|
26
|
-
capture_haml *args, &block
|
|
27
|
-
|
|
28
|
-
elsif block.respond_to?(:call)
|
|
29
|
-
block.call *args
|
|
30
|
-
|
|
31
|
-
elsif block_given? and respond_to(:block_is_haml?) and block_is_haml?(default_block)
|
|
32
|
-
capture_haml *args, &default_block
|
|
33
|
-
|
|
34
|
-
elsif block_given?
|
|
35
|
-
yield
|
|
36
|
-
|
|
37
|
-
else
|
|
38
|
-
''
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
protected
|
|
43
|
-
def content_block
|
|
44
|
-
file_key = (referrer || self).to_sym
|
|
45
|
-
@@content_blocks ||= Hash.new
|
|
46
|
-
@@content_blocks[file_key] ||= Hash.new
|
|
47
|
-
end
|
|
1
|
+
class Hyde
|
|
2
|
+
module Helpers
|
|
3
|
+
def partial(path, locals={})
|
|
4
|
+
partial = Partial[path.to_s, page] or return ''
|
|
5
|
+
partial.to_html :page => self
|
|
48
6
|
end
|
|
49
7
|
end
|
|
8
|
+
end
|
data/lib/hyde/layout.rb
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
project.root(:layouts, path)
|
|
5
|
-
end
|
|
1
|
+
class Hyde
|
|
2
|
+
class Layout < Page
|
|
3
|
+
attr_accessor :page
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
def self.[](id, page)
|
|
6
|
+
object = super(id, page.project)
|
|
7
|
+
object.page = page if object
|
|
8
|
+
object
|
|
11
9
|
end
|
|
10
|
+
|
|
11
|
+
protected
|
|
12
|
+
def self.root_path(project, *a)
|
|
13
|
+
project.path(:layouts, *a)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def default_layout
|
|
17
|
+
nil
|
|
18
|
+
end
|
|
19
|
+
end
|
|
12
20
|
end
|
data/lib/hyde/meta.rb
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def initialize(page)
|
|
6
|
-
@page = page
|
|
7
|
-
super nil
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def |(data)
|
|
11
|
-
# TODO: Consider OStruct here?
|
|
12
|
-
@table.merge data #if data.is_a? Hash
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def layout=(value)
|
|
16
|
-
super value
|
|
17
|
-
if value.is_a?(String)
|
|
18
|
-
@page.layout = @page.project[value, :Layout]
|
|
19
|
-
@page.layout.referrer = (page.referrer || page)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
1
|
+
class Hyde
|
|
2
|
+
class Meta < OpenStruct
|
|
3
|
+
def merge!(hash)
|
|
4
|
+
@table.merge(hash)
|
|
22
5
|
end
|
|
23
6
|
end
|
|
7
|
+
end
|