details.rb 1.05 KB
Newer Older
Sylvester Keil's avatar
Sylvester Keil committed
1 2 3 4
module Jekyll
  class Scholar

    class Details < Page
5
      include Scholar::Utilities
6

Sylvester Keil's avatar
Sylvester Keil committed
7 8
      def initialize(site, base, dir, entry)
        @site, @base, @dir = site, base, dir
9

Sylvester Keil's avatar
Sylvester Keil committed
10
        @config = Scholar.defaults.merge(site.config['scholar'] || {})
11

Sylvester Keil's avatar
fix #55  
Sylvester Keil committed
12 13
        @name = entry.key.to_s.gsub(/[:\s]+/, '_')
        @name << '.html'
Sylvester Keil's avatar
Sylvester Keil committed
14 15 16

        process(@name)
        read_yaml(File.join(base, '_layouts'), config['details_layout'])
17

18
        data.merge!(reference_data(entry))
19 20
      end

Sylvester Keil's avatar
Sylvester Keil committed
21 22 23
    end

    class DetailsGenerator < Generator
24
      include Scholar::Utilities
25

Sylvester Keil's avatar
Sylvester Keil committed
26
      safe true
27
      priority :high
Sylvester Keil's avatar
Sylvester Keil committed
28 29

      attr_reader :config
30

Sylvester Keil's avatar
Sylvester Keil committed
31
      def generate(site)
32
        @site, @config = site, Scholar.defaults.merge(site.config['scholar'] || {})
33

34 35
        if generate_details?
          entries.each do |entry|
36
            details = Details.new(site, site.source, File.join('', details_path), entry)
Sylvester Keil's avatar
Sylvester Keil committed
37 38
            details.render(site.layouts, site.site_payload)
            details.write(site.dest)
39

Sylvester Keil's avatar
Sylvester Keil committed
40 41
            site.pages << details
          end
42

Sylvester Keil's avatar
Sylvester Keil committed
43 44
        end
      end
45

Sylvester Keil's avatar
Sylvester Keil committed
46 47 48 49
    end


  end
50
end