#!/usr/bin/ruby # VARIABLES # TEMPLATE_DIR = "#{ENV["HOME"]}/templates/" SELF_DIR = "#{ENV["HOME"]}/writing/" # GENERATE TEMPLATES # def gen_templates(path) base_path = path.split('.').first html_path = base_path + '.html' gemtext_path = base_path + '.gmi' name = base_path.split('/').last html_template = "#{html_path} ;;HTML_HEADER;;#{name};;
;;TO_HTML;;#{path};;
back home
||HTML_FOOTER|| " gemtext_template = "#{gemtext_path} ;;TO_GEMTEXT;;#{path};; ---------------------- => ../ back => /~de_alchmst home " File.write(File.join(TEMPLATE_DIR, "writing." + html_path.split(SELF_DIR) .last.gsub('/', '.') + '.template'), html_template) File.write(File.join(TEMPLATE_DIR, "writing." + gemtext_path.split(SELF_DIR) .last.gsub('/', '.') + '.template'), gemtext_template) end # HANDLE DIRECTORIES RECURSIVELY # def handle_dir(path) Dir.children(path).each { |child| full_path = File.join(path, child) if File.directory? full_path handle_dir full_path elsif child.match(/.*\.moml/) gen_templates full_path end } end # start from the beginning handle_dir SELF_DIR