diff --git a/apps/popconlaunch/ChangeLog b/apps/popconlaunch/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/popconlaunch/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/apps/popconlaunch/README.md b/apps/popconlaunch/README.md new file mode 100644 index 000000000..7804ebd73 --- /dev/null +++ b/apps/popconlaunch/README.md @@ -0,0 +1,9 @@ +Popcon +====== + +Display apps sorted by regular use. + +Settings +-------- + +- `Show Clocks` - Whether clocks are shown in the app list. Default `Yes`. diff --git a/apps/popconlaunch/app.png b/apps/popconlaunch/app.png new file mode 100644 index 000000000..8b4e6caa2 Binary files /dev/null and b/apps/popconlaunch/app.png differ diff --git a/apps/popconlaunch/boot.ts b/apps/popconlaunch/boot.ts new file mode 100644 index 000000000..cb62ca643 --- /dev/null +++ b/apps/popconlaunch/boot.ts @@ -0,0 +1,43 @@ +// TODO: fastload +const oldRead = require("Storage").readJSON; +let cache; + +const ensureCache = () => { + if(!cache){ + cache = oldRead("popcon.cache.json", 1); + if(!cache) + cache = {}; + } +}; + +const saveCache = () => { + require("Storage").writeJSON("popcon.cache.json", cache); +}; + +const sortCache = () => { + // TODO +}; + +require("Storage").readJSON = (fname, skipExceptions) => { + const j = oldRead(fname, skipExceptions); + + if(fname.test(/\.info$/)){ + ensureCache(); + + if(j.src && cache[j.src]?.sortorder) + j.sortorder = cache[j.src].sortorder; + } + + return j; +} satisfies typeof oldRead; + +const oldLoad = load; +load = (src) => { + ensureCache(); + cache[src].pop++; + cache[src].last = Date.now(); + sortCache(); + saveCache(); + + return oldLoad(src); +}; diff --git a/apps/popconlaunch/metadata.json b/apps/popconlaunch/metadata.json new file mode 100644 index 000000000..906ad473a --- /dev/null +++ b/apps/popconlaunch/metadata.json @@ -0,0 +1,19 @@ +{ + "id": "popconlaunch", + "name": "Popcon Launcher", + "shortName": "Popcon", + "version": "0.01", + "description": "Launcher displaying your favourite (popular) apps first", + "readme": "README.md", + "icon": "TODO_app.png", + "type": "launch", + "tags": "tool,system,launcher", + "supports": ["BANGLEJS2"], + "storage": [ + {"name":"popcon.boot.js","url":"boot.js"} + ], + "data": [ + {"name":"popcon.cache.json"} + ], + "sortorder": -10 +}