[script] Display when GitHub project was updated (#931)
This commit is contained in:
parent
78cec97c84
commit
8069e0be7c
|
@ -69,6 +69,14 @@ def apps_latest(apps, num)
|
||||||
a[0..num - 1]
|
a[0..num - 1]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def apps_updated(apps, num)
|
||||||
|
a = apps.select { |a| a['updated'] != nil }
|
||||||
|
.sort_by { |k, v| DateTime.parse(k['updated']) }
|
||||||
|
.reverse
|
||||||
|
|
||||||
|
a[0..num - 1]
|
||||||
|
end
|
||||||
|
|
||||||
def output_apps(apps, appstoreonly)
|
def output_apps(apps, appstoreonly)
|
||||||
o = ''
|
o = ''
|
||||||
apps.each do |a|
|
apps.each do |a|
|
||||||
|
@ -82,6 +90,7 @@ def output_apps(apps, appstoreonly)
|
||||||
lang = a['lang']
|
lang = a['lang']
|
||||||
|
|
||||||
date_added = a['date_added']
|
date_added = a['date_added']
|
||||||
|
date_updated = a['updated']
|
||||||
screenshots = a['screenshots']
|
screenshots = a['screenshots']
|
||||||
license = a['license']
|
license = a['license']
|
||||||
|
|
||||||
|
@ -118,6 +127,13 @@ def output_apps(apps, appstoreonly)
|
||||||
unless stars.nil?
|
unless stars.nil?
|
||||||
details << output_stars(stars)
|
details << output_stars(stars)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless date_updated.nil?
|
||||||
|
date = DateTime.parse(date_updated)
|
||||||
|
formatted_date = date.strftime "%Y"
|
||||||
|
details << "<code>#{formatted_date}</code> "
|
||||||
|
end
|
||||||
|
|
||||||
o << details
|
o << details
|
||||||
|
|
||||||
o << "</summary>"
|
o << "</summary>"
|
||||||
|
@ -129,8 +145,8 @@ def output_apps(apps, appstoreonly)
|
||||||
|
|
||||||
unless date_added.nil?
|
unless date_added.nil?
|
||||||
date = DateTime.parse(date_added)
|
date = DateTime.parse(date_added)
|
||||||
formatted_date = date.strftime "%B %e, %Y"
|
formatted_date = date.strftime "%B %Y"
|
||||||
details_list.push "Added #{formatted_date}"
|
details_list.push "Added: `#{formatted_date}`"
|
||||||
end
|
end
|
||||||
|
|
||||||
unless license.nil?
|
unless license.nil?
|
||||||
|
@ -213,14 +229,14 @@ def write_archive(j, subtitle)
|
||||||
puts "wrote #{file} ✨"
|
puts "wrote #{file} ✨"
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_latest(j, num, subtitle)
|
def write_latest(j, num, sub1, sub2)
|
||||||
t = j['title']
|
t = j['title']
|
||||||
apps = j["projects"]
|
apps = j["projects"]
|
||||||
footer = j['footer']
|
footer = j['footer']
|
||||||
latest = apps_latest(apps, num)
|
latest = apps_latest(apps, num)
|
||||||
|
|
||||||
output = "\# #{t} Latest\n\n"
|
output = "\# #{t} Latest\n\n"
|
||||||
output << subtitle
|
output << sub1
|
||||||
output << "\n"
|
output << "\n"
|
||||||
|
|
||||||
count = 1
|
count = 1
|
||||||
|
@ -231,6 +247,20 @@ def write_latest(j, num, subtitle)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
updated = apps_updated(apps, num)
|
||||||
|
|
||||||
|
output << "\n"
|
||||||
|
output << sub2
|
||||||
|
output << "\n"
|
||||||
|
|
||||||
|
count = 1
|
||||||
|
updated.each do |a|
|
||||||
|
t = a['title']
|
||||||
|
s = a['source']
|
||||||
|
output << "#{count}. [#{t}](#{s})\n"
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
|
||||||
output << "\n"
|
output << "\n"
|
||||||
output << footer
|
output << footer
|
||||||
|
|
||||||
|
@ -316,5 +346,6 @@ write_list(j, APPSTORE, subtitle_app_store, true)
|
||||||
subtitle_archive = "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"
|
subtitle_archive = "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"
|
||||||
write_archive(j, subtitle_archive)
|
write_archive(j, subtitle_archive)
|
||||||
|
|
||||||
subtitle_latest = "These are the #{LATEST_NUM} latest entries from the [main list](https://github.com/dkhamsing/open-source-ios-apps).\n\n"
|
subtitle_latest = "## Lastest additions to the [main list](https://github.com/dkhamsing/open-source-ios-apps)\n"
|
||||||
write_latest(j, LATEST_NUM, subtitle_latest)
|
subtitle_updated = "## Most recently updated\n"
|
||||||
|
write_latest(j, LATEST_NUM, subtitle_latest, subtitle_updated)
|
||||||
|
|
|
@ -20,8 +20,8 @@ apps.each_with_index do |a, index|
|
||||||
begin
|
begin
|
||||||
g = s.gsub('https://github.com/', '')
|
g = s.gsub('https://github.com/', '')
|
||||||
r = client.repo g
|
r = client.repo g
|
||||||
stars = r['stargazers_count']
|
a['stars'] = r['stargazers_count']
|
||||||
a['stars'] = stars
|
a['updated'] = r['pushed_at']
|
||||||
updated.push a
|
updated.push a
|
||||||
rescue => e
|
rescue => e
|
||||||
puts "\nerror for #{s}: #{e}"
|
puts "\nerror for #{s}: #{e}"
|
|
@ -155,6 +155,11 @@
|
||||||
"description": "Date when project was added.",
|
"description": "Date when project was added.",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"updated": {
|
||||||
|
"title": "Date Updated",
|
||||||
|
"description": "Date when project was updated.",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"screenshots": {
|
"screenshots": {
|
||||||
"title": "Screenshots",
|
"title": "Screenshots",
|
||||||
"description": "Links to screenshot images.",
|
"description": "Links to screenshot images.",
|
||||||
|
|
4147
contents.json
4147
contents.json
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue