dimples 9.0.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/bin/dimples +12 -13
 - data/lib/dimples/config.rb +33 -0
 - data/lib/dimples/metadata.rb +36 -0
 - data/lib/dimples/pager.rb +34 -16
 - data/lib/dimples/site.rb +55 -123
 - data/lib/dimples/sources/base.rb +75 -0
 - data/lib/dimples/sources/layout.rb +12 -0
 - data/lib/dimples/sources/page.rb +31 -0
 - data/lib/dimples/sources/post.rb +30 -0
 - data/lib/dimples/version.rb +1 -1
 - data/lib/dimples.rb +9 -5
 - metadata +21 -76
 - data/lib/dimples/document.rb +0 -69
 - data/lib/dimples/errors.rb +0 -12
 - data/lib/dimples/frontmatter.rb +0 -20
 - data/lib/dimples/page.rb +0 -8
 - data/lib/dimples/post.rb +0 -21
 - data/lib/dimples/template.rb +0 -8
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: fcf53e67d092ae60028fef082c0741343badb88483bc2d1c6b19fea30d0a5aca
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: bb884858e735d7e1c23c91a17c7f99ab8f4cddffa6b871530b85194147ac7fd4
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8735afa42f1a1c921764bcc5a80babfa3620662c55beddd13f8825e19807bec00c5e1de835ff121221423b1c9dd04615456078461ba1be1ac28c85545b42af09
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a0ee67d073361ad66fbfa49f545b39b9753571d053b3d4cbab1fbbb54a0799a46cb53569c03dd6c3bbcc506b501ba758a40554fcc4a1fecf4a1118c709a225f5
         
     | 
    
        data/bin/dimples
    CHANGED
    
    | 
         @@ -1,27 +1,26 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #!/usr/bin/env ruby
         
     | 
| 
       2 
