hydeweb 0.0.5 → 0.0.7
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 +28 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/data/new_site/hyde.conf +4 -0
- data/data/new_site/layouts/default.haml +3 -2
- data/hydeweb.gemspec +115 -105
- data/lib/hyde/clicommand.rb +2 -1
- data/lib/hyde/clicommands.rb +13 -2
- data/lib/hyde/helpers.rb +16 -9
- data/lib/hyde/layout.rb +5 -0
- data/lib/hyde/meta.rb +1 -1
- data/lib/hyde/page.rb +124 -7
- data/lib/hyde/page_factory.rb +12 -2
- data/lib/hyde/project.rb +17 -6
- data/lib/hyde/renderer.rb +17 -3
- data/lib/hyde/renderers.rb +45 -12
- data/lib/hyde/sinatra/init.rb +5 -3
- data/lib/hyde/utils.rb +10 -0
- data/lib/hyde.rb +15 -14
- data/lib/hyde_misc/console.rb +4 -0
- data/manual/Extending/ExtendingHyde.md +3 -2
- data/manual/Hyde.md +9 -4
- data/manual/Introduction/Configuration.md +67 -1
- data/manual/Introduction/GettingStarted.md +7 -9
- data/manual/Introduction/Installation.md +2 -2
- data/manual/Introduction/Layouts.md +11 -1
- data/manual/Introduction/Metadata.md +92 -0
- data/manual/Introduction/Partials.md +10 -0
- data/manual/Introduction/TemplateLanguages.md +5 -5
- data/manual/Tips/Tips.md +42 -0
- data/test/fixtures/content_for/layouts/cf-args.haml +2 -0
- data/test/fixtures/content_for/layouts/cf.haml +14 -0
- data/test/fixtures/content_for/site/cf-args-default.haml +2 -0
- data/test/fixtures/content_for/site/cf-args.haml +5 -0
- data/test/fixtures/content_for/site/cf.haml +6 -0
- data/test/fixtures/content_for/site/cf2.haml +3 -0
- data/test/fixtures/content_for/www_control/cf-args-default.html +1 -0
- data/test/fixtures/content_for/www_control/cf-args.html +2 -0
- data/test/fixtures/content_for/www_control/cf.html +17 -0
- data/test/fixtures/content_for/www_control/cf2.html +19 -0
- metadata +38 -16
- data/.gitignore +0 -25
- /data/test/fixtures/{two → content_for}/_config.yml +0 -0
- /data/test/fixtures/{two → content_for}/layouts/default.haml +0 -0
- /data/test/fixtures/{two → content_for}/layouts/shared/test.haml +0 -0
- /data/test/fixtures/{two → content_for}/site/default.html.haml +0 -0
- /data/test/fixtures/{two → content_for}/site/index.html.haml +0 -0
- /data/test/fixtures/{two → content_for}/site/var.html.haml +0 -0
- /data/test/fixtures/{two → content_for}/www_control/default.html +0 -0
- /data/test/fixtures/{two → content_for}/www_control/index.html +0 -0
- /data/test/fixtures/{two → content_for}/www_control/var.html +0 -0
data/lib/hyde/project.rb
CHANGED
@@ -22,7 +22,7 @@ module Hyde
|
|
22
22
|
where = ''
|
23
23
|
where = @config.send("#{args.shift.to_s}_path") if args[0].class == Symbol
|
24
24
|
path = args
|
25
|
-
File.expand_path
|
25
|
+
File.expand_path File.join([@root, where, path].reject { |s| s.empty? })
|
26
26
|
end
|
27
27
|
|
28
28
|
# Can raise a NoRootError
|
@@ -112,9 +112,15 @@ module Hyde
|
|
112
112
|
root(:layouts, '**/*'),
|
113
113
|
root(:extensions, '**/*'),
|
114
114
|
root(:output, '**/*'),
|
115
|
-
|
115
|
+
custom_ignored_files,
|
116
116
|
@config_file
|
117
|
-
].uniq
|
117
|
+
].flatten.uniq
|
118
|
+
end
|
119
|
+
|
120
|
+
def custom_ignored_files
|
121
|
+
list = @config.send("ignore")
|
122
|
+
return [] unless list.is_a?(Array)
|
123
|
+
Dir[*(list.map { |path| root(:site, path) })]
|
118
124
|
end
|
119
125
|
|
120
126
|
# Returns a list of ignored files based on the {ignore_list}.
|
@@ -126,6 +132,10 @@ module Hyde
|
|
126
132
|
end
|
127
133
|
end
|
128
134
|
|
135
|
+
def self.config_filenames
|
136
|
+
['_config.yml', 'hyde.conf', '.hyderc']
|
137
|
+
end
|
138
|
+
|
129
139
|
protected
|
130
140
|
|
131
141
|
# Looks for the hyde config file to determine the project root.
|
@@ -135,7 +145,7 @@ module Hyde
|
|
135
145
|
ret = nil
|
136
146
|
while ret.nil?
|
137
147
|
# See if any of these files exist
|
138
|
-
|
148
|
+
self.class.config_filenames.each do |config_name|
|
139
149
|
config_file = File.join(check, config_name)
|
140
150
|
ret ||= [check, config_file] if File.exists? config_file
|
141
151
|
end
|
@@ -152,13 +162,13 @@ module Hyde
|
|
152
162
|
#
|
153
163
|
def load_extensions
|
154
164
|
# Load the init.rb file
|
155
|
-
require(
|
165
|
+
require root('init.rb') if File.exists?(root 'init.rb')
|
156
166
|
|
157
167
|
# Load the gems in the config file
|
158
168
|
@config.gems.each { |gem| require gem }
|
159
169
|
|
160
170
|
# Load the extensions
|
161
|
-
ext_roots = Dir[root
|
171
|
+
ext_roots = Dir[root(:extensions, '*')].select { |d| File.directory? d }
|
162
172
|
ext_roots.each do |dir|
|
163
173
|
ext = File.basename(dir)
|
164
174
|
|
@@ -179,6 +189,7 @@ module Hyde
|
|
179
189
|
'partials_path' => 'layouts',
|
180
190
|
'site_path' => 'site',
|
181
191
|
'output_path' => 'public',
|
192
|
+
'port' => 4833,
|
182
193
|
'gems' => []
|
183
194
|
}
|
184
195
|
end
|
data/lib/hyde/renderer.rb
CHANGED
@@ -2,6 +2,18 @@ require "ostruct"
|
|
2
2
|
|
3
3
|
module Hyde
|
4
4
|
module Renderer
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def get(extname, default=Hyde::Renderer::Passthru)
|
8
|
+
klass = extname.to_s.capitalize.to_sym
|
9
|
+
|
10
|
+
begin
|
11
|
+
Hyde::Renderers.const_get(klass)
|
12
|
+
rescue NameError
|
13
|
+
default
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
5
17
|
class Base
|
6
18
|
include Hyde::Utils
|
7
19
|
|
@@ -26,9 +38,11 @@ module Hyde
|
|
26
38
|
@markup
|
27
39
|
end
|
28
40
|
|
29
|
-
def self.
|
30
|
-
|
31
|
-
|
41
|
+
def layoutable?(*a) self.class.layoutable?(*a); end
|
42
|
+
def default_ext(*a) self.class.default_ext(*a); end
|
43
|
+
|
44
|
+
def self.layoutable?() false; end
|
45
|
+
def self.default_ext() ''; end
|
32
46
|
|
33
47
|
protected
|
34
48
|
def require_lib(lib, gem=lib)
|
data/lib/hyde/renderers.rb
CHANGED
@@ -1,18 +1,29 @@
|
|
1
1
|
module Hyde
|
2
2
|
module Renderers
|
3
3
|
class Haml < Renderer::Parsable
|
4
|
+
def self.layoutable?() true; end
|
5
|
+
def self.default_ext() '.html'; end
|
6
|
+
|
4
7
|
def evaluate(scope, data={}, &block)
|
5
|
-
|
8
|
+
require 'haml'
|
6
9
|
begin
|
7
|
-
@engine = ::Haml::Engine.new(markup,
|
10
|
+
@engine = ::Haml::Engine.new(markup, engine_options)
|
8
11
|
@engine.render scope, data, &block
|
9
12
|
rescue ::Haml::SyntaxError => e
|
10
13
|
raise Hyde::RenderError.new(e.message, :line => e.line)
|
11
14
|
end
|
12
15
|
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
def engine_options
|
19
|
+
{ :escape_html => true }
|
20
|
+
end
|
13
21
|
end
|
14
22
|
|
15
23
|
class Erb < Renderer::Parsable
|
24
|
+
def self.layoutable?() true; end
|
25
|
+
def self.default_ext() '.html'; end
|
26
|
+
|
16
27
|
def evaluate(scope, data={}, &block)
|
17
28
|
require_lib 'erb'
|
18
29
|
@engine = ::ERB.new markup
|
@@ -20,6 +31,33 @@ module Hyde
|
|
20
31
|
end
|
21
32
|
end
|
22
33
|
|
34
|
+
class Sass < Haml
|
35
|
+
def self.layoutable?() false; end
|
36
|
+
def self.default_ext() '.css'; end
|
37
|
+
|
38
|
+
def evaluate(scope, data={}, &block)
|
39
|
+
require 'sass'
|
40
|
+
begin
|
41
|
+
@engine = ::Sass::Engine.new(markup, engine_options)
|
42
|
+
@engine.render
|
43
|
+
rescue ::Sass::SyntaxError => e
|
44
|
+
raise Hyde::RenderError.new(e.message, :line => e.line)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
def engine_options
|
50
|
+
{ :syntax => :sass, :load_paths => [File.dirname(@filename)], :cache => false }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Scss < Sass
|
55
|
+
protected
|
56
|
+
def engine_options
|
57
|
+
super.merge :syntax => :scss
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
23
61
|
class Less < Renderer::Base
|
24
62
|
def self.default_ext
|
25
63
|
'.css'
|
@@ -39,14 +77,10 @@ module Hyde
|
|
39
77
|
end
|
40
78
|
end
|
41
79
|
|
42
|
-
#class Sass < Renderer::Base
|
43
|
-
# def evaluate(scope, data={}, &block)
|
44
|
-
# require 'haml'
|
45
|
-
# @engine = ::Sass::Engine.new(File.open(filename))
|
46
|
-
# end
|
47
|
-
#end
|
48
|
-
|
49
80
|
class Md < Renderer::Parsable
|
81
|
+
def self.layoutable?() true; end
|
82
|
+
def self.default_ext() '.html'; end
|
83
|
+
|
50
84
|
def evaluate(s, d={}, &block)
|
51
85
|
require_lib 'maruku'
|
52
86
|
Maruku.new(markup).to_html
|
@@ -54,9 +88,8 @@ module Hyde
|
|
54
88
|
end
|
55
89
|
|
56
90
|
class Textile < Renderer::Parsable
|
57
|
-
def self.
|
58
|
-
|
59
|
-
end
|
91
|
+
def self.layoutable?() true; end
|
92
|
+
def self.default_ext() '.html'; end
|
60
93
|
|
61
94
|
def evaluate(s, d={}, &block)
|
62
95
|
require_lib 'redcloth', 'RedCloth'
|
data/lib/hyde/sinatra/init.rb
CHANGED
@@ -15,9 +15,11 @@ class Main < Sinatra::Base
|
|
15
15
|
@@project ||= $project
|
16
16
|
|
17
17
|
def self.show_start
|
18
|
+
port = $project.config.port
|
19
|
+
|
18
20
|
puts "Starting server..."
|
19
|
-
puts " http://127.0.0.1
|
20
|
-
puts " http://127.0.0.1
|
21
|
+
puts " http://127.0.0.1:#{port} Homepage"
|
22
|
+
puts " http://127.0.0.1:#{port}/- File list"
|
21
23
|
puts ""
|
22
24
|
end
|
23
25
|
|
@@ -59,4 +61,4 @@ class Main < Sinatra::Base
|
|
59
61
|
end
|
60
62
|
|
61
63
|
Main.show_start
|
62
|
-
Main.run!
|
64
|
+
Main.run! :port => $project.config.port
|
data/lib/hyde/utils.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
module Hyde
|
2
2
|
module Utils
|
3
|
+
protected
|
4
|
+
def escape_html(str)
|
5
|
+
str.
|
6
|
+
gsub('&', '&').
|
7
|
+
gsub('"', '"').
|
8
|
+
gsub('<', '<').
|
9
|
+
gsub('>', '>').
|
10
|
+
gsub("'", '&39;')
|
11
|
+
end
|
12
|
+
|
3
13
|
def same_file?(a, b)
|
4
14
|
File.expand_path(a) == File.expand_path(b)
|
5
15
|
end
|
data/lib/hyde.rb
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
|
3
3
|
module Hyde
|
4
|
-
|
5
|
-
|
6
|
-
autoload :
|
7
|
-
autoload :
|
8
|
-
autoload :
|
9
|
-
autoload :
|
10
|
-
autoload :
|
11
|
-
autoload :
|
12
|
-
autoload :
|
13
|
-
autoload :
|
14
|
-
autoload :
|
15
|
-
autoload :
|
16
|
-
autoload :
|
17
|
-
autoload :
|
4
|
+
LIB_PATH = File.dirname(__FILE__)
|
5
|
+
|
6
|
+
autoload :OStruct, "#{LIB_PATH}/hyde/ostruct"
|
7
|
+
autoload :Project, "#{LIB_PATH}/hyde/project"
|
8
|
+
autoload :Layout, "#{LIB_PATH}/hyde/layout"
|
9
|
+
autoload :Page, "#{LIB_PATH}/hyde/page"
|
10
|
+
autoload :PageFactory, "#{LIB_PATH}/hyde/page_factory"
|
11
|
+
autoload :Renderer, "#{LIB_PATH}/hyde/renderer"
|
12
|
+
autoload :Renderers, "#{LIB_PATH}/hyde/renderers"
|
13
|
+
autoload :Utils, "#{LIB_PATH}/hyde/utils"
|
14
|
+
autoload :Meta, "#{LIB_PATH}/hyde/meta"
|
15
|
+
autoload :CLICommand, "#{LIB_PATH}/hyde/clicommand"
|
16
|
+
autoload :CLICommands, "#{LIB_PATH}/hyde/clicommands"
|
17
|
+
autoload :Helpers, "#{LIB_PATH}/hyde/helpers"
|
18
|
+
autoload :Partial, "#{LIB_PATH}/hyde/partial"
|
18
19
|
|
19
20
|
Error = Class.new(::StandardError)
|
20
21
|
NoGemError = Class.new(Error)
|
@@ -42,7 +42,7 @@ In this example, we'll create a simple helper function.
|
|
42
42
|
# extensions/hyde-blog/hyde-blog.rb
|
43
43
|
module Hyde
|
44
44
|
module Helpers
|
45
|
-
module
|
45
|
+
module FormHelpers
|
46
46
|
def form_tag(meth, action, &b)
|
47
47
|
[ "<form method='#{meth}' action='#{action}'>",
|
48
48
|
b.call,
|
@@ -57,7 +57,7 @@ In your project's site files, you can then now use this helper.
|
|
57
57
|
|
58
58
|
# site/my_page.html.haml
|
59
59
|
%h1 My form
|
60
|
-
|
60
|
+
!= form_tag 'post', '/note/new' do
|
61
61
|
%p
|
62
62
|
%label Your name:
|
63
63
|
%input{ :type => 'text', :name => 'name' }
|
@@ -115,3 +115,4 @@ This may now be used in the command line.
|
|
115
115
|
Adding parsers
|
116
116
|
--------------
|
117
117
|
|
118
|
+
TODO.
|
data/manual/Hyde.md
CHANGED
@@ -40,16 +40,21 @@ Introduction
|
|
40
40
|
- `++++` {file:Installation Installation} -- Start here
|
41
41
|
- `++++` {file:GettingStarted Getting started}
|
42
42
|
- `++--` {file:TemplateLanguages Template languages}
|
43
|
-
-
|
44
|
-
-
|
45
|
-
-
|
46
|
-
-
|
43
|
+
- `+---` {file:Layouts Layouts}
|
44
|
+
- `++++` {file:Partials Partials}
|
45
|
+
- `++++` {file:Metadata Metadata}
|
46
|
+
- `++++` {file:Configuration Configuration}
|
47
47
|
|
48
48
|
Extending Hyde
|
49
49
|
--------------
|
50
50
|
|
51
51
|
- `+++-` {file:ExtendingHyde Extending Hyde}
|
52
52
|
|
53
|
+
Tips and tricks
|
54
|
+
---------------
|
55
|
+
|
56
|
+
- `+++-` {file:Tips Tips}
|
57
|
+
|
53
58
|
Basic info
|
54
59
|
----------
|
55
60
|
|
@@ -1,4 +1,70 @@
|
|
1
1
|
Configuration
|
2
2
|
=============
|
3
3
|
|
4
|
-
`hyde.conf`
|
4
|
+
Configuration is done through the file `hyde.conf` placed in
|
5
|
+
your project's root folder. A sample config file is generated
|
6
|
+
when doing `hyde create`.
|
7
|
+
|
8
|
+
It is a YAML file, so the basic format of the file is:
|
9
|
+
|
10
|
+
option: value
|
11
|
+
# Lines starting with # are comments that are ignored.
|
12
|
+
|
13
|
+
Options
|
14
|
+
-------
|
15
|
+
|
16
|
+
hyde_requirement
|
17
|
+
: The minimum version of Hyde needed by the project. Example:
|
18
|
+
|
19
|
+
hyde_requirement: 0.0.5
|
20
|
+
|
21
|
+
site_path
|
22
|
+
: The folder where the site's main files are kept. (you can set this to '.')
|
23
|
+
This is the path where your main files are. Example:
|
24
|
+
|
25
|
+
# myproject/hyde.conf
|
26
|
+
site_path: site
|
27
|
+
|
28
|
+
# This will instruct hyde to look at myproject/site/ for the
|
29
|
+
# files of the project.
|
30
|
+
|
31
|
+
layouts_path
|
32
|
+
: The folder where the layout templates (and partials) are kept. See the
|
33
|
+
{file:Layouts Layouts} section for information on Hyde layouts.
|
34
|
+
|
35
|
+
partials_path
|
36
|
+
: The folder for partials. See the {file:Partials Partials} section for
|
37
|
+
an overview of what partials are.
|
38
|
+
|
39
|
+
extensions_path
|
40
|
+
: The folder where the optional extensions are kept. See the
|
41
|
+
{file:ExtendingHyde Extending Hyde} section for more info on extensions.
|
42
|
+
|
43
|
+
output_path
|
44
|
+
: The folder where the HTML files are to be built when typing `hyde build`.
|
45
|
+
|
46
|
+
More options
|
47
|
+
------------
|
48
|
+
|
49
|
+
These options are not in the default `hyde.conf`, but you may simply
|
50
|
+
add them in.
|
51
|
+
|
52
|
+
port
|
53
|
+
: The port number. Defaults to 4833 unless set. Example:
|
54
|
+
|
55
|
+
port: 4999
|
56
|
+
|
57
|
+
gems
|
58
|
+
: This is a list of Ruby gems to be autoloaded into Hyde. Some extensions
|
59
|
+
are available as gems and may simply be added here to be used. Example:
|
60
|
+
|
61
|
+
gems:
|
62
|
+
- hyde-rst
|
63
|
+
- hyde-zip
|
64
|
+
|
65
|
+
Hidden hyde config file
|
66
|
+
-----------------------
|
67
|
+
|
68
|
+
Don't like seeing `hyde.conf` littering up your project folder? Rename
|
69
|
+
it to `.hyderc`.
|
70
|
+
|
@@ -20,7 +20,7 @@ but is recommended as it's a nice way to see your changes in real time.
|
|
20
20
|
hyde start
|
21
21
|
|
22
22
|
After typing this, you will see the server has started. Point your web browser to
|
23
|
-
`http://localhost:
|
23
|
+
`http://localhost:4833` to see your site. You should now see your project's
|
24
24
|
default "welcome" page.
|
25
25
|
|
26
26
|
|
@@ -32,22 +32,20 @@ stored. In general, dropping any file in this folder will make it accessible wit
|
|
32
32
|
same filename.
|
33
33
|
|
34
34
|
Try this: create a file called `products.html` and fill it up like you would an
|
35
|
-
HTML page. After that, point your browser to `http://localhost:
|
35
|
+
HTML page. After that, point your browser to `http://localhost:4833/products.html`,
|
36
36
|
which should now show the page you were working on.
|
37
37
|
|
38
38
|
You may also put your files in subfolders. If you were to create the file
|
39
39
|
`site/assets/my_style.css`, it should be accessible through
|
40
|
-
`http://localhost:
|
40
|
+
`http://localhost:4833/assets/my_style.css`.
|
41
41
|
|
42
42
|
Dynamic files
|
43
43
|
-------------
|
44
44
|
|
45
|
-
|
46
|
-
ends in one of
|
47
|
-
|
48
|
-
this case, HAML).
|
49
|
-
|
50
|
-
More about this in the next section.
|
45
|
+
Hyde supports many templating languages like HAML, Less, and ERB (more on this later).
|
46
|
+
If your file ends in one of these supported extensions (e.g., `index.haml`), it
|
47
|
+
is assumed to be a dynamic file and will be rendered by it's corresponding templating
|
48
|
+
engine (in this case, HAML).
|
51
49
|
|
52
50
|
Building HTML files
|
53
51
|
-------------------
|
@@ -10,7 +10,7 @@ by typing `ruby --version` in the command line.
|
|
10
10
|
|
11
11
|
Install Hyde by typing:
|
12
12
|
|
13
|
-
gem install
|
13
|
+
gem install hydeweb
|
14
14
|
|
15
|
-
If this process fails, you can instead try `sudo gem install
|
15
|
+
If this process fails, you can instead try `sudo gem install hydeweb`.
|
16
16
|
|
@@ -1,4 +1,14 @@
|
|
1
1
|
Layouts
|
2
2
|
=======
|
3
3
|
|
4
|
-
|
4
|
+
Defining layouts
|
5
|
+
----------------
|
6
|
+
|
7
|
+
1. Create a file called layouts/default.haml (or .erb)
|
8
|
+
2. use `yield` to show the page's contents
|
9
|
+
3. Voila
|
10
|
+
|
11
|
+
Using your own layouts
|
12
|
+
----------------------
|
13
|
+
|
14
|
+
Use the `layout` metadata key. See the next section.
|
@@ -1,2 +1,94 @@
|
|
1
1
|
Metadata
|
2
2
|
========
|
3
|
+
|
4
|
+
You may include metadata for pages by placing a YAML document at the beginning
|
5
|
+
of your page files. Be sure to separate your actual page from the metadata
|
6
|
+
using two hyphens (`--`)!
|
7
|
+
|
8
|
+
# mypage.haml
|
9
|
+
title: This is my page
|
10
|
+
author: Jason White
|
11
|
+
--
|
12
|
+
%div
|
13
|
+
-# You may access metadata in using `page.meta.<key>`.
|
14
|
+
%h1= page.meta.title
|
15
|
+
%cite
|
16
|
+
by
|
17
|
+
= page.meta.author
|
18
|
+
|
19
|
+
Special metadata keys
|
20
|
+
---------------------
|
21
|
+
|
22
|
+
Hyde has a few reserved keys.
|
23
|
+
|
24
|
+
### title
|
25
|
+
|
26
|
+
You may define a title for a page. You may then access this using `page.title`.
|
27
|
+
|
28
|
+
# mypage-two.haml
|
29
|
+
title: This is my page
|
30
|
+
--
|
31
|
+
%h1= page.title
|
32
|
+
|
33
|
+
This shows:
|
34
|
+
|
35
|
+
<h1>This is my page</h1>
|
36
|
+
|
37
|
+
If you do not define a title for a page, Hyde automatically uses the page's
|
38
|
+
filename instead.
|
39
|
+
|
40
|
+
# mypage-three.haml
|
41
|
+
%h1= page.title
|
42
|
+
|
43
|
+
Output:
|
44
|
+
|
45
|
+
<h1>mypage-three</h1>
|
46
|
+
|
47
|
+
### position
|
48
|
+
|
49
|
+
You may manually define the order of your pages using the 'position' key.
|
50
|
+
|
51
|
+
# about.haml
|
52
|
+
title: About us
|
53
|
+
position: 1
|
54
|
+
--
|
55
|
+
|
56
|
+
# services.haml
|
57
|
+
title: Services
|
58
|
+
position: 2
|
59
|
+
--
|
60
|
+
|
61
|
+
# contact.haml
|
62
|
+
title: Contact us
|
63
|
+
position: 9
|
64
|
+
--
|
65
|
+
|
66
|
+
This will affect the sort order of menus and such. Specifically, it the
|
67
|
+
outputs of functions such as `page.children`, `page.siblings`, `page.next`,
|
68
|
+
and so on.
|
69
|
+
|
70
|
+
The pages will then be ordered like so:
|
71
|
+
|
72
|
+
- About us
|
73
|
+
- Services
|
74
|
+
- Contact us
|
75
|
+
|
76
|
+
If positions have not been defined, they will be sorted alphabetically by
|
77
|
+
filename, i.e.:
|
78
|
+
|
79
|
+
- About us
|
80
|
+
- Contact us
|
81
|
+
- Services
|
82
|
+
|
83
|
+
### layout
|
84
|
+
|
85
|
+
By default, a page will use the `default` layout. To change this, simply
|
86
|
+
define a layout key in your metadata:
|
87
|
+
|
88
|
+
# products/camera_cx-300.haml
|
89
|
+
title: CX-300 Camera
|
90
|
+
layout: product
|
91
|
+
|
92
|
+
This will search for `layouts/product.*` (whichever extension it finds) in
|
93
|
+
your project, and use that as the layout. (This is assuming, of course, that
|
94
|
+
you haven't changed the default `layouts/` path in your Hyde config file.)
|
@@ -60,4 +60,14 @@ In your files, call a partial by:
|
|
60
60
|
<!-- site/index.html.erb -->
|
61
61
|
<%= partial 'shared/product', { :name => '5MP Camera CX-300', :description => 'This is a camera with an adjustable focal length and Bluetooth support.' } %>
|
62
62
|
|
63
|
+
Partials in HAML files
|
64
|
+
----------------------
|
63
65
|
|
66
|
+
HAML support in Hyde has the `escape_html` option on by default. You
|
67
|
+
will need to use `!= partial` instead of `= partial`.
|
68
|
+
|
69
|
+
-# Don't forget the exclamation point!
|
70
|
+
!= partial 'shared/product'
|
71
|
+
|
72
|
+
If you omit the `!`, the partial will be rendered with it's HTML code
|
73
|
+
escaped.
|
@@ -26,14 +26,14 @@ Hyde supports the following languages out-of-the-box:
|
|
26
26
|
|
27
27
|
This means that the following files will be translated accordingly:
|
28
28
|
|
29
|
-
| products.
|
30
|
-
| control.
|
31
|
-
| site.xml.erb
|
29
|
+
| products.haml | becomes `products.html` (rendered through HAML) |
|
30
|
+
| control.less | becomes `control.css` (rendered through Less CSS) |
|
31
|
+
| site.xml.erb | becomes `site.xml` (rendered through Embedded Ruby) |
|
32
32
|
|
33
33
|
Example
|
34
34
|
-------
|
35
35
|
|
36
|
-
When creating a new site, have a look at `index.
|
36
|
+
When creating a new site, have a look at `index.haml`.
|
37
37
|
|
38
38
|
...
|
39
39
|
|
@@ -45,7 +45,7 @@ Headers
|
|
45
45
|
Layouts
|
46
46
|
-------
|
47
47
|
|
48
|
-
Layouts are supported for
|
48
|
+
Layouts are supported for HAML, Markdown, Textile and ERB languages.
|
49
49
|
|
50
50
|
...
|
51
51
|
|
data/manual/Tips/Tips.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Tips
|
2
|
+
====
|
3
|
+
|
4
|
+
Here are some tips and tricks!
|
5
|
+
|
6
|
+
Simpler folder structure
|
7
|
+
------------------------
|
8
|
+
|
9
|
+
The default folder structure looks like this:
|
10
|
+
|
11
|
+
project/
|
12
|
+
hyde.conf
|
13
|
+
layouts/
|
14
|
+
partials/
|
15
|
+
public/
|
16
|
+
extensions/
|
17
|
+
site/
|
18
|
+
about.html
|
19
|
+
contact.html
|
20
|
+
|
21
|
+
Here is a cleaner structure often used in simpler projects:
|
22
|
+
|
23
|
+
project/
|
24
|
+
about.html
|
25
|
+
contact.html
|
26
|
+
|
27
|
+
.hyderc
|
28
|
+
_/
|
29
|
+
layouts/
|
30
|
+
partials/
|
31
|
+
public/
|
32
|
+
extensions/
|
33
|
+
|
34
|
+
You may do this by editing your Hyde config file like so:
|
35
|
+
|
36
|
+
site_path: .
|
37
|
+
layouts_path: _/layouts
|
38
|
+
extensions_path: _/extensions
|
39
|
+
partials_path: _/partials
|
40
|
+
output_path: _/public
|
41
|
+
|
42
|
+
Optionally, you can rename `hyde.conf` to `.hyderc` to make it even cleaner.
|