Order categories and boards correctly; correctly organize them by nesting level
This commit is contained in:
parent
dc0191a04a
commit
bf4a5f2b5d
@ -3,6 +3,8 @@ from .forum import Forum
|
||||
from .wiki import Wiki
|
||||
from .archive_generator import ArchiveGenerator
|
||||
|
||||
import sys
|
||||
|
||||
BASEDIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
FORUM_DATABASE = os.path.join(BASEDIR, "forum", "forum.sqlite")
|
||||
WIKI_DIRECTORY = os.path.join(BASEDIR, "wiki")
|
||||
@ -14,15 +16,20 @@ FORUM_ARCHIVES = os.path.join(ARCHIVES_BASEDIR, "forums")
|
||||
WIKI_ARCHIVES = os.path.join(ARCHIVES_BASEDIR, "wiki")
|
||||
|
||||
def main():
|
||||
archive_forum()
|
||||
|
||||
def archive_forum():
|
||||
forum = Forum(FORUM_DATABASE)
|
||||
|
||||
generator = ArchiveGenerator(TEMPLATES_DIR, STATIC_DIR)
|
||||
generator.generate_forum(forum, FORUM_ARCHIVES)
|
||||
|
||||
def archive_wiki():
|
||||
wiki = None
|
||||
for entry in os.listdir(WIKI_DIRECTORY):
|
||||
if entry.endswith(".xml"):
|
||||
wiki = Wiki(os.path.join(WIKI_DIRECTORY, entry))
|
||||
|
||||
generator = ArchiveGenerator(TEMPLATES_DIR, STATIC_DIR)
|
||||
#generator.generate_forum(forum, FORUM_ARCHIVES)
|
||||
|
||||
if wiki:
|
||||
generator = ArchiveGenerator(TEMPLATES_DIR, STATIC_DIR)
|
||||
generator.generate_wiki(wiki, WIKI_ARCHIVES)
|
@ -1,8 +1,14 @@
|
||||
import sqlite3
|
||||
|
||||
PREFIX = "smf_"
|
||||
GET_BOARDS = "SELECT * FROM `{}boards`".format(PREFIX)
|
||||
GET_CATEGORIES = "SELECT * FROM `{}categories`".format(PREFIX)
|
||||
GET_BOARDS = """
|
||||
SELECT * FROM `{}boards`
|
||||
ORDER BY `board_order` ASC
|
||||
""".format(PREFIX)
|
||||
GET_CATEGORIES = """
|
||||
SELECT * FROM `{}categories`
|
||||
ORDER BY `cat_order` ASC
|
||||
""".format(PREFIX)
|
||||
GET_THREADS = """
|
||||
SELECT * FROM `{}topics` AS `topics`, `{}messages` AS `messages`
|
||||
WHERE `topics`.`id_board`=? AND `messages`.`id_msg`=`topics`.`id_first_msg`
|
||||
@ -25,9 +31,9 @@ class Forum():
|
||||
categories = [dict(category) for category in self.get_categories()]
|
||||
boards = [dict(board) for board in self.get_boards()]
|
||||
for category in categories:
|
||||
category['children'] = [board for board in boards if board['id_cat'] == category['id_cat']]
|
||||
category['children'] = [child for child in boards if child['id_cat'] == category['id_cat'] and child['child_level'] == 0]
|
||||
for board in boards:
|
||||
board['children'] = [board for board in boards if board['id_parent'] == board['id_board']]
|
||||
board['children'] = [child for child in boards if child['id_parent'] == board['id_board']]
|
||||
return categories
|
||||
|
||||
def get_categories (self):
|
||||
|
@ -1,5 +1,6 @@
|
||||
body { font-family: monospace; }
|
||||
|
||||
ul.boards { margin-left: 0; padding-left: 0; }
|
||||
.category, .board { list-style-type: none;}
|
||||
.category .name, .board .name { font-weight: bold; }
|
||||
.board .board { margin-left: 10px; }
|
||||
|
@ -1,7 +1,9 @@
|
||||
{{#children}}
|
||||
<li class="board">
|
||||
<div class="name"><a href="board-{{id_board}}">{{name}}</a></div>
|
||||
<div class="description">{{description}}</div>
|
||||
{{>child_boards}}
|
||||
</li>
|
||||
{{/children}}
|
||||
<ul class="boards">
|
||||
{{#children}}
|
||||
<li class="board">
|
||||
<div class="name"><a href="board-{{id_board}}">{{name}}</a></div>
|
||||
<div class="description">{{description}}</div>
|
||||
{{>child_boards}}
|
||||
</li>
|
||||
{{/children}}
|
||||
</ul>
|
Loading…
x
Reference in New Issue
Block a user