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.
Files changed (151) hide show
  1. data/{CHANGELOG → HISTORY.md} +6 -0
  2. data/Rakefile +2 -52
  3. data/bin/hyde +3 -23
  4. data/bin/hyde01 +7 -0
  5. data/data/new_site/README.md +1 -1
  6. data/data/new_site/hyde.conf +9 -6
  7. data/lib/hyde/cli/helpers.rb +40 -0
  8. data/lib/hyde/cli.rb +86 -0
  9. data/lib/hyde/config.rb +37 -0
  10. data/lib/hyde/helpers.rb +6 -47
  11. data/lib/hyde/layout.rb +17 -9
  12. data/lib/hyde/meta.rb +5 -21
  13. data/lib/hyde/page.rb +207 -159
  14. data/lib/hyde/partial.rb +10 -5
  15. data/lib/hyde/project.rb +58 -208
  16. data/lib/hyde/server.rb +57 -0
  17. data/lib/hyde.rb +28 -51
  18. data/test/fixture/extensions/extensions/a/a.rb +1 -0
  19. data/test/fixture/extensions/hyde.conf +8 -0
  20. data/test/fixture/extensions/site/index.haml +1 -0
  21. data/test/fixture/fail_type/control/about/index.html +2 -0
  22. data/test/fixture/fail_type/control/about/us.html +2 -0
  23. data/test/fixture/fail_type/control/index.html +1 -0
  24. data/test/fixture/fail_type/hyde.conf +8 -0
  25. data/test/fixture/fail_type/site/index.haml +4 -0
  26. data/test/fixture/nested_layout/control/index.html +2 -0
  27. data/test/fixture/nested_layout/hyde.conf +8 -0
  28. data/test/fixture/nested_layout/layouts/default.haml +2 -0
  29. data/test/{fixtures/content_for/site/default.html.haml → fixture/nested_layout/layouts/post.haml} +1 -0
  30. data/test/fixture/nested_layout/site/index.haml +4 -0
  31. data/test/fixture/one/control/about/index.css +2 -0
  32. data/test/fixture/one/control/cheers.html +5 -0
  33. data/test/fixture/one/control/css/style.css +2 -0
  34. data/test/fixture/one/control/hello.html +5 -0
  35. data/test/fixture/one/control/hi.html +1 -0
  36. data/test/fixture/one/control/index.html +7 -0
  37. data/test/fixture/one/hyde.conf +9 -0
  38. data/test/fixture/one/layouts/default.haml +4 -0
  39. data/test/fixture/one/partials/menu.haml +3 -0
  40. data/test/fixture/one/site/about/index.scss +1 -0
  41. data/test/fixture/one/site/cheers.html.haml +1 -0
  42. data/test/fixture/one/site/css/style.scss +2 -0
  43. data/test/fixture/one/site/hello.haml +1 -0
  44. data/test/fixture/one/site/hi.html +1 -0
  45. data/test/fixture/one/site/index.haml +7 -0
  46. data/test/fixture/parent/control/about/index.html +2 -0
  47. data/test/fixture/parent/control/about/us.html +2 -0
  48. data/test/fixture/parent/control/index.html +1 -0
  49. data/test/fixture/parent/hyde.conf +8 -0
  50. data/test/fixture/parent/site/about/index.haml +3 -0
  51. data/test/fixture/parent/site/about/us.haml +3 -0
  52. data/test/fixture/parent/site/index.haml +3 -0
  53. data/test/fixture/sort/hyde.conf +8 -0
  54. data/test/fixture/sort/site/about/hardy.haml +4 -0
  55. data/test/fixture/sort/site/about/intrepid.haml +4 -0
  56. data/test/fixture/sort/site/about.haml +3 -0
  57. data/test/fixture/subclass/control/index.html +1 -0
  58. data/test/fixture/subclass/extensions/a/a.rb +12 -0
  59. data/test/fixture/subclass/hyde.conf +8 -0
  60. data/test/fixture/subclass/layouts/default.haml +1 -0
  61. data/test/fixture/subclass/layouts/post.haml +1 -0
  62. data/test/fixture/subclass/site/index.haml +4 -0
  63. data/test/helper.rb +15 -21
  64. data/test/unit/extensions_test.rb +16 -0
  65. data/test/unit/fixture_test.rb +77 -0
  66. data/test/unit/hyde_test.rb +30 -0
  67. metadata +107 -153
  68. data/.yardopts +0 -5
  69. data/LICENSE +0 -20
  70. data/VERSION +0 -1
  71. data/data/new_site/.gitignore +0 -24
  72. data/data/pages/404.html +0 -3
  73. data/hydeweb.gemspec +0 -159
  74. data/lib/hyde/clicommand.rb +0 -60
  75. data/lib/hyde/clicommands.rb +0 -128
  76. data/lib/hyde/ostruct.rb +0 -13
  77. data/lib/hyde/page_factory.rb +0 -90
  78. data/lib/hyde/renderer.rb +0 -133
  79. data/lib/hyde/renderers.rb +0 -100
  80. data/lib/hyde/sinatra/init.rb +0 -64
  81. data/lib/hyde/utils.rb +0 -43
  82. data/lib/hyde_misc/console.rb +0 -4
  83. data/manual/Extending/ExtendingHyde.md +0 -118
  84. data/manual/Hyde.md +0 -63
  85. data/manual/Introduction/Configuration.md +0 -70
  86. data/manual/Introduction/GettingStarted.md +0 -64
  87. data/manual/Introduction/Installation.md +0 -16
  88. data/manual/Introduction/Layouts.md +0 -14
  89. data/manual/Introduction/Metadata.md +0 -94
  90. data/manual/Introduction/Partials.md +0 -73
  91. data/manual/Introduction/TemplateLanguages.md +0 -59
  92. data/manual/Tips/Tips.md +0 -42
  93. data/test/fixtures/content_for/_config.yml +0 -8
  94. data/test/fixtures/content_for/layouts/cf-args.haml +0 -2
  95. data/test/fixtures/content_for/layouts/cf.haml +0 -14
  96. data/test/fixtures/content_for/layouts/default.haml +0 -4
  97. data/test/fixtures/content_for/layouts/shared/test.haml +0 -4
  98. data/test/fixtures/content_for/site/cf-args-default.haml +0 -2
  99. data/test/fixtures/content_for/site/cf-args.haml +0 -5
  100. data/test/fixtures/content_for/site/cf.haml +0 -6
  101. data/test/fixtures/content_for/site/cf2.haml +0 -3
  102. data/test/fixtures/content_for/site/index.html.haml +0 -9
  103. data/test/fixtures/content_for/site/var.html.haml +0 -5
  104. data/test/fixtures/content_for/www_control/cf-args-default.html +0 -1
  105. data/test/fixtures/content_for/www_control/cf-args.html +0 -2
  106. data/test/fixtures/content_for/www_control/cf.html +0 -17
  107. data/test/fixtures/content_for/www_control/cf2.html +0 -19
  108. data/test/fixtures/content_for/www_control/default.html +0 -2
  109. data/test/fixtures/content_for/www_control/index.html +0 -10
  110. data/test/fixtures/content_for/www_control/var.html +0 -2
  111. data/test/fixtures/custom/_config.yml +0 -8
  112. data/test/fixtures/custom/extensions/custom/custom.rb +0 -9
  113. data/test/fixtures/custom/layouts/default.haml +0 -8
  114. data/test/fixtures/custom/layouts/erbtest.erb +0 -2
  115. data/test/fixtures/custom/layouts/shared/sidebar.haml +0 -4
  116. data/test/fixtures/custom/site/about/index.html +0 -1
  117. data/test/fixtures/custom/site/assets/common.css.less +0 -1
  118. data/test/fixtures/custom/site/assets/style.css.less +0 -3
  119. data/test/fixtures/custom/site/foo.html.haml +0 -3
  120. data/test/fixtures/custom/site/index.html.haml +0 -6
  121. data/test/fixtures/custom/site/layout_test.html.haml +0 -6
  122. data/test/fixtures/custom/site/lol.html.erb +0 -7
  123. data/test/fixtures/custom/site/markdown.html.md +0 -8
  124. data/test/fixtures/custom/site/yes.html +0 -2
  125. data/test/fixtures/custom/www_control/about/index.html +0 -1
  126. data/test/fixtures/custom/www_control/assets/common.css +0 -1
  127. data/test/fixtures/custom/www_control/assets/style.css +0 -6
  128. data/test/fixtures/custom/www_control/foo.html +0 -1
  129. data/test/fixtures/custom/www_control/index.html +0 -16
  130. data/test/fixtures/custom/www_control/layout_test.html +0 -16
  131. data/test/fixtures/custom/www_control/lol.html +0 -5
  132. data/test/fixtures/custom/www_control/markdown.html +0 -17
  133. data/test/fixtures/custom/www_control/yes.html +0 -2
  134. data/test/fixtures/default/_config.yml +0 -8
  135. data/test/fixtures/default/extensions/custom/custom.rb +0 -2
  136. data/test/fixtures/default/layouts/default.haml +0 -5
  137. data/test/fixtures/default/site/about/index.html +0 -1
  138. data/test/fixtures/default/site/foo.html.haml +0 -3
  139. data/test/fixtures/default/site/index.html.haml +0 -6
  140. data/test/fixtures/default/site/layout_test.html.haml +0 -6
  141. data/test/fixtures/default/site/yes.html +0 -2
  142. data/test/fixtures/default/www_control/about/index.html +0 -1
  143. data/test/fixtures/default/www_control/foo.html +0 -1
  144. data/test/fixtures/default/www_control/index.html +0 -9
  145. data/test/fixtures/default/www_control/layout_test.html +0 -9
  146. data/test/fixtures/default/www_control/yes.html +0 -2
  147. data/test/test_all_fixtures.rb +0 -51
  148. data/test/test_build.rb +0 -20
  149. data/test/test_hyde.rb +0 -75
  150. data/test/test_page.rb +0 -26
  151. data/test/test_utils.rb +0 -22
