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