lib/view.rb in inqlude-0.0.8 vs lib/view.rb in inqlude-0.7.0

- old
+ new

@@ -14,12 +14,11 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. class View - attr_accessor :enable_disqus - attr_accessor :enable_search + attr_accessor :enable_disqus,:enable_search,:manifest,:library,:group_name attr_reader :root def initialize handler @manifest_handler = handler end @@ -27,30 +26,49 @@ def create output_dir puts "Creating web site in '#{output_dir}' from '#{@manifest_handler.settings.manifest_path}'" assert_dir output_dir + system "cp #{view_dir}/favicon.ico #{output_dir}" + assert_dir "#{output_dir}/public" system "cp #{view_dir}/public/* #{output_dir}/public/" + + assert_dir "#{output_dir}/schema" + system "cp #{schema_dir}/* #{output_dir}/schema" @root = "" render_template "index", output_dir - render_template "edge", output_dir + render_template "development", output_dir + render_template "unreleased", output_dir + render_template "commercial", output_dir + render_template "all", output_dir render_template "about", output_dir render_template "get", output_dir render_template "contribute", output_dir render_template "search", output_dir + + groups_path = "#{output_dir}/groups/" + assert_dir groups_path + + @root = "../" + + @group_name = "kde-frameworks" + file_name = "groups/kde-frameworks" + render_template "group", output_dir, file_name + + library_path = "#{output_dir}/libraries/" assert_dir library_path @root = "../" @manifest_handler.libraries.each do |library| @library = library - @manifest = library.manifests.last + @manifest = library.latest_manifest file_name = "libraries/" + library.name render_template "library", output_dir, file_name end end @@ -88,11 +106,11 @@ @manifest[ attr ] end end def link_to_manifest name - "<a href=\"libraries/#{name}.html\">#{name}</a>" + "<a href=\"#{@root}libraries/#{name}.html\">#{name}</a>" end def link url "<a href=\"#{url}\" target=\"_blank\">#{url}</a>" end @@ -131,10 +149,13 @@ out += "</div>" out end def version_content + if @manifest["schema_type"] == "generic" + raise "Can't get version for generic manifest '#{@manifest["name"]}'" + end out = @manifest["version"] out += " (#{@manifest["maturity"]})" out += "<span class='release-date'>" out += "released on #{@manifest["release_date"]}" out += "</span>" @@ -183,11 +204,30 @@ if @manifest_handler.libraries(maturity).empty? @manifest_handler.read_remote end @manifest_handler.libraries(maturity) end + + def unreleased_libraries + @manifest_handler.unreleased_libraries + end + def commercial_libraries + @manifest_handler.commercial_libraries + end + + def group_title + if @group_name == "kde-frameworks" + return "KDE Frameworks" + end + "" + end + + def group + @manifest_handler.group(@group_name) + end + def disqus_enabled? @enable_disqus end def more_urls? @@ -207,18 +247,19 @@ url += "/#{@manifest["name"]}.#{@manifest["release_date"]}.manifest" url end def old_versions - versions = Array.new - count = @library.manifests.count - if count > 1 - versions = @library.manifests[0..count-2].map {|m| m["version"] } - end + versions = @library.versions.reject{ |v| v == @manifest["version"] } versions.reverse end + def render_description + doc = Kramdown::Document.new(@manifest["description"]) + doc.to_html + end + private def assert_dir name Dir::mkdir name unless File.exists? name end @@ -227,8 +268,12 @@ File.read( view_dir + "#{name}.html.haml" ) end def view_dir File.expand_path( File.dirname( __FILE__ ) + "/../view/" ) + "/" + end + + def schema_dir + File.expand_path( File.dirname( __FILE__ ) + "/../schema/" ) + "/" end end