aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Iezzi <aiezzi@alessandroiezzi.it>2024-04-24 12:40:28 +0200
committerAlessandro Iezzi <aiezzi@alessandroiezzi.it>2024-04-25 11:33:30 +0200
commit8fc9304e3b1185ce3140c6fac35e877aed8fbd7d (patch)
treeed19703ffb373b367e1cd5f3f38974574a7dbab5
parent7333ab41a213879d8a5f3f439a8d2cd8ebc1dbc3 (diff)
downloadhyde-8fc9304e3b1185ce3140c6fac35e877aed8fbd7d.tar.gz
hyde-8fc9304e3b1185ce3140c6fac35e877aed8fbd7d.zip
Move listarticles inside Hyde class
-rwxr-xr-xhyde.rb33
1 files changed, 16 insertions, 17 deletions
diff --git a/hyde.rb b/hyde.rb
index 828c7a2..d64872c 100755
--- a/hyde.rb
+++ b/hyde.rb
@@ -25,6 +25,22 @@ require_relative 'page.rb'
require_relative 'optparser.rb'
class Hyde
+ def self.listarticles(path, max)
+ pages = Array.new
+ Dir.glob(path).each { |file|
+ if (file.end_with?(".rhtml") && File.file?(file))
+ date = Date.parse(file.gsub(/.*\/(.*)_.*/, '\1'))
+ pages.append(Page.new(file, date))
+ max = max - 1
+ if (max == 0)
+ break
+ end
+ end
+ }
+
+ return pages
+ end
+
def self.main
# Parse arguments from the CLI
options = HydeOptionParser.parse
@@ -41,23 +57,6 @@ Considerations on file formats.
.tmpl -- Are templates, they don't need configuration files
=end
-def listarticles(path, max)
- pages = Array.new
- Dir.glob(path).each { |file|
- if (file.end_with?(".rhtml") && File.file?(file))
- config = YAML.load_file(file + '.config')
- file["rhtml"] = "html"
- date = Date.parse(file.gsub(/.*\/(.*)_.*/, '\1'))
- pages.append(Page.new(config['title'], file, nil, config['description'], date, config['classes'], nil))
- max = max - 1
- if (max == 0)
- break
- end
- end
- }
-
- return pages
-end
# Every file needs a config file. It is similar to the YAML block in head to files processed by gohugo or jekyll.
configfile = options[:fileName] + '.config'