gumdrop 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog.md +11 -0
 - data/gumdrop.gemspec +0 -2
 - data/lib/gumdrop/callbacks.rb +27 -0
 - data/lib/gumdrop/content.rb +5 -2
 - data/lib/gumdrop/context.rb +1 -5
 - data/lib/gumdrop/generator.rb +8 -15
 - data/lib/gumdrop/server.rb +13 -5
 - data/lib/gumdrop/site.rb +47 -20
 - data/lib/gumdrop/stitch_support.rb +0 -1
 - data/lib/gumdrop/version.rb +1 -1
 - data/lib/gumdrop.rb +2 -2
 - metadata +3 -2
 
    
        data/ChangeLog.md
    CHANGED
    
    | 
         @@ -1,3 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # v0.6.3
         
     | 
| 
      
 2 
     | 
    
         
            +
            - Added `generated` flag to Content object
         
     | 
| 
      
 3 
     | 
    
         
            +
            - Added `config` to Generator context
         
     | 
| 
      
 4 
     | 
    
         
            +
            - Added callbacks to site build process. Callbacks:
         
     | 
| 
      
 5 
     | 
    
         
            +
                - on_start
         
     | 
| 
      
 6 
     | 
    
         
            +
                - on_scan
         
     | 
| 
      
 7 
     | 
    
         
            +
                - on_generate
         
     | 
| 
      
 8 
     | 
    
         
            +
                - on_render
         
     | 
| 
      
 9 
     | 
    
         
            +
                - on_end
         
     | 
| 
      
 10 
     | 
    
         
            +
            - Dev server doesn't check last build time for static assets.
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       1 
12 
     | 
    
         
             
            # v0.6.2
         
     | 
| 
       2 
13 
     | 
    
         
             
            - Consolidated stitch support code into single file
         
     | 
| 
       3 
14 
     | 
    
         
             
            - Bugfix: Generates better relative paths for Content objects
         
     | 
    
        data/gumdrop.gemspec
    CHANGED
    
    
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Gumdrop
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Callbacks
         
     | 
| 
      
 3 
     | 
    
         
            +
                
         
     | 
| 
      
 4 
     | 
    
         
            +
                # For defining callbacks
         
     | 
| 
      
 5 
     | 
    
         
            +
                def callback(*callback_names)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  callback_names.each do |name|
         
     | 
| 
      
 7 
     | 
    
         
            +
                    class_eval <<-EOF
         
     | 
| 
      
 8 
     | 
    
         
            +
                      def #{name}(*args, &block)
         
     | 
| 
      
 9 
     | 
    
         
            +
                        if block
         
     | 
| 
      
 10 
     | 
    
         
            +
                          @_#{name} = [] if @_#{name}.nil?
         
     | 
| 
      
 11 
     | 
    
         
            +
                          @_#{name} << block
         
     | 
| 
      
 12 
     | 
    
         
            +
                        elsif @_#{name}
         
     | 
| 
      
 13 
     | 
    
         
            +
                          @_#{name}.each do |cb|
         
     | 
| 
      
 14 
     | 
    
         
            +
                            cb.call(*args)
         
     | 
| 
      
 15 
     | 
    
         
            +
                          end
         
     | 
| 
      
 16 
     | 
    
         
            +
                        end
         
     | 
| 
      
 17 
     | 
    
         
            +
                      end
         
     | 
| 
      
 18 
     | 
    
         
            +
                    EOF
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
              
         
     | 
| 
      
 22 
     | 
    
         
            +
                alias_method :callbacks, :callback
         
     | 
| 
      
 23 
     | 
    
         
            +
                alias_method :define_callback, :callback
         
     | 
| 
      
 24 
     | 
    
         
            +
                alias_method :define_callbacks, :callback
         
     | 
| 
      
 25 
     | 
    
         
            +
              
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/gumdrop/content.rb
    CHANGED
    
    | 
         @@ -15,6 +15,7 @@ module Gumdrop 
     | 
|
| 
       15 
15 
     | 
    
         
             
                              :params, 
         
     | 
| 
       16 
16 
     | 
    
         
             
                              :site, 
         
     | 
| 
       17 
17 
     | 
    
         
             
                              :ignored, 
         
     | 
