aardi 1.0.0 → 2.0.1
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/lib/aardi/abstract_blog.rb +9 -4
- data/lib/aardi/abstract_feed.rb +15 -3
- data/lib/aardi/abstract_page_support.rb +9 -3
- data/lib/aardi/archive.rb +24 -19
- data/lib/aardi/atom_feed.rb +2 -4
- data/lib/aardi/blog.rb +18 -12
- data/lib/aardi/config.rb +15 -16
- data/lib/aardi/content_hashes.rb +11 -4
- data/lib/aardi/custom_renderer.rb +1 -3
- data/lib/aardi/day.rb +4 -3
- data/lib/aardi/errors.rb +6 -0
- data/lib/aardi/file_target.rb +8 -9
- data/lib/aardi/folder.rb +5 -10
- data/lib/aardi/home.rb +13 -14
- data/lib/aardi/home_footer_links.rb +21 -0
- data/lib/aardi/init_files/config.yml +1 -0
- data/lib/aardi/json_feed.rb +2 -3
- data/lib/aardi/metadata.rb +36 -0
- data/lib/aardi/month.rb +11 -11
- data/lib/aardi/orphanage.rb +3 -3
- data/lib/aardi/page_content.rb +2 -2
- data/lib/aardi/page_target.rb +4 -6
- data/lib/aardi/post.rb +10 -20
- data/lib/aardi/post_bookmark_line.rb +26 -0
- data/lib/aardi/renderer.rb +42 -0
- data/lib/aardi/site.rb +11 -43
- data/lib/aardi/sitemap.rb +11 -5
- data/lib/aardi/tag_blog.rb +42 -0
- data/lib/aardi/tags.rb +61 -0
- data/lib/aardi/tasks/homepage.rake +1 -1
- data/lib/aardi/tasks/init.rake +3 -6
- data/lib/aardi/tasks/load_config.rake +1 -1
- data/lib/aardi/tasks/new.rake +1 -1
- data/lib/aardi/tasks/render.rake +2 -0
- data/lib/aardi/tasks/server.rake +1 -1
- data/lib/aardi/template.rb +33 -19
- data/lib/aardi/timekeeper.rb +5 -12
- data/lib/aardi/version.rb +1 -1
- data/lib/aardi/year.rb +7 -6
- data/lib/aardi.rb +50 -40
- metadata +9 -3
- data/lib/aardi/ledger.rb +0 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 129167c280727dd641e8842090ea97a9a15cb342d8ac6a160a0cd9591c3cbc4c
|
|
4
|
+
data.tar.gz: 51dadc501772acb3ee741463e475296f27864af8d323f576f7753b6f69334b48
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 242ddfb6fc66e2593daa08dffc5f8dbaf5313838d46fad8903d58355a4b597b03ae339855e52b1cf6ada248f5b6c5cfa3521bf85b6b81dccaf0e6fd14e0cb1f0
|
|
7
|
+
data.tar.gz: e0af3d46e798c83d87da4b332b86814342401da1b5ee602f8b637d39e30535487a42e477571f84657c105165ac718cc6fd58856166be5495f33c0493ecd87c4f
|
data/lib/aardi/abstract_blog.rb
CHANGED
|
@@ -4,13 +4,18 @@ module Aardi
|
|
|
4
4
|
class AbstractBlog
|
|
5
5
|
attr_reader :key
|
|
6
6
|
|
|
7
|
-
def metadata = (@metadata ||=
|
|
7
|
+
def metadata = (@metadata ||= Metadata.new)
|
|
8
8
|
|
|
9
9
|
def mtime = children.max_by(&:mtime)&.mtime
|
|
10
10
|
|
|
11
11
|
def render
|
|
12
|
-
children.
|
|
13
|
-
|
|
12
|
+
children.each_with_object({}) { |child, acc| acc.merge!(child.render) }.merge!(write_target)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def title
|
|
16
|
+
return "#{base_title} - #{@tag}" if @tag
|
|
17
|
+
|
|
18
|
+
base_title
|
|
14
19
|
end
|
|
15
20
|
|
|
16
21
|
private
|
|
@@ -20,7 +25,7 @@ module Aardi
|
|
|
20
25
|
end
|
|
21
26
|
|
|
22
27
|
def write_target
|
|
23
|
-
source = PageContent.new
|
|
28
|
+
source = PageContent.new(content, title, metadata)
|
|
24
29
|
PageTarget.new(source, target_path).write
|
|
25
30
|
end
|
|
26
31
|
end
|
data/lib/aardi/abstract_feed.rb
CHANGED
|
@@ -2,25 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
module Aardi
|
|
4
4
|
class AbstractFeed < AbstractBlog
|
|
5
|
-
def initialize(posts)
|
|
5
|
+
def initialize(posts, archive_path = nil, tag = nil)
|
|
6
|
+
@archive_path = archive_path
|
|
6
7
|
@posts = posts
|
|
8
|
+
@tag = tag
|
|
7
9
|
end
|
|
8
10
|
|
|
9
11
|
def render
|
|
10
12
|
write_target
|
|
11
13
|
end
|
|
12
14
|
|
|
13
|
-
def target_path
|
|
15
|
+
def target_path
|
|
16
|
+
return "./#{@archive_path}/#{feed_file}" if @archive_path
|
|
17
|
+
|
|
18
|
+
"./#{feed_file}"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Keep #title private so Nokogiri `:title` in ATOMFeed#feed_details
|
|
22
|
+
# as an element name rather than a delegated call.
|
|
23
|
+
private :title
|
|
14
24
|
|
|
15
25
|
private
|
|
16
26
|
|
|
27
|
+
def base_title = Config[:site_title]
|
|
28
|
+
|
|
17
29
|
def children
|
|
18
30
|
@posts
|
|
19
31
|
end
|
|
20
32
|
|
|
21
33
|
def creation = children.max_by(&:creation)&.creation
|
|
22
34
|
|
|
23
|
-
def feed_url = "#{
|
|
35
|
+
def feed_url = "#{Config[:site_url]}#{target_path[1..]}"
|
|
24
36
|
|
|
25
37
|
def updated = children.max_by(&:updated)&.updated
|
|
26
38
|
|
|
@@ -2,19 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
module Aardi
|
|
4
4
|
module AbstractPageSupport
|
|
5
|
-
|
|
5
|
+
def metadata
|
|
6
|
+
@metadata
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def mtime
|
|
10
|
+
@mtime
|
|
11
|
+
end
|
|
6
12
|
|
|
7
13
|
def parse_source(path)
|
|
8
14
|
File.open(path, encoding: 'utf-8') do |file|
|
|
9
15
|
parts = file.read.rpartition("\n----\n")
|
|
10
|
-
@metadata =
|
|
16
|
+
@metadata = Metadata.new(parts.first, path)
|
|
11
17
|
@src_content = parts.last
|
|
12
18
|
@mtime = file.mtime.utc
|
|
13
19
|
end
|
|
14
20
|
end
|
|
15
21
|
|
|
16
22
|
def title
|
|
17
|
-
metadata
|
|
23
|
+
metadata.title || @src_content[/\A(?:#+ +)?([^\n]+)/, 1]
|
|
18
24
|
end
|
|
19
25
|
end
|
|
20
26
|
end
|
data/lib/aardi/archive.rb
CHANGED
|
@@ -2,47 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
module Aardi
|
|
4
4
|
class Archive < AbstractBlog
|
|
5
|
-
def initialize(
|
|
6
|
-
@posts = posts
|
|
5
|
+
def initialize(archive_path, tag = nil, tags = nil)
|
|
7
6
|
@archive_path = archive_path
|
|
7
|
+
@tag = tag
|
|
8
|
+
@tags = tags
|
|
9
|
+
@index = Hash.new { |hash, year| hash[year] = Year.new(year, @archive_path, @tag) }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def <<(post)
|
|
13
|
+
@index[post.creation.year] << post
|
|
8
14
|
end
|
|
9
15
|
|
|
10
16
|
def content
|
|
11
17
|
year_fmt = "| %<year>s | %<months>s \n"
|
|
12
|
-
month_fmt = "[ %<count>s ](#{
|
|
18
|
+
month_fmt = "[ %<count>s ](#{Config[:site_url]}/%<archive_path>s/%<year>s/%<month>s/)"
|
|
13
19
|
|
|
14
|
-
|
|
20
|
+
rows = years.map { |year| year.archive_row(year_fmt, month_fmt) }.join
|
|
21
|
+
"#{title_heading}#{tag_list}**When**:\n\n#{table_header}#{rows}"
|
|
15
22
|
end
|
|
16
23
|
|
|
17
24
|
def target_path = "./#{@archive_path}/index.html"
|
|
18
25
|
|
|
19
|
-
def title = Aardi.config[:blog_archive_title]
|
|
20
|
-
|
|
21
26
|
private
|
|
22
27
|
|
|
23
|
-
def
|
|
24
|
-
index = Hash.new { |hash, year| hash[year] = Year.new(year, @archive_path) }
|
|
25
|
-
@posts.each do |post|
|
|
26
|
-
index[post.year] << post
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
index
|
|
30
|
-
end
|
|
28
|
+
def base_title = Config[:blog_archive_title]
|
|
31
29
|
|
|
32
30
|
def children
|
|
33
31
|
years
|
|
34
32
|
end
|
|
35
33
|
|
|
36
|
-
def
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
||Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec|
|
|
34
|
+
def table_header
|
|
35
|
+
"||Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec|
|
|
40
36
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
41
37
|
"
|
|
42
38
|
end
|
|
43
39
|
|
|
40
|
+
def tag_list
|
|
41
|
+
return '' unless @tags
|
|
42
|
+
return '' if @tags.empty?
|
|
43
|
+
|
|
44
|
+
"**What**: #{@tags.inline_links}\n\n"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def title_heading = "# #{title}\n\n"
|
|
48
|
+
|
|
44
49
|
def years
|
|
45
|
-
@years ||=
|
|
50
|
+
@years ||= @index.values.sort_by { |date| -date.key }
|
|
46
51
|
end
|
|
47
52
|
end
|
|
48
53
|
end
|
data/lib/aardi/atom_feed.rb
CHANGED
|
@@ -15,14 +15,12 @@ module Aardi
|
|
|
15
15
|
# :reek:TooManyStatements
|
|
16
16
|
# rubocop:disable Metrics/MethodLength
|
|
17
17
|
def feed_details(feed)
|
|
18
|
-
aardi_config = Aardi.config
|
|
19
|
-
|
|
20
18
|
feed.author do
|
|
21
|
-
name(
|
|
19
|
+
name(Config[:site_author])
|
|
22
20
|
end
|
|
23
21
|
|
|
24
22
|
subnodes = { id: feed_url, link: { href: feed_url, rel: 'self' },
|
|
25
|
-
title
|
|
23
|
+
title:, updated: updated.iso8601 }
|
|
26
24
|
|
|
27
25
|
subnodes.each do |node, value|
|
|
28
26
|
feed.public_send node, value
|
data/lib/aardi/blog.rb
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
module Aardi
|
|
4
4
|
class Blog < AbstractBlog
|
|
5
|
-
def initialize
|
|
6
|
-
@
|
|
7
|
-
@
|
|
5
|
+
def initialize
|
|
6
|
+
@posts = []
|
|
7
|
+
@blog_path = nil
|
|
8
|
+
@archive_path = Config[:blog_archive_path]
|
|
9
|
+
@tags = Tags.new
|
|
8
10
|
end
|
|
9
11
|
|
|
10
|
-
def
|
|
11
|
-
@posts
|
|
12
|
+
def <<(post)
|
|
13
|
+
@posts << post
|
|
14
|
+
archive << post
|
|
15
|
+
@tags << post
|
|
12
16
|
end
|
|
13
17
|
|
|
14
18
|
def report_recent
|
|
@@ -18,15 +22,15 @@ module Aardi
|
|
|
18
22
|
private
|
|
19
23
|
|
|
20
24
|
def archive
|
|
21
|
-
Archive.new(
|
|
25
|
+
@archive ||= Archive.new(@archive_path, tag, @tags)
|
|
22
26
|
end
|
|
23
27
|
|
|
24
28
|
def atom_feed
|
|
25
|
-
ATOMFeed.new(feed_posts)
|
|
29
|
+
ATOMFeed.new(feed_posts, @blog_path, tag)
|
|
26
30
|
end
|
|
27
31
|
|
|
28
32
|
def children
|
|
29
|
-
[archive, home, atom_feed, json_feed]
|
|
33
|
+
[archive, home, atom_feed, json_feed, *@tags]
|
|
30
34
|
end
|
|
31
35
|
|
|
32
36
|
def feed_posts
|
|
@@ -34,17 +38,19 @@ module Aardi
|
|
|
34
38
|
end
|
|
35
39
|
|
|
36
40
|
def home
|
|
37
|
-
Home.new(recent_posts(:blog_home_posts), @archive_path)
|
|
41
|
+
Home.new(recent_posts(:blog_home_posts), @archive_path, @blog_path, tag)
|
|
38
42
|
end
|
|
39
43
|
|
|
40
44
|
def json_feed
|
|
41
|
-
JSONFeed.new(feed_posts)
|
|
45
|
+
JSONFeed.new(feed_posts, @blog_path, tag)
|
|
42
46
|
end
|
|
43
47
|
|
|
44
48
|
def recent_posts(conf_key)
|
|
45
|
-
posts.
|
|
49
|
+
@posts.max_by(Config[conf_key], &:creation)
|
|
46
50
|
end
|
|
47
51
|
|
|
48
|
-
def
|
|
52
|
+
def tag = nil
|
|
53
|
+
|
|
54
|
+
def write_target = {}
|
|
49
55
|
end
|
|
50
56
|
end
|
data/lib/aardi/config.rb
CHANGED
|
@@ -2,25 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
module Aardi
|
|
4
4
|
class Config
|
|
5
|
-
|
|
6
|
-
@data = {}
|
|
7
|
-
end
|
|
5
|
+
RAISE_ON_MISS = ->(_, key) { raise KeyError, "Key not found: #{key.inspect}" }
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
@data = Hash.new(&RAISE_ON_MISS)
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
class << self
|
|
10
|
+
def [](key) = @data[key]
|
|
11
|
+
def fetch(key, default = nil) = @data.fetch(key, default)
|
|
12
|
+
def load(path) = prepare(File.read(path))
|
|
13
|
+
|
|
14
|
+
def prepare(config_yaml)
|
|
15
|
+
@data.merge!(YAML.safe_load(config_yaml).transform_keys(&:to_sym))
|
|
16
|
+
@data.freeze
|
|
17
|
+
self
|
|
18
|
+
end
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
config_hash.transform_keys!(&:to_sym)
|
|
20
|
-
config_hash[:markup_options]&.transform_keys!(&:to_sym)
|
|
21
|
-
@data.merge!(config_hash)
|
|
22
|
-
@data.freeze
|
|
23
|
-
self
|
|
20
|
+
def reset
|
|
21
|
+
@data = Hash.new(&RAISE_ON_MISS)
|
|
22
|
+
end
|
|
24
23
|
end
|
|
25
24
|
end
|
|
26
25
|
end
|
data/lib/aardi/content_hashes.rb
CHANGED
|
@@ -15,6 +15,16 @@ module Aardi
|
|
|
15
15
|
@hashes[path] = hash
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
def replace(new_hashes)
|
|
19
|
+
@hashes = new_hashes
|
|
20
|
+
@new_hashes = nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def save(new_hashes)
|
|
24
|
+
replace(new_hashes)
|
|
25
|
+
write
|
|
26
|
+
end
|
|
27
|
+
|
|
18
28
|
def write
|
|
19
29
|
return if new_hashes == @original_hashes
|
|
20
30
|
|
|
@@ -30,10 +40,7 @@ module Aardi
|
|
|
30
40
|
|
|
31
41
|
def read_hashes
|
|
32
42
|
@original_hashes = File.exist?(@path) ? File.read(@path) : ''
|
|
33
|
-
@hashes = @original_hashes.
|
|
34
|
-
path, hash = line.split(':', 2)
|
|
35
|
-
[path.strip, hash.to_i]
|
|
36
|
-
end
|
|
43
|
+
@hashes = @original_hashes.scan(/^(.+): (\d+)$/).to_h { |path, hash| [path, hash.to_i] }
|
|
37
44
|
end
|
|
38
45
|
end
|
|
39
46
|
end
|
|
@@ -7,9 +7,7 @@ module Aardi
|
|
|
7
7
|
HEADER_SQUEEZE = /&#.*?;|"|[^a-z0-9\-_]/
|
|
8
8
|
|
|
9
9
|
def header(text, header_level)
|
|
10
|
-
|
|
11
|
-
id = header_id(text)
|
|
12
|
-
"<h#{header_level} id=\"#{id}\">#{squeezed_text}</h#{header_level}>"
|
|
10
|
+
"<h#{header_level} id=\"#{header_id(text)}\">#{text.squeeze(' ')}</h#{header_level}>"
|
|
13
11
|
end
|
|
14
12
|
|
|
15
13
|
def link(link, title, content)
|
data/lib/aardi/day.rb
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
module Aardi
|
|
4
4
|
# :reek:TooManyInstanceVariables
|
|
5
5
|
class Day < AbstractBlog
|
|
6
|
-
def initialize(year, month, key, archive_path)
|
|
6
|
+
def initialize(year, month, key, archive_path, tag = nil)
|
|
7
7
|
@year = year
|
|
8
8
|
@month = month
|
|
9
9
|
@key = key
|
|
10
10
|
@archive_path = archive_path
|
|
11
|
+
@tag = tag
|
|
11
12
|
@posts = []
|
|
12
13
|
end
|
|
13
14
|
|
|
@@ -29,10 +30,10 @@ module Aardi
|
|
|
29
30
|
"./#{@archive_path}/#{@year}/#{@month}/#{self}/index.html"
|
|
30
31
|
end
|
|
31
32
|
|
|
32
|
-
def title = date.strftime('%A, %-e %B %Y')
|
|
33
|
-
|
|
34
33
|
private
|
|
35
34
|
|
|
35
|
+
def base_title = date.strftime('%A, %-e %B %Y')
|
|
36
|
+
|
|
36
37
|
def children
|
|
37
38
|
@posts
|
|
38
39
|
end
|
data/lib/aardi/errors.rb
ADDED
data/lib/aardi/file_target.rb
CHANGED
|
@@ -3,20 +3,22 @@
|
|
|
3
3
|
module Aardi
|
|
4
4
|
class FileTarget
|
|
5
5
|
def initialize(src, target_path)
|
|
6
|
+
renderer = Aardi.renderer
|
|
6
7
|
@src = src
|
|
7
8
|
@path = target_path
|
|
8
|
-
@content_hashes =
|
|
9
|
+
@content_hashes = renderer.content_hashes
|
|
10
|
+
@html_files = renderer.html_files
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
# :reek:TooManyStatements
|
|
12
14
|
def write
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return unless do_write
|
|
15
|
+
hash = @src.output_hash
|
|
16
|
+
return { @path => hash } unless should_write?
|
|
16
17
|
|
|
17
18
|
FileUtils.mkdir_p(File.dirname(@path))
|
|
18
19
|
File.write(@path, "#{@src.output}\n")
|
|
19
20
|
puts("Wrote #{@path}")
|
|
21
|
+
{ @path => hash }
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
private
|
|
@@ -33,11 +35,8 @@ module Aardi
|
|
|
33
35
|
return true unless file_exists?
|
|
34
36
|
return false unless output_hash_changed?
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def update_hash
|
|
40
|
-
@content_hashes[@path] = @src.output_hash
|
|
38
|
+
# in case cache missing (or corrupt) yet file good.
|
|
39
|
+
@src.output != File.read(@path).strip
|
|
41
40
|
end
|
|
42
41
|
end
|
|
43
42
|
end
|
data/lib/aardi/folder.rb
CHANGED
|
@@ -7,12 +7,12 @@ module Aardi
|
|
|
7
7
|
@normalized_path = "#{path.sub(/^\./, '')}/"
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def mtime = children.
|
|
10
|
+
def mtime = children.filter_map(&:mtime).max
|
|
11
11
|
|
|
12
12
|
def render
|
|
13
|
-
children.
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
result = children.each_with_object({}) { |child, acc| acc.merge!(child.render) }
|
|
14
|
+
Aardi.renderer.sitemap.record_mtime(@normalized_path, mtime) unless @path == '.'
|
|
15
|
+
result
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
private
|
|
@@ -26,16 +26,11 @@ module Aardi
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def paths
|
|
29
|
-
@paths ||= FileList["#{@path}/*"].exclude(
|
|
29
|
+
@paths ||= FileList["#{@path}/*"].exclude(Config[:files_to_exclude])
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def sources
|
|
33
33
|
@sources ||= paths.filter_map { |path| Page.new(path) if path.end_with?('.md') }
|
|
34
34
|
end
|
|
35
|
-
|
|
36
|
-
def update_sitemap
|
|
37
|
-
# '.' is the top level so skip it since the homepage will register itself
|
|
38
|
-
Aardi.ledger[:sitemap].update_mtime(@normalized_path, mtime) unless @path == '.'
|
|
39
|
-
end
|
|
40
35
|
end
|
|
41
36
|
end
|
data/lib/aardi/home.rb
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
module Aardi
|
|
4
4
|
class Home < AbstractBlog
|
|
5
|
-
def initialize(posts, archive_path)
|
|
5
|
+
def initialize(posts, archive_path, blog_path = nil, tag = nil)
|
|
6
6
|
@posts = posts
|
|
7
7
|
@archive_path = archive_path
|
|
8
|
+
@blog_path = blog_path
|
|
9
|
+
@tag = tag
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
def content
|
|
@@ -12,36 +14,33 @@ module Aardi
|
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
def render
|
|
15
|
-
Aardi.
|
|
17
|
+
Aardi.renderer.sitemap.update_mtime('/', mtime) unless @blog_path
|
|
16
18
|
write_target
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
def target_path
|
|
21
|
+
def target_path
|
|
22
|
+
return "./#{@blog_path}/index.html" if @blog_path
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
'./index.html'
|
|
25
|
+
end
|
|
22
26
|
|
|
23
27
|
private
|
|
24
28
|
|
|
29
|
+
def base_title = Config[:blog_home_title]
|
|
30
|
+
|
|
25
31
|
def children
|
|
26
32
|
@posts
|
|
27
33
|
end
|
|
28
34
|
|
|
29
|
-
def content_footer
|
|
30
|
-
site_url = Aardi.config[:site_url]
|
|
31
|
-
more_archive = "[Archive](#{site_url}/#{@archive_path}/)"
|
|
32
|
-
more_rss = "[RSS](#{site_url}/index.xml)"
|
|
33
|
-
more_json = "[JSON](#{site_url}/index.json)"
|
|
34
|
-
"**More:** #{more_archive}, #{more_rss}, #{more_json}"
|
|
35
|
-
end
|
|
35
|
+
def content_footer = HomeFooterLinks.new(@blog_path).to_s
|
|
36
36
|
|
|
37
37
|
def days_hash
|
|
38
38
|
@days_hash ||= @posts.group_by { |post| post.creation.strftime('%Y-%m-%d') }
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def post_day_content(post_day)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"## #{date_header}\n#{posts_content}"
|
|
42
|
+
first_post = post_day.first
|
|
43
|
+
"## #{first_post.creation.strftime('%A, %e %B %Y')}\n#{post_day.map(&:content).join}"
|
|
45
44
|
end
|
|
46
45
|
|
|
47
46
|
def post_days_content
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Aardi
|
|
4
|
+
class HomeFooterLinks
|
|
5
|
+
def initialize(blog_path)
|
|
6
|
+
@blog_path = blog_path
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def to_s
|
|
10
|
+
"**More:** [Archive](#{archive_url}), [RSS](#{rss_url}), [JSON](#{json_url})"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def archive_url = "#{base_url}/#{Config[:blog_archive_path]}/"
|
|
16
|
+
def base_url = "#{Config[:site_url]}#{feed_base}"
|
|
17
|
+
def feed_base = @blog_path ? "/#{@blog_path}" : ''
|
|
18
|
+
def json_url = "#{base_url}/index.json"
|
|
19
|
+
def rss_url = "#{base_url}/index.xml"
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lib/aardi/json_feed.rb
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
module Aardi
|
|
4
4
|
class JSONFeed < AbstractFeed
|
|
5
5
|
def content
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
home_page_url: aardi_config[:site_url], feed_url: }
|
|
6
|
+
feed_content = { version: 'https://jsonfeed.org/version/1.1', title:,
|
|
7
|
+
home_page_url: Config[:site_url], feed_url: }
|
|
9
8
|
feed_content[:items] = @posts.map { |post| post_details(post) }
|
|
10
9
|
|
|
11
10
|
JSON.pretty_generate(feed_content)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Aardi
|
|
4
|
+
class Metadata
|
|
5
|
+
KNOWN_KEYS = %w[Title Description Creation Updated Tags].freeze
|
|
6
|
+
|
|
7
|
+
def initialize(yaml_str = '', source = nil)
|
|
8
|
+
yaml = YAML.safe_load(yaml_str, permitted_classes: [Time])
|
|
9
|
+
@yaml = {}
|
|
10
|
+
@yaml = yaml if yaml.is_a? Hash
|
|
11
|
+
confirm_keys(source)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def creation = @yaml['Creation']
|
|
15
|
+
def description = @yaml['Description']
|
|
16
|
+
def empty? = @yaml.empty?
|
|
17
|
+
def tags = @yaml['Tags']&.split&.sort
|
|
18
|
+
def title = @yaml['Title']
|
|
19
|
+
def updated = @yaml['Updated']
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def confirm_keys(source)
|
|
24
|
+
unknown = @yaml.keys - KNOWN_KEYS
|
|
25
|
+
return if unknown.empty?
|
|
26
|
+
|
|
27
|
+
unknown.each { |key| warn "Ignored unknown declaration '#{key}'#{source_location(source)}" }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def source_location(source)
|
|
31
|
+
return '' unless source
|
|
32
|
+
|
|
33
|
+
" in #{source}"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/aardi/month.rb
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Aardi
|
|
4
|
+
# :reek:TooManyInstanceVariables
|
|
4
5
|
class Month < AbstractBlog
|
|
5
|
-
def initialize(year, key, archive_path)
|
|
6
|
+
def initialize(year, key, archive_path, tag = nil)
|
|
6
7
|
@year = year
|
|
7
8
|
@key = key
|
|
8
9
|
@archive_path = archive_path
|
|
9
|
-
@index = Hash.new { |hash, day| hash[day] = Day.new(year, self, day, archive_path) }
|
|
10
|
+
@index = Hash.new { |hash, day| hash[day] = Day.new(year, self, day, archive_path, tag) }
|
|
11
|
+
@tag = tag
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
def <<(post)
|
|
13
|
-
@index[post.day] << post
|
|
15
|
+
@index[post.creation.day] << post
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
def archive_cell(month_fmt)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
return ' |' if count.zero?
|
|
20
|
+
|
|
21
|
+
"#{format(month_fmt, count:, archive_path: @archive_path, year: @year, month: self)} |"
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
def content
|
|
22
|
-
@content ||=
|
|
23
|
-
days_content = days.map { |day| "##{day.content}" }.join
|
|
24
|
-
"# #{title}\n#{days_content}"
|
|
25
|
-
end
|
|
25
|
+
@content ||= "# #{title}\n#{days.map { |day| "##{day.content}" }.join}"
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def count = days.sum(&:count)
|
|
@@ -31,12 +31,12 @@ module Aardi
|
|
|
31
31
|
"./#{@archive_path}/#{@year}/#{self}/index.html"
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
def title = Date.new(@year.key, @key).strftime('%B %Y')
|
|
35
|
-
|
|
36
34
|
def to_s = @key.to_s.rjust(2, '0')
|
|
37
35
|
|
|
38
36
|
private
|
|
39
37
|
|
|
38
|
+
def base_title = Date.new(@year.key, @key).strftime('%B %Y')
|
|
39
|
+
|
|
40
40
|
def children
|
|
41
41
|
days
|
|
42
42
|
end
|
data/lib/aardi/orphanage.rb
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
module Aardi
|
|
4
4
|
class Orphanage
|
|
5
|
-
def report
|
|
6
|
-
|
|
5
|
+
def report(html_files, generated_paths)
|
|
6
|
+
(html_files - generated_paths).each { |path| warn("Orphan: #{path}") unless ignored?(path) }
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
private
|
|
10
10
|
|
|
11
11
|
def ignored?(path)
|
|
12
|
-
Array(
|
|
12
|
+
Array(Config.fetch(:ignore_orphans)).any? { |prefix| path.start_with?(prefix) }
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|