2 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
            $LOAD_PATH.unshift(File.join(__dir__,  
     | 
| 
      
 4 
     | 
    
         
            +
            $LOAD_PATH.unshift(File.join(__dir__, '..', 'lib'))
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            require  
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            source_path = ARGV[0]
         
     | 
| 
       9 
     | 
    
         
            -
            output_path = ARGV[1]
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            config_path = File.join(Dir.pwd, "config.yml")
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'dimples'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'yaml'
         
     | 
| 
       12 
8 
     | 
    
         | 
| 
      
 9 
     | 
    
         
            +
            config_path = File.join(Dir.pwd, 'config.yml')
         
     | 
| 
       13 
10 
     | 
    
         
             
            config = {}
         
     | 
| 
       14 
11 
     | 
    
         | 
| 
       15 
12 
     | 
    
         
             
            if File.exist?(config_path)
         
     | 
| 
       16 
     | 
    
         
            -
              begin
         
     | 
| 
       17 
     | 
    
         
            -
                 
     | 
| 
      
 13 
     | 
    
         
            +
              config = begin
         
     | 
| 
      
 14 
     | 
    
         
            +
                YAML.safe_load_file(config_path, symbolize_names: true)
         
     | 
| 
       18 
15 
     | 
    
         
             
              rescue YAML::Error
         
     | 
| 
       19 
     | 
    
         
            -
                puts  
     | 
| 
      
 16 
     | 
    
         
            +
                puts 'Failed to parse config - using defaults'
         
     | 
| 
      
 17 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 18 
     | 
    
         
            +
                {}
         
     | 
| 
       20 
19 
     | 
    
         
             
              end
         
     | 
| 
       21 
20 
     | 
    
         
             
            end
         
     | 
| 
       22 
21 
     | 
    
         | 
| 
       23 
22 
     | 
    
         
             
            begin
         
     | 
| 
       24 
     | 
    
         
            -
              Dimples::Site.generate( 
     | 
| 
       25 
     | 
    
         
            -
            rescue  
     | 
| 
       26 
     | 
    
         
            -
              puts "Error: #{ 
     | 
| 
      
 23 
     | 
    
         
            +
              Dimples::Site.generate(config)
         
     | 
| 
      
 24 
     | 
    
         
            +
            rescue StandardError => e
         
     | 
| 
      
 25 
     | 
    
         
            +
              puts "Error generating site: #{e}"
         
     | 
| 
       27 
26 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,33 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Dimples
         
     | 
| 
      
 4 
     | 
    
         
            +
              # Configuration settings for a site.
         
     | 
| 
      
 5 
     | 
    
         
            +
              class Config
         
     | 
| 
      
 6 
     | 
    
         
            +
                def self.defaults
         
     | 
| 
      
 7 
     | 
    
         
            +
                  {
         
     | 
| 
      
 8 
     | 
    
         
            +
                    sources: { root: '.', posts: './posts', pages: './pages', layouts: './layouts', static: './static' },
         
     | 
| 
      
 9 
     | 
    
         
            +
                    output: { root: './site', posts: './site/posts', categories: './site/categories' }
         
     | 
| 
      
 10 
     | 
    
         
            +
                  }
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                def initialize(options = {})
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @options = Config.defaults
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  options&.each do |key, value|
         
     | 
| 
      
 17 
     | 
    
         
            +
                    @options[key]&.merge!(value)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  %i[sources output].each do |type|
         
     | 
| 
      
 21 
     | 
    
         
            +
                    @options[type].each { |key, value| @options[type][key] = File.expand_path(value) }
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                def dig(*args)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  @options.dig(*args)
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                def [](key)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  @options[key]
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Dimples
         
     | 
| 
      
 4 
     | 
    
         
            +
              # A class representing metadata passed into a template for rendering.
         
     | 
| 
      
 5 
     | 
    
         
            +
              class Metadata
         
     | 
| 
      
 6 
     | 
    
         
            +
                attr_reader :keys
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                def initialize(source)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  source.each do |key, value|
         
     | 
| 
      
 10 
     | 
    
         
            +
                    self.class.send(:attr_reader, key)
         
     | 
| 
      
 11 
     | 
    
         
            +
                    instance_variable_set("@#{key}", build(value))
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  @keys = source.keys
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def build(item)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  case item
         
     | 
| 
      
 19 
     | 
    
         
            +
                  when Array
         
     | 
| 
      
 20 
     | 
    
         
            +
                    item.map { |i| build(i) }
         
     | 
| 
      
 21 
     | 
    
         
            +
                  when Hash
         
     | 
| 
      
 22 
     | 
    
         
            +
                    item.empty? ? item : Metadata.new(item)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  else
         
     | 
| 
      
 24 
     | 
    
         
            +
                    item
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                def method_missing(_method_name, *_args)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  nil
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                def respond_to_missing?(_method_name, _include_private)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  true
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/dimples/pager.rb
    CHANGED
    
    | 
         @@ -1,6 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module Dimples
         
     | 
| 
      
 4 
     | 
    
         
            +
              # A class for paginating a collection of posts.
         
     | 
| 
       4 
5 
     | 
    
         
             
              class Pager
         
     | 
| 
       5 
6 
     | 
    
         
             
                PER_PAGE = 5
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
         @@ -8,18 +9,31 @@ module Dimples 
     | 
|
| 
       8 
9 
     | 
    
         | 
| 
       9 
10 
     | 
    
         
             
                attr_reader :current_page, :previous_page, :next_page, :page_count
         
     | 
| 
       10 
11 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
                def  
     | 
| 
      
 12 
     | 
    
         
            +
                def self.paginate(site, url, posts, metadata = {})
         
     | 
| 
      
 13 
     | 
    
         
            +
                  new(site, url, posts).paginate(metadata)
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                def initialize(site, url, posts)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @site = site
         
     | 
| 
       12 
18 
     | 
    
         
             
                  @url = url
         
     | 
| 
       13 
19 
     | 
    
         
             
                  @posts = posts
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                  @ 
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  @per_page = @site.config.dig(:pagination, :per_page) || PER_PAGE
         
     | 
| 
      
 22 
     | 
    
         
            +
                  @page_prefix = @site.config.dig(:pagination, :page_prefix) || 'page_'
         
     | 
| 
       16 
23 
     | 
    
         
             
                  @page_count = (posts.length.to_f / @per_page.to_i).ceil
         
     | 
| 
       17 
24 
     | 
    
         | 
| 
       18 
25 
     | 
    
         
             
                  step_to(1)
         
     | 
| 
       19 
26 
     | 
    
         
             
                end
         
     | 
| 
       20 
27 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                def  
     | 
| 
       22 
     | 
    
         
            -
                  (1..@page_count).each  
     | 
| 
      
 28 
     | 
    
         
            +
                def paginate(metadata)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  (1..@page_count).each do |index|
         
     | 
| 
      
 30 
     | 
    
         
            +
                    step_to(index)
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                    @site.layouts['posts']&.write(
         
     | 
| 
      
 33 
     | 
    
         
            +
                      File.join(@site.config[:output][:root], current_page_url, 'index.html'),
         
     | 
| 
      
 34 
     | 
    
         
            +
                      metadata.merge(pagination: self.metadata, url: current_page_url)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    )
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
       23 
37 
     | 
    
         
             
                end
         
     | 
| 
       24 
38 
     | 
    
         | 
| 
       25 
39 
     | 
    
         
             
                def step_to(page)
         
     | 
| 
         @@ -43,7 +57,7 @@ module Dimples 
     | 
|
| 
       43 
57 
     | 
    
         
             
                end
         
     | 
| 
       44 
58 
     | 
    
         | 
| 
       45 
59 
     | 
    
         
             
                def current_page_url
         
     | 
| 
       46 
     | 
    
         
            -
                   
     | 
| 
      
 60 
     | 
    
         
            +
                  @current_page == 1 ? @url : "#{@url}#{@page_prefix}#{@current_page}"
         
     | 
| 
       47 
61 
     | 
    
         
             
                end
         
     | 
| 
       48 
62 
     | 
    
         | 
| 
       49 
63 
     | 
    
         
             
                def first_page_url
         
     | 
| 
         @@ -51,20 +65,30 @@ module Dimples 
     | 
|
| 
       51 
65 
     | 
    
         
             
                end
         
     | 
| 
       52 
66 
     | 
    
         | 
| 
       53 
67 
     | 
    
         
             
                def last_page_url
         
     | 
| 
       54 
     | 
    
         
            -
                   
     | 
| 
      
 68 
     | 
    
         
            +
                  @page_count == 1 ? @url : "#{@url}#{@page_prefix}#{@page_count}"
         
     | 
| 
       55 
69 
     | 
    
         
             
                end
         
     | 
| 
       56 
70 
     | 
    
         | 
| 
       57 
71 
     | 
    
         
             
                def previous_page_url
         
     | 
| 
       58 
72 
     | 
    
         
             
                  return unless @previous_page
         
     | 
| 
       59 
73 
     | 
    
         | 
| 
       60 
     | 
    
         
            -
                   
     | 
| 
      
 74 
     | 
    
         
            +
                  @previous_page == 1 ? @url : "#{@url}#{@page_prefix}#{@previous_page}"
         
     | 
| 
       61 
75 
     | 
    
         
             
                end
         
     | 
| 
       62 
76 
     | 
    
         | 
| 
       63 
77 
     | 
    
         
             
                def next_page_url
         
     | 
| 
       64 
78 
     | 
    
         
             
                  "#{@url}#{@page_prefix}#{@next_page}" if @next_page
         
     | 
| 
       65 
79 
     | 
    
         
             
                end
         
     | 
| 
       66 
80 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
                def  
     | 
| 
      
 81 
     | 
    
         
            +
                def urls
         
     | 
| 
      
 82 
     | 
    
         
            +
                  {
         
     | 
| 
      
 83 
     | 
    
         
            +
                    current_page: current_page_url,
         
     | 
| 
      
 84 
     | 
    
         
            +
                    first_page: first_page_url,
         
     | 
| 
      
 85 
     | 
    
         
            +
                    last_page: last_page_url,
         
     | 
| 
      
 86 
     | 
    
         
            +
                    previous_page: previous_page_url,
         
     | 
| 
      
 87 
     | 
    
         
            +
                    next_page: next_page_url
         
     | 
| 
      
 88 
     | 
    
         
            +
                  }
         
     | 
| 
      
 89 
     | 
    
         
            +
                end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                def metadata
         
     | 
| 
       68 
92 
     | 
    
         
             
                  {
         
     | 
| 
       69 
93 
     | 
    
         
             
                    posts: posts_at(current_page),
         
     | 
| 
       70 
94 
     | 
    
         
             
                    current_page: @current_page,
         
     | 
| 
         @@ -72,13 +96,7 @@ module Dimples 
     | 
|
| 
       72 
96 
     | 
    
         
             
                    post_count: @posts.count,
         
     | 
| 
       73 
97 
     | 
    
         
             
                    previous_page: @previous_page,
         
     | 
| 
       74 
98 
     | 
    
         
             
                    next_page: @next_page,
         
     | 
| 
       75 
     | 
    
         
            -
                    urls:  
     | 
| 
       76 
     | 
    
         
            -
                      current_page: current_page_url,
         
     | 
| 
       77 
     | 
    
         
            -
                      first_page: first_page_url,
         
     | 
| 
       78 
     | 
    
         
            -
                      last_page: last_page_url,
         
     | 
| 
       79 
     | 
    
         
            -
                      previous_page: previous_page_url,
         
     | 
| 
       80 
     | 
    
         
            -
                      next_page: next_page_url
         
     | 
| 
       81 
     | 
    
         
            -
                    }
         
     | 
| 
      
 99 
     | 
    
         
            +
                    urls: urls
         
     | 
| 
       82 
100 
     | 
    
         
             
                  }
         
     | 
| 
       83 
101 
     | 
    
         
             
                end
         
     | 
| 
       84 
102 
     | 
    
         
             
              end
         
     | 
    
        data/lib/dimples/site.rb
    CHANGED
    
    | 
         @@ -1,173 +1,105 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            require  
     | 
| 
       6 
     | 
    
         
            -
            require  
     | 
| 
       7 
     | 
    
         
            -
            require "date"
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'fileutils'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'tilt'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'date'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'yaml'
         
     | 
| 
       8 
7 
     | 
    
         | 
| 
       9 
8 
     | 
    
         
             
            module Dimples
         
     | 
| 
      
 9 
     | 
    
         
            +
              # A class representing a single generated website.
         
     | 
| 
       10 
10 
     | 
    
         
             
              class Site
         
     | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
      
 11 
     | 
    
         
            +
                attr_accessor :config
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                def self.generate( 
     | 
| 
       14 
     | 
    
         
            -
                  new( 
     | 
| 
      
 13 
     | 
    
         
            +
                def self.generate(config = {})
         
     | 
| 
      
 14 
     | 
    
         
            +
                  new(config).generate
         
     | 
| 
       15 
15 
     | 
    
         
             
                end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
                 
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                def initialize(source_path, output_path, config)
         
     | 
| 
       20 
     | 
    
         
            -
                  @paths = {
         
     | 
| 
       21 
     | 
    
         
            -
                    source: File.expand_path(source_path || Dir.pwd),
         
     | 
| 
       22 
     | 
    
         
            -
                    destination: File.expand_path(output_path || File.join(Dir.pwd, "site"))
         
     | 
| 
       23 
     | 
    
         
            -
                  }
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                  @config = DEFAULT_CONFIG
         
     | 
| 
       26 
     | 
    
         
            -
                  @config.merge!(config) if config&.is_a?(Hash)
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                  %w[pages posts static templates].each do |type|
         
     | 
| 
       29 
     | 
    
         
            -
                    @paths[type.to_sym] = File.join(@paths[:source], type)
         
     | 
| 
       30 
     | 
    
         
            -
                  end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                  scan_posts
         
     | 
| 
       33 
     | 
    
         
            -
                  scan_pages
         
     | 
| 
       34 
     | 
    
         
            -
                  scan_templates
         
     | 
| 
      
 17 
     | 
    
         
            +
                def initialize(config = {})
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @config = Config.new(config)
         
     | 
| 
       35 
19 
     | 
    
         
             
                end
         
     | 
| 
       36 
20 
     | 
    
         | 
| 
       37 
21 
     | 
    
         
             
                def generate
         
     | 
| 
       38 
     | 
    
         
            -
                   
     | 
| 
       39 
     | 
    
         
            -
                    unless @config.dig(:generation, :overwrite_directory)
         
     | 
| 
       40 
     | 
    
         
            -
                      raise GenerationError.new("The site directory (#{@paths[:destination]}) already exists.")
         
     | 
| 
       41 
     | 
    
         
            -
                    end
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                    FileUtils.rm_rf(@paths[:destination])
         
     | 
| 
       44 
     | 
    
         
            -
                  end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                  Dir.mkdir(@paths[:destination])
         
     | 
| 
      
 22 
     | 
    
         
            +
                  prepare_output_directory
         
     | 
| 
       47 
23 
     | 
    
         | 
| 
       48 
24 
     | 
    
         
             
                  generate_posts
         
     | 
| 
       49 
     | 
    
         
            -
                  generate_pages
         
     | 
| 
       50 
25 
     | 
    
         
             
                  generate_categories
         
     | 
| 
      
 26 
     | 
    
         
            +
                  generate_pages
         
     | 
| 
       51 
27 
     | 
    
         | 
| 
       52 
28 
     | 
    
         
             
                  copy_assets
         
     | 
| 
       53 
29 
     | 
    
         
             
                end
         
     | 
| 
       54 
30 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
                 
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                   
     | 
| 
      
 31 
     | 
    
         
            +
                def posts
         
     | 
| 
      
 32 
     | 
    
         
            +
                  @posts ||= Dir.glob(File.join(@config[:sources][:posts], '**', '*.markdown')).map do |path|
         
     | 
| 
      
 33 
     | 
    
         
            +
                    Dimples::Sources::Post.new(self, path)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end.sort_by!(&:date).reverse!
         
     | 
| 
       59 
35 
     | 
    
         
             
                end
         
     | 
| 
       60 
36 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
                def  
     | 
| 
       62 
     | 
    
         
            -
                  @ 
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                  @categories = {}
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
                  @posts.each do |post|
         
     | 
| 
       68 
     | 
    
         
            -
                    post.categories&.each do |category|
         
     | 
| 
       69 
     | 
    
         
            -
                      @categories[category] ||= []
         
     | 
| 
       70 
     | 
    
         
            -
                      @categories[category] << post
         
     | 
| 
       71 
     | 
    
         
            -
                    end
         
     | 
| 
      
 37 
     | 
    
         
            +
                def pages
         
     | 
| 
      
 38 
     | 
    
         
            +
                  @pages ||= Dir.glob(File.join(@config[:sources][:pages], '**', '*.erb')).map do |path|
         
     | 
| 
      
 39 
     | 
    
         
            +
                    Dimples::Sources::Page.new(self, path)
         
     | 
| 
       72 
40 
     | 
    
         
             
                  end
         
     | 
| 
       73 
41 
     | 
    
         
             
                end
         
     | 
| 
       74 
42 
     | 
    
         | 
| 
       75 
     | 
    
         
            -
                def  
     | 
| 
       76 
     | 
    
         
            -
                  @ 
     | 
| 
      
 43 
     | 
    
         
            +
                def layouts
         
     | 
| 
      
 44 
     | 
    
         
            +
                  @layouts ||= Dir.glob(File.join(@config[:sources][:layouts], '**', '*.erb')).to_h do |path|
         
     | 
| 
      
 45 
     | 
    
         
            +
                    [File.basename(path, '.erb'), Dimples::Sources::Layout.new(self, path)]
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
       77 
47 
     | 
    
         
             
                end
         
     | 
| 
       78 
48 
     | 
    
         | 
| 
       79 
     | 
    
         
            -
                def  
     | 
| 
       80 
     | 
    
         
            -
                  @ 
     | 
| 
       81 
     | 
    
         
            -
                     
     | 
| 
       82 
     | 
    
         
            -
                       
     | 
| 
       83 
     | 
    
         
            -
                         
     | 
| 
       84 
     | 
    
         
            -
                         
     | 
| 
      
 49 
     | 
    
         
            +
                def categories
         
     | 
| 
      
 50 
     | 
    
         
            +
                  @categories ||= {}.tap do |categories|
         
     | 
| 
      
 51 
     | 
    
         
            +
                    posts.each do |post|
         
     | 
| 
      
 52 
     | 
    
         
            +
                      post.categories.each do |category|
         
     | 
| 
      
 53 
     | 
    
         
            +
                        categories[category] ||= []
         
     | 
| 
      
 54 
     | 
    
         
            +
                        categories[category].append(post)
         
     | 
| 
       85 
55 
     | 
    
         
             
                      end
         
     | 
| 
       86 
56 
     | 
    
         
             
                    end
         
     | 
| 
       87 
     | 
    
         
            -
                end
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
                def write_file(path, content)
         
     | 
| 
       90 
     | 
    
         
            -
                  directory_path = File.dirname(path)
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
                  Dir.mkdir(directory_path) unless Dir.exist?(directory_path)
         
     | 
| 
       93 
     | 
    
         
            -
                  File.write(path, content)
         
     | 
| 
       94 
     | 
    
         
            -
                end
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
                def generate_paginated_posts(posts, path, context = {})
         
     | 
| 
       97 
     | 
    
         
            -
                  pager = Dimples::Pager.new("#{path.sub(@paths[:destination], "")}/", posts)
         
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
                  pager.each do |index|
         
     | 
| 
       100 
     | 
    
         
            -
                    page = Dimples::Page.new(nil, layout: "posts")
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
                    page_path =
         
     | 
| 
       103 
     | 
    
         
            -
                      if index == 1
         
     | 
| 
       104 
     | 
    
         
            -
                        path
         
     | 
| 
       105 
     | 
    
         
            -
                      else
         
     | 
| 
       106 
     | 
    
         
            -
                        File.join(path, "page_#{index}")
         
     | 
| 
       107 
     | 
    
         
            -
                      end
         
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
                    write_file(
         
     | 
| 
       110 
     | 
    
         
            -
                      File.join(page_path, page.filename),
         
     | 
| 
       111 
     | 
    
         
            -
                      render(page, context.merge!(pagination: pager.to_context))
         
     | 
| 
       112 
     | 
    
         
            -
                    )
         
     | 
| 
       113 
57 
     | 
    
         
             
                  end
         
     | 
| 
       114 
58 
     | 
    
         
             
                end
         
     | 
| 
       115 
59 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
                def  
     | 
| 
       117 
     | 
    
         
            -
                   
     | 
| 
       118 
     | 
    
         
            -
                  Dir.mkdir(directory_path)
         
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
                  @posts.each do |post|
         
     | 
| 
       121 
     | 
    
         
            -
                    path = File.join(directory_path, post.slug, post.filename)
         
     | 
| 
       122 
     | 
    
         
            -
                    write_file(path, render(post, post: post))
         
     | 
| 
       123 
     | 
    
         
            -
                  end
         
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
                  generate_paginated_posts(@posts, directory_path)
         
     | 
| 
       126 
     | 
    
         
            -
                  generate_feed(@posts.slice(0, 10), @paths[:destination])
         
     | 
| 
      
 60 
     | 
    
         
            +
                def metadata
         
     | 
| 
      
 61 
     | 
    
         
            +
                  @metadata ||= Metadata.new(posts: posts, categories: categories)
         
     | 
| 
       127 
62 
     | 
    
         
             
                end
         
     | 
| 
       128 
63 
     | 
    
         | 
| 
       129 
     | 
    
         
            -
                 
     | 
| 
       130 
     | 
    
         
            -
                  @pages.each do |page|
         
     | 
| 
       131 
     | 
    
         
            -
                    path =
         
     | 
| 
       132 
     | 
    
         
            -
                      if page.path
         
     | 
| 
       133 
     | 
    
         
            -
                        File.dirname(page.path).sub(@paths[:pages], @paths[:destination])
         
     | 
| 
       134 
     | 
    
         
            -
                      else
         
     | 
| 
       135 
     | 
    
         
            -
                        @paths[:destination]
         
     | 
| 
       136 
     | 
    
         
            -
                      end
         
     | 
| 
      
 64 
     | 
    
         
            +
                private
         
     | 
| 
       137 
65 
     | 
    
         | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
                   
     | 
| 
      
 66 
     | 
    
         
            +
                def generate_posts
         
     | 
| 
      
 67 
     | 
    
         
            +
                  posts.each(&:write)
         
     | 
| 
      
 68 
     | 
    
         
            +
                  Pager.paginate(self, @config[:output][:posts].gsub(@config[:output][:root], '').concat('/'), posts)
         
     | 
| 
      
 69 
     | 
    
         
            +
                  generate_feed(@config[:output][:root], posts)
         
     | 
| 
       140 
70 
     | 
    
         
             
                end
         
     | 
| 
       141 
71 
     | 
    
         | 
| 
       142 
72 
     | 
    
         
             
                def generate_categories
         
     | 
| 
       143 
     | 
    
         
            -
                   
     | 
| 
       144 
     | 
    
         
            -
                     
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
       146 
     | 
    
         
            -
                     
     | 
| 
       147 
     | 
    
         
            -
                    generate_feed(posts.slice(0, 10), category_path)
         
     | 
| 
      
 73 
     | 
    
         
            +
                  categories.each do |category, posts|
         
     | 
| 
      
 74 
     | 
    
         
            +
                    metadata = { title: category.capitalize, category: category }
         
     | 
| 
      
 75 
     | 
    
         
            +
                    Pager.paginate(self, "/categories/#{category}/", posts, metadata)
         
     | 
| 
      
 76 
     | 
    
         
            +
                    generate_feed(File.join(@config[:output][:root], 'categories', category), posts)
         
     | 
| 
       148 
77 
     | 
    
         
             
                  end
         
     | 
| 
       149 
78 
     | 
    
         
             
                end
         
     | 
| 
       150 
79 
     | 
    
         | 
| 
       151 
     | 
    
         
            -
                def  
     | 
| 
       152 
     | 
    
         
            -
                   
     | 
| 
       153 
     | 
    
         
            -
                  write_file(File.join(path, "feed.atom"), render(page, posts: posts))
         
     | 
| 
      
 80 
     | 
    
         
            +
                def generate_pages
         
     | 
| 
      
 81 
     | 
    
         
            +
                  pages.each(&:write)
         
     | 
| 
       154 
82 
     | 
    
         
             
                end
         
     | 
| 
       155 
83 
     | 
    
         | 
| 
       156 
     | 
    
         
            -
                def  
     | 
| 
       157 
     | 
    
         
            -
                  return  
     | 
| 
      
 84 
     | 
    
         
            +
                def generate_feed(output_path, posts)
         
     | 
| 
      
 85 
     | 
    
         
            +
                  return if layouts['feed'].nil?
         
     | 
| 
       158 
86 
     | 
    
         | 
| 
       159 
     | 
    
         
            -
                   
     | 
| 
      
 87 
     | 
    
         
            +
                  layouts['feed'].write(
         
     | 
| 
      
 88 
     | 
    
         
            +
                    File.join(output_path, 'feed.atom'),
         
     | 
| 
      
 89 
     | 
    
         
            +
                    posts: posts.slice(0, 10)
         
     | 
| 
      
 90 
     | 
    
         
            +
                  )
         
     | 
| 
       160 
91 
     | 
    
         
             
                end
         
     | 
| 
       161 
92 
     | 
    
         | 
| 
       162 
     | 
    
         
            -
                def  
     | 
| 
       163 
     | 
    
         
            -
                   
     | 
| 
      
 93 
     | 
    
         
            +
                def prepare_output_directory
         
     | 
| 
      
 94 
     | 
    
         
            +
                  raise "The site directory (#{@config[:output][:root]}) already exists." if Dir.exist?(@config[:output][:root])
         
     | 
| 
       164 
95 
     | 
    
         | 
| 
       165 
     | 
    
         
            -
                   
     | 
| 
      
 96 
     | 
    
         
            +
                  Dir.mkdir(@config[:output][:root])
         
     | 
| 
      
 97 
     | 
    
         
            +
                end
         
     | 
| 
       166 
98 
     | 
    
         | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
      
 99 
     | 
    
         
            +
                def copy_assets
         
     | 
| 
      
 100 
     | 
    
         
            +
                  return unless Dir.exist?(@config[:sources][:static])
         
     | 
| 
       169 
101 
     | 
    
         | 
| 
       170 
     | 
    
         
            -
                  output
         
     | 
| 
      
 102 
     | 
    
         
            +
                  FileUtils.cp_r(File.join(@config[:sources][:static], '.'), @config[:output][:root])
         
     | 
| 
       171 
103 
     | 
    
         
             
                end
         
     | 
| 
       172 
104 
     | 
    
         
             
              end
         
     | 
| 
       173 
105 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,75 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Dimples
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Sources
         
     | 
| 
      
 5 
     | 
    
         
            +
                # A base class representing a source file with frontmatter metadata that can be rendered.
         
     | 
| 
      
 6 
     | 
    
         
            +
                class Base
         
     | 
| 
      
 7 
     | 
    
         
            +
                  FRONT_MATTER_PATTERN = /^(-{3}\n.*?\n?)^(-{3}*$\n?)/m
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  attr_accessor :path, :metadata, :contents
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  def initialize(site, path)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    @site = site
         
     | 
| 
      
 13 
     | 
    
         
            +
                    @path = File.expand_path(path)
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                    @metadata = default_metadata
         
     | 
| 
      
 16 
     | 
    
         
            +
                    @contents = File.read(@path)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                    parse_metadata(@contents)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  def parse_metadata(contents)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    matches = contents.match(FRONT_MATTER_PATTERN)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    return unless matches
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    @metadata.merge!(YAML.safe_load(matches[1], symbolize_names: true, permitted_classes: [Date]))
         
     | 
| 
      
 26 
     | 
    
         
            +
                    @contents = matches.post_match.strip
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                    @metadata.each_key do |key|
         
     | 
| 
      
 29 
     | 
    
         
            +
                      self.class.send(:define_method, key.to_sym) { @metadata[key] }
         
     | 
| 
      
 30 
     | 
    
         
            +
                    end
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                  def write(output_path = nil, metadata = {})
         
     | 
| 
      
 34 
     | 
    
         
            +
                    output = render(metadata)
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    output_path = File.join(output_directory, filename) if output_path.nil?
         
     | 
| 
      
 37 
     | 
    
         
            +
                    output_dir = File.dirname(output_path)
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    FileUtils.mkdir_p(output_dir) unless File.directory?(output_dir)
         
     | 
| 
      
 40 
     | 
    
         
            +
                    File.write(output_path, output)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                  def render(render_metadata = {}, body = nil)
         
     | 
| 
      
 44 
     | 
    
         
            +
                    render_metadata[:site] ||= @site.metadata
         
     | 
| 
      
 45 
     | 
    
         
            +
                    render_metadata[:page] ||= metadata
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                    output = template.render(Metadata.new(render_metadata)) { body }
         
     | 
| 
      
 48 
     | 
    
         
            +
                    return output unless @metadata[:layout] && @site.layouts[@metadata[:layout]]
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                    @site.layouts[@metadata[:layout]].render(render_metadata, output)
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                  def output_directory
         
     | 
| 
      
 54 
     | 
    
         
            +
                    @site.config[:output][:root]
         
     | 
| 
      
 55 
     | 
    
         
            +
                  end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                  def url
         
     | 
| 
      
 58 
     | 
    
         
            +
                    @metadata[:url] || output_directory.gsub(@site.config[:output][:root], '')
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                  def template
         
     | 
| 
      
 62 
     | 
    
         
            +
                    raise NotImplementedError, 'You must set a Tilt template for this class.'
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                  private
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                  def default_metadata
         
     | 
| 
      
 68 
     | 
    
         
            +
                    {
         
     | 
| 
      
 69 
     | 
    
         
            +
                      layout: nil,
         
     | 
| 
      
 70 
     | 
    
         
            +
                      filename: 'index.html'
         
     | 
| 
      
 71 
     | 
    
         
            +
                    }
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Dimples
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Sources
         
     | 
| 
      
 5 
     | 
    
         
            +
                # A single page on a site.
         
     | 
| 
      
 6 
     | 
    
         
            +
                class Page < Base
         
     | 
| 
      
 7 
     | 
    
         
            +
                  def output_directory
         
     | 
| 
      
 8 
     | 
    
         
            +
                    @output_directory ||= File.dirname(@path).gsub(
         
     | 
| 
      
 9 
     | 
    
         
            +
                      @site.config[:sources][:pages],
         
     | 
| 
      
 10 
     | 
    
         
            +
                      @site.config[:output][:root]
         
     | 
| 
      
 11 
     | 
    
         
            +
                    ).concat('/')
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def url
         
     | 
| 
      
 15 
     | 
    
         
            +
                    @metadata[:url] || super.tap do |url|
         
     | 
| 
      
 16 
     | 
    
         
            +
                      url.concat(filename) unless filename == 'index.html'
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  def template
         
     | 
| 
      
 21 
     | 
    
         
            +
                    @template ||= Tilt::ERBTemplate.new { @contents }
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  private
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  def default_metadata
         
     | 
| 
      
 27 
     | 
    
         
            +
                    super.merge!(layout: 'page')
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Dimples
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Sources
         
     | 
| 
      
 5 
     | 
    
         
            +
                # A page from a site with a date.
         
     | 
| 
      
 6 
     | 
    
         
            +
                class Post < Base
         
     | 
| 
      
 7 
     | 
    
         
            +
                  def output_directory
         
     | 
| 
      
 8 
     | 
    
         
            +
                    @output_directory ||= File.dirname(@path).gsub(
         
     | 
| 
      
 9 
     | 
    
         
            +
                      @site.config[:sources][:posts],
         
     | 
| 
      
 10 
     | 
    
         
            +
                      @site.config[:output][:posts]
         
     | 
| 
      
 11 
     | 
    
         
            +
                    ).concat("/#{@metadata[:slug]}/")
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def template
         
     | 
| 
      
 15 
     | 
    
         
            +
                    @template ||= Tilt::RedcarpetTemplate.new { @contents }
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  private
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  def default_metadata
         
     | 
| 
      
 21 
     | 
    
         
            +
                    super.tap do |defaults|
         
     | 
| 
      
 22 
     | 
    
         
            +
                      defaults[:layout] = 'post'
         
     | 
| 
      
 23 
     | 
    
         
            +
                      defaults[:slug] = File.basename(@path, '.markdown')
         
     | 
| 
      
 24 
     | 
    
         
            +
                      defaults[:date] = File.birthtime(@path)
         
     | 
| 
      
 25 
     | 
    
         
            +
                      defaults[:categories] = []
         
     | 
| 
      
 26 
     | 
    
         
            +
                    end
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/dimples/version.rb
    CHANGED
    
    
    
        data/lib/dimples.rb
    CHANGED
    
    | 
         @@ -2,8 +2,12 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            $LOAD_PATH.unshift(__dir__)
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
            require  
     | 
| 
       6 
     | 
    
         
            -
            require  
     | 
| 
       7 
     | 
    
         
            -
            require  
     | 
| 
       8 
     | 
    
         
            -
            require  
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
            require 'dimples/config'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'dimples/metadata'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'dimples/pager'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'dimples/site'
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            require 'dimples/sources/base'
         
     | 
| 
      
 11 
     | 
    
         
            +
            require 'dimples/sources/page'
         
     | 
| 
      
 12 
     | 
    
         
            +
            require 'dimples/sources/post'
         
     | 
| 
      
 13 
     | 
    
         
            +
            require 'dimples/sources/layout'
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: dimples
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version:  
     | 
| 
      
 4 
     | 
    
         
            +
              version: 10.1.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Daniel Bogan
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire:
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2024-02-04 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: erubi
         
     | 
| 
         @@ -16,98 +16,42 @@ dependencies: 
     | 
|
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
17 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: '1. 
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '1.12'
         
     | 
| 
       20 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
24 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version: '1. 
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '1.12'
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
28 
     | 
    
         
             
              name: redcarpet
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
31 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version: '3. 
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '3.6'
         
     | 
| 
       34 
34 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       35 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
38 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
     | 
    
         
            -
                    version: '3. 
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '3.6'
         
     | 
| 
       41 
41 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
42 
     | 
    
         
             
              name: tilt
         
     | 
| 
       43 
43 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       44 
44 
     | 
    
         
             
                requirements:
         
     | 
| 
       45 
45 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       46 
46 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       47 
     | 
    
         
            -
                    version: '2. 
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '2.3'
         
     | 
| 
       48 
48 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       49 
49 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       50 
50 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       51 
51 
     | 
    
         
             
                requirements:
         
     | 
| 
       52 
52 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       53 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
     | 
    
         
            -
                    version: '2. 
     | 
| 
       55 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       56 
     | 
    
         
            -
              name: rake
         
     | 
| 
       57 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       58 
     | 
    
         
            -
                requirements:
         
     | 
| 
       59 
     | 
    
         
            -
                - - "~>"
         
     | 
| 
       60 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       61 
     | 
    
         
            -
                    version: '13.0'
         
     | 
| 
       62 
     | 
    
         
            -
              type: :development
         
     | 
| 
       63 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       64 
     | 
    
         
            -
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       65 
     | 
    
         
            -
                requirements:
         
     | 
| 
       66 
     | 
    
         
            -
                - - "~>"
         
     | 
| 
       67 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       68 
     | 
    
         
            -
                    version: '13.0'
         
     | 
| 
       69 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       70 
     | 
    
         
            -
              name: rspec
         
     | 
| 
       71 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       72 
     | 
    
         
            -
                requirements:
         
     | 
| 
       73 
     | 
    
         
            -
                - - "~>"
         
     | 
| 
       74 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       75 
     | 
    
         
            -
                    version: '3.12'
         
     | 
| 
       76 
     | 
    
         
            -
              type: :development
         
     | 
| 
       77 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       78 
     | 
    
         
            -
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       79 
     | 
    
         
            -
                requirements:
         
     | 
| 
       80 
     | 
    
         
            -
                - - "~>"
         
     | 
| 
       81 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       82 
     | 
    
         
            -
                    version: '3.12'
         
     | 
| 
       83 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       84 
     | 
    
         
            -
              name: rubocop-rspec
         
     | 
| 
       85 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       86 
     | 
    
         
            -
                requirements:
         
     | 
| 
       87 
     | 
    
         
            -
                - - "~>"
         
     | 
| 
       88 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       89 
     | 
    
         
            -
                    version: '2.22'
         
     | 
| 
       90 
     | 
    
         
            -
              type: :development
         
     | 
| 
       91 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       92 
     | 
    
         
            -
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       93 
     | 
    
         
            -
                requirements:
         
     | 
| 
       94 
     | 
    
         
            -
                - - "~>"
         
     | 
| 
       95 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       96 
     | 
    
         
            -
                    version: '2.22'
         
     | 
| 
       97 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       98 
     | 
    
         
            -
              name: standard
         
     | 
| 
       99 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       100 
     | 
    
         
            -
                requirements:
         
     | 
| 
       101 
     | 
    
         
            -
                - - "~>"
         
     | 
| 
       102 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       103 
     | 
    
         
            -
                    version: '1.28'
         
     | 
| 
       104 
     | 
    
         
            -
              type: :development
         
     | 
| 
       105 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       106 
     | 
    
         
            -
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       107 
     | 
    
         
            -
                requirements:
         
     | 
| 
       108 
     | 
    
         
            -
                - - "~>"
         
     | 
| 
       109 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       110 
     | 
    
         
            -
                    version: '1.28'
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '2.3'
         
     | 
| 
       111 
55 
     | 
    
         
             
            description: A simple tool for building static websites.
         
     | 
| 
       112 
56 
     | 
    
         
             
            email:
         
     | 
| 
       113 
57 
     | 
    
         
             
            - d+dimples@waferbaby.com
         
     | 
| 
         @@ -118,20 +62,21 @@ extra_rdoc_files: [] 
     | 
|
| 
       118 
62 
     | 
    
         
             
            files:
         
     | 
| 
       119 
63 
     | 
    
         
             
            - bin/dimples
         
     | 
| 
       120 
64 
     | 
    
         
             
            - lib/dimples.rb
         
     | 
| 
       121 
     | 
    
         
            -
            - lib/dimples/ 
     | 
| 
       122 
     | 
    
         
            -
            - lib/dimples/ 
     | 
| 
       123 
     | 
    
         
            -
            - lib/dimples/frontmatter.rb
         
     | 
| 
       124 
     | 
    
         
            -
            - lib/dimples/page.rb
         
     | 
| 
      
 65 
     | 
    
         
            +
            - lib/dimples/config.rb
         
     | 
| 
      
 66 
     | 
    
         
            +
            - lib/dimples/metadata.rb
         
     | 
| 
       125 
67 
     | 
    
         
             
            - lib/dimples/pager.rb
         
     | 
| 
       126 
     | 
    
         
            -
            - lib/dimples/post.rb
         
     | 
| 
       127 
68 
     | 
    
         
             
            - lib/dimples/site.rb
         
     | 
| 
       128 
     | 
    
         
            -
            - lib/dimples/ 
     | 
| 
      
 69 
     | 
    
         
            +
            - lib/dimples/sources/base.rb
         
     | 
| 
      
 70 
     | 
    
         
            +
            - lib/dimples/sources/layout.rb
         
     | 
| 
      
 71 
     | 
    
         
            +
            - lib/dimples/sources/page.rb
         
     | 
| 
      
 72 
     | 
    
         
            +
            - lib/dimples/sources/post.rb
         
     | 
| 
       129 
73 
     | 
    
         
             
            - lib/dimples/version.rb
         
     | 
| 
       130 
74 
     | 
    
         
             
            homepage: http://github.com/waferbaby/dimples
         
     | 
| 
       131 
75 
     | 
    
         
             
            licenses:
         
     | 
| 
       132 
76 
     | 
    
         
             
            - MIT
         
     | 
| 
       133 
     | 
    
         
            -
            metadata: 
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
      
 77 
     | 
    
         
            +
            metadata:
         
     | 
| 
      
 78 
     | 
    
         
            +
              rubygems_mfa_required: 'true'
         
     | 
| 
      
 79 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
       135 
80 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       136 
81 
     | 
    
         
             
            require_paths:
         
     | 
| 
       137 
82 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -139,15 +84,15 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       139 
84 
     | 
    
         
             
              requirements:
         
     | 
| 
       140 
85 
     | 
    
         
             
              - - ">"
         
     | 
| 
       141 
86 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       142 
     | 
    
         
            -
                  version: ' 
     | 
| 
      
 87 
     | 
    
         
            +
                  version: '3.0'
         
     | 
| 
       143 
88 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       144 
89 
     | 
    
         
             
              requirements:
         
     | 
| 
       145 
90 
     | 
    
         
             
              - - ">="
         
     | 
| 
       146 
91 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       147 
92 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       148 
93 
     | 
    
         
             
            requirements: []
         
     | 
| 
       149 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
       150 
     | 
    
         
            -
            signing_key:
         
     | 
| 
      
 94 
     | 
    
         
            +
            rubygems_version: 3.4.10
         
     | 
| 
      
 95 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
       151 
96 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       152 
97 
     | 
    
         
             
            summary: A basic static site generator
         
     | 
| 
       153 
98 
     | 
    
         
             
            test_files: []
         
     | 
    
        data/lib/dimples/document.rb
    DELETED
    
    | 
         @@ -1,69 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require_relative "frontmatter"
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            module Dimples
         
     | 
| 
       6 
     | 
    
         
            -
              class Document
         
     | 
| 
       7 
     | 
    
         
            -
                attr_accessor :metadata, :contents, :path, :rendered_contents
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                def initialize(path = nil, metadata = {})
         
     | 
| 
       10 
     | 
    
         
            -
                  @path = path
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                  if @path
         
     | 
| 
       13 
     | 
    
         
            -
                    @metadata, @contents = Dimples::FrontMatter.parse(File.read(path))
         
     | 
| 
       14 
     | 
    
         
            -
                  else
         
     | 
| 
       15 
     | 
    
         
            -
                    @metadata = {}
         
     | 
| 
       16 
     | 
    
         
            -
                    @contents = ""
         
     | 
| 
       17 
     | 
    
         
            -
                  end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                  @metadata.merge!(metadata)
         
     | 
| 
       20 
     | 
    
         
            -
                end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                def filename
         
     | 
| 
       23 
     | 
    
         
            -
                  "#{basename}.#{extension}"
         
     | 
| 
       24 
     | 
    
         
            -
                end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                def basename
         
     | 
| 
       27 
     | 
    
         
            -
                  @metadata.fetch(:filename, "index")
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                def extension
         
     | 
| 
       31 
     | 
    
         
            -
                  @metadata.fetch(:extension, "html")
         
     | 
| 
       32 
     | 
    
         
            -
                end
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
                def layout
         
     | 
| 
       35 
     | 
    
         
            -
                  @metadata.fetch(:layout, nil)
         
     | 
| 
       36 
     | 
    
         
            -
                end
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                def render(context = {}, content = "")
         
     | 
| 
       39 
     | 
    
         
            -
                  context_obj = Object.new
         
     | 
| 
       40 
     | 
    
         
            -
                  context.each do |key, value|
         
     | 
| 
       41 
     | 
    
         
            -
                    context_obj.instance_variable_set("@#{key}", value)
         
     | 
| 
       42 
     | 
    
         
            -
                  end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                  @rendered_contents = renderer.render(context_obj) { content }
         
     | 
| 
       45 
     | 
    
         
            -
                end
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
                private
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                def renderer
         
     | 
| 
       50 
     | 
    
         
            -
                  @renderer ||= begin
         
     | 
| 
       51 
     | 
    
         
            -
                    callback = proc { contents }
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                    if @path
         
     | 
| 
       54 
     | 
    
         
            -
                      Tilt.new(@path, {}, &callback)
         
     | 
| 
       55 
     | 
    
         
            -
                    else
         
     | 
| 
       56 
     | 
    
         
            -
                      Tilt::StringTemplate.new(&callback)
         
     | 
| 
       57 
     | 
    
         
            -
                    end
         
     | 
| 
       58 
     | 
    
         
            -
                  end
         
     | 
| 
       59 
     | 
    
         
            -
                end
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
                def method_missing(method_name, *_args)
         
     | 
| 
       62 
     | 
    
         
            -
                  @metadata[method_name] if @metadata.key?(method_name)
         
     | 
| 
       63 
     | 
    
         
            -
                end
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                def respond_to_missing?(method_name, include_private)
         
     | 
| 
       66 
     | 
    
         
            -
                  @metadata.key?(method_name) || super
         
     | 
| 
       67 
     | 
    
         
            -
                end
         
     | 
| 
       68 
     | 
    
         
            -
              end
         
     | 
| 
       69 
     | 
    
         
            -
            end
         
     | 
    
        data/lib/dimples/errors.rb
    DELETED
    
    
    
        data/lib/dimples/frontmatter.rb
    DELETED
    
    | 
         @@ -1,20 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require "yaml"
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            module Dimples
         
     | 
| 
       6 
     | 
    
         
            -
              module FrontMatter
         
     | 
| 
       7 
     | 
    
         
            -
                PATTERN = /^(-{3}\n.*?\n?)^(-{3}*$\n?)/m.freeze
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                def self.parse(contents)
         
     | 
| 
       10 
     | 
    
         
            -
                  metadata = {}
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                  if (matches = contents.match(PATTERN))
         
     | 
| 
       13 
     | 
    
         
            -
                    metadata = YAML.safe_load(matches[1], symbolize_names: true, permitted_classes: [Date])
         
     | 
| 
       14 
     | 
    
         
            -
                    contents = matches.post_match.strip
         
     | 
| 
       15 
     | 
    
         
            -
                  end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                  [metadata, contents]
         
     | 
| 
       18 
     | 
    
         
            -
                end
         
     | 
| 
       19 
     | 
    
         
            -
              end
         
     | 
| 
       20 
     | 
    
         
            -
            end
         
     | 
    
        data/lib/dimples/page.rb
    DELETED
    
    
    
        data/lib/dimples/post.rb
    DELETED
    
    | 
         @@ -1,21 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require_relative "document"
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            require "date"
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            module Dimples
         
     | 
| 
       8 
     | 
    
         
            -
              class Post < Document
         
     | 
| 
       9 
     | 
    
         
            -
                def date
         
     | 
| 
       10 
     | 
    
         
            -
                  @metadata.fetch(:date, DateTime.now)
         
     | 
| 
       11 
     | 
    
         
            -
                end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                def layout
         
     | 
| 
       14 
     | 
    
         
            -
                  @metadata.fetch(:layout, "post")
         
     | 
| 
       15 
     | 
    
         
            -
                end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                def slug
         
     | 
| 
       18 
     | 
    
         
            -
                  File.basename(@path, ".markdown")
         
     | 
| 
       19 
     | 
    
         
            -
                end
         
     | 
| 
       20 
     | 
    
         
            -
              end
         
     | 
| 
       21 
     | 
    
         
            -
            end
         
     |