hydeweb 0.0.1.pre3 → 0.0.1.pre4

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 (43) hide show
  1. data/.gitignore +1 -0
  2. data/README.md +5 -7
  3. data/VERSION +1 -1
  4. data/bin/hyde +2 -2
  5. data/data/new_site/.gitignore +24 -0
  6. data/data/new_site/_config.yml +1 -1
  7. data/data/new_site/layouts/default.haml +1 -1
  8. data/data/new_site/site/index.html.haml +5 -0
  9. data/lib/hyde/init.rb +7 -0
  10. data/lib/hyde/ostruct.rb +4 -0
  11. data/lib/hyde/page.rb +36 -12
  12. data/lib/hyde/project.rb +30 -15
  13. data/lib/hyde/renderer.rb +52 -7
  14. data/lib/hyde/renderers.rb +41 -9
  15. data/lib/hyde/scope.rb +12 -0
  16. data/lib/hyde/template_helpers.rb +6 -0
  17. data/lib/hyde.rb +8 -0
  18. data/test/fixtures/custom/layouts/default.haml +3 -1
  19. data/test/fixtures/custom/layouts/erbtest.erb +2 -0
  20. data/test/fixtures/custom/site/assets/common.css.less +1 -0
  21. data/test/fixtures/custom/site/assets/style.css.less +3 -0
  22. data/test/fixtures/custom/site/lol.html.erb +7 -0
  23. data/test/fixtures/custom/site/markdown.html.md +8 -0
  24. data/test/fixtures/custom/{www → www_control}/about/index.html +0 -0
  25. data/test/fixtures/custom/www_control/assets/common.css +1 -0
  26. data/test/fixtures/custom/www_control/assets/style.css +6 -0
  27. data/test/fixtures/custom/{www → www_control}/foo.html +0 -0
  28. data/test/fixtures/custom/{www → www_control}/index.html +0 -0
  29. data/test/fixtures/custom/{www → www_control}/layout_test.html +0 -0
  30. data/test/fixtures/custom/www_control/lol.html +5 -0
  31. data/test/fixtures/custom/www_control/markdown.html +10 -0
  32. data/test/fixtures/custom/{www → www_control}/yes.html +0 -0
  33. data/test/fixtures/default/_config.yml +1 -1
  34. data/test/fixtures/default/_layouts/default.haml +1 -1
  35. data/test/fixtures/default/{_www → www_control}/Users/rsc/Workdesk/hyde/hyde/test/fixtures/default/about/index.html +0 -0
  36. data/test/fixtures/default/{_www → www_control}/about/index.html +0 -0
  37. data/test/fixtures/default/{_www → www_control}/foo.html +0 -0
  38. data/test/fixtures/default/{_www → www_control}/index.html +0 -0
  39. data/test/fixtures/default/{_www → www_control}/layout_test.html +0 -0
  40. data/test/fixtures/default/{_www → www_control}/yes.html +0 -0
  41. data/test/test_all_fixtures.rb +47 -0
  42. metadata +29 -15
  43. data/data/new_site/site/index.html +0 -5
data/.gitignore CHANGED
@@ -22,3 +22,4 @@ pkg
22
22
  .rvmrc
23
23
  .yardoc
24
24
  doc
25
+ www
data/README.md CHANGED
@@ -4,7 +4,7 @@ Hyde
4
4
  Installation
5
5
  ------------
6
6
 
7
- gem install hydeweb
7
+ gem install hydeweb --pre
8
8
 
9
9
  Usage
10
10
  -----
@@ -18,16 +18,14 @@ To do
18
18
  -----
19
19
 
20
20
  - partials support
21
- - more renderers
22
- - less
23
- - markdown
24
- - textile
25
-
26
21
  - extensions support
27
-
28
22
  - _meta.yml
29
23
 
30
24
  Done:
31
25
 
32
26
  - hyde build
33
27
  - hyde gen
28
+ - more renderers
29
+ - less
30
+ - markdown
31
+ - textile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1.pre3
1
+ 0.0.1.pre4
data/bin/hyde CHANGED
@@ -50,8 +50,8 @@ elsif options[:action] == 'create'
50
50
 
