summaryrefslogtreecommitdiff
path: root/util.rb
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-08-27 17:36:46 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-08-27 17:36:46 -0400
commitb373a3a6e1702e7514bb405122a2311d16d85fcd (patch)
tree1b8ededef1b8ac60ec3b1a8a347cfc1669f61bb1 /util.rb
parentd4359dc767d3524a16f529f3545d89ab558e1b8f (diff)
Teach it to make atom:entry files
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