#require 'Action'
require 'erb'
OSX.require_framework "WebKit"
OSX.require_framework "Quartz"

class OutlineHTML
  
@@pageTemplate=ERB.new <<-EOF 
<html>
<head>
<title>Click Print once the outline looks how you like</title>
<link href="outline.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="todo_a.css" type="text/css" media="all" title="no title" charset="utf-8">
<script src="outline.js">
</script>
</head>

<body onLoad="outlineInit()">
<ul class="outline">
	<% projects.each do |curProject| %>
	  <%= itemRecurse(curProject) %>
	<% end %>
</ul>
</body>
</html>
EOF

@@itemTemplate=ERB.new <<-EOF
<% if @controller.filteredObjectsAndAncestors.containsObject?(project) %>
<% if project.kids != nil %>
<LI><%= project.name.to_s %></span>
<% else %>
<LI  class="<%= project.itemState %>"><span class="<%= project.actionState %>"><%= project.name.to_s %></span>
<% end %>
  <% if project.noteString != nil %>
    <UL>
		<LI class="note"><PRE><%= project.noteString.to_s %></PRE></LI>
    </UL>
  <% end %>
  <% if project.kids != nil %>
    <UL class="smaller">
    <% project.kids.each do |child| %>
		<%= itemRecurse(child) %>
	<% end %>
    </UL>
  <% end %>
</LI>
<% end %>
EOF

  def itemRecurse(project)
    @@itemTemplate.result(binding())
  end
  
  def buildHTMLForProjects(projects,browser)
	@browser=browser
	@controller=@browser.outlineController
    html = @@pageTemplate.result(binding())
  end
  
end