51
51
  else
52
52
  site_name = options[:params][0]
53
- if Dir.exists? site_name
54
- ostream << "This director already exists!\n"
53
+ if File.directory? site_name
54
+ ostream << "This directory already exists!\n"
55
55
  exit
56
56
  end
57
57
 
@@ -0,0 +1,24 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+ *.swo
16
+ *.swn
17
+
18
+ ## PROJECT::GENERAL
19
+ coverage
20
+ rdoc
21
+ pkg
22
+
23
+ ## PROJECT::SPECIFIC
24
+ public
@@ -14,4 +14,4 @@ layouts_path: layouts
14
14
  extensions_path: extensions
15
15
 
16
16
  # The folder where the HTML files are to be built when typing `hyde build`.
17
- output_path: output
17
+ output_path: public
@@ -3,7 +3,7 @@
3
3
  %head
4
4
  %title= title
5
5
  %body
6
- =content
6
+ =yield
7
7
  %div#footer
8
8
  %hr
9
9
  %p Generated by Hyde
@@ -0,0 +1,5 @@
1
+ layout: default
2
+ title: Your new Hyde site
3
+ --
4
+ %h1 It works!
5
+ %p This is your new site. Feel free to take a look around!
data/lib/hyde/init.rb CHANGED
@@ -5,6 +5,11 @@ require "logger"
5
5
  $:.unshift File.dirname(__FILE__) + "/.."
6
6
  require 'hyde'
7
7
 
8
+ puts "Starting server..."
9
+ puts " http://127.0.0.1:4567 Homepage"
10
+ puts " http://127.0.0.1:4567/- File list"
11
+ puts ""
12
+
8
13
  class Main < Sinatra::Base
9
14
  @@project ||= Hyde::Project.new
10
15
 
@@ -18,6 +23,8 @@ class Main < Sinatra::Base
18
23
  get '/*' do
19
24
  begin
20
25
  path = params[:splat][0]
26
+ type = File.extname(path)[1..-1]
27
+ content_type type.to_sym if type.is_a? String
21
28
  @@project.render path
22
29
  rescue Hyde::NotFound
23
30
  raise Sinatra::NotFound
data/lib/hyde/ostruct.rb CHANGED
@@ -6,6 +6,10 @@ module Hyde
6
6
  hash.each_pair { |k, v| self.set!(k, v) }
7
7
  end
8
8
 
9
+ def include?(key)
10
+ @table.keys.include? key
11
+ end
12
+
9
13
  protected
10
14
  def set!(key, value)
11
15
  self.send "#{key.to_s}=".to_sym, value
data/lib/hyde/page.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  module Hyde
2
2
  class Page
3
- attr :filename, :renderer, :meta,
4
- :page, :layout, :project
3
+ attr :filename
4
+ attr :renderer
5
+ attr :meta
6
+ attr :page
7
+ attr :layout
8
+ attr :project
5
9
 
6
10
  # The filename of the source file.
7
11
  # @example
@@ -22,19 +26,35 @@ module Hyde
22
26
  attr_reader :project
23
27
 
24
28
  # Factory
29
+ # Try {Project#get_page} instead
25
30
  def self.create(path, project, page_class = Page)
26
31
  info = get_page_info(path, project)
27
32
  page = page_class.new(path, project, info[:renderer], info[:filename])
28
33
  end
29
34
 
30
35
  # Returns the rendered output.
31
- def render( data = {} )
32
- output = @renderer.render(@meta.merge(data))
33
- unless @layout.nil?
34
- hash = @meta.merge({ "content" => output })
35
- output = @layout.render hash
36
- end
37
- output
36
+ def render(data = {}, &block)
37
+ if self.is_a? Layout
38
+ # puts debug
39
+ end
40
+ output = @renderer.render(data, &block)
41
+ # BUG: @layout should build on top of that data
42
+ output = @layout.render(@meta.merge data) { output } unless @layout.nil?
43
+ output
44
+ end
45
+
46
+ def method_missing(meth, *args, &blk)
47
+ if meta.keys.include?(meth.to_s)
48
+ meta[meth.to_s]
49
+ elsif meta.keys.include?(meth.to_sym)
50
+ meta[meth.to_sym]
51
+ else
52
+ raise NoMethodError.new "Undefined method `#{self.class}::#{meth}`"
53
+ end
54
+ end
55
+
56
+ def get_binding
57
+ binding
38
58
  end
