Permalink
Browse files

* Starting in on the classes..

  • Loading branch information...
1 parent f94497a commit 9eb7036350a6bdef8b116e1453a2142790dbe3ef Erik Hollensbe committed Jul 8, 2010
Showing with 48 additions and 20 deletions.
  1. +38 −6 lib/hanna/hanna.rb
  2. +10 −14 lib/hanna/template_files/page.haml
View
@@ -116,10 +116,11 @@ def generate_file_files
values = {
:file => file,
+ :entry => file,
:stylesheet => stylesheet,
:classmod => nil,
:title => file.base_name,
- :list_title => nil,
+ :list_title => file.base_name,
:description => file.description
}
@@ -135,6 +136,36 @@ def generate_file_files
end
end
+ def generate_class_files
+ class_page = haml_file(templjoin(CLASS_PAGE))
+ # FIXME refactor
+
+ @classes.each do |klass|
+ outfile = classfile(klass)
+ stylesheet = Pathname.new(STYLE_OUT).relative_path_from(outfile.dirname)
+
+ values = {
+ :file => klass.path,
+ :entry => klass,
+ :stylesheet => stylesheet,
+ :classmod => klass.type,
+ :title => klass.full_name,
+ :list_title => nil,
+ :description => klass.description
+ }
+
+ result = with_layout(values) { class_page.to_html(binding, :values => values) { '' } }
+
+ # FIXME XXX sanity check
+ dir = outfile.dirname
+ unless File.directory? dir
+ FileUtils.mkdir_p dir
+ end
+
+ File.open(outfile, 'w') { |f| f << result }
+ end
+ end
+
def with_layout(values)
layout = haml_file(templjoin(LAYOUT))
layout.to_html(binding, :values => values) { yield }
@@ -190,7 +221,7 @@ def render_class_tree(entries, parent=nil)
out << '<li>'
- out << link_to(text, File.join(CLASS_DIR, klass.full_name.split('::')) + '.html')
+ out << link_to(text, classfile(klass))
if subentries = @classes.select { |x| x.full_name =~ /^#{klass.full_name}::/ }
subentries.each { |x| namespaces[x.full_name] = true }
@@ -237,10 +268,11 @@ def link_to_method(entry, url = nil, classname = nil)
module_name = entry.parent_name
link_to %Q(<span class="method_name">#{h method_name}</span> <span class="module_name">(#{h module_name})</span>), url, classname
end
-
- #########
- protected
- #########
+
+ def classfile(klass)
+ # FIXME sloooooooow
+ Pathname.new(File.join(CLASS_DIR, klass.full_name.split('::')) + '.html')
+ end
def outjoin(name)
File.join(@outputdir, name)
@@ -1,13 +1,13 @@
- file_page = !values[:classmod]
-- title_in_description = values[:file].description && values[:file].description =~ /^\s*<h1>/m
+- title_in_description = values[:entry].description && values[:entry].description =~ /^\s*<h1>/m
.header
- title = capture_haml do
- if file_page
= values[:file].name
- else
%span.type= values[:classmod]
- = values[:file].path
+ = values[:entry].full_name
- if title_in_description
.name= title
- else
@@ -16,32 +16,28 @@
- if file_page
.paths
= values[:file].relative_name
- -#- if values[:cvsurl]
- -#== (#{link_to 'view online', values[:cvsurl]})
- else
%ol.paths
- - values[:infiles].each_with_index do |file, index|
+ - values[:entry].in_files.each_with_index do |file, index|
%li{ :class => index > 0 ? 'other' : nil }
- = link_to file[:full_path], file[:full_path_url]
- - if file[:cvsurl]
- == (#{link_to 'view online', file[:cvsurl]})
- - if values[:infiles].size > 1
+ = link_to file.full_name, file.full_name
+ - if values[:entry].in_files.size > 1
%li
%a.show{ :href => '#', :onclick => 'this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false' } show all
- - if values[:file].parent
+ - if values[:entry].parent
.parent
Parent:
- %strong= link_to values[:file].parent, values[:file].parent.name
+ %strong= link_to values[:entry].parent, values[:entry].parent.name
- - if values[:dtm_modified]
+ - if values[:entry].respond_to?(:last_modified) and values[:entry].last_modified
.last-update
Last Update:
- %span.datetime= values[:dtm_modified]
+ %span.datetime= values[:entry].last_modified
#content
#text
- if values[:description]
#description~ sanitize_code_blocks frame_link values[:description]
- = sanitize_code_blocks frame_link yield
+ = frame_link yield

0 comments on commit 9eb7036

Please sign in to comment.