From a712134b5db192e1fecffbb6e2a2cacb89f23e67 Mon Sep 17 00:00:00 2001 From: dkhamsing Date: Fri, 13 May 2016 09:22:57 -0700 Subject: [PATCH] [script] Support archived apps --- .github/CONTRIBUTING.md | 4 ++++ .github/convert.rb | 46 ++++++++++++++++++++++++++++++++++++++++- .github/deploy.sh | 4 +++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index b0fb8a1e..4dd74952 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -5,6 +5,10 @@ To contribute to`open-source-ios-apps`, update the **contents.json** file (this Please [open an issue](https://github.com/dkhamsing/open-source-ios-apps/issues) and contact @dkhamsing, @kvnbautista or @scribblemaniac. +## Delete app + +To delete an app, add the value **archive** to the `tags` field. + ## New app Adding a `JSON` entry diff --git a/.github/convert.rb b/.github/convert.rb index 78324d16..dcdafffe 100644 --- a/.github/convert.rb +++ b/.github/convert.rb @@ -3,6 +3,9 @@ require 'json' README = 'README.md' +ARCHIVE = 'ARCHIVE.md' +ARCHIVE_TAG = 'archive' + def output_stars(number) case number when 100...200 @@ -35,8 +38,23 @@ def output_flag(lang) end end +def apps_archived(apps) + a = apps.select {|a| a['tags'] != nil }.select {|b| b['tags'].include?ARCHIVE_TAG} + a.sort_by { |k, v| k['title'] } +end + def apps_for_cat(apps, id) - s = apps.select do |a| + f = apps.select do |a| + + tags = a['tags'] + if tags.nil? + true + else + !(tags.include? ARCHIVE_TAG) + end + end + + s = f.select do |a| cat = a['category'] cat.class == Array ? cat.include?(id) : (cat == id) end @@ -133,7 +151,33 @@ def write_readme(j) puts "wrote #{README} ✨" end +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" + # output << + end + + output << "\n" + output << f + + file = ARCHIVE + File.open(file, 'w') { |f| f.write output } + puts "wrote #{file} ✨" +end + c = File.read 'contents.json' j = JSON.parse c write_readme(j) +write_archive(j) diff --git a/.github/deploy.sh b/.github/deploy.sh index e3fbdbc4..e33d835a 100755 --- a/.github/deploy.sh +++ b/.github/deploy.sh @@ -8,7 +8,9 @@ git config user.email "dkhamsing@users.noreply.github.com" #git checkout master git add README.md - git commit -m "[auto] [ci skip] Generate README" +git add ARCHIVE.md +git commit -m "[auto] [ci skip] Generate ARCHIVE" + git push --quiet "https://${GH_TOKEN}@github.com/dkhamsing/open-source-ios-apps" master:master > /dev/null 2>&1