diff --git a/generator.py b/generator.py index fd2dcc4..1301957 100755 --- a/generator.py +++ b/generator.py @@ -12,9 +12,6 @@ import argparse, json, os, re, shutil from datetime import datetime from jinja2 import Environment, FileSystemLoader -import sys -#reload(sys); sys.setdefaultencoding('utf-8') - def fromunixtime(value): return datetime.fromtimestamp(value).strftime('%Y-%m-%d %H:%M:%S') @@ -71,14 +68,17 @@ def find_unregistered_users(data): return unregistered_users +def find_board_id(board): + return board['link'].split('/')[-2] + def render_boards(boards, template_board, template_thread, outpath, title): for board in boards: rendered_board = template_board.render(board=board, title=title + ' - ' + board['title']) - write_render(rendered_board, os.path.join('board', url_replacer(board['title']) + '.html'), outpath) + write_render(rendered_board, os.path.join('board', find_board_id(board) + '_' + url_replacer(board['title']) + '.html'), outpath) for thread in board['threads']: rendered_thread = template_thread.render(board=board, thread=thread, title=title + ' - ' + thread['title']) - write_render(rendered_thread, os.path.join('board', 'thread', url_replacer(thread['title']) + '.html'), outpath) + write_render(rendered_thread, os.path.join('board', 'thread', thread['id'] + '_' + url_replacer(thread['title']) + '.html'), outpath) render_boards(board['boards'], template_board, template_thread, outpath, title) @@ -94,6 +94,7 @@ def render(inputfile, staticpath, outpath, title): env.filters['fromunixtime'] = fromunixtime env.filters['tohtml'] = tohtml env.filters['url_replacer'] = url_replacer + env.filters['find_board_id'] = find_board_id template_users = env.get_template('users.html.j2') template_user = env.get_template('user.html.j2') diff --git a/templates/board.html.j2 b/templates/board.html.j2 index b279fc9..f7bc752 100644 --- a/templates/board.html.j2 +++ b/templates/board.html.j2 @@ -14,14 +14,14 @@ {% if board.boards |length > 0 %}