petrify 0.4.1 → 0.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 94f71745111149308518a17e071ea3a12a53f79240abdd7d529d7d833d6e8eb0
4
- data.tar.gz: 26009fb5255c181893c404d77686c192773a132632e5da85517ad5fed3ba3e9f
2
+ SHA1:
3
+ metadata.gz: 6c086ef4cd464da1a9ef636ea37412ff44971678
4
+ data.tar.gz: 901f9b8fbe04b7c88ff912ce97cd1ca67acf87d8
5
5
  SHA512:
6
- metadata.gz: 63aee6c19e3233cc598fdf88521050c5f28edf5afd6f1a7294860ee411683d15f1b454b71ecbbebe8f0ee7f8b5f902e10f9d21032148b8a4e32289db8a17afc0
7
- data.tar.gz: cd71782936abc7c19641394c59ab73fe00666aa99549ea0e55e813c72055616926e511bf86d27772943711957b426707b2632eba76641bbcb051509550013bef
6
+ metadata.gz: 0c875f3552659e165a733b04bea2c622bae1b4187cb114d65c1f078401200be8e40ff440d4faa58be270bc040801faa0935d7399319f953fc159d041534e123c
7
+ data.tar.gz: a6b05544836e62ff26ac486723b2af99bad66d8c89ff650ac3079383848adcceb4ad5466995f01b65cff34a82d37772c5b21f37329091f8c7acc8593463f9f42
@@ -8,6 +8,7 @@ module Petrify
8
8
  @@working_dir = File.join(Dir.pwd, @@output_dir)
9
9
  @@views_dir = 'views'
10
10
  @@layout_fn = File.join(@@views_dir, 'layout.haml')
11
+ @@sitemap = []
11
12
 
12
13
  # https://stackoverflow.com/questions/917566/ruby-share-logger-instance-among-module-classes#6768164
13
14
  @@log = Logger.new($stdout)
@@ -24,9 +25,8 @@ module Petrify
24
25
  end
25
26
 
26
27
  File.write(fn, html)
28
+ add_to_sitemap(fn)
27
29
  @@log.info fn
28
- # TODO - add page to sitemap.xml or sitemap.txt
29
- # https://support.google.com/webmasters/answer/183668?hl=en&ref_topic=4581190
30
30
  end
31
31
 
32
32
  # Write a CSV file from an array of hashes (or an empty array)
@@ -45,6 +45,7 @@ module Petrify
45
45
  end
46
46
 
47
47
  File.write(fn, csv_string)
48
+ add_to_sitemap(fn)
48
49
  @@log.info fn
49
50
  end
50
51
 
@@ -54,6 +55,26 @@ module Petrify
54
55
  fn = File.join(dir, filename)
55
56
  File.write(fn, data)
56
57
  @@log.info fn
58
+ add_to_sitemap(fn) unless filename == 'sitemap.txt'
59
+ end
60
+
61
+ # Output a sitemap text file to the site root
62
+ def self.sitemap(baseurl)
63
+ # Add trailing slash to baseurl unless there's already one there
64
+ baseurl += '/' unless baseurl.match(/\/$/)
65
+
66
+ data = []
67
+ @@sitemap.each do |fn|
68
+ data << baseurl + fn
69
+ end
70
+
71
+ file('.', 'sitemap.txt', data.join("\n"))
72
+ end
73
+
74
+ def self.add_to_sitemap(fn)
75
+ path_bits = fn.split('/')[1..-1]
76
+ path_bits.pop if path_bits[-1] == 'index.html'
77
+ @@sitemap << File.join(path_bits)
57
78
  end
58
79
 
59
80
  def self.setup
@@ -1,3 +1,3 @@
1
1
  module Petrify
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.licenses = ['MIT']
12
12
  spec.summary = %q{A data(base)-driven static site generator with Haml templates.}
13
13
  #spec.description = %q{TODO: Write a longer description or delete this line.}
14
- spec.homepage = "https://git.adrianshort.org/adrianshort/petrify"
14
+ spec.homepage = "https://git.adrianshort.org/adrian/petrify"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
17
  f.match(%r{^(test|spec|features)/})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: petrify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Short
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-13 00:00:00.000000000 Z
11
+ date: 2020-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -69,7 +69,7 @@ files:
69
69
  - lib/petrify.rb
70
70
  - lib/petrify/version.rb
71
71
  - petrify.gemspec
72
- homepage: https://git.adrianshort.org/adrianshort/petrify
72
+ homepage: https://git.adrianshort.org/adrian/petrify
73
73
  licenses:
74
74
  - MIT
75
75
  metadata: {}
@@ -88,7 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
- rubygems_version: 3.0.2
91
+ rubyforge_project:
92
+ rubygems_version: 2.5.2.3
92
93
  signing_key:
93
94
  specification_version: 4
94
95
  summary: A data(base)-driven static site generator with Haml templates.