Assign all stock apps an emoji, show them in the app list, and let the editor set them.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4242 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
53692a1ea8
commit
ec65faa12d
@ -1,3 +1,4 @@
|
||||
{
|
||||
"type": "tildefriends-app"
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "🎛"
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"type": "tildefriends-app"
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "📜"
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"type": "tildefriends-app"
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "💻"
|
||||
}
|
@ -1,18 +1,28 @@
|
||||
async function fetch_info(apps) {
|
||||
let result = {};
|
||||
for (let [key, value] of Object.entries(apps)) {
|
||||
let blob = await ssb.blobGet(value);
|
||||
blob = blob ? utf8Decode(blob) : '{}';
|
||||
result[key] = JSON.parse(blob);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
var apps = await core.apps();
|
||||
var core_apps = await core.apps('core');
|
||||
var apps = await fetch_info(await core.apps());
|
||||
var core_apps = await fetch_info(await core.apps('core'));
|
||||
var doc = `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
.container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, 8em);
|
||||
grid-template-columns: repeat(auto-fill, 64px);
|
||||
justify-content: space-around;
|
||||
}
|
||||
.app {
|
||||
height: 8em;
|
||||
width: 8em;
|
||||
height: 96px;
|
||||
width: 64px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
@ -21,7 +31,7 @@ async function main() {
|
||||
}
|
||||
.app > a {
|
||||
text-decoration: none;
|
||||
max-width: 8em;
|
||||
max-width: 64px;
|
||||
text-overflow: ellipsis ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
@ -42,7 +52,7 @@ async function main() {
|
||||
|
||||
let icon_a = document.createElement('a');
|
||||
let icon = document.createElement('div');
|
||||
icon.appendChild(document.createTextNode('📦'));
|
||||
icon.appendChild(document.createTextNode(apps[app].emoji || '📦'));
|
||||
icon.style.fontSize = 'xxx-large';
|
||||
icon_a.appendChild(icon);
|
||||
icon_a.href = '/~' + name + '/' + app + '/';
|
||||
@ -63,4 +73,4 @@ async function main() {
|
||||
app.setDocument(doc);
|
||||
}
|
||||
|
||||
main();
|
||||
main();
|
||||
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"type": "tildefriends-app"
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "💽"
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"type": "tildefriends-app"
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "📚"
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"type": "tildefriends-app"
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "➡️"
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"type": "tildefriends-app"
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "🐌"
|
||||
}
|
@ -79,7 +79,7 @@ class TfElement extends LitElement {
|
||||
WHERE author = ? AND
|
||||
rowid > ? AND
|
||||
rowid <= ? AND
|
||||
json_extract(content, "$.type") = "contact"
|
||||
json_extract(content, '$.type') = 'contact'
|
||||
ORDER BY sequence
|
||||
`,
|
||||
[id, last_row_id, max_row_id]);
|
||||
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"type": "tildefriends-app"
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "☑️"
|
||||
}
|
@ -4,7 +4,7 @@ let gPermissions;
|
||||
|
||||
let gCurrentFile;
|
||||
let gFiles = {};
|
||||
let gApp = {files: {}};
|
||||
let gApp = {files: {}, emoji: '📦'};
|
||||
let gEditor;
|
||||
let gSplit;
|
||||
let gGraphs = {};
|
||||
@ -219,6 +219,8 @@ function load(path) {
|
||||
document.getElementById("editPane").style.display = 'flex';
|
||||
}
|
||||
gApp = json;
|
||||
gApp.emoji = gApp.emoji || '📦';
|
||||
document.getElementById('icon').value = gApp.emoji;
|
||||
}
|
||||
if (!isApp) {
|
||||
document.getElementById("editPane").style.display = 'flex';
|
||||
@ -293,6 +295,7 @@ function save(save_to) {
|
||||
let app = {
|
||||
type: "tildefriends-app",
|
||||
files: Object.fromEntries(Object.keys(gFiles).map(x => [x, gFiles[x].id || gApp.files[x]])),
|
||||
emoji: gApp.emoji || '📦',
|
||||
};
|
||||
Object.values(gFiles).forEach(function(file) { delete file.id; });
|
||||
gApp = JSON.parse(JSON.stringify(app));
|
||||
@ -325,6 +328,14 @@ function save(save_to) {
|
||||
});
|
||||
}
|
||||
|
||||
function changeIcon() {
|
||||
let value = prompt('Enter a new app icon emoji:');
|
||||
if (value !== undefined) {
|
||||
gApp.emoji = value || '📦';
|
||||
document.getElementById('icon').value = gApp.emoji;
|
||||
}
|
||||
}
|
||||
|
||||
function deleteApp() {
|
||||
let name = document.getElementById("name");
|
||||
let path = name && name.value ? name.value : url();
|
||||
@ -965,6 +976,7 @@ window.addEventListener("load", function() {
|
||||
document.getElementById('closeStats').addEventListener('click', () => closeStats());
|
||||
document.getElementById('closeEditor').addEventListener('click', () => closeEditor());
|
||||
document.getElementById('save').addEventListener('click', () => save());
|
||||
document.getElementById('icon').addEventListener('click', () => changeIcon());
|
||||
document.getElementById('delete').addEventListener('click', () => deleteApp());
|
||||
document.getElementById('trace_button').addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
|
@ -30,6 +30,7 @@
|
||||
<div class="navigation hbox">
|
||||
<input type="button" id="closeEditor" name="closeEditor" value="Close">
|
||||
<input type="button" id="save" name="save" value="Save">
|
||||
<input type="button" id="icon" name="icon" value="📦">
|
||||
<input type="text" id="name" name="name" style="flex: 1 1; min-width: 1em"></input>
|
||||
<input type="button" id="delete" name="delete" value="Delete">
|
||||
<input type="button" id="trace_button" value="Trace">
|
||||
|
Loading…
Reference in New Issue
Block a user