Added timestamps for real now.

- python script puts them in the info.json files if not there yet
- frontend shows it correctly
This commit is contained in:
Joachim Nielandt 2018-01-04 20:48:59 +01:00
parent 1c693a796c
commit 8446ed6c99
9 changed files with 24 additions and 22 deletions

View File

@ -1,7 +1,7 @@
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h5 class="card-title">{{post.title}}</h5> <h5 class="card-title">{{post.title}}</h5>
<h6 class="card-subtitle mb-2 text-muted"><span class="badge badge-secondary">{{post.type}}</span> {{post.lastmodified}}</h6> <h6 class="card-subtitle mb-2 text-muted"><span class="badge badge-secondary">{{post.type}}</span> {{post.created_timestamp}}</h6>
<div class="card-text" #htmlcontainer></div> <div class="card-text" #htmlcontainer></div>
</div> </div>
</div> </div>

View File

@ -1,9 +1,9 @@
export class Post { export class Post {
lastmodified: Date;
type: string; type: string;
title: any; title: any;
id:String; id:String;
created_timestamp: Date;
constructor(id:String) { constructor(id:String) {
this.id = id; this.id = id;

View File

@ -22,7 +22,9 @@ export class DataloaderService {
let temp:Post = new Post(post.id); let temp:Post = new Post(post.id);
temp.title = post.info.title; temp.title = post.info.title;
temp.type = post.type; temp.type = post.type;
temp.lastmodified = new Date(post.lastmodified*1000); console.log('got this timestamp: '+post.info.created_timestamp);
temp.created_timestamp = new Date(post.info.created_timestamp*1000);
console.log('converted it to this: '+temp.created_timestamp);
res.push(temp); res.push(temp);
} }
// console.log('these are the posts...'); // console.log('these are the posts...');

View File

@ -1,3 +1 @@
{ {"created_timestamp": 1515094679.342938, "title": "Who said Web 1.0 was dead anyway?"}
"title":"Who said Web 1.0 was dead anyway?"
}

View File

@ -1,3 +1 @@
{ {"created_timestamp": 1515094644.215065, "title": "cupboard"}
"title":"cupboard"
}

View File

@ -1,3 +1 @@
{ {"created_timestamp": 1515094644.214663, "title": "Test title"}
"title": "Test title"
}

View File

@ -1,3 +1 @@
{ {"created_timestamp": 1515094644.215333, "title": "some things about lxc in arch"}
"title":"some things about lxc in arch"
}

View File

@ -1 +1 @@
[{"info": {"title": "Test title"}, "lastmodified": 1514908964.183, "post": [], "type": "project", "id": "test"}, {"info": {"title": "cupboard"}, "lastmodified": 1514918689.4108193, "post": [], "type": "project", "id": "cupboard1"}, {"info": {"title": "some things about lxc in arch"}, "lastmodified": 1514918926.0, "post": [], "type": "tech", "id": "lxdarch"}, {"info": {"title": "Who said Web 1.0 was dead anyway?"}, "lastmodified": 1515009160.0915291, "post": [], "type": "blog", "id": "first"}] [{"info": {"created_timestamp": 1515094644.214663, "title": "Test title"}, "post": [], "type": "project", "id": "test"}, {"info": {"created_timestamp": 1515094644.215065, "title": "cupboard"}, "post": [], "type": "project", "id": "cupboard1"}, {"info": {"created_timestamp": 1515094644.215333, "title": "some things about lxc in arch"}, "post": [], "type": "tech", "id": "lxdarch"}, {"info": {"test": "some dummy value", "created_timestamp": 1515094679.342938, "title": "Who said Web 1.0 was dead anyway?"}, "post": [], "type": "blog", "id": "first"}]

View File

@ -1,5 +1,6 @@
import os; import os;
import json; import json;
import time;
# each folder in the post folder is a type of post # each folder in the post folder is a type of post
base = '../assets/post' base = '../assets/post'
@ -32,12 +33,19 @@ for type in types:
temp['post'] = []; temp['post'] = [];
temp['info'] = d; temp['info'] = d;
# figure out the last change of any file in the folder # have to write the 'modified date' in the info.json of the post if it's not there yet
lastchange = 0; if not d.has_key('created_timestamp'):
contents = os.listdir(postdir); d['created_timestamp'] = time.time()
for contentfile in contents: # persist it in the json file itself
lastchange = max(lastchange,os.path.getmtime(postdir+"/"+contentfile)) with open(infofile, 'w') as infooutfile:
temp['lastmodified'] = lastchange; json.dump(d, infooutfile)
# # figure out the last change of any file in the folder
# lastchange = 0;
# contents = os.listdir(postdir);
# for contentfile in contents:
# lastchange = max(lastchange,os.path.getmtime(postdir+"/"+contentfile))
# temp['lastmodified'] = lastchange;
jsonresult.append(temp); jsonresult.append(temp);