Organized the index slightly.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3235 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2016-06-02 23:33:01 +00:00
parent dca3ad9b79
commit be18e46a17
4 changed files with 51 additions and 35 deletions

View File

@ -1,5 +1,7 @@
"use strict"; "use strict";
//! {"category": "work in progress"}
class Log { class Log {
constructor(name, capacity) { constructor(name, capacity) {
this._name = name; this._name = name;

View File

@ -27,48 +27,60 @@ function index() {
} }
} }
let packagesByCategory = {};
packages.forEach(function(app) {
let category = (app.manifest ? app.manifest.category : null) || "other";
if (!packagesByCategory[category]) {
packagesByCategory[category] = [];
}
packagesByCategory[category].push(app);
});
terminal.cork(); terminal.cork();
terminal.clear(); terminal.clear();
terminal.print("Available applications [active users]:"); terminal.print("Available applications [active users]:");
packages.sort(function(x, y) { for (let category in packagesByCategory) {
return Math.sign(x.owner.localeCompare(y.owner)) * 10 + Math.sign(x.name.localeCompare(y.name)) * 1; terminal.print({style: "font-weight: bold", value: category});
}).forEach(function(app) { packagesByCategory[category].sort(function(x, y) {
let users = usersByApp["/~" + app.owner + "/" + app.name]; return Math.sign(x.owner.localeCompare(y.owner)) * 10 + Math.sign(x.name.localeCompare(y.name)) * 1;
let services = servicesByApp["/~" + app.owner + "/" + app.name]; }).forEach(function(app) {
let message = []; let users = usersByApp["/~" + app.owner + "/" + app.name];
if (users || services) { let services = servicesByApp["/~" + app.owner + "/" + app.name];
message.push(" ["); let message = [];
if (users) { if (users || services) {
let counts = {}; message.push(" [");
for (let i = 0; i < users.length; i++) { if (users) {
counts[users[i]] = (counts[users[i]] || 0) + 1; let counts = {};
for (let i = 0; i < users.length; i++) {
counts[users[i]] = (counts[users[i]] || 0) + 1;
}
let names = Object.keys(counts).sort();
for (let i = 0; i < names.length; i++) {
var name = names[i];
if (message.length > 1) {
message.push(", ");
}
message.push({class: "orange", value: name});
if (counts[name] > 1) {
message.push({class: "base01", value: "(x" + counts[name] + ")"});
}
}
} }
let names = Object.keys(counts).sort(); if (services) {
for (let i = 0; i < names.length; i++) { if (users) {
var name = names[i];
if (message.length > 1) {
message.push(", "); message.push(", ");
} }
message.push({class: "orange", value: name}); message.push("⚒".repeat(services.length));
if (counts[name] > 1) {
message.push({class: "base01", value: "(x" + counts[name] + ")"});
}
} }
message.push("]");
} }
if (services) { terminal.print(
if (users) { "• ",
message.push(", "); {href: "/~" + app.owner + "/" + app.name, target: "_self"},
} message,
message.push("⚒".repeat(services.length)); app.manifest && app.manifest.description ? " - " + app.manifest.description.toString() : "");
} });
message.push("]"); }
}
terminal.print(
"* ",
{href: "/~" + app.owner + "/" + app.name, target: "_self"},
message,
app.manifest && app.manifest.description ? " - " + app.manifest.description.toString() : "");
});
terminal.uncork(); terminal.uncork();
}); });
} }

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
//! {"permissions": ["network"]} //! {"category": "libraries", "permissions": ["network"]}
terminal.print("Hello, world!"); terminal.print("Hello, world!");

View File

@ -1,5 +1,7 @@
"use strict"; "use strict";
//! {"category": "libraries"}
function fileList(settings) { function fileList(settings) {
let prefix = settings.prefix || ""; let prefix = settings.prefix || "";