2016-05-16 19:29:04 +02:00
|
|
|
require_relative 'osia_helper'
|
2016-05-13 16:58:49 +02:00
|
|
|
require 'date'
|
2016-05-11 16:22:10 +02:00
|
|
|
|
2016-05-13 17:50:39 +02:00
|
|
|
README = 'README.md'
|
2016-05-11 16:22:10 +02:00
|
|
|
|
2016-05-13 18:22:57 +02:00
|
|
|
ARCHIVE = 'ARCHIVE.md'
|
|
|
|
ARCHIVE_TAG = 'archive'
|
|
|
|
|
2017-06-14 23:07:35 +02:00
|
|
|
APPSTORE = 'APPSTORE.md'
|
|
|
|
|
2016-05-13 18:22:57 +02:00
|
|
|
def apps_archived(apps)
|
|
|
|
a = apps.select {|a| a['tags'] != nil }.select {|b| b['tags'].include?ARCHIVE_TAG}
|
2017-03-28 19:11:16 +02:00
|
|
|
a.sort_by { |k, v| k['title'].downcase }
|
2016-05-13 18:22:57 +02:00
|
|
|
end
|
|
|
|
|
2016-05-11 16:22:10 +02:00
|
|
|
def apps_for_cat(apps, id)
|
2016-05-13 18:22:57 +02:00
|
|
|
f = apps.select do |a|
|
|
|
|
|
|
|
|
tags = a['tags']
|
|
|
|
if tags.nil?
|
|
|
|
true
|
|
|
|
else
|
|
|
|
!(tags.include? ARCHIVE_TAG)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
s = f.select do |a|
|
2016-08-25 16:35:26 +02:00
|
|
|
cat = a['category-ids']
|
2016-05-11 17:07:03 +02:00
|
|
|
cat.class == Array ? cat.include?(id) : (cat == id)
|
|
|
|
end
|
2016-06-12 06:06:12 +02:00
|
|
|
s.sort_by { |k, v| k['title'].downcase }
|
2016-05-11 17:07:03 +02:00
|
|
|
end
|
|
|
|
|
2017-06-14 23:07:35 +02:00
|
|
|
def output_apps(apps, appstoreonly)
|
2016-05-11 16:22:10 +02:00
|
|
|
o = ''
|
2016-05-11 17:07:03 +02:00
|
|
|
apps.each do |a|
|
2016-09-03 03:39:38 +02:00
|
|
|
name = a['title']
|
|
|
|
link = a['source']
|
|
|
|
itunes = a['itunes']
|
|
|
|
homepage = a['homepage']
|
|
|
|
desc = a['description']
|
|
|
|
tags = a['tags']
|
|
|
|
stars = a['stars']
|
|
|
|
lang = a['lang']
|
2016-05-11 16:22:10 +02:00
|
|
|
|
2016-09-03 03:39:38 +02:00
|
|
|
date_added = a['date_added']
|
|
|
|
screenshots = a['screenshots']
|
|
|
|
license = a['license']
|
2016-07-28 17:15:37 +02:00
|
|
|
|
2016-09-03 03:39:38 +02:00
|
|
|
t = "#{name}"
|
2016-05-11 16:22:10 +02:00
|
|
|
|
2016-09-03 03:39:38 +02:00
|
|
|
if desc.nil?
|
|
|
|
t << ' '
|
|
|
|
else
|
|
|
|
t << ": #{desc} " if desc.size>0
|
|
|
|
end
|
|
|
|
|
|
|
|
unless itunes.nil?
|
|
|
|
t << "[` App Store`](#{itunes}) "
|
|
|
|
end
|
2017-06-14 23:07:35 +02:00
|
|
|
|
|
|
|
if appstoreonly
|
|
|
|
next if itunes.nil?
|
|
|
|
end
|
|
|
|
|
2016-09-03 03:39:38 +02:00
|
|
|
o << "- #{t} \n"
|
|
|
|
|
2017-03-21 21:44:52 +01:00
|
|
|
o << " <details><summary>"
|
2016-09-03 03:39:38 +02:00
|
|
|
|
|
|
|
details = if tags.nil?
|
2017-03-21 21:44:52 +01:00
|
|
|
'<code>objc</code> '
|
2016-09-03 03:39:38 +02:00
|
|
|
else
|
|
|
|
''
|
|
|
|
end
|
|
|
|
|
|
|
|
unless tags.nil?
|
2017-03-21 21:44:52 +01:00
|
|
|
details << '<code>swift</code> ' if tags.include? 'swift'
|
2016-05-11 16:22:10 +02:00
|
|
|
|
2016-09-03 03:39:38 +02:00
|
|
|
tags.each do |t|
|
2017-03-21 21:44:52 +01:00
|
|
|
details << "<code>#{t.downcase}</code> " if t.downcase!='swift'
|
2016-05-11 16:22:10 +02:00
|
|
|
end
|
2016-09-03 03:39:38 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
unless lang.nil?
|
|
|
|
details << output_flag(lang)
|
|
|
|
details << ' '
|
|
|
|
end
|
|
|
|
|
|
|
|
unless stars.nil?
|
|
|
|
details << output_stars(stars)
|
|
|
|
end
|
|
|
|
o << details
|
|
|
|
|
|
|
|
o << "</summary>"
|
|
|
|
|
|
|
|
details_list = []
|
|
|
|
|
|
|
|
details_list.push link
|
|
|
|
|
|
|
|
unless homepage.nil?
|
|
|
|
details_list.push homepage
|
|
|
|
end
|
2016-05-11 16:22:10 +02:00
|
|
|
|
2016-09-03 03:39:38 +02:00
|
|
|
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?
|
|
|
|
license_display = license=='other'? "`#{license}`" : "[`#{license}`](http://choosealicense.com/licenses/#{license}/)"
|
|
|
|
details_list.push "License: #{license_display}"
|
|
|
|
end
|
|
|
|
|
2017-03-21 21:44:52 +01:00
|
|
|
details = "\n\n "
|
2016-09-03 03:39:38 +02:00
|
|
|
details << details_list[0]
|
|
|
|
details_list[1..-1].each { |x| details << "<br> #{x}" }
|
|
|
|
|
|
|
|
unless screenshots.nil?
|
2017-03-21 21:44:52 +01:00
|
|
|
details << "\n <div>"
|
2016-09-03 03:39:38 +02:00
|
|
|
screenshots.each_with_index do |s, i|
|
|
|
|
details << "<img height='300' alt='#{name} image #{i+1}' src='#{screenshots[i]}'> "
|
2016-07-28 17:15:37 +02:00
|
|
|
end
|
2016-09-03 03:39:38 +02:00
|
|
|
details << "\n</div>"
|
|
|
|
end
|
|
|
|
|
2017-03-21 21:44:52 +01:00
|
|
|
details << "\n </details>\n\n"
|
2016-09-03 03:39:38 +02:00
|
|
|
o << details
|
2016-05-11 16:22:10 +02:00
|
|
|
end
|
|
|
|
o
|
|
|
|
end
|
|
|
|
|
2016-08-08 22:20:47 +02:00
|
|
|
def output_badges(count)
|
|
|
|
date = DateTime.now
|
|
|
|
date_display = date.strftime "%B %e, %Y"
|
2017-03-21 15:51:59 +01:00
|
|
|
date_display = date_display.gsub ' ', '%20'
|
2016-08-08 22:20:47 +02:00
|
|
|
|
|
|
|
b = "![](https://img.shields.io/badge/Projects-#{count}-green.svg) [![](https://img.shields.io/badge/Twitter-@opensourceios-blue.svg)](https://twitter.com/opensourceios) ![](https://img.shields.io/badge/Updated-#{date_display}-lightgrey.svg)"
|
|
|
|
b
|
|
|
|
end
|
|
|
|
|
2016-05-16 19:29:04 +02:00
|
|
|
def output_flag(lang)
|
|
|
|
case lang
|
2016-08-24 16:07:27 +02:00
|
|
|
when 'deu'
|
2016-05-31 16:22:29 +02:00
|
|
|
'🇩🇪'
|
2016-10-14 15:37:21 +02:00
|
|
|
when 'fra'
|
|
|
|
'🇫🇷'
|
2016-05-16 19:29:04 +02:00
|
|
|
when 'jpn'
|
|
|
|
'🇯🇵'
|
|
|
|
when 'ltz'
|
|
|
|
'🇱🇺'
|
2016-05-20 17:28:20 +02:00
|
|
|
when 'nld'
|
|
|
|
'🇳🇱'
|
2016-05-16 19:29:04 +02:00
|
|
|
when 'por'
|
2016-07-18 17:26:17 +02:00
|
|
|
'🇵🇹'
|
2016-05-16 19:29:04 +02:00
|
|
|
when 'spa'
|
|
|
|
'🇪🇸'
|
2016-10-27 16:19:25 +02:00
|
|
|
when 'rus'
|
|
|
|
'🇷🇺'
|
2016-05-16 19:29:04 +02:00
|
|
|
when 'zho'
|
|
|
|
'🇨🇳'
|
|
|
|
else
|
|
|
|
''
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def output_stars(number)
|
|
|
|
case number
|
|
|
|
when 100...200
|
|
|
|
'🔥'
|
|
|
|
when 200...500
|
|
|
|
'🔥🔥'
|
|
|
|
when 500...1000
|
|
|
|
'🔥🔥🔥'
|
|
|
|
when 1000...2000
|
|
|
|
'🔥🔥🔥🔥'
|
|
|
|
when 2000...100000
|
|
|
|
'🔥🔥🔥🔥🔥'
|
|
|
|
else
|
|
|
|
''
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-06-14 23:44:45 +02:00
|
|
|
def write_list(j, file, appstoreonly = false)
|
2016-05-13 17:50:39 +02:00
|
|
|
t = j['title']
|
2016-08-08 22:20:47 +02:00
|
|
|
subt = j['subtitle']
|
2017-06-15 18:20:00 +02:00
|
|
|
|
|
|
|
desc = if appstoreonly
|
|
|
|
'List of open-source apps published on the App Store (complete list [here](https://github.com/dkhamsing/open-source-ios-apps))'
|
|
|
|
else
|
|
|
|
j['description']
|
|
|
|
end
|
|
|
|
|
2016-05-13 17:50:39 +02:00
|
|
|
h = j['header']
|
|
|
|
f = j['footer']
|
|
|
|
cats = j['categories']
|
|
|
|
apps = j['projects']
|
2016-05-11 16:22:10 +02:00
|
|
|
|
2016-05-13 17:50:39 +02:00
|
|
|
output = '# ' + t
|
|
|
|
output << "\n\n"
|
2017-06-15 18:20:00 +02:00
|
|
|
output << desc
|
2017-06-14 23:07:35 +02:00
|
|
|
|
|
|
|
if appstoreonly == false
|
|
|
|
output << "\n\n#{subt}\n\n"
|
|
|
|
output << output_badges(apps.count)
|
|
|
|
end
|
2016-05-13 16:58:49 +02:00
|
|
|
|
2016-08-09 14:58:50 +02:00
|
|
|
output << "\n\nJump to\n\n"
|
2016-05-13 16:58:49 +02:00
|
|
|
|
2016-05-13 17:50:39 +02:00
|
|
|
cats.each do |c|
|
2016-06-06 18:00:38 +02:00
|
|
|
title = c['title']
|
|
|
|
m = title.match /\[.*?\]/
|
|
|
|
title = m[0].sub('[', '').sub(']', '') unless m.nil?
|
|
|
|
temp = "#{' ' unless c['parent']==nil }- [#{title}](\##{c['id']}) \n"
|
2016-05-13 17:50:39 +02:00
|
|
|
output << temp
|
|
|
|
end
|
2016-05-11 16:22:10 +02:00
|
|
|
|
2016-07-29 17:18:19 +02:00
|
|
|
output << "- [Thanks](#thanks)\n"
|
|
|
|
output << "- [Contact](#contact)\n"
|
|
|
|
|
2016-05-13 17:50:39 +02:00
|
|
|
output << "\n"
|
|
|
|
output << h
|
|
|
|
output << "\n"
|
2016-05-11 16:22:10 +02:00
|
|
|
|
2016-05-13 17:50:39 +02:00
|
|
|
cats.each do |c|
|
|
|
|
temp = "\n#\##{'#' unless c['parent']==nil } #{c['title']} \n \n"
|
2016-05-11 16:22:10 +02:00
|
|
|
|
2016-05-13 17:50:39 +02:00
|
|
|
d = c['description']
|
|
|
|
temp << "#{d} — " unless d.nil?
|
2016-05-11 19:53:59 +02:00
|
|
|
|
2016-05-13 17:50:39 +02:00
|
|
|
temp << "[back to top](#readme) \n \n"
|
|
|
|
output << temp
|
2016-05-11 19:53:59 +02:00
|
|
|
|
2016-05-13 17:50:39 +02:00
|
|
|
cat_apps = apps_for_cat(apps, c['id'])
|
2017-06-14 23:07:35 +02:00
|
|
|
output << output_apps(cat_apps, appstoreonly)
|
2016-05-13 17:50:39 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
output << "\n"
|
|
|
|
output << f
|
2016-05-11 16:22:10 +02:00
|
|
|
|
2017-06-14 23:07:35 +02:00
|
|
|
File.open(file, 'w') { |f| f.write output }
|
|
|
|
puts "wrote #{file} ✨"
|
2016-05-11 16:22:10 +02:00
|
|
|
end
|
|
|
|
|
2016-05-13 18:22:57 +02:00
|
|
|
def write_archive(j)
|
|
|
|
t = j['title']
|
|
|
|
desc = "This is an archive of the [main list](https://github.com/dkhamsing/open-source-ios-apps) for projects that are no longer maintained / old.\n\n"
|
|
|
|
f = "## Contact\n\n- [github.com/dkhamsing](https://github.com/dkhamsing)\n- [twitter.com/dkhamsing](https://twitter.com/dkhamsing)\n"
|
|
|
|
apps = j['projects']
|
|
|
|
archived = apps_archived apps
|
|
|
|
|
|
|
|
output = "\# #{t} Archive\n\n"
|
|
|
|
output << desc
|
|
|
|
|
|
|
|
archived.each do |a|
|
|
|
|
t = a['title']
|
|
|
|
s = a['source']
|
|
|
|
output << "- #{t} #{s}\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
output << "\n"
|
|
|
|
output << f
|
|
|
|
|
|
|
|
file = ARCHIVE
|
|
|
|
File.open(file, 'w') { |f| f.write output }
|
|
|
|
puts "wrote #{file} ✨"
|
|
|
|
end
|
|
|
|
|
2016-05-16 19:29:04 +02:00
|
|
|
j = get_json
|
2016-05-11 16:22:10 +02:00
|
|
|
|
2017-06-14 23:44:45 +02:00
|
|
|
write_list(j, README)
|
2016-05-13 18:22:57 +02:00
|
|
|
write_archive(j)
|
2017-06-14 23:44:45 +02:00
|
|
|
write_list(j, APPSTORE, true)
|