39
59
 
40
60
  # Sets the meta data as read from the file.
@@ -87,14 +107,18 @@ module Hyde
87
107
  matches.each do |match|
88
108
  begin
89
109
  ext = File.extname(match)[1..-1].capitalize.to_sym
110
+ exts << File.extname(match)
90
111
  r_class = Hyde::Renderers.const_get(ext)
91
- exts << ext
92
112
  renderer ||= r_class
93
113
  filename = match
94
- rescue NoMethodError; end
114
+ rescue NoMethodError
115
+ # pass
116
+ rescue NameError # Renderer not found
117
+ # pass
118
+ end
95
119
  end
96
120
 
97
- raise NotFound.new("No matching renderers found: " + exts.inspect) \
121
+ raise NotFound.new("No matching (#{exts.join(", ")}) renderers found for `#{path}`") \
98
122
  if renderer.nil?
99
123
  end
100
124
 
data/lib/hyde/project.rb CHANGED
@@ -20,17 +20,22 @@ module Hyde
20
20
  attr_accessor :config
21
21
 
22
22
  def initialize( root = Dir.pwd )
23
+ @config = OStruct.new defaults
24
+
25
+ # find_root
23
26
  @root = root
24
27
  @config_file ||= "#{@root}/_config.yml"
25
28
 
26
- @config = OStruct.new defaults
27
29
  @config.merge! YAML::load_file(@config_file) if File.exists? @config_file
28
30
  end
29
31
 
30
32
  def method_missing(meth, *args, &blk)
31
- @config.send meth # SHOULD SEND AND ERROR!!
33
+ raise NoMethodError, "No method `#{meth}`" unless @config.include?(meth)
34
+ @config.send meth
32
35
  end
33
36
 
37
+ # Returns a page in a certain URL path.
38
+ # @return {Page} or a subclass of it
34
39
  def get_page(path)
35
40
  path = "index.html" if path.empty?
36
41
  Page.create path, self
@@ -45,19 +50,26 @@ module Hyde
45
50
  get_page(path).render
46
51
  end
47
52
 
53
+ # Writes the output files.
54
+ # @param
55
+ # ostream - (Stream) Where to send the messages
48
56
  def build(ostream = nil)
49
- raise Errno::EEXISTS if File.exists? root(:output) and not Dir.exists? root(:output)
50
- Dir.mkdir root(:output) unless Dir.exists? root(:output)
51
-
52
- files.each do |path|
53
- ostream << " * #{output_path}/#{path}\n" if ostream
54
- mfile = force_file_open(root(:output, path))
55
- mfile << render(path)
56
- mfile.close
57
+ raise Errno::EEXISTS if File.exists? root(:output) and not File.directory? root(:output)
58
+ Dir.mkdir root(:output) unless File.directory? root(:output)
59
+
60
+ begin
61
+ files.each do |path|
62
+ ostream << " * #{output_path}/#{path}\n" if ostream
63
+ mfile = force_file_open(root(:output, path))
64
+ mfile << render(path)
65
+ mfile.close
66
+ end
67
+ rescue NoGemError => e
68
+ ostream << "Error: #{e.message}\n"
57
69
  end
58
70
  end
59
71
 
60
- # Returns a list of all URLs
72
+ # Returns a list of all URL paths
61
73
  def files
62
74
  @file_list ||= Dir[File.join(root(:site), '**', '*')].inject([]) do |a, match|
63
75
  # Make sure its the canonical name
@@ -65,7 +77,7 @@ module Hyde
65
77
  file = path.gsub /^#{Regexp.escape root(:site)}\/?/, ''
66
78
  ext = File.extname(file)[1..-1]
