[script] add details

This commit is contained in:
Daniel Khamsing 2016-07-28 08:15:37 -07:00
parent 88c6c1a36d
commit 3a3adde19e

View File

@ -41,6 +41,10 @@ def output_apps(apps)
stars = a['stars'] stars = a['stars']
lang = a['lang'] lang = a['lang']
date_added = a['date_added']
screenshots = a['screenshots']
license = a['license']
o << "- #{name}" o << "- #{name}"
if desc.nil? if desc.nil?
@ -49,6 +53,10 @@ def output_apps(apps)
o << ": #{desc} " if desc.size>0 o << ": #{desc} " if desc.size>0
end end
unless itunes.nil?
o << "[` App Store`](#{itunes}) "
end
unless tags.nil? unless tags.nil?
o << '`Swift` ' if tags.include? 'swift' o << '`Swift` ' if tags.include? 'swift'
end end
@ -62,9 +70,42 @@ def output_apps(apps)
end end
o << "\n" o << "\n"
o << " - #{link}\n"
o << " - #{homepage}\n" unless homepage.nil? show_details = !homepage.nil? || !screenshots.nil? || !license.nil? || !date_added.nil?
o << " - #{itunes}\n" unless itunes.nil?
if (!show_details)
o << " - #{link}\n"
else
details = " <details><summary>#{link}</summary>\n"
details_list = []
unless date_added.nil?
date = DateTime.parse(date_added)
formatted_date = date.strftime "%B %e, %Y"
details_list.push "Added #{formatted_date}"
end
unless license.nil?
details_list.push "License: `#{license}`"
end
unless homepage.nil?
details_list.push homepage
end
details << ' '
details << details_list[0]
details_list[1..-1].each { |x| details << " - #{x}" }
unless screenshots.nil?
screenshots.each_with_index do |s, i|
details << " ![#{name} image #{i+1}](#{screenshots[i]})" unless screenshots.nil?
end
end
details << "\n </details>\n"
o << details
end
end end
o o
end end