diff options
Diffstat (limited to 'cgi/manage.py')
-rw-r--r-- | cgi/manage.py | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/cgi/manage.py b/cgi/manage.py index e3d7704..cd1a215 100644 --- a/cgi/manage.py +++ b/cgi/manage.py @@ -1398,10 +1398,12 @@ def manage(self, path_split): if not administrator: return + return + board = setBoard(path_split[3]) - threads = FetchAll( - 'SELECT * FROM archive WHERE boardid = %s ORDER BY timestamp DESC' % board['id']) + threads = FetchAll('SELECT * FROM archive WHERE boardid = %s ORDER BY timestamp DESC' % board['id']) + for item in threads: t = time.time() self.output += str(item['timestamp']) + '<br />' @@ -1410,22 +1412,50 @@ def manage(self, path_split): str(item["timestamp"]) + ".json" if os.path.isfile(fname): import json + with open(fname) as f: thread = json.load(f) - thread['posts'] = [ - dict(list(zip(thread['keys'], row))) for row in thread['posts']] - template_fname = "txt_archive.html" - - post_preview = cut_home_msg( - thread['posts'][0]['message'], 0) - page = renderTemplate("txt_archive.html", {"threads": [ - thread], "preview": post_preview}, False) + + #thread['posts'] = [dict(list(zip(thread['keys'], row))) for row in thread['posts']] + + #if 'posterid' not in thread['keys']: + # for post in thread['posts']: + # half = post['timestamp_formatted'].split(' ID:') + # if len(half) > 1: + # post['timestamp_formatted'] = half[0] + # post['posterid'] = half[1] + # else: + # post['posterid'] = '' + # + # thread['keys'].append('posterid') + + #if 'message' not in thread: + # thread['message'] = thread['posts'][0]['message'] + # thread['keys'].append('message') + + #thread['posts'] = [[row[key] for key in thread['keys']] for row in thread['posts']] + + ##raise UserError(thread) + + #try: + # with open(fname, "w") as f: + # json.dump(thread, f, indent=0) + #except: + # raise UserError("Can't edit") + + thread['posts'] = [dict(list(zip(thread['keys'], row))) for row in thread['posts']] + + post_preview = cut_msg(thread['message'], 0) + + page = renderTemplate("txt_archive.html", {"threads": [thread], "preview": post_preview}, False) + with open(Settings.ROOT_DIR + board["dir"] + "/kako/" + str(thread['timestamp']) + ".html", "w") as f: f.write(page) self.output += 'done' + str(time.time() - t) + '<br />' else: self.output += 'El hilo no existe.<br />' + elif path_split[2] == 'fixexpires': if not administrator: return |