67
79
 
68
- if ignored_files.include?(path) or Dir.exists?(match)
80
+ if ignored_files.include?(path) or File.directory?(match)
69
81
  # pass
70
82
  elsif not get_renderer(ext).nil? # Has a renderer associated
71
83
  a << file.chomp(".#{ext}")
@@ -77,7 +89,7 @@ module Hyde
77
89
  end
78
90
 
79
91
  def ignore_list
80
- @ignote_list ||= [
92
+ @ignore_list ||= [
81
93
  root(:layouts, '**/*'),
82
94
  root(:extensions, '**/*'),
83
95
  root(:output, '**/*'),
@@ -85,6 +97,8 @@ module Hyde
85
97
  ]
86
98
  end
87
99
 
100
+ # Returns a list of ignored files.
101
+ # TODO: This is innefficient... do it another way
88
102
  def ignored_files
89
103
  @ignored_files ||= ignore_list.inject([]) { |a, spec|
90
104
  Dir[spec].each { |file| a << File.expand_path(file) }; a
@@ -96,14 +110,15 @@ module Hyde
96
110
  { 'layouts_path' => 'layouts',
97
111
  'extensions_path' => 'extensions',
98
112
  'site_path' => 'site',
99
- 'output_path' => 'output'
113
+ 'output_path' => 'public'
100
114
  }
101
115
  end
102
116
 
117
+ # Returns the renderer associated with the given file extension.
103
118
  def get_renderer(name)
104
119
  begin
105
120
  class_name = name.to_s.capitalize.to_sym
106
- renderer = Renderers.const_get(class_name)
121
+ renderer = ::Hyde::Renderers.const_get(class_name)
107
122
  rescue NameError
108
123
  renderer = nil
109
124
  end
data/lib/hyde/renderer.rb CHANGED
@@ -14,15 +14,56 @@ module Hyde
14
14
  @filename = filename
15
15
  end
16
16
 
17
- def render( data = {} )
17
+ def render(data, &block)
18
+ scope = build_scope(page, data)
19
+ evaluate scope, data, &block
20
+ end
21
+
22
+ def markup
23
+ File.open(filename) { |f| @markup = f.read } unless @markup
24
+ @markup
25
+ end
26
+
27
+ protected
28
+ def require_lib(lib, gem=lib)
29
+ begin
30
+ require lib
31
+ rescue LoadError
32
+ class_name = self.class.to_s.downcase
33
+ ext = /[^:]*$/.match(class_name)
34
+ raise NoGemError.new("To use .#{ext} files, type: `gem install #{gem}`")
35
+ end
36
+ end
37
+
38
+ def build_scope(page, data)
39
+ # Page is the scope
40
+ scope = page.get_binding
41
+ scope_object = eval("self", scope)
42
+
43
+ # Inherit local vars
44
+ scope_object.send(:instance_variable_set, '@_locals', data)
45
+ f_set_locals = data.keys.map { |k| "#{k} = @_locals[#{k.inspect}];" }.join("\n")
46
+ eval(f_set_locals, scope)
47
+
48
+ scope_object.instance_eval do
49
+ def eval_block(src, &block)
50
+ # This will let you eval something, and `yield` within that block.
51
+ eval src
52
+ end
53
+ extend Hyde::TemplateHelpers
54
+ end
55
+
56
+ scope
57
+ end
58
+
59
+ # Override me
60
+ def evaluate(scope, data, &block)
18
61
  ""
19
62
  end
20
63
  end
21
64
 
22
65
  # Any filetype that is split with the -- separator
23
66
  class Parsable < Base
24
- @markup = ""
25
-
26
67
  def initialize(page, filename)
27
68
  super page, filename
28
69
 
@@ -37,6 +78,10 @@ module Hyde
37
78
  end
38
79
  end
39
80
 
81
+ def markup
82
+ @markup
83
+ end
84
+
40
85
  protected
41
86
  def get_file_parts(filename, *args)
42
87
  options = { :max_parts => -1 }
@@ -57,10 +102,10 @@ module Hyde
57
102
  end
58
103
 
59
104
  class Passthru < Base
60
- def render( data = {} )
61
- data = ""
62
- File.open(@page.filename, "r").each_line { |line| data << line }
63
- data
105
+ def render(data = 0, &block)
106
+ output = ''
107
+ File.open(@page.filename, "r") { |f| output = f.read }
108
+ output
64
109
  end
65
110
  end
66
111
  end
@@ -1,16 +1,48 @@
1
- require 'haml'
2
-
3
1
  module Hyde
4
2
  module Renderers
5
3
  class Haml < Renderer::Parsable
6
- def render( data = {} )
7
- @engine = ::Haml::Engine.new(@markup, {})
4
+ def evaluate(scope, data={}, &block)
5
+ require_lib 'haml'
6
+ @engine = ::Haml::Engine.new(markup, {})
7
+ @engine.render scope, data, &block
8
+ end
9
+ end
10
+
11
+ class Erb < Renderer::Parsable
12
+ def evaluate(scope, data={}, &block)
13
+ require_lib 'erb'
14
+ @engine = ::ERB.new markup
15
+ # So that we can yield!
16
+ eval("self", scope).eval_block @engine.src, &block
17
+ end
18
+ end
19
+
20
+ class Less < Renderer::Base
21
+ def evaluate(scope, data={}, &block)
22
+ require_lib 'less'
23
+ @engine = ::Less::Engine.new(File.open(filename))
24
+ @engine.to_css
25
+ end
26
+ end
27
+
28
+ #class Sass < Renderer::Base
29
+ # def evaluate(scope, data={}, &block)
30
+ # require 'haml'
31
+ # @engine = ::Sass::Engine.new(File.open(filename))
32
+ # end
33
+ #end
34
+
35
+ class Md < Renderer::Parsable
36
+ def evaluate(s, d={}, &block)
37
+ require_lib 'maruku'
38
+ Maruku.new(markup).to_html
39
+ end
40
+ end
8
41
 
9
- if data.is_a? Hash
10
- @engine.render OpenStruct.new data
11
- else
12
- @engine.render data
13
- end
42
+ class Textile < Renderer::Parsable
43
+ def evaluate(s, d={}, &block)
44
+ require_lib 'redcloth', 'RedCloth'
45
+ RedCloth.new(markup).to_html
14
46
  end
15
47
  end
16
48
  end
data/lib/hyde/scope.rb ADDED
@@ -0,0 +1,12 @@
1
+ module Hyde
2
+ # HAXXX... to be deprecated
3
+ class Scope
4
+ def data=(data)
5
+ @data = OpenStruct.new(data)
6
+ end
7
+
8
+ def method_missing(meth, *args, &blk)
9
+ @data.send meth
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ module Hyde
2
+ module TemplateHelpers
3
+ # def render # partial support
4
+ # end
5
+ end
6
+ end
data/lib/hyde.rb CHANGED
@@ -9,7 +9,15 @@ module Hyde
9
9
  autoload :Renderer, "#{prefix}/hyde/renderer"
10
10
  autoload :Renderers, "#{prefix}/hyde/renderers"
11
11
  autoload :Utils, "#{prefix}/hyde/utils"
12
+ autoload :Scope, "#{prefix}/hyde/scope"
13
+ autoload :TemplateHelpers,"#{prefix}/hyde/template_helpers"
14
+
15
+ class Exception < ::Exception
16
+ end
12
17
 
13
18
  class NotFound < Exception
14
19
  end
20
+
21
+ class NoGemError < Exception
22
+ end
15
23
  end
@@ -1,5 +1,7 @@
1
+ title: Site
2
+ --
1
3
  %title= title
2
4
  != "<!-- (default layout) -->"
3
5
  %h2 Template
4
6
  %div
5
- =content
7
+ =yield
@@ -0,0 +1,2 @@
1
+ Hello
2
+ <%= yield %>
@@ -0,0 +1 @@
1
+ body { background: white; }
@@ -0,0 +1,3 @@
1
+ @import "common.css.less";
2
+ .test { outline: 0; }
3
+ #menu { color: red; .test; }
@@ -0,0 +1,7 @@
1
+ yay: 444
2
+ layout: erbtest
3
+ title: This is from lol.html
4
+ --
5
+ Hey there!
6
+ <%= self.inspect %>
7
+ <%= yay %>
@@ -0,0 +1,8 @@
1
+ layout: default
2
+ --
3
+ Markdown test
4
+ =============
5
+
6
+ * This file is generated from Markdown.
7
+ * ...
8
+
@@ -0,0 +1 @@
1
+ body { background: white; }
@@ -0,0 +1,6 @@
1
+ body { background: white; }
2
+ .test { outline: 0; }
3
+ #menu {
4
+ color: red;
5
+ outline: 0;
6
+ }
File without changes
@@ -0,0 +1,5 @@
1
+ Hello
2
+ Hey there!
3
+ #<Hyde::Page:0x0000010126a930 @project=#<Hyde::Project:0x00000100b35058 @config=#<Hyde::OStruct layouts_path="layouts", extensions_path="extensions", site_path="site", output_path="www", ignore=["hyde", "_*"]>, @root="/Users/rsc/Workdesk/hyde/test/fixtures/custom", @config_file="/Users/rsc/Workdesk/hyde/test/fixtures/custom/_config.yml", @ignore_list=["/Users/rsc/Workdesk/hyde/test/fixtures/custom/layouts/**/*", "/Users/rsc/Workdesk/hyde/test/fixtures/custom/extensions/**/*", "/Users/rsc/Workdesk/hyde/test/fixtures/custom/www/**/*", "/Users/rsc/Workdesk/hyde/test/fixtures/custom/_config.yml"], @ignored_files=["/Users/rsc/Workdesk/hyde/test/fixtures/custom/layouts/default.haml", "/Users/rsc/Workdesk/hyde/test/fixtures/custom/layouts/erbtest.erb", "/Users/rsc/Workdesk/hyde/test/fixtures/custom/_config.yml"], @file_list=["about/index.html", "assets/common.css", "assets/style.css", "foo.html", "index.html", "layout_test.html", "lol.html", "markdown.html", "yes.html"]>, @name="lol.html", @meta={"yay"=>444, "layout"=>"erbtest", "title"=>"This is from lol.html"}, @filename="/Users/rsc/Workdesk/hyde/test/fixtures/custom/site/lol.html.erb", @renderer=#<Hyde::Renderers::Erb:0x0000010126a578 @page=#<Hyde::Page:0x0000010126a930 ...>, @filename="/Users/rsc/Workdesk/hyde/test/fixtures/custom/site/lol.html.erb", @markup="Hey there!\n<%= self.inspect %>\n<%= yay %>\n", @engine=#<ERB:0x0000010125ebc0 @safe_level=nil, @src="#coding:US-ASCII\n_erbout = ''; _erbout.concat \"Hey there!\\n\"\n; _erbout.concat(( self.inspect ).to_s); _erbout.concat \"\\n\"\n; _erbout.concat(( yay ).to_s); _erbout.concat \"\\n\"\n; _erbout.force_encoding(__ENCODING__)", @enc=#<Encoding:US-ASCII>, @filename=nil>>, @_locals={}, @layout=#<Hyde::Layout:0x000001012624a0 @project=#<Hyde::Project:0x00000100b35058 @config=#<Hyde::OStruct layouts_path="layouts", extensions_path="extensions", site_path="site", output_path="www", ignore=["hyde", "_*"]>, @root="/Users/rsc/Workdesk/hyde/test/fixtures/custom", @config_file="/Users/rsc/Workdesk/hyde/test/fixtures/custom/_config.yml", @ignore_list=["/Users/rsc/Workdesk/hyde/test/fixtures/custom/layouts/**/*", "/Users/rsc/Workdesk/hyde/test/fixtures/custom/extensions/**/*", "/Users/rsc/Workdesk/hyde/test/fixtures/custom/www/**/*", "/Users/rsc/Workdesk/hyde/test/fixtures/custom/_config.yml"], @ignored_files=["/Users/rsc/Workdesk/hyde/test/fixtures/custom/layouts/default.haml", "/Users/rsc/Workdesk/hyde/test/fixtures/custom/layouts/erbtest.erb", "/Users/rsc/Workdesk/hyde/test/fixtures/custom/_config.yml"], @file_list=["about/index.html", "assets/common.css", "assets/style.css", "foo.html", "index.html", "layout_test.html", "lol.html", "markdown.html", "yes.html"]>, @name="erbtest", @meta={}, @filename="/Users/rsc/Workdesk/hyde/test/fixtures/custom/layouts/erbtest.erb", @renderer=#<Hyde::Renderers::Erb:0x000001012623f8 @page=#<Hyde::Layout:0x000001012624a0 ...>, @filename="/Users/rsc/Workdesk/hyde/test/fixtures/custom/layouts/erbtest.erb", @markup="Hello\n<%= yield %>\n">>>
4
+ 444
5
+
@@ -0,0 +1,10 @@
1
+ <title>Site</title>
2
+ <!-- (default layout) -->
3
+ <h2>Template</h2>
4
+ <div>
5
+ <h1 id='markdown_test'>Markdown test</h1>
6
+
7
+ <ul>
8
+ <li>This file is generated from Markdown. * &#8230;</li>
9
+ </ul>
10
+ </div>
File without changes
@@ -2,7 +2,7 @@
2
2
  layouts_path: _layouts
3
3
  extensions_path: _extensions
4
4
  site_path: .
5
- output_path: _www
5
+ output_path: www
6
6
  ignore:
7
7
  - hyde
8
8
  - _*
@@ -2,4 +2,4 @@
2
2
  != "<!-- (default layout) -->"
3
3
  %h2 Template
4
4
  %div
5
- =content
5
+ =yield
@@ -0,0 +1,47 @@
1
+ require "helper"
2
+ require 'fileutils'
3
+
4
+ class TestAllFixtures < Test::Unit::TestCase
5
+ @@root = File.join(Dir.pwd, 'test', 'fixtures')
6
+
7
+ def setup
8
+ @original_pwd = Dir.pwd
9
+ end
10
+
11
+ def teardown
12
+ # Remove all the generated www's
13
+ Dir["#{@@root}/**/www"].each do |match|
14
+ FileUtils.rm_rf match
15
+ end
16
+ Dir.chdir @original_pwd
17
+ end
18
+
19
+ def self.all_sites
20
+ @@sites ||= Dir["#{@@root}/*"] \
21
+ .reject { |f| not Dir.exists? f } \
22
+ .map { |f| File.basename(f) }
23
+ end
24
+
25
+ all_sites.each do |site|
26
+ describe "Test `#{site}`" do
27
+ should "Build it properly and have identical files to the control" do
28
+ @project = Hyde::Project.new File.join(@@root, site)
29
+ @project.build
30
+
31
+ unknown_root = @project.root :site
32
+ control_root = @project.root 'www_control'
33
+
34
+ if not Dir.exists? control_root
35
+ flunk "No www_control"
36
+ else
37
+ @project.files.reject { |f| not Dir.exists? f }.each do |path|
38
+ unknown = File.open(File.join(unknown_root, path)).read
39
+ control = File.open(File.join(control_root, path)).read
40
+
41
+ assert_equal control, unknown
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 0
8
8
  - 1
9
- - pre3
10
- version: 0.0.1.pre3
9
+ - pre4
10
+ version: 0.0.1.pre4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rico Sta. Cruz
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-04-28 00:00:00 +08:00
19
+ date: 2010-04-30 00:00:00 +08:00
20
20
  default_executable: hyde
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -78,10 +78,11 @@ files:
78
78
  - Rakefile
79
79
  - VERSION
80
80
  - bin/hyde
81
+ - data/new_site/.gitignore
81
82
  - data/new_site/README.md
82
83
  - data/new_site/_config.yml
83
84
  - data/new_site/layouts/default.haml
84
- - data/new_site/site/index.html
85
+ - data/new_site/site/index.html.haml
85
86
  - lib/hyde.rb
86
87
  - lib/hyde/init.rb
87
88
  - lib/hyde/layout.rb
@@ -90,33 +91,45 @@ files:
90
91
  - lib/hyde/project.rb
91
92
  - lib/hyde/renderer.rb
92
93
  - lib/hyde/renderers.rb
94
+ - lib/hyde/scope.rb
95
+ - lib/hyde/template_helpers.rb
93
96
  - lib/hyde/utils.rb
94
97
  - test/fixtures/custom/_config.yml
95
98
  - test/fixtures/custom/layouts/default.haml
99
+ - test/fixtures/custom/layouts/erbtest.erb
96
100
  - test/fixtures/custom/site/about/index.html
101
+ - test/fixtures/custom/site/assets/common.css.less
102
+ - test/fixtures/custom/site/assets/style.css.less
97
103
  - test/fixtures/custom/site/foo.html.haml
98
104
  - test/fixtures/custom/site/index.html.haml
99
105
  - test/fixtures/custom/site/layout_test.html.haml
106
+ - test/fixtures/custom/site/lol.html.erb
107
+ - test/fixtures/custom/site/markdown.html.md
100
108
  - test/fixtures/custom/site/yes.html
101
- - test/fixtures/custom/www/about/index.html
102
- - test/fixtures/custom/www/foo.html
103
- - test/fixtures/custom/www/index.html
104
- - test/fixtures/custom/www/layout_test.html
105
- - test/fixtures/custom/www/yes.html
109
+ - test/fixtures/custom/www_control/about/index.html
110
+ - test/fixtures/custom/www_control/assets/common.css
111
+ - test/fixtures/custom/www_control/assets/style.css
112
+ - test/fixtures/custom/www_control/foo.html
113
+ - test/fixtures/custom/www_control/index.html
114
+ - test/fixtures/custom/www_control/layout_test.html
115
+ - test/fixtures/custom/www_control/lol.html
116
+ - test/fixtures/custom/www_control/markdown.html
117
+ - test/fixtures/custom/www_control/yes.html
106
118
  - test/fixtures/default/_config.yml
107
119
  - test/fixtures/default/_layouts/default.haml
108
- - test/fixtures/default/_www/Users/rsc/Workdesk/hyde/hyde/test/fixtures/default/about/index.html
109
- - test/fixtures/default/_www/about/index.html
110
- - test/fixtures/default/_www/foo.html
111
- - test/fixtures/default/_www/index.html
112
- - test/fixtures/default/_www/layout_test.html
113
- - test/fixtures/default/_www/yes.html
114
120
  - test/fixtures/default/about/index.html
115
121
  - test/fixtures/default/foo.html.haml
116
122
  - test/fixtures/default/index.html.haml
117
123
  - test/fixtures/default/layout_test.html.haml
124
+ - test/fixtures/default/www_control/Users/rsc/Workdesk/hyde/hyde/test/fixtures/default/about/index.html
125
+ - test/fixtures/default/www_control/about/index.html
126
+ - test/fixtures/default/www_control/foo.html
127
+ - test/fixtures/default/www_control/index.html
128
+ - test/fixtures/default/www_control/layout_test.html
129
+ - test/fixtures/default/www_control/yes.html
118
130
  - test/fixtures/default/yes.html
119
131
  - test/helper.rb
132
+ - test/test_all_fixtures.rb
120
133
  - test/test_build.rb
121
134
  - test/test_hyde.rb
122
135
  - test/test_utils.rb
@@ -154,6 +167,7 @@ specification_version: 3
154
167
  summary: Website preprocessor
155
168
  test_files:
156
169
  - test/helper.rb
170
+ - test/test_all_fixtures.rb
157
171
  - test/test_build.rb
158
172
  - test/test_hyde.rb
159
173
  - test/test_utils.rb
@@ -1,5 +0,0 @@
1
- layout: default
2
- title: Your new Hyde site
3
- --
4
- <h1>It works!</h1>
5
- <p>This is your new site. Feel free to take a look around!</p>