diff --git a/.gitignore b/.gitignore index abc3e9bd1..be33fbc90 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules package-lock.json .DS_Store *.js.bak +appdates.csv diff --git a/bin/pre-publish.sh b/bin/pre-publish.sh index 47822dbf2..6a80f2516 100755 --- a/bin/pre-publish.sh +++ b/bin/pre-publish.sh @@ -5,12 +5,14 @@ node bin/sanitycheck.js || exit 1 echo "Sanity check passed." -echo "Finding most recent apps..." +echo "Finding app dates..." +# Create list of: +# appid,created_time,modified_time cd apps for appfolder in *; do - echo "$(git log --follow --format=%ai $appfolder),$appfolder" | tail -n 1 ; -done | grep -v _example_ | sort -r > ../recent.csv + echo "$appfolder,$(git log --follow --format=%ai -- $appfolder | tail -n 1),$(git log --follow --format=%ai -- $appfolder | head -n 1)" ; +done | grep -v _example_ | grep -v unknown.png > ../appdates.csv cd .. echo "Ready to publish" diff --git a/index.html b/index.html index 0d23c2c0b..6d0566d13 100644 --- a/index.html +++ b/index.html @@ -95,7 +95,8 @@
diff --git a/js/index.js b/js/index.js index 94c3e86a4..031391f52 100644 --- a/js/index.js +++ b/js/index.js @@ -1,6 +1,6 @@ var appJSON = []; // List of apps and info from apps.json var appsInstalled = []; // list of app JSON -var appPublishDates = {}; // list of app publish dates from recent.csv +var appSortInfo = {}; // list of data to sort by, from appdates.csv { created, modified } var files = []; // list of files on Bangle var DEFAULTSETTINGS = { pretokenise : true, @@ -20,11 +20,14 @@ httpGet("apps.json").then(apps=>{ refreshFilter(); }); -httpGet("recent.csv").then(csv=>{ +httpGet("appdates.csv").then(csv=>{ document.querySelector(".sort-nav").classList.remove("hidden"); csv.split("\n").forEach(line=>{ var l = line.split(","); - appPublishDates[l[1]] = Date.parse(l[0]); + appSortInfo[l[0]] = { + created : Date.parse(l[1]), + modified : Date.parse(l[2]) + }; }); }).catch(err=>{ console.log("No recent.csv - app sort disabled"); @@ -231,8 +234,8 @@ function refreshLibrary() { if (activeSort) { visibleApps = visibleApps.slice(); // clone the array so sort doesn't mess with original - if (activeSort=="new") { - visibleApps = visibleApps.sort((a,b) => appPublishDates[b.id] - appPublishDates[a.id]); + if (activeSort=="created" || activeSort=="modified") { + visibleApps = visibleApps.sort((a,b) => appSortInfo[b.id][activeSort] - appSortInfo[a.id][activeSort]); } else throw new Error("Unknown sort type "+activeSort); }