diff options
author | 2024-04-24 15:36:13 +0200 | |
---|---|---|
committer | 2024-04-25 11:33:30 +0200 | |
commit | 56e06420ca9b211304802118f355fb0c3139fa06 (patch) | |
tree | e364753422321a10bb7467db1594f7b8de9452e8 | |
parent | 8fc9304e3b1185ce3140c6fac35e877aed8fbd7d (diff) | |
download | hyde-56e06420ca9b211304802118f355fb0c3139fa06.tar.gz hyde-56e06420ca9b211304802118f355fb0c3139fa06.zip |
Move the config parser inside Page class
-rwxr-xr-x | hyde.rb | 17 | ||||
-rw-r--r-- | page.rb | 31 | ||||
-rwxr-xr-x | scripts/update-copiright.sh | 6 |
3 files changed, 37 insertions, 17 deletions
@@ -58,26 +58,9 @@ Considerations on file formats. =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' -if(!File.exist?(configfile) && !options[:fileName].end_with?("tmpl")) - puts 'Cannot find configuration file: ' + configfile - exit 1 -end -if(File.exist?(configfile)) - config = YAML.load_file(configfile) - if(config != nil) - title = config['title'] - pageNames = config['pageNames'] - description = config['description'] - classes = config['classes'] - master = config['master'] - category = config['category'] - end -end page = Page.new(title, options[:fileName], pageNames, description, nil, classes, category) @@ -27,6 +27,37 @@ class Page attr_reader :classes attr_reader :category + def parseConfig(configFile) + if (File.exist?(configFile)) + config = YAML.load_file(configFile) + if (config != nil) + @title = config['title'] + @pageNames = config['pageNames'] + @description = config['description'] + @classes = config['classes'] + @master = config['master'] + @category = config['category'] + if (@date == nil) + @date = config['date'] + end + if (@baseHref == nil) + @baseHref= config['baseHref'] + end + end + end + end + + attr_writer :fileName + attr_writer :title + attr_writer :pageNames + attr_writer :description + attr_writer :date + attr_writer :classes + attr_writer :category + attr_writer :master + attr_writer :content + attr_writer :baseHref + def initialize1 title, pageFileName, pageNames, description, date, classes, category @title = title @pageFileName = pageFileName diff --git a/scripts/update-copiright.sh b/scripts/update-copiright.sh new file mode 100755 index 0000000..798d6d3 --- /dev/null +++ b/scripts/update-copiright.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +for i in `grep -sE 'Copyright \(C\) 2022.*' * | sed 's/:.*//'`; do + sed -E "s/Copyright \(C\) 2022.*/Copyright (C) 2022-`date +%Y` Alessandro Iezzi <aiezzi AT alessandroiezzi DOT it>/" +done + |