| 
      
 18 
     | 
    
         
            +
                              :generated,
         
     | 
| 
       18 
19 
     | 
    
         
             
                              :full_path
         
     | 
| 
       19 
20 
     | 
    
         | 
| 
       20 
21 
     | 
    
         
             
                def initialize(path, site, params={})
         
     | 
| 
         @@ -22,6 +23,7 @@ module Gumdrop 
     | 
|
| 
       22 
23 
     | 
    
         
             
                  @params= HashObject.new params
         
     | 
| 
       23 
24 
     | 
    
         
             
                  @full_path= path
         
     | 
| 
       24 
25 
     | 
    
         
             
                  @ignored= false
         
     | 
| 
      
 26 
     | 
    
         
            +
                  @generated= false
         
     | 
| 
       25 
27 
     | 
    
         
             
                  @path= get_source_path
         
     | 
| 
       26 
28 
     | 
    
         
             
                  @level= (@path.split('/').length - 1)
         
     | 
| 
       27 
29 
     | 
    
         
             
                  @source_filename= File.basename path
         
     | 
| 
         @@ -44,6 +46,7 @@ module Gumdrop 
     | 
|
| 
       44 
46 
     | 
    
         
             
                    context.reset_data 'current_depth'=>@level, 'current_slug'=>@slug, 'page'=>self, 'layout'=>default_layout, 'params'=>self.params
         
     | 
| 
       45 
47 
     | 
    
         
             
                  end
         
     | 
| 
       46 
48 
     | 
    
         
             
                  context.set_content self, locals
         
     | 
| 
      
 49 
     | 
    
         
            +
                  @site.report " Rendering: #{@uri}", :warning
         
     | 
| 
       47 
50 
     | 
    
         
             
                  content= @template.render(context) 
         
     | 
| 
       48 
51 
     | 
    
         
             
                  return content if ignore_layout
         
     | 
| 
       49 
52 
     | 
    
         
             
                  layout= context.get_template()
         
     | 
| 
         @@ -56,7 +59,7 @@ module Gumdrop 
     | 
|
| 
       56 
59 
     | 
    
         | 
| 
       57 
60 
     | 
    
         
             
                def renderTo(context, output_path, filters=[], opts={})
         
     | 
| 
       58 
61 
     | 
    
         
             
                  return copyTo(output_path, opts) unless useLayout?
         
     | 
| 
       59 
     | 
    
         
            -
                  @site.report " Rendering: #{@uri}", :warning
         
     | 
| 
      
 62 
     | 
    
         
            +
                  # @site.report " Rendering: #{@uri}", :warning
         
     | 
| 
       60 
63 
     | 
    
         
             
                  output= render(context)
         
     | 
| 
       61 
64 
     | 
    
         
             
                  filters.each {|f| output= f.call(output, self) }
         
     | 
| 
       62 
65 
     | 
    
         
             
                  File.open output_path, 'w' do |f|
         
     | 
| 
         @@ -117,7 +120,7 @@ module Gumdrop 
     | 
|
| 
       117 
120 
     | 
    
         
             
                end
         
     | 
| 
       118 
121 
     | 
    
         | 
| 
       119 
122 
     | 
    
         
             
                def get_uri
         
     | 
| 
       120 
     | 
    
         
            -
                  uri= File.join File.dirname(@path), @filename 
     | 
| 
      
 123 
     | 
    
         
            +
                  uri= File.join File.dirname(@path), @filename
         
     | 
| 
       121 
124 
     | 
    
         
             
                  if uri.starts_with? './'
         
     | 
| 
       122 
125 
     | 
    
         
             
                    uri[2..-1]
         
     | 
| 
       123 
126 
     | 
    
         
             
                  else
         
     | 
    
        data/lib/gumdrop/context.rb
    CHANGED
    
    | 
         @@ -70,21 +70,17 @@ module Gumdrop 
     | 
|
| 
       70 
70 
     | 
    
         
             
                  @site
         
     | 
| 
       71 
71 
     | 
    
         
             
                end
         
     | 
| 
       72 
72 
     | 
    
         | 
| 
       73 
     | 
    
         
            -
                # Access to settings  
     | 
