From d4878be7fa95f3b1782961bacd36895e8e552b38 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Mon, 24 Apr 2023 22:29:17 +0100 Subject: [PATCH] popcon: initial launch-sortorder modification app --- apps/popconlaunch/ChangeLog | 1 + apps/popconlaunch/README.md | 9 +++++++ apps/popconlaunch/app.png | Bin 0 -> 899 bytes apps/popconlaunch/boot.ts | 43 ++++++++++++++++++++++++++++++++ apps/popconlaunch/metadata.json | 19 ++++++++++++++ 5 files changed, 72 insertions(+) create mode 100644 apps/popconlaunch/ChangeLog create mode 100644 apps/popconlaunch/README.md create mode 100644 apps/popconlaunch/app.png create mode 100644 apps/popconlaunch/boot.ts create mode 100644 apps/popconlaunch/metadata.json 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 0000000000000000000000000000000000000000..8b4e6caa2fe4720a32f492bd00c6e68751fabfbc GIT binary patch literal 899 zcmV-}1AP36P)EZi8a;XNfX0KK)EG5t2&jmXSR!CR3JOvSF^w(VT@Oq6O4&}^ElAua zX|l63`{wtXcjoO3*x1-CYovub^cOBY?cfcO1>;+VoWa;>Pk;!SG_WW*Es5gZ1-`R@ z4t>oKYJ)f#xYia)IV)#&xZ*BHYck+F1K9eED0&f|F;Lm{VL;rb?(c)W{8d& zzrH4`vJJ?>K!fln4K4LjpAx19%+|UjgL{LF?3gt^suTXG8HN@KQv>tY{cLjA%Q)j? zIX0ma_G_?6n>drF(WulAaitj}A^+b$v5k$*zr})O^uogfX;+bphn_9#OZ}pdk^!&c zqrUVgUd3m%o}@|o!cmyJiIaP-*BlK-1F7-kNoN^X5h5L~tnN`_& zI3(jUhvcNZU>jbg3|-gg8hTDln@m+>N(dP^vh_T*8x8>Qb*ytvU&Y#;lz3_Z*tBLl zEghFFmS~QUfhzCr>E}|Fxr&yKOBoXz4vqjF zlzKwtw{idZM95W(Tbb#rO0Wkqaj6$F@MWZp>h=2o=nr;LTzCQiH!$$4i=w<5W87%F zs6NXOGI0OH6?#VB0k9%#HO2Wg(|z6FTj}`r1kmXWJk5wmGlUFGsuA7}JOW^&y9!O$ zkR=&S*XaHEp1^o_Mn#&D^ig6k6`9rJMEHEc@fMjg8GR Z=Px>?AD_-bQjY)t002ovPDHLkV1j2qp7Q_z literal 0 HcmV?d00001 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 +}