From 4c3f03c1a7c622c3e92081664b42c96831b43dca Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 23 Dec 2017 15:02:32 -0500 Subject: Let LocalPage::load decide how to handle different file types --- config.yaml | 1 - lib/page_index.rb | 6 ++++-- lib/page_local.rb | 12 ++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/config.yaml b/config.yaml index 072ba80..05a31d2 100644 --- a/config.yaml +++ b/config.yaml @@ -1,5 +1,4 @@ url: "https://www.andrewdm.me/" -html_suffixes: ["md", "org"] # Licenses default_license: "CC BY-SA-3.0" diff --git a/lib/page_index.rb b/lib/page_index.rb index 42c9e21..31d4682 100644 --- a/lib/page_index.rb +++ b/lib/page_index.rb @@ -28,13 +28,15 @@ class IndexPage < LocalPage @ls ||= Dir::entries(local_infile) .select{|fname|not fname.start_with?(".")} .map{|fname|"#{local_infile}/#{fname}"} - .select{|path|Dir::exist?(path) or Config::get.html_suffixes.include?(File::extname(path).gsub(/^[.]/, ''))} end def index_pages if @pages.nil? @pages = Set[] for path in _ls - @pages.add( Dir::exist?(path) ? IndexPage::new(path) : LocalPage::new(path) ) + page = LocalPage::load(path) + unless page.nil? + @pages.add(page) + end end for data in (_metadata['external'] || []) @pages.add(RemotePage::new(data)) diff --git a/lib/page_local.rb b/lib/page_local.rb index e13fa33..e956f6a 100644 --- a/lib/page_local.rb +++ b/lib/page_local.rb @@ -9,6 +9,18 @@ require 'pandoc' require 'person' class LocalPage < Page + def self.load(inpath) + case + when Dir::exist?(inpath) + require 'page_index' + return IndexPage::new(inpath) + when [".md", ".org"].include?(File::extname(inpath)) + return LocalPage::new(inpath) + else + return nil + end + end + def initialize(infile) @infile = infile super() -- cgit v1.2.3-54-g00ecf