| 
      
 73 
     | 
    
         
            +
                # Access to settings as defined in the configure block
         
     | 
| 
       74 
74 
     | 
    
         
             
                def config
         
     | 
| 
       75 
75 
     | 
    
         
             
                  @site.config
         
     | 
| 
       76 
76 
     | 
    
         
             
                end
         
     | 
| 
       77 
77 
     | 
    
         | 
| 
       78 
78 
     | 
    
         
             
                def reset_data(preset={})
         
     | 
| 
       79 
     | 
    
         
            -
                  # TODO: Add a setting for reloading data on every request/page
         
     | 
| 
       80 
     | 
    
         
            -
                  #  was this for the server?
         
     | 
| 
       81 
     | 
    
         
            -
                  # @site.data.reset if !Gumdrop.config.cache_data
         
     | 
| 
       82 
79 
     | 
    
         
             
                  @state = preset
         
     | 
| 
       83 
80 
     | 
    
         
             
                end
         
     | 
| 
       84 
81 
     | 
    
         | 
| 
       85 
82 
     | 
    
         
             
                def method_missing(name, value=nil)
         
     | 
| 
       86 
83 
     | 
    
         
             
                  @state=  Hash.new {|h,k| h[k]= nil } if @state.nil? 
         
     | 
| 
       87 
     | 
    
         
            -
                  # puts "Looking for >> #{name} in #{@state.keys}"
         
     | 
| 
       88 
84 
     | 
    
         
             
                  unless value.nil?
         
     | 
| 
       89 
85 
     | 
    
         
             
                    @state[name.to_s]= value
         
     | 
| 
       90 
86 
     | 
    
         
             
                  else
         
     | 
    
        data/lib/gumdrop/generator.rb
    CHANGED
    
    | 
         @@ -20,9 +20,9 @@ module Gumdrop 
     | 
|
| 
       20 
20 
     | 
    
         
             
                # This should probably not be accessible to the generators
         
     | 
| 
       21 
21 
     | 
    
         
             
                def execute
         
     | 
| 
       22 
22 
     | 
    
         
             
                  if @content.is_a? Proc
         
     | 
| 
       23 
     | 
    
         
            -
                     
     | 
| 
      
 23 
     | 
    
         
            +
                    instance_eval &@content
         
     | 
| 
       24 
24 
     | 
    
         
             
                  else
         
     | 
| 
       25 
     | 
    
         
            -
                     
     | 
| 
      
 25 
     | 
    
         
            +
                    instance_eval File.read(@content.path)
         
     | 
| 
       26 
26 
     | 
    
         
             
                  end
         
     | 
| 
       27 
27 
     | 
    
         
             
                end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
         @@ -33,6 +33,10 @@ module Gumdrop 
     | 
|
| 
       33 
33 
     | 
    
         
             
                def data
         
     | 
| 
       34 
34 
     | 
    
         
             
                  @site.data
         
     | 
| 
       35 
35 
     | 
    
         
             
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                def config
         
     | 
| 
      
 38 
     | 
    
         
            +
                  @site.config
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
       36 
40 
     | 
    
         | 
| 
       37 
41 
     | 
    
         
             
                def set(var_name, value)
         
     | 
| 
       38 
42 
     | 
    
         
             
                  params[var_name]= value
         
     | 
| 
         @@ -120,18 +124,6 @@ module Gumdrop 
     | 
|
| 
       120 
124 
     | 
    
         
             
                    end
         
     | 
| 
       121 
125 
     | 
    
         
             
                  end
         
     | 
| 
       122 
126 
     | 
    
         
             
                end
         
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
              private
         
     | 
| 
       125 
     | 
    
         
            -
                
         
     | 
| 
       126 
     | 
    
         
            -
                def run_dsl_from_source(source)
         
     | 
| 
       127 
     | 
    
         
            -
                  # puts source
         
     | 
| 
       128 
     | 
    
         
            -
                  instance_eval source
         
     | 
| 
       129 
     | 
    
         
            -
                end
         
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
                def run_dsl_from_proc(proc)
         
     | 
| 
       132 
     | 
    
         
            -
                  # puts source
         
     | 
| 
       133 
     | 
    
         
            -
                  instance_eval &proc
         
     | 
