Attaching files to posts sort of works. Whew.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3799 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
e84ced6f79
commit
d77c452120
@ -1 +1 @@
|
|||||||
{"type":"tildefriends-app","files":{"app.js":"&mDHhPk+YJm9K32UmO6WNUoJGM1tX4Dx7GIMjLvyurXg=.sha256","index.html":"&WJSszNEPd6ypJkfTUu/YHSDvU8VZrAHvyRmzNoZBPb0=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&3dPiSNYjoJE3zn1oTT1SBhbvkW9MHr7ZUDxUJiBI1Ss=.sha256","tf.js":"&DQtOS/nh5/a6QlqNrIb5Zi3Bz4pn3MBe5peRkwLZuyA=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256","tf-shared.js":"&+qPP3g4CAUlkt8K4iBCZ+F5Fy6N7fu6MggvSVss2juE=.sha256"}}
|
{"type":"tildefriends-app","files":{"app.js":"&ZPex8H1nwzrEHSgi5SkvfTlSzSIutT6iHOY08LWkwZg=.sha256","index.html":"&H2L4kR9xDS6oS7EDpesDCDB3JXDjcLTBg9XoR2mZaZw=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&3dPiSNYjoJE3zn1oTT1SBhbvkW9MHr7ZUDxUJiBI1Ss=.sha256","tf.js":"&RAwMitnSkY+F3lDbyXAvWYT1QOX0lUsNZC+JE7KW4JM=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256","tf-shared.js":"&+qPP3g4CAUlkt8K4iBCZ+F5Fy6N7fu6MggvSVss2juE=.sha256"}}
|
@ -421,6 +421,8 @@ core.register('message', async function(m) {
|
|||||||
if (g_ready) {
|
if (g_ready) {
|
||||||
await refresh(g_selected);
|
await refresh(g_selected);
|
||||||
}
|
}
|
||||||
|
} else if (m.event == 'storeBlobComplete') {
|
||||||
|
await app.postMessage({storeBlobComplete: m.path});
|
||||||
} else if (m.event == 'focus' || m.event == 'blur') {
|
} else if (m.event == 'focus' || m.event == 'blur') {
|
||||||
/* Shh. */
|
/* Shh. */
|
||||||
} else {
|
} else {
|
||||||
|
@ -73,6 +73,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</md-card-content>
|
</md-card-content>
|
||||||
<md-card-actions>
|
<md-card-actions>
|
||||||
|
<md-button class="md-icon-button" @click="attach">
|
||||||
|
<md-icon>attach_file</md-icon>
|
||||||
|
</md-button>
|
||||||
<md-menu>
|
<md-menu>
|
||||||
<md-button md-menu-trigger>Share App</md-button>
|
<md-button md-menu-trigger>Share App</md-button>
|
||||||
<md-menu-content>
|
<md-menu-content>
|
||||||
|
@ -143,6 +143,14 @@ function processMessages() {
|
|||||||
if (g_data.selected == g_data.whoami) {
|
if (g_data.selected == g_data.whoami) {
|
||||||
updateEditUser();
|
updateEditUser();
|
||||||
}
|
}
|
||||||
|
} else if (key == 'storeBlobComplete') {
|
||||||
|
var blob = event.data.storeBlobComplete;
|
||||||
|
g_data.post_text = (g_data.post_text || '') + `\n![${blob.name}](${blob.path.substring(1)})`;
|
||||||
|
Vue.set(g_data.mentions, blob.path.substring(1), {
|
||||||
|
link: blob.path.substring(1),
|
||||||
|
name: blob.name,
|
||||||
|
type: blob.type,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
g_data[key] = event.data[key];
|
g_data[key] = event.data[key];
|
||||||
}
|
}
|
||||||
@ -229,6 +237,26 @@ window.addEventListener('load', function() {
|
|||||||
set_hash(hash) {
|
set_hash(hash) {
|
||||||
window.parent.postMessage({action: 'setHash', hash: hash ? hash : '#'}, '*');
|
window.parent.postMessage({action: 'setHash', hash: hash ? hash : '#'}, '*');
|
||||||
},
|
},
|
||||||
|
attach() {
|
||||||
|
var input = document.createElement('input');
|
||||||
|
input.type = 'file';
|
||||||
|
input.onchange = function(event) {
|
||||||
|
var file = event.target.files[0];
|
||||||
|
file.arrayBuffer().then(function(buffer) {
|
||||||
|
console.log(buffer);
|
||||||
|
window.parent.postMessage({action: 'storeBlob',
|
||||||
|
blob: {
|
||||||
|
name: file.name,
|
||||||
|
type: file.type,
|
||||||
|
buffer: buffer,
|
||||||
|
}
|
||||||
|
}, '*');
|
||||||
|
}).catch(function(e) {
|
||||||
|
console.log('error', e);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
input.click();
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
window.parent.postMessage('ready', '*');
|
window.parent.postMessage('ready', '*');
|
||||||
|
@ -644,6 +644,18 @@ function message(event) {
|
|||||||
iframe.setAttribute("height", event.data.height);
|
iframe.setAttribute("height", event.data.height);
|
||||||
} else if (event.data && event.data.action == "setHash") {
|
} else if (event.data && event.data.action == "setHash") {
|
||||||
window.location.hash = event.data.hash;
|
window.location.hash = event.data.hash;
|
||||||
|
} else if (event.data && event.data.action == 'storeBlob') {
|
||||||
|
var request = new XMLHttpRequest();
|
||||||
|
request.addEventListener("loadend", function() {
|
||||||
|
if (request.status == 200) {
|
||||||
|
var iframe = document.getElementById("document");
|
||||||
|
iframe.contentWindow.postMessage({'storeBlobComplete': {name: event.data.blob.name, path: request.responseText, type: event.data.blob.type}}, '*');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
request.open('POST', "/save", true);
|
||||||
|
request.setRequestHeader("Content-Type", "application/binary");
|
||||||
|
console.log('storing', event.data.blob.buffer);
|
||||||
|
request.send(event.data.blob.buffer);
|
||||||
} else {
|
} else {
|
||||||
send({event: "message", message: event.data});
|
send({event: "message", message: event.data});
|
||||||
}
|
}
|
||||||
|
@ -390,7 +390,7 @@ function handleConnection(client) {
|
|||||||
if (headers["content-length"] != undefined) {
|
if (headers["content-length"] != undefined) {
|
||||||
bodyToRead = parseInt(headers["content-length"]);
|
bodyToRead = parseInt(headers["content-length"]);
|
||||||
lineByLine = false;
|
lineByLine = false;
|
||||||
body = "";
|
body = new Uint8Array(bodyToRead);
|
||||||
return true;
|
return true;
|
||||||
} else if (headers["connection"]
|
} else if (headers["connection"]
|
||||||
&& headers["connection"].toLowerCase().split(",").map(x => x.trim()).indexOf("upgrade") != -1
|
&& headers["connection"].toLowerCase().split(",").map(x => x.trim()).indexOf("upgrade") != -1
|
||||||
@ -406,9 +406,12 @@ function handleConnection(client) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
line = utf8Decode(line);
|
var offset = body.length - bodyToRead;
|
||||||
body += line;
|
if (line.length > body.length - offset) {
|
||||||
bodyToRead -= length;
|
line = line.slice(0, body.length - offset);
|
||||||
|
}
|
||||||
|
body.set(line, offset);
|
||||||
|
bodyToRead -= line.length;
|
||||||
if (bodyToRead <= 0) {
|
if (bodyToRead <= 0) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user