def setup_path(dir = nil)
      dir ||= chapter.path
      dir = Tools.valid_path_name(dir)
      name = self.name.tr('/', '')
      file = Dir.entries(dir).find { |f| f[name] } if Dir.exist?(dir)
      path = Tools.file_join(dir, file || name)
      @path = Tools.relative_or_absolute_path(path)
    end
def setup_path(dir = nil)
      dir ||= chapter.path
      dir = Tools.valid_path_name(dir)
      name = self.name.tr('/', '')
      file = Dir.entries(dir).find { |f| f[name] } if Dir.exist?(dir)
      path = Tools.file_join(dir, file || name)
      @path = Tools.relative_or_absolute_path(path)
    end
Set path of page to file path if a file exists or to path
 without file extension if file is not found. File extensions
 are appended only after the file has been downloaded.