| 
       134 
     | 
    
         
            -
                end
         
     | 
| 
       135 
127 
     | 
    
         | 
| 
       136 
128 
     | 
    
         
             
              end
         
     | 
| 
       137 
129 
     | 
    
         | 
| 
         @@ -139,8 +131,9 @@ module Gumdrop 
     | 
|
| 
       139 
131 
     | 
    
         
             
                # Nothing special, per se...
         
     | 
| 
       140 
132 
     | 
    
         | 
| 
       141 
133 
     | 
    
         
             
                def initialize(path, block, site, params={})
         
     | 
| 
       142 
     | 
    
         
            -
                  @content_block= block
         
     | 
| 
       143 
134 
     | 
    
         
             
                  super(path, site, params)
         
     | 
| 
      
 135 
     | 
    
         
            +
                  @content_block= block
         
     | 
| 
      
 136 
     | 
    
         
            +
                  @generated= true
         
     | 
| 
       144 
137 
     | 
    
         
             
                end
         
     | 
| 
       145 
138 
     | 
    
         | 
| 
       146 
139 
     | 
    
         
             
                def render(context=nil, ignore_layout=false,  reset_context=true, locals={})
         
     | 
    
        data/lib/gumdrop/server.rb
    CHANGED
    
    | 
         @@ -5,6 +5,8 @@ require 'logger' 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            module Gumdrop
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
      
 8 
     | 
    
         
            +
              STATIC_ASSETS= %w(.jpg .jpe .jpeg .gif .ico .png)
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
       8 
10 
     | 
    
         
             
              class Server < Sinatra::Base
         
     | 
| 
       9 
11 
     | 
    
         
             
                site_file= Gumdrop.fetch_site_file
         
     | 
| 
       10 
12 
     | 
    
         
             
                unless site_file.nil?
         
     | 
| 
         @@ -29,11 +31,13 @@ module Gumdrop 
     | 
|
| 
       29 
31 
     | 
    
         | 
| 
       30 
32 
     | 
    
         
             
                    file_path= get_content_path params[:splat].join('/'), site
         
     | 
| 
       31 
33 
     | 
    
         
             
                    site.report "[#{$$}] GET /#{params[:splat].join('/')} -> #{file_path}"
         
     | 
| 
       32 
     | 
    
         
            -
                     
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                       
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
      
 34 
     | 
    
         
            +
                    unless static_asset file_path
         
     | 
| 
      
 35 
     | 
    
         
            +
                      since_last_build= Time.now.to_i - site.last_run.to_i
         
     | 
| 
      
 36 
     | 
    
         
            +
                      # site.report "!>!>>>>> since_last_build: #{since_last_build}"
         
     | 
| 
      
 37 
     | 
    
         
            +
                      if since_last_build > site.config.server_timeout
         
     | 
| 
      
 38 
     | 
    
         
            +
                        site.report "[#{$$}] Rebuilding from Source (#{since_last_build} > #{site.config.server_timeout})"
         
     | 
| 
      
 39 
     | 
    
         
            +
                        site.rescan()
         
     | 
| 
      
 40 
     | 
    
         
            +
                      end
         
     | 
| 
       37 
41 
     | 
    
         
             
                    end
         
     | 
| 
       38 
42 
     | 
    
         | 
| 
       39 
43 
     | 
    
         
             
                    if site.node_tree.has_key? file_path
         
     | 
| 
         @@ -79,6 +83,10 @@ module Gumdrop 
     | 
|
| 
       79 
83 
     | 
    
         
             
                    Gumdrop.handle_proxy opts, proxy_to, env
         
     | 
| 
       80 
84 
     | 
    
         
             
                  end
         
     | 
| 
       81 
85 
     | 
    
         | 
| 
      
 86 
     | 
    
         
            +
                  def static_asset(file_path)
         
     | 
| 
      
 87 
     | 
    
         
            +
                    STATIC_ASSETS.include? File.extname(file_path).to_s
         
     | 
| 
      
 88 
     | 
    
         
            +
                  end
         
     | 
| 
      
 89 
     | 
    
         
            +
                  
         
     | 
| 
       82 
90 
     | 
    
         
             
                  run!
         
     | 
