lib/view.rb in inqlude-0.10.0 vs lib/view.rb in inqlude-0.11.0
- old
+ new
@@ -16,11 +16,11 @@
class View
attr_accessor :enable_disqus,:enable_search,:manifest,:library,:group_name,:templates
attr_reader :root
-
+
def initialize handler
@manifest_handler = handler
end
def create output_dir
@@ -29,14 +29,14 @@
system "cp #{view_dir}/favicon.ico #{output_dir}"
if templates == "two-column"
system "cp #{view_dir}/ios.ico #{output_dir}"
end
-
+
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"
create_inqlude_all(output_dir)
@@ -50,18 +50,18 @@
end
end
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 = "../"
@@ -104,12 +104,14 @@
@content = Haml::Engine.new( page ).render( binding )
output_path = ""
if file_name
output_path = "#{output_dir}/#{file_name}.html"
+ @file = file_name
else
output_path = "#{output_dir}/#{name}.html"
+ @file = name
end
File.open output_path, "w" do |file|
file.puts layout_engine.render( binding )
end
@@ -200,16 +202,32 @@
out += "(older versions: #{old_versions.join(", ")})"
out += "</span>"
end
out
end
-
+
+ def add_footer
+ if @file == "index"
+ text = 'Last updated on ' + Date.today.to_s
+ else
+ text = ""
+ end
+ out = "Inqlude is a "
+ out += link_to "KDE project", "http://kde.org"
+ out += "|"
+ out += link_to "Legal", "http://www.kde.org/community/whatiskde/impressum.php"
+ out += "<span class='footer-text'>"
+ out += text
+ out += "</span>"
+ out
+ end
+
def markup_email email
if email =~ /(.*) <(.*)>/
name = $1
email = $2
-
+
return "<a href=\"mailto:#{email}\">#{name}</a>"
else
return email
end
end
@@ -233,15 +251,15 @@
out += "<li><a href=\"#{url}\">#{text}</a></li>"
end
end
out
end
-
+
def libraries maturity = nil
@manifest_handler.libraries(maturity)
end
-
+
def unreleased_libraries
@manifest_handler.unreleased_libraries
end
def commercial_libraries
@@ -256,11 +274,11 @@
if @group_name == "kde-frameworks"
return "KDE Frameworks"
end
""
end
-
+
def group
@manifest_handler.group(@group_name)
end
def topic name
@@ -268,11 +286,11 @@
end
def no_of_libraries topic
@manifest_handler.no_of_libraries(topic)
end
-
+
def disqus_enabled?
@enable_disqus
end
def more_urls?
@@ -284,11 +302,11 @@
end
end
end
return false
end
-
+
def editor_url
url = "https://github.com/cornelius/inqlude-data/blob/master/"
url += @manifest.name
url += "/#{@manifest.name}.#{@manifest.release_date}.manifest"
url
@@ -307,14 +325,14 @@
def topics
['API', 'Artwork', 'Bindings', 'Communication', 'Data', 'Desktop', 'Development', 'Graphics', 'Logging', 'Mobile', 'Multimedia', 'Printing', 'QML', 'Scripting', 'Security', 'Text', 'Web', 'Widgets']
end
private
-
+
def assert_dir name
Dir::mkdir name unless File.exists? name
- end
-
+ end
+
def template name
File.read( view_dir + "#{name}.html.haml" )
end
def view_dir