Skip to content

Commit 5c47d05

Browse files
authored
Merge branch 'master' into rubocop
2 parents cd4b7a9 + ca2ca84 commit 5c47d05

File tree

4 files changed

+50
-44
lines changed

4 files changed

+50
-44
lines changed
Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,61 @@
11
## HEAD
22

33
### Minor Enhancements
4+
5+
* Make Archive subclass of Page (#67)
46
* Don't limit slugs/title to strings (#41)
7+
* Enable incremental operation (#58)
8+
9+
### Development Fixes
510

6-
## 2.1.0
11+
* Update Travis config and Gemfile for Ruby < 2.2.2 support (#68)
12+
* Consolidate History file to work with jekyllbot (#80)
13+
14+
## 2.1.0
715

816
### Minor Enhancements
17+
918
* Update Jekyll dependency to allow Jekyll 3 (#33)
1019
* Update docs to reflect changes in v2.0.0 (#31)
1120
* Add compatibility with Jekyll 3 (#48)
1221
* Update to reflect release of Jekyll 3 (#52)
1322
* Support revised documents/collections in Jekyll 3 (#53)
1423

15-
## Development Fixes
16-
* Test against Jekyll 2, 3, and GitHub Pages (#48)
24+
### Development Fixes
1725

18-
### Bug Fixes
26+
* Test against Jekyll 2, 3, and GitHub Pages (#48)
1927

2028
## 2.0.0 / 2015-01-06
2129

2230
### Minor Enhancements
31+
2332
* Move Date object from `page.title` to `page.date` (#26)
2433
* Add documentation to repository (#25)
2534

2635
### Bug Fixes
36+
2737
* Change Jekyll dependency to ~> 2.4 (#23)
2838

2939
## 1.0.0 / 2014-09-26
3040

3141
### Major Enhancements
42+
3243
* Support type-specific layouts
3344
* Pass `Date` object to Liquid in case of date-based archives
3445
* Liquid `{{ site.archives }}` support
3546
* Generate month and day archives
3647

3748
### Minor Enhancements
49+
3850
* Add version file and move everything into `Archives` module
3951
* Use `Jekyll::Utils.slugify` for slugging
4052
* Require use to specify what types of archives are enabled
4153

4254
## 0.1.0 / 2014-08-17
55+
4356
* First release
4457
* Generate year, category, and tag archives
4558

4659
## 0.0.0 / 2014-08-17
60+
4761
* Birthday!

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Automatically generate post archives by dates, tags, and categories.
44

5-
[![Gem Version](https://badge.fury.io/rb/jekyll-archives.png)](http://badge.fury.io/rb/jekyll-archives)
5+
[![Gem Version](https://badge.fury.io/rb/jekyll-archives.svg)](http://badge.fury.io/rb/jekyll-archives)
66
[![Build Status](https://travis-ci.org/jekyll/jekyll-archives.svg?branch=master)](https://travis-ci.org/jekyll/jekyll-archives)
77

88
## Getting started

lib/jekyll-archives.rb

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ module Archives
66
autoload :Archive, "jekyll-archives/archive"
77
autoload :VERSION, "jekyll-archives/version"
88

9-
if Jekyll.const_defined? :Hooks
10-
Jekyll::Hooks.register :site, :after_reset do |site|
11-
# We need to disable incremental regen for Archives to generate with the
12-
# correct content
13-
site.regenerator.instance_variable_set(:@disabled, true)
14-
end
15-
end
16-
179
class Archives < Jekyll::Generator
1810
safe true
1911

@@ -45,13 +37,8 @@ def generate(site)
4537
@site.config["jekyll-archives"] = @config
4638

4739
read
48-
render
49-
write
40+
@site.pages.concat(@archives)
5041

51-
@site.keep_files ||= []
52-
@archives.each do |archive|
53-
@site.keep_files << archive.relative_path
54-
end
5542
@site.config["archives"] = @archives
5643
end
5744

@@ -108,7 +95,8 @@ def render
10895
# Write archives to their destination
10996
def write
11097
@archives.each do |archive|
111-
archive.write(@site.dest)
98+
archive.write(@site.dest) if archive.regenerate?
99+
archive.add_dependencies
112100
end
113101
end
114102

lib/jekyll-archives/archive.rb

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
module Jekyll
22
module Archives
3-
class Archive
4-
include Convertible
3+
class Archive < Jekyll::Page
54

6-
attr_accessor :posts, :type, :name, :slug
7-
attr_accessor :data, :content, :output
8-
attr_accessor :path, :ext
9-
attr_accessor :site
5+
attr_accessor :posts, :type, :slug
106

117
# Attributes for Liquid templates
128
ATTRIBUTES_FOR_LIQUID = %w(
@@ -17,6 +13,7 @@ class Archive
1713
name
1814
path
1915
url
16+
permalink
2017
).freeze
2118

2219
# Initialize a new Archive page
@@ -34,8 +31,8 @@ def initialize(site, title, type, posts)
3431
@config = site.config["jekyll-archives"]
3532

3633
# Generate slug if tag or category (taken from jekyll/jekyll/features/support/env.rb)
37-
if title.to_s.length
38-
@slug = Utils.slugify(title.to_s)
34+
if title.is_a? String
35+
@slug = Utils.slugify(title)
3936
end
4037

4138
# Use ".html" for file extension and url for path
@@ -90,6 +87,10 @@ def url
9087
raise ArgumentError, "Template \"#{template}\" provided is invalid."
9188
end
9289

90+
def permalink
91+
data && data.is_a?(Hash) && data['permalink']
92+
end
93+
9394
# Add any necessary layouts to this post
9495
#
9596
# layouts - The Hash of {"name" => "layout"}.
@@ -104,6 +105,17 @@ def render(layouts, site_payload)
104105
do_layout(payload, layouts)
105106
end
106107

108+
# Add dependencies for incremental mode
109+
def add_dependencies
110+
if defined? site.regenerator
111+
archive_path = site.in_dest_dir(relative_path)
112+
site.regenerator.add(archive_path)
113+
@posts.each do |post|
114+
site.regenerator.add_dependency(archive_path, post.path)
115+
end
116+
end
117+
end
118+
107119
# Convert this Convertible's data to a Hash suitable for use by Liquid.
108120
#
109121
# Returns the Hash representation of this Convertible.
@@ -135,17 +147,6 @@ def date
135147
end
136148
end
137149

138-
# Obtain destination path.
139-
#
140-
# dest - The String path to the destination dir.
141-
#
142-
# Returns the destination file path String.
143-
def destination(dest)
144-
path = Jekyll.sanitized_path(dest, URL.unescape_path(url))
145-
path = File.join(path, "index.html") if url =~ /\/$/
146-
path
147-
end
148-
149150
# Obtain the write path relative to the destination directory
150151
#
151152
# Returns the destination relative path String.
@@ -155,15 +156,18 @@ def relative_path
155156
path
156157
end
157158

159+
def regenerate?
160+
if defined? site.regenerator
161+
site.regenerator.regenerate?(self)
162+
else
163+
true
164+
end
165+
end
166+
158167
# Returns the object as a debug String.
159168
def inspect
160169
"#<Jekyll:Archive @type=#{@type} @title=#{@title} @data=#{@data.inspect}>"
161170
end
162-
163-
# Returns the Boolean of whether this Page is HTML or not.
164-
def html?
165-
true
166-
end
167171
end
168172
end
169173
end

0 commit comments

Comments
 (0)