| 
       83 
91 
     | 
    
         
             
                else
         
     | 
| 
       84 
92 
     | 
    
         
             
                  puts "Not in a valid Gumdrop site directory."
         
     | 
    
        data/lib/gumdrop/site.rb
    CHANGED
    
    | 
         @@ -1,7 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'pathname'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            # WORK IN PROGRESS!
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
3 
     | 
    
         
             
            module Gumdrop
         
     | 
| 
       6 
4 
     | 
    
         | 
| 
       7 
5 
     | 
    
         
             
              DEFAULT_OPTIONS= {
         
     | 
| 
         @@ -34,12 +32,20 @@ module Gumdrop 
     | 
|
| 
       34 
32 
     | 
    
         
             
                            :sitefile,
         
     | 
| 
       35 
33 
     | 
    
         
             
                            :node_tree,
         
     | 
| 
       36 
34 
     | 
    
         
             
                            :last_run
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                extend Callbacks
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                callbacks :on_start, 
         
     | 
| 
      
 39 
     | 
    
         
            +
                          :on_scan, 
         
     | 
| 
      
 40 
     | 
    
         
            +
                          :on_generate, 
         
     | 
| 
      
 41 
     | 
    
         
            +
                          :on_render, 
         
     | 
| 
      
 42 
     | 
    
         
            +
                          :on_end
         
     | 
| 
       38 
43 
     | 
    
         | 
| 
       39 
44 
     | 
    
         
             
                def initialize(sitefile, opts={})
         
     | 
| 
       40 
     | 
    
         
            -
                  @sitefile 
     | 
| 
       41 
     | 
    
         
            -
                  @root_path 
     | 
| 
       42 
     | 
    
         
            -
                  @opts 
     | 
| 
      
 45 
     | 
    
         
            +
                  @sitefile  = File.expand_path sitefile
         
     | 
| 
      
 46 
     | 
    
         
            +
                  @root_path = File.dirname @sitefile
         
     | 
| 
      
 47 
     | 
    
         
            +
                  @opts      = opts
         
     | 
| 
      
 48 
     | 
    
         
            +
                  @last_run  = nil
         
     | 
| 
       43 
49 
     | 
    
         
             
                  reset_all()
         
     | 
| 
       44 
50 
     | 
    
         
             
                end
         
     | 
| 
       45 
51 
     | 
    
         | 
| 
         @@ -67,7 +73,9 @@ module Gumdrop 
     | 
|
| 
       67 
73 
     | 
    
         | 
| 
       68 
74 
     | 
    
         
             
                def scan
         
     | 
| 
       69 
75 
     | 
    
         
             
                  build_tree()
         
     | 
| 
      
 76 
     | 
    
         
            +
                  on_scan()
         
     | 
| 
       70 
77 
     | 
    
         
             
                  run_generators()
         
     | 
| 
      
 78 
     | 
    
         
            +
                  on_generate()
         
     | 
| 
       71 
79 
     | 
    
         
             
                  @last_run= Time.now
         
     | 
| 
       72 
80 
     | 
    
         
             
                  self
         
     | 
| 
       73 
81 
     | 
    
         
             
                end
         
     | 
| 
         @@ -80,19 +88,21 @@ module Gumdrop 
     | 
|
| 
       80 
88 
     | 
    
         
             
                end
         
     | 
| 
       81 
89 
     | 
    
         | 
| 
       82 
90 
     | 
    
         
             
                def build
         
     | 
| 
      
 91 
     | 
    
         
            +
                  on_start()
         
     | 
| 
       83 
92 
     | 
    
         
             
                  scan()
         
     | 
| 
       84 
93 
     | 
    
         
             
                  render()
         
     | 
| 
      
 94 
     | 
    
         
            +
                  on_render()
         
     | 
| 
       85 
95 
     | 
    
         
             
                  @last_run= Time.now
         
     | 
| 
      
 96 
     | 
    
         
            +
                  on_end()
         
     | 
| 
       86 
97 
     | 
    
         
             
                  self
         
     | 
| 
       87 
98 
     | 
    
         
             
                end
         
     | 
| 
       88 
99 
     | 
    
         | 
| 
       89 
100 
     | 
    
         
             
                def report(msg, level=:info)
         
     | 
| 
       90 
     | 
    
         
            -
                  # ll= @config.log_level
         
     | 
| 
       91 
101 
     | 
    
         
             
                  case level
         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
      
 102 
     | 
    
         
            +
                    when :info
         
     | 
| 
      
 103 
     | 
    
         
            +
                      @log.info msg
         
     | 
| 
      
 104 
     | 
    
         
            +
                    when :warning
         
     | 
| 
      
 105 
     | 
    
         
            +
                      @log.warn msg
         
     | 
| 
       96 
106 
     | 
    
         
             
                  else
         
     | 
| 
       97 
107 
     | 
    
         
             
                    puts msg
         
     | 
| 
       98 
108 
     | 
    
         
             
                    @log.error msg
         
     | 
| 
         @@ -114,29 +124,30 @@ module Gumdrop 
     | 
|
| 
       114 
124 
     | 
    
         
             
                  @blacklist       = []
         
     | 
| 
       115 
125 
     | 
    
         
             
                  @greylist        = []
         
     | 
| 
       116 
126 
     | 
    
         
             
                  @redirects       = []
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
       118 
128 
     | 
    
         
             
                  @node_tree       = Hash.new {|h,k| h[k]= nil }
         
     | 
| 
       119 
129 
     | 
    
         
             
                  @layouts         = Hash.new {|h,k| h[k]= nil }
         
     | 
| 
       120 
130 
     | 
    
         
             
                  @partials        = Hash.new {|h,k| h[k]= nil }
         
     | 
| 
       121 
131 
     | 
    
         
             
                  @generators      = Hash.new {|h,k| h[k]= nil }
         
     | 
| 
      
 132 
     | 
    
         
            +
                  
         
     | 
| 
       122 
133 
     | 
    
         
             
                  @config          = Gumdrop::Config.new DEFAULT_OPTIONS
         
     | 
| 
       123 
134 
     | 
    
         | 
| 
       124 
135 
     | 
    
         
             
                  load_sitefile()
         
     | 
| 
       125 
136 
     | 
    
         | 
| 
       126 
137 
     | 
    
         
             
                  @data_path       = get_expanded_path(@config.data_dir)
         
     | 
| 
       127 
     | 
    
         
            -
                  @data            = Gumdrop::DataManager.new self, @data_path
         
     | 
| 
       128 
138 
     | 
    
         
             
                  @src_path        = get_expanded_path(@config.source_dir)
         
     | 
| 
       129 
     | 
    
         
            -
                  @src_path_parts  = @src_path.split('/')
         
     | 
| 
       130 
139 
     | 
    
         
             
                  @out_path        = get_expanded_path(@config.output_dir)
         
     | 
| 
       131 
140 
     | 
    
         | 
| 
      
 141 
     | 
    
         
            +
                  @data            = Gumdrop::DataManager.new self, @data_path
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
       132 
143 
     | 
    
         
             
                  init_logging()
         
     | 
| 
       133 
144 
     | 
    
         
             
                end
         
     | 
| 
       134 
145 
     | 
    
         | 
| 
       135 
146 
     | 
    
         
             
                def init_logging
         
     | 
| 
       136 
147 
     | 
    
         
             
                  begin
         
     | 
| 
       137 
     | 
    
         
            -
                    @log 
     | 
| 
      
 148 
     | 
    
         
            +
                    @log = Logger.new @config.log, 'daily'
         
     | 
| 
       138 
149 
     | 
    
         
             
                  rescue
         
     | 
| 
       139 
     | 
    
         
            -
                    @log 
     | 
| 
      
 150 
     | 
    
         
            +
                    @log = Logger.new STDOUT
         
     | 
| 
       140 
151 
     | 
    
         
             
                  end
         
     | 
| 
       141 
152 
     | 
    
         
             
                  @log.formatter = proc do |severity, datetime, progname, msg|
         
     | 
| 
       142 
153 
     | 
    
         
             
                    "#{datetime}: #{msg}\n"
         
     | 
| 
         @@ -152,7 +163,7 @@ module Gumdrop 
     | 
|
| 
       152 
163 
     | 
    
         
             
                end
         
     | 
| 
       153 
164 
     | 
    
         | 
| 
       154 
165 
     | 
    
         
             
                def load_sitefile
         
     | 
| 
       155 
     | 
    
         
            -
                  source=  
     | 
| 
      
 166 
     | 
    
         
            +
                  source= File.read( @sitefile )
         
     | 
| 
       156 
167 
     | 
    
         
             
                  dsl = SitefileDSL.new self
         
     | 
| 
       157 
168 
     | 
    
         
             
                  dsl.instance_eval source
         
     | 
| 
       158 
169 
     | 
    
         
             
                  dsl
         
     | 
| 
         @@ -169,7 +180,6 @@ module Gumdrop 
     | 
|
| 
       169 
180 
     | 
    
         
             
                  end
         
     | 
| 
       170 
181 
     | 
    
         | 
| 
       171 
182 
     | 
    
         
             
                  # Scan Filesystem
         
     | 
| 
       172 
     | 
    
         
            -
                  #puts "Running in: #{root}"
         
     | 
| 
       173 
183 
     | 
    
         
             
                  Dir.glob("#{src_path}/**/*", File::FNM_DOTMATCH).each do |path|
         
     | 
| 
       174 
184 
     | 
    
         
             
                    unless File.directory? path or @config.ignore.include?( File.basename(path) )
         
     | 
| 
       175 
185 
     | 
    
         
             
                      node= Content.new(path, self)
         
     | 
| 
         @@ -192,6 +202,7 @@ module Gumdrop 
     | 
|
| 
       192 
202 
     | 
    
         
             
                          # puts "Creating partial #{partial_name} from #{path}"
         
     | 
| 
       193 
203 
     | 
    
         
             
                          partials[partial_name]= node
         
     | 
| 
       194 
204 
     | 
    
         
             
                          partials[partial_node_path]= node
         
     | 
| 
      
 205 
     | 
    
         
            +
                        
         
     | 
| 
       195 
206 
     | 
    
         
             
                        else
         
     | 
| 
       196 
207 
     | 
    
         
             
                          @node_tree[path]= node
         
     | 
| 
       197 
208 
     | 
    
         
             
                        end
         
     | 
| 
         @@ -212,8 +223,7 @@ module Gumdrop 
     | 
|
| 
       212 
223 
     | 
    
         
             
                    report "[Compiling to #{@out_path}]", :info
         
     | 
| 
       213 
224 
     | 
    
         
             
                    @node_tree.keys.sort.each do |path|
         
     | 
| 
       214 
225 
     | 
    
         
             
                      node= @node_tree[path]
         
     | 
| 
       215 
     | 
    
         
            -
                      unless node.ignored  
     | 
| 
       216 
     | 
    
         
            -
                        # node= @node_tree[path]
         
     | 
| 
      
 226 
     | 
    
         
            +
                      unless node.ignored 
         
     | 
| 
       217 
227 
     | 
    
         
             
                        output_path= File.join(@out_path, node.to_s)
         
     | 
| 
       218 
228 
     | 
    
         
             
                        FileUtils.mkdir_p File.dirname(output_path)
         
     | 
| 
       219 
229 
     | 
    
         
             
                        node.renderTo render_context, output_path, content_filters
         
     | 
| 
         @@ -267,6 +277,23 @@ module Gumdrop 
     | 
|
| 
       267 
277 
     | 
    
         
             
                    @site.config.instance_eval &block
         
     | 
| 
       268 
278 
     | 
    
         
             
                  end
         
     | 
| 
       269 
279 
     | 
    
         
             
                end
         
     | 
| 
      
 280 
     | 
    
         
            +
                
         
     | 
| 
      
 281 
     | 
    
         
            +
                # Callbacks
         
     | 
| 
      
 282 
     | 
    
         
            +
                def on_start(&block)
         
     | 
| 
      
 283 
     | 
    
         
            +
                  @site.on_start &block
         
     | 
| 
      
 284 
     | 
    
         
            +
                end
         
     | 
| 
      
 285 
     | 
    
         
            +
                def on_scan(&block)
         
     | 
| 
      
 286 
     | 
    
         
            +
                  @site.on_scan &block
         
     | 
| 
      
 287 
     | 
    
         
            +
                end
         
     | 
| 
      
 288 
     | 
    
         
            +
                def on_generate(&block)
         
     | 
| 
      
 289 
     | 
    
         
            +
                  @site.on_generate &block
         
     | 
| 
      
 290 
     | 
    
         
            +
                end
         
     | 
| 
      
 291 
     | 
    
         
            +
                def on_render(&block)
         
     | 
| 
      
 292 
     | 
    
         
            +
                  @site.on_render &block
         
     | 
| 
      
 293 
     | 
    
         
            +
                end
         
     | 
| 
      
 294 
     | 
    
         
            +
                def on_end(&block)
         
     | 
| 
      
 295 
     | 
    
         
            +
                  @site.on_end &block
         
     | 
| 
      
 296 
     | 
    
         
            +
                end
         
     | 
| 
       270 
297 
     | 
    
         | 
| 
       271 
298 
     | 
    
         
             
              end
         
     | 
| 
       272 
299 
     | 
    
         | 
    
        data/lib/gumdrop/version.rb
    CHANGED
    
    
    
        data/lib/gumdrop.rb
    CHANGED
    
    | 
         @@ -6,6 +6,7 @@ require 'active_support/all' 
     | 
|
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            module Gumdrop
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
      
 9 
     | 
    
         
            +
              autoload :Callbacks, "gumdrop/callbacks"
         
     | 
| 
       9 
10 
     | 
    
         
             
              autoload :Context, "gumdrop/context"
         
     | 
| 
       10 
11 
     | 
    
         
             
              autoload :Content, "gumdrop/content"
         
     | 
| 
       11 
12 
     | 
    
         
             
              autoload :DataManager, "gumdrop/data_manager"
         
     | 
| 
         @@ -13,7 +14,6 @@ module Gumdrop 
     | 
|
| 
       13 
14 
     | 
    
         
             
              autoload :HashObject, "gumdrop/hash_object"
         
     | 
| 
       14 
15 
     | 
    
         
             
              autoload :Pager, "gumdrop/data_manager"
         
     | 
| 
       15 
16 
     | 
    
         
             
              autoload :Server, "gumdrop/server"
         
     | 
| 
       16 
     | 
    
         
            -
              # autoload :Site, "gumdrop/site"
         
     | 
| 
       17 
17 
     | 
    
         
             
              autoload :VERSION, "gumdrop/version"
         
     | 
| 
       18 
18 
     | 
    
         
             
              autoload :ViewHelpers, "gumdrop/view_helpers"
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
         @@ -30,7 +30,7 @@ module Gumdrop 
     | 
|
| 
       30 
30 
     | 
    
         
             
                    site.build
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
       32 
32 
     | 
    
         
             
                    Dir.chdir old
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
       34 
34 
     | 
    
         
             
                    puts "Done."
         
     | 
| 
       35 
35 
     | 
    
         
             
                  else
         
     | 
| 
       36 
36 
     | 
    
         
             
                    puts "Not in a valid Gumdrop site directory."
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version 
     | 
|
| 
       5 
5 
     | 
    
         
             
              segments: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              - 0
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 6
         
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
       9 
     | 
    
         
            -
              version: 0.6. 
     | 
| 
      
 8 
     | 
    
         
            +
              - 3
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.6.3
         
     | 
| 
       10 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       11 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       12 
12 
     | 
    
         
             
            - Matt McCray
         
     | 
| 
         @@ -113,6 +113,7 @@ files: 
     | 
|
| 
       113 
113 
     | 
    
         
             
            - bin/gumdrop
         
     | 
| 
       114 
114 
     | 
    
         
             
            - gumdrop.gemspec
         
     | 
| 
       115 
115 
     | 
    
         
             
            - lib/gumdrop.rb
         
     | 
| 
      
 116 
     | 
    
         
            +
            - lib/gumdrop/callbacks.rb
         
     | 
| 
       116 
117 
     | 
    
         
             
            - lib/gumdrop/cli.rb
         
     | 
| 
       117 
118 
     | 
    
         
             
            - lib/gumdrop/content.rb
         
     | 
| 
       118 
119 
     | 
    
         
             
            - lib/gumdrop/context.rb
         
     |