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.
- data/.gitignore +1 -0
- data/README.md +5 -7
- data/VERSION +1 -1
- data/bin/hyde +2 -2
- data/data/new_site/.gitignore +24 -0
- data/data/new_site/_config.yml +1 -1
- data/data/new_site/layouts/default.haml +1 -1
- data/data/new_site/site/index.html.haml +5 -0
- data/lib/hyde/init.rb +7 -0
- data/lib/hyde/ostruct.rb +4 -0
- data/lib/hyde/page.rb +36 -12
- data/lib/hyde/project.rb +30 -15
- data/lib/hyde/renderer.rb +52 -7
- data/lib/hyde/renderers.rb +41 -9
- data/lib/hyde/scope.rb +12 -0
- data/lib/hyde/template_helpers.rb +6 -0
- data/lib/hyde.rb +8 -0
- data/test/fixtures/custom/layouts/default.haml +3 -1
- data/test/fixtures/custom/layouts/erbtest.erb +2 -0
- data/test/fixtures/custom/site/assets/common.css.less +1 -0
- data/test/fixtures/custom/site/assets/style.css.less +3 -0
- data/test/fixtures/custom/site/lol.html.erb +7 -0
- data/test/fixtures/custom/site/markdown.html.md +8 -0
- data/test/fixtures/custom/{www → www_control}/about/index.html +0 -0
- data/test/fixtures/custom/www_control/assets/common.css +1 -0
- data/test/fixtures/custom/www_control/assets/style.css +6 -0
- data/test/fixtures/custom/{www → www_control}/foo.html +0 -0
- data/test/fixtures/custom/{www → www_control}/index.html +0 -0
- data/test/fixtures/custom/{www → www_control}/layout_test.html +0 -0
- data/test/fixtures/custom/www_control/lol.html +5 -0
- data/test/fixtures/custom/www_control/markdown.html +10 -0
- data/test/fixtures/custom/{www → www_control}/yes.html +0 -0
- data/test/fixtures/default/_config.yml +1 -1
- data/test/fixtures/default/_layouts/default.haml +1 -1
- data/test/fixtures/default/{_www → www_control}/Users/rsc/Workdesk/hyde/hyde/test/fixtures/default/about/index.html +0 -0
- data/test/fixtures/default/{_www → www_control}/about/index.html +0 -0
- data/test/fixtures/default/{_www → www_control}/foo.html +0 -0
- data/test/fixtures/default/{_www → www_control}/index.html +0 -0
- data/test/fixtures/default/{_www → www_control}/layout_test.html +0 -0
- data/test/fixtures/default/{_www → www_control}/yes.html +0 -0
- data/test/test_all_fixtures.rb +47 -0
- metadata +29 -15
- data/data/new_site/site/index.html +0 -5
    
        data/.gitignore
    CHANGED
    
    
    
        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. | 
| 1 | 
            +
            0.0.1.pre4
         | 
    
        data/bin/hyde
    CHANGED
    
    
    
        data/data/new_site/_config.yml
    CHANGED
    
    
    
        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
    
    
    
        data/lib/hyde/page.rb
    CHANGED
    
    | @@ -1,7 +1,11 @@ | |
| 1 1 | 
             
            module Hyde
         | 
| 2 2 | 
             
              class Page 
         | 
| 3 | 
            -
                attr :filename | 
| 4 | 
            -
             | 
| 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( | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 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 | 
| 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 | 
| 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 | 
            -
                   | 
| 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  | 
| 50 | 
            -
                  Dir.mkdir root(:output)  unless  | 
| 51 | 
            -
             | 
| 52 | 
            -
                   | 
| 53 | 
            -
                     | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 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  | 
| 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  | 
| 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 | 
            -
                  @ | 
| 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'     => ' | 
| 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( | 
| 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( | 
| 61 | 
            -
                     | 
| 62 | 
            -
                    File.open(@page.filename, "r") | 
| 63 | 
            -
                     | 
| 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
         | 
    
        data/lib/hyde/renderers.rb
    CHANGED
    
    | @@ -1,16 +1,48 @@ | |
| 1 | 
            -
            require 'haml'
         | 
| 2 | 
            -
             | 
| 3 1 | 
             
            module Hyde
         | 
| 4 2 | 
             
              module Renderers
         | 
| 5 3 | 
             
                class Haml < Renderer::Parsable
         | 
| 6 | 
            -
                  def  | 
| 7 | 
            -
                     | 
| 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 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
                     | 
| 12 | 
            -
             | 
| 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
    
    
    
        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
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            body { background: white; }
         | 
| 
            File without changes
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            body { background: white; }
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            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 | 
            +
             | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| @@ -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 | 
            -
              -  | 
| 10 | 
            -
              version: 0.0.1. | 
| 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- | 
| 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/ | 
| 102 | 
            -
            - test/fixtures/custom/ | 
| 103 | 
            -
            - test/fixtures/custom/ | 
| 104 | 
            -
            - test/fixtures/custom/ | 
| 105 | 
            -
            - test/fixtures/custom/ | 
| 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
         |