@@ -1,64 +0,0 @@
1
- require 'rubygems'
2
- begin
3
- require 'sinatra/base'
4
- rescue LoadError
5
- STDERR << "You need the sinatra gem to use `hyde start`. Type: `gem install sinatra`\n"
6
- exit
7
- end
8
-
9
- $:.unshift File.dirname(__FILE__) + "/../.."
10
- require 'hyde'
11
-
12
- $project = Hyde::Project.new
13
-
14
- class Main < Sinatra::Base
15
- @@project ||= $project
16
-
17
- def self.show_start
18
- port = $project.config.port
19
-
20
- puts "Starting server..."
21
- puts " http://127.0.0.1:#{port} Homepage"
22
- puts " http://127.0.0.1:#{port}/- File list"
23
- puts ""
24
- end
25
-
26
- get '/-' do
27
- @@project.files.inject("") do |a, path|
28
- a << "<li><a href='#{path}'>#{path}</a></li>"
29
- a
30
- end
31
- end
32
-
33
- get '/*' do
34
- begin
35
- path = params[:splat][0]
36
- type = File.extname(path)[1..-1]
37
- content_type type.to_sym if type.is_a? String
38
-
39
- page = @@project[path]
40
-
41
- # Send the last modified time
42
- last_modified File.mtime(page.filename)
43
- cache_control :public, :must_revalidate, :max_age => 60
44
-
45
- page.render
46
-
47
- rescue Hyde::RenderError => e
48
- puts " * `#{path}` line #{e.line} error"
49
- puts " *** #{e.message}".gsub("\n","\n *** ")
50
- e.message
51
-
52
- rescue Hyde::NotFound
53
- raise Sinatra::NotFound
54
- end
55
- end
56
-
57
- not_found do
58
- html_path = File.join(File.dirname(__FILE__), %w[.. .. .. data pages 404.html])
59
- File.open(html_path) { |f| f.read } + (" "*4096)
60
- end
61
- end
62
-
63
- Main.show_start
64
- Main.run! :port => $project.config.port
data/lib/hyde/utils.rb DELETED
@@ -1,43 +0,0 @@
1
- module Hyde
2
- module Utils
3
- protected
4
- def escape_html(str)
5
- str.
6
- gsub('&', '&amp;').
7
- gsub('"', '&quot;').
8
- gsub('<', '&lt;').
9
- gsub('>', '&gt;').
10
- gsub("'", '&39;')
11
- end
12
-
13
- def same_file?(a, b)
14
- File.expand_path(a) == File.expand_path(b)
15
- end
16
-
17
- def matches_files?(needle, haystack)
18
- haystack.inject(false) do |a, match|
19
- a ||= same_file?(needle, match)
20
- end
21
- end
22
-
23
- def force_file_open(filepath, &blk)
24
- require 'fileutils'
25
- FileUtils.mkdir_p File.dirname(filepath)
26
-
27
- if block_given?
28
- File.open filepath, 'w', &blk
29
- else
30
- File.new filepath, 'w'
31
- end
32
- end
33
-
34
- # Returns all helper classes under the Hyde::Helpers module.
35
- def get_helpers
36
- Hyde::Helpers.constants.inject([Hyde::Helpers]) do |a, constant|
37
- mod = Hyde::Helpers.const_get(constant)
38
- a << mod if mod.is_a? Module
39
- a
40
- end
41
- end
42
- end
43
- end
@@ -1,4 +0,0 @@
1
- prefix = File.join(File.dirname(__FILE__), '..', 'hyde.rb')
2
- require prefix
3
- $project = Hyde::Project.new
4
- puts "Use $project"
@@ -1,118 +0,0 @@
1
- Extending Hyde
2
- ==============
3
-
4
- Creating extensions
5
- -------------------
6
-
7
- In your Hyde project's extensions folder (`extensions` by default), create a file called
8
- `<name>/<name>.rb`, where `<name>` is the name of your extension. This file will automatically loaded.
9
-
10
- Example:
11
-
12
- # extensions/hyde-blog/hyde-blog.rb
13
- module Hyde
14
- # Set up autoload hooks for the other classes
15
- prefix = File.dirname(__FILE__)
16
- autoload :Blog, "#{prefix}/lib/blog.rb"
17
- end
18
-
19
- Creating extensions as gems
20
- ---------------------------
21
-
22
- You may also create your extensions as gems. It is recommended to name them as `hyde-(name)`,
23
- for instance, `hyde-blog`.
24
-
25
- To load gem extensions in your Hyde project, add them to the `gems` section of your project's
26
- config file (typically `hyde.conf`). Example:
27
-
28
- # hyde.conf
29
- gems:
30
- - hyde-blog
31
- - hyde-clean
32
-
33
- Adding helpers
34
- --------------
35
-
36
- Make a module under `Hyde::Helpers`. Any functions here will be available to your files.
37
-
38
- Example:
39
-
40
- In this example, we'll create a simple helper function.
41
-
42
- # extensions/hyde-blog/hyde-blog.rb
43
- module Hyde
44
- module Helpers
45
- module FormHelpers
46
- def form_tag(meth, action, &b)
47
- [ "<form method='#{meth}' action='#{action}'>",
48
- b.call,
49
- "</form>"
50
- ].join("\n")
51
- end
52
- end
53
- end
54
- end
55
-
56
- In your project's site files, you can then now use this helper.
57
-
58
- # site/my_page.html.haml
59
- %h1 My form
60
- != form_tag 'post', '/note/new' do
61
- %p
62
- %label Your name:
63
- %input{ :type => 'text', :name => 'name' }
64
- %p
65
- %label Your email:
66
- %input{ :type => 'text', :name => 'email' }
67
-
68
- Adding commands
69
- ---------------
70
-
71
- Create a subclass of the class {Hyde::CLICommand} and place it under the {Hyde::CLICommands} module.
72
- The name of the class will be the command it will be accessible as.
73
-
74
- This example below defines a new `clean` command, which will be accessible by typing `hyde clean`.
75
- It will also show under `hyde --help` since it provides a `desc`.
76
-
77
- # extensions/hyde-clean/hyde-clean.rb
78
- module Hyde
79
- module CLICommands
80
- class Clean < CLICommand
81
- desc "Cleans up your project's dirt"
82
-
83
- def self.run(*a)
84
- if a.size > 0
85
- log "Unknown arguments: #{a.join(' ')}"
86
- log "Type `hyde --help clean` for more information."
87
- exit
88
- end
89
-
90
- log "Cleaning..."
91
- # Do stuff here
92
- log "All clean!"
93
- end
94
- end
95
- end
96
- end
97
-
98
- This may now be used in the command line.
99
-
100
- $ hyde clean all
101
- Unknown arguments: all
102
- Type `hyde --help clean` for more information.
103
-
104
- $ hyde clean
105
- Cleaning...
106
- All done!
107
-
108
- $ hyde --help
109
- Usage: hyde <command> arguments
110
-
111
- Commands:
112
- ....
113
- clean Cleans up your project's dirt
114
-
115
- Adding parsers
116
- --------------
117
-
118
- TODO.
data/manual/Hyde.md DELETED
@@ -1,63 +0,0 @@
1
- Hyde
2
- ====
3
-
4
- Hyde is a website preprocessor.
5
-
6
- - __Layouts and Partials:__ Hyde lets you define your site's header and footer
7
- layouts in a separate file, and even separate snippets of your site
8
- into reuseable components (partials). Your code will be much cleaner and
9
- DRYer!
10
-
11
- - __Template languages:__ Hyde lets you write your site in any template
12
- language you need -- the translation will be taken care of for you.
13
- Hyde supports HAML, LessCSS, Markdown, SASS and Textile by default, and
14
- more can be added through extensions.
15
-
16
- - __Extendable:__ Hyde is easily customizable with extensions. You can add
17
- new helpers, new commands, support for new languages and many more by
18
- simply adding the extensions to your project folder. Some are even
19
- available as simple Ruby gems!
20
-
21
- - __Design fast:__ Hyde comes with a web server that lets you serve up
22
- your site locally. Any changes to your files will be seen on your next
23
- browser refresh!
24
-
25
- - __Build your site as static HTMLs:__ You can export your site as plain
26
- HTML files with one simple command.
27
-
28
- Why use Hyde?
29
- -------------
30
-
31
- It's like building a static site, but better! You can use Hyde for:
32
-
33
- - Building HTML prototypes
34
- - Building sites with no dynamic logic
35
- - Creating a blog where the entries are stored in a source repository
36
-
37
- Introduction
38
- ------------
39
-
40
- - `++++` {file:Installation Installation} -- Start here
41
- - `++++` {file:GettingStarted Getting started}
42
- - `++--` {file:TemplateLanguages Template languages}
43
- - `+---` {file:Layouts Layouts}
44
- - `++++` {file:Partials Partials}
45
- - `++++` {file:Metadata Metadata}
46
- - `++++` {file:Configuration Configuration}
47
-
48
- Extending Hyde
49
- --------------
50
-
51
- - `+++-` {file:ExtendingHyde Extending Hyde}
52
-
53
- Tips and tricks
54
- ---------------
55
-
56
- - `+++-` {file:Tips Tips}
57
-
58
- Basic info
59
- ----------
60
-
61
- - {file:AUTHORS Credits}
62
- - {file:LICENSE License}
63
-
@@ -1,70 +0,0 @@
1
- Configuration
2
- =============
3
-
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
-
@@ -1,64 +0,0 @@
1
- Getting started
2
- ===============
3
-
4
- Starting your first project
5
- ---------------------------
6
-
7
- Create your first project with:
8
-
9
- hyde create <name>
10
-
11
- Where `<name>` is the name of your project. This will create a folder with that
12
- name, along with some sample files to get you started.
13
-
14
- Starting
15
- --------
16
-
17
- Begin working on your project by starting the Hyde webserver. This is optional,
18
- but is recommended as it's a nice way to see your changes in real time.
19
-
20
- hyde start
21
-
22
- After typing this, you will see the server has started. Point your web browser to
23
- `http://localhost:4833` to see your site. You should now see your project's
24
- default "welcome" page.
25
-
26
-
27
- Editing your site
28
- -----------------
29
-
30
- Your project has a subfolder called `site` -- this is where all the site's files are
31
- stored. In general, dropping any file in this folder will make it accessible with the
32
- same filename.
33
-
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:4833/products.html`,
36
- which should now show the page you were working on.
37
-
38
- You may also put your files in subfolders. If you were to create the file
39
- `site/assets/my_style.css`, it should be accessible through
40
- `http://localhost:4833/assets/my_style.css`.
41
-
42
- Dynamic files
43
- -------------
44
-
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).
49
-
50
- Building HTML files
51
- -------------------
52
-
53
- The `hyde start` webserver is good for local development, but when it's time to
54
- deploy your site, you will need to build your files. This process outputs raw
55
- HTML files for your entire site (for the dynamic files), with Hyde translating
56
- any files that need translation (e.g., HAML and ERB files).
57
-
58
- Build your files by typing this in the command prompt:
59
-
60
- hyde build
61
-
62
- This will create a folder called `public/` where the built files are stored.
63
- You can now deploy this folder to your webserver.
64
-
@@ -1,16 +0,0 @@
1
- Installation
2
- ============
3
-
4
- First, make sure that you have Ruby (>= version 1.8) installed. You can do this
5
- by typing `ruby --version` in the command line.
6
-
7
- - For Mac users, there's no need to do anything. Ruby comes with the OS by default.
8
- - For Windows users, I don't know.
9
- - For Ubuntu users, `sudo apt-get install ruby`.
10
-
11
- Install Hyde by typing:
12
-
13
- gem install hydeweb
14
-
15
- If this process fails, you can instead try `sudo gem install hydeweb`.
16
-
@@ -1,14 +0,0 @@
1
- Layouts
2
- =======
3
-
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,94 +0,0 @@
1
- Metadata
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.)
@@ -1,73 +0,0 @@
1
- Partials
2
- ========
3
-
4
- A partial is a snippet of code that you can reuse in any page of your site.
5
- This is particularly useful for repetitive sections, and for sections that may
6
- make your files too large to manage.
7
-
8
- Creating partials
9
- -----------------
10
-
11
- Put your partial file anywhere in the `layouts` folder, e.g.:
12
-
13
- <!-- layouts/shared/sidebar.erb -->
14
- <div id='#sidebar'>
15
- <h2><span>Sidebar</span><h2>
16
- <div class='description'>
17
- <p>This is a sidebar partial defined in a separate file.</p>
18
- </div>
19
- </div>
20
-
21
- In your site's files, you can invoke a partial through:
22
-
23
- <!-- site/index.html.erb -->
24
- <h1>Partial:</h1>
25
- <%= partial 'shared/sidebar' %>
26
- <span>End of partial.</span>
27
- <span>This is now text from index.html.</span>
28
-
29
- This will output:
30
-
31
- <!-- public/index.html -->
32
- <h1>Partial:</h1>
33
- <div id='#sidebar'>
34
- <h2><span>Sidebar</span><h2>
35
- <div class='description'>
36
- <p>This is a sidebar partial defined in a separate file.</p>
37
- </div>
38
- </div>
39
- <span>End of partial.</span>
40
- <span>This is now text from index.html.</span>
41
-
42
- Partials with local variables
43
- -----------------------------
44
-
45
- You can define a partial with some local variables that will be passed
46
- to it by the caller.
47
-
48
- <!-- layouts/shared/product.erb -->
49
- <div class='product'>
50
- <div class='title'>
51
- <h2><%= name %></h2>
52
- </div>
53
- <div class='desc'>
54
- <p><%= description %></p>
55
- </div>
56
- </div>
57
-
58
- In your files, call a partial by:
59
-
60
- <!-- site/index.html.erb -->
61
- <%= partial 'shared/product', { :name => '5MP Camera CX-300', :description => 'This is a camera with an adjustable focal length and Bluetooth support.' } %>
62
-
63
- Partials in HAML files
64
- ----------------------
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.
@@ -1,59 +0,0 @@
1
- Template languages
2
- ==================
3
-
4
- Hyde comes with support for some common template languages. This means you can
5
- write your site in a language like Markdown or HAML, and have Hyde take care
6
- of translating them accordingly.
7
-
8
- If a file ends in one of Hyde's supported file extensions (like `.haml`), it will be stripped
9
- out and the file will be rendered using the template engine in that extension (in
10
- this case, HAML).
11
-
12
- Supported languages
13
- -------------------
14
-
15
- Hyde supports the following languages out-of-the-box:
16
-
17
- - HTML template languages
18
- - `.haml` -- HAML
19
- - `.md` -- Markdown
20
- - `.textile` -- Textile
21
- - `.erb` -- ERB (Embedded Ruby)
22
-
23
- - CSS template languages
24
- - `.less` -- LessCSS
25
- - `.sass` -- SASS
26
-
27
- This means that the following files will be translated accordingly:
28
-
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
-
33
- Example
34
- -------
35
-
36
- When creating a new site, have a look at `index.haml`.
37
-
38
- ...
39
-
40
- Headers
41
- -------
42
-
43
- ...
44
-
45
- Layouts
46
- -------
47
-
48
- Layouts are supported for HAML, Markdown, Textile and ERB languages.
49
-
50
- ...
51
-
52
- Embedded Ruby features
53
- ----------------------
54
-
55
- Some languages (like HAML and ERB) has support for embedding Ruby code in the
56
- documents. This will let you do some nifty things in Hyde:
57
-
58
- - Partials
59
- - Helpers