Class: Ichiban::HTMLFile

Inherits:
ProjectFile show all
Defined in:
lib/ichiban/project_file.rb

Instance Attribute Summary

Attributes inherited from ProjectFile

#abs, #rel

Instance Method Summary collapse

Methods inherited from ProjectFile

#dest, from_abs, #has_dest?, #initialize, register_type, #rel_to, #replace_ext

Constructor Details

This class inherits a constructor from Ichiban::ProjectFile

Instance Method Details

#dest_rel_to_compiledObject



68
69
70
71
# File 'lib/ichiban/project_file.rb', line 68

def dest_rel_to_compiled
  d = @rel.slice('html/'.length..-1)
  (d.end_with?('.markdown') or d.end_with?('.md')) ? replace_ext(d, 'html') : d
end

#updateObject



73
74
75
# File 'lib/ichiban/project_file.rb', line 73

def update
  Ichiban::HTMLCompiler.new(self).compile
end

#web_pathObject



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/ichiban/project_file.rb', line 77

def web_path
  d = dest_rel_to_compiled
  fname = File.basename(d, File.extname(d))
  if fname == 'index'
    # If this is an index file, the web path is just the folder name.
    '/' + File.dirname(d) + '/'
  else
    p = '/' + File.join(File.dirname(d), fname) + '/'
    p.sub!('/./', '/') if p.start_with?('/./')
    p
  end
end