summaryrefslogtreecommitdiff
path: root/util.rb
diff options
context:
space:
mode:
Diffstat (limited to 'util.rb')
-rw-r--r--util.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/util.rb b/util.rb
new file mode 100644
index 0000000..f7bd1b9
--- /dev/null
+++ b/util.rb
@@ -0,0 +1,51 @@
+class Person
+ def initialize(name)
+ @name = name
+ end
+ def name
+ @name
+ end
+ def uri
+ $person_uris[@name]
+ end
+ def email
+ $person_emails[@name]
+ end
+ def html
+ if not email.nil?
+ return "<a href=\"mailto:#{email}\">#{name}</a>"
+ elsif not uri.nil?
+ return "<a href=\"#{uri}\">#{name}</a>"
+ else
+ return @name
+ end
+ end
+ def atom
+ ret = ""
+ ret += "<name>#{name}</name>" unless name.nil?
+ ret += "<uri>#{uri}</uri>" unless uri.nil?
+ ret += "<email>#{email}</email>" unless email.nil?
+ end
+end
+
+class License
+ def initialize(name)
+ @name = name
+ end
+ def name
+ @name
+ end
+ def url
+ $license_urls[@name]
+ end
+ def html
+ "<a href=\"#{url}\">#{name}</a>"
+ end
+end
+
+def html_escape(html)
+ html
+ .gsub('&', '&amp;')
+ .gsub('>', '&gt;')
+ .gsub('<', '&lt;')
+end