dimples 10.1.4 → 10.2.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 +2 -4
- data/lib/dimples/config.rb +15 -15
- data/lib/dimples/pager.rb +3 -5
- data/lib/dimples/site.rb +12 -10
- data/lib/dimples/sources/base.rb +2 -2
- data/lib/dimples/sources/page.rb +2 -2
- data/lib/dimples/sources/post.rb +2 -2
- data/lib/dimples/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b82d0d0b1768cb2feeaa99bdcffdbe091e4a74464e1626ab945fa6261f44b066
|
4
|
+
data.tar.gz: 905531f3cd50da2854b43b413c69459c26c36faae05b18de53e434f9d4b8405f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34b59758473587a23629d2459c95362f12484a43f9395c6f188eb6f90adf83b648b7cab6be8e47f4755992a60e6578bc2c2906db626f132bb5bb75d4388e1533
|
7
|
+
data.tar.gz: 7caf87e0d6fe6435b9b1459b2d3a111ee5952ca6bf98b5db4f0b90752aad262f417c6ef024e02dd7a8873384a2fa18e1eaa0722cc39579e550181f459e582a7c
|
data/bin/dimples
CHANGED
@@ -12,10 +12,8 @@ config = {}
|
|
12
12
|
if File.exist?(config_path)
|
13
13
|
config = begin
|
14
14
|
YAML.safe_load_file(config_path, symbolize_names: true)
|
15
|
-
rescue
|
16
|
-
puts
|
17
|
-
ensure
|
18
|
-
{}
|
15
|
+
rescue StandardError => e
|
16
|
+
puts "Failed to parse config #{e} - using defaults"
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
data/lib/dimples/config.rb
CHANGED
@@ -3,31 +3,31 @@
|
|
3
3
|
module Dimples
|
4
4
|
# Configuration settings for a site.
|
5
5
|
class Config
|
6
|
+
SOURCE_PATHS = { pages: 'pages', posts: 'posts', layouts: 'layouts', static: 'static' }.freeze
|
7
|
+
|
8
|
+
attr_accessor :source_paths, :build_paths, :pagination
|
9
|
+
|
6
10
|
def self.defaults
|
7
11
|
{
|
8
|
-
|
9
|
-
|
12
|
+
build: './site',
|
13
|
+
pathnames: { posts: 'posts', categories: 'categories' },
|
14
|
+
pagination: { page_prefix: 'page_', per_page: 5 }
|
10
15
|
}
|
11
16
|
end
|
12
17
|
|
13
18
|
def initialize(options = {})
|
14
|
-
|
19
|
+
options = Config.defaults.merge(options)
|
15
20
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
%i[sources output].each do |type|
|
21
|
-
@options[type].each { |key, value| @options[type][key] = File.expand_path(value) }
|
22
|
-
end
|
21
|
+
@source_paths = expand_paths(File.expand_path(Dir.pwd), SOURCE_PATHS.dup)
|
22
|
+
@build_paths = expand_paths(File.expand_path(options[:build]), options[:pathnames])
|
23
|
+
@pagination = options[:pagination]
|
23
24
|
end
|
24
25
|
|
25
|
-
def
|
26
|
-
|
27
|
-
end
|
26
|
+
def expand_paths(root, paths)
|
27
|
+
root = File.expand_path(root)
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
paths.transform_values! { |value| File.expand_path(File.join(root, value)) }
|
30
|
+
paths.tap { |expanded_paths| expanded_paths[:root] = root }
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/lib/dimples/pager.rb
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
module Dimples
|
4
4
|
# A class for paginating a collection of posts.
|
5
5
|
class Pager
|
6
|
-
PER_PAGE = 5
|
7
|
-
|
8
6
|
include Enumerable
|
9
7
|
|
10
8
|
attr_reader :current_page, :previous_page, :next_page, :page_count
|
@@ -18,8 +16,8 @@ module Dimples
|
|
18
16
|
@url = url
|
19
17
|
@posts = posts
|
20
18
|
|
21
|
-
@per_page = @site.config.
|
22
|
-
@page_prefix = @site.config.
|
19
|
+
@per_page = @site.config.pagination[:per_page]
|
20
|
+
@page_prefix = @site.config.pagination[:page_prefix]
|
23
21
|
@page_count = (posts.length.to_f / @per_page.to_i).ceil
|
24
22
|
|
25
23
|
step_to(1)
|
@@ -30,7 +28,7 @@ module Dimples
|
|
30
28
|
step_to(index)
|
31
29
|
|
32
30
|
@site.layouts['posts']&.write(
|
33
|
-
File.join(@site.config[:
|
31
|
+
File.join(@site.config.build_paths[:root], current_page_url, 'index.html'),
|
34
32
|
metadata.merge(pagination: self.metadata, url: current_page_url)
|
35
33
|
)
|
36
34
|
end
|
data/lib/dimples/site.rb
CHANGED
@@ -29,19 +29,19 @@ module Dimples
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def posts
|
32
|
-
@posts ||= Dir.glob(File.join(@config[:
|
32
|
+
@posts ||= Dir.glob(File.join(@config.source_paths[:posts], '**', '*.markdown')).map do |path|
|
33
33
|
Dimples::Sources::Post.new(self, path)
|
34
34
|
end.sort_by!(&:date).reverse!
|
35
35
|
end
|
36
36
|
|
37
37
|
def pages
|
38
|
-
@pages ||= Dir.glob(File.join(@config[:
|
38
|
+
@pages ||= Dir.glob(File.join(@config.source_paths[:pages], '**', '*.erb')).map do |path|
|
39
39
|
Dimples::Sources::Page.new(self, path)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
def layouts
|
44
|
-
@layouts ||= Dir.glob(File.join(@config[:
|
44
|
+
@layouts ||= Dir.glob(File.join(@config.source_paths[:layouts], '**', '*.erb')).to_h do |path|
|
45
45
|
[File.basename(path, '.erb'), Dimples::Sources::Layout.new(self, path)]
|
46
46
|
end
|
47
47
|
end
|
@@ -65,15 +65,15 @@ module Dimples
|
|
65
65
|
|
66
66
|
def generate_posts
|
67
67
|
posts.each(&:write)
|
68
|
-
Pager.paginate(self, @config[:
|
69
|
-
generate_feed(@config[:
|
68
|
+
Pager.paginate(self, @config.build_paths[:posts].gsub(@config.build_paths[:root], '').concat('/'), posts)
|
69
|
+
generate_feed(@config.build_paths[:root], posts)
|
70
70
|
end
|
71
71
|
|
72
72
|
def generate_categories
|
73
73
|
categories.each do |category, posts|
|
74
74
|
metadata = { title: category.capitalize, category: category }
|
75
75
|
Pager.paginate(self, "/categories/#{category}/", posts, metadata)
|
76
|
-
generate_feed(File.join(@config[:
|
76
|
+
generate_feed(File.join(@config.build_paths[:root], 'categories', category), posts)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -91,15 +91,17 @@ module Dimples
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def prepare_output_directory
|
94
|
-
|
94
|
+
if Dir.exist?(@config.build_paths[:root])
|
95
|
+
raise "The site directory (#{@config.build_paths[:root]}) already exists."
|
96
|
+
end
|
95
97
|
|
96
|
-
Dir.mkdir(@config[:
|
98
|
+
Dir.mkdir(@config.build_paths[:root])
|
97
99
|
end
|
98
100
|
|
99
101
|
def copy_assets
|
100
|
-
return unless Dir.exist?(@config[:
|
102
|
+
return unless Dir.exist?(@config.source_paths[:static])
|
101
103
|
|
102
|
-
FileUtils.cp_r(File.join(@config[:
|
104
|
+
FileUtils.cp_r(File.join(@config.source_paths[:static], '.'), @config.build_paths[:root])
|
103
105
|
end
|
104
106
|
end
|
105
107
|
end
|
data/lib/dimples/sources/base.rb
CHANGED
@@ -56,11 +56,11 @@ module Dimples
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def output_directory
|
59
|
-
@site.config[:
|
59
|
+
@site.config.build_paths[:root]
|
60
60
|
end
|
61
61
|
|
62
62
|
def url_for(path)
|
63
|
-
path.gsub(@site.config[:
|
63
|
+
path.gsub(@site.config.build_paths[:root], '').concat('/')
|
64
64
|
end
|
65
65
|
|
66
66
|
def template
|
data/lib/dimples/sources/page.rb
CHANGED
@@ -6,8 +6,8 @@ module Dimples
|
|
6
6
|
class Page < Base
|
7
7
|
def output_directory
|
8
8
|
@output_directory ||= File.dirname(@path).gsub(
|
9
|
-
@site.config[:
|
10
|
-
@site.config[:
|
9
|
+
@site.config.source_paths[:pages],
|
10
|
+
@site.config.build_paths[:root]
|
11
11
|
).concat('/')
|
12
12
|
end
|
13
13
|
|
data/lib/dimples/sources/post.rb
CHANGED
@@ -6,8 +6,8 @@ module Dimples
|
|
6
6
|
class Post < Base
|
7
7
|
def output_directory
|
8
8
|
@output_directory ||= File.dirname(@path).gsub(
|
9
|
-
@site.config[:
|
10
|
-
@site.config[:
|
9
|
+
@site.config.source_paths[:posts],
|
10
|
+
@site.config.build_paths[:posts]
|
11
11
|
).concat("/#{slug}/")
|
12
12
|
end
|
13
13
|
|
data/lib/dimples/version.rb
CHANGED
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: 10.
|
4
|
+
version: 10.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Bogan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erb
|