forked from cory/tildefriends
Adding a number of work-in-progress packages. Some data structures built on top of the key-value store and an http client, among others.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3310 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -50,17 +50,20 @@ class Blog {
|
||||
async submitPost(post) {
|
||||
let now = new Date();
|
||||
let oldPost = await this._documents.get(post.name);
|
||||
if (!oldPost) {
|
||||
post.created = now;
|
||||
post.author = core.user.name;
|
||||
if (!await this._list.getByKey(post.name)) {
|
||||
this._list.push(post.name);
|
||||
} else {
|
||||
for (let key in oldPost) {
|
||||
if (!post[key]) {
|
||||
post[key] = oldPost[key];
|
||||
}
|
||||
}
|
||||
for (let key in oldPost) {
|
||||
if (!post[key]) {
|
||||
post[key] = oldPost[key];
|
||||
}
|
||||
}
|
||||
if (!post.created) {
|
||||
post.created = now;
|
||||
}
|
||||
if (!post.author) {
|
||||
post.author = core.user.name;
|
||||
}
|
||||
post.modified = now;
|
||||
await this._documents.set(post.name, post);
|
||||
}
|
||||
|
Reference in New Issue
Block a user