Add hidden_tags config option
This commit is contained in:
parent
be9f4fefc2
commit
c49d21f693
@ -14,10 +14,11 @@ from redstring.parser import (
|
||||
)
|
||||
|
||||
|
||||
def generate_index_document(directory: str) -> Document:
|
||||
def generate_index_document(config) -> Document:
|
||||
"""
|
||||
Generate a document describing a document collection.
|
||||
"""
|
||||
directory = config['root']
|
||||
categories: dict = {}
|
||||
|
||||
# categories = {
|
||||
@ -35,11 +36,17 @@ def generate_index_document(directory: str) -> Document:
|
||||
with open(os.path.join(directory, filename)) as f:
|
||||
document: Document = load(f)
|
||||
|
||||
# Check if this document specifies a tab, and create it if necessary.
|
||||
# Check if this document specifies a tab.
|
||||
if category_tag := document.get_tag('category'):
|
||||
category_name = category_tag.value
|
||||
else:
|
||||
category_name = 'index'
|
||||
|
||||
# Skip hidden tabs in guest mode.
|
||||
if (not config['edit']) and (category_name in config.get('hidden_tabs', [])):
|
||||
continue
|
||||
|
||||
# Create it if necessary.
|
||||
if category_name not in categories:
|
||||
categories[category_name] = {}
|
||||
destination_category = categories[category_name]
|
||||
@ -72,7 +79,7 @@ def generate_index_document(directory: str) -> Document:
|
||||
|
||||
destination_topic.append((doc_id, doc_title))
|
||||
|
||||
# Build an index document
|
||||
# Build an index document.
|
||||
def document_link(info):
|
||||
doc_id, doc_title = info
|
||||
return (
|
||||
|
@ -60,7 +60,7 @@ def root():
|
||||
|
||||
@app.route('/index/', methods=['GET'])
|
||||
def index():
|
||||
document = generate_index_document(current_app.config['root'])
|
||||
document = generate_index_document(current_app.config)
|
||||
return render_template('doc.jinja', document=document, index=True)
|
||||
|
||||
|
||||
@ -179,6 +179,7 @@ def read_config(app, path):
|
||||
config = json.load(f)
|
||||
app.config['root'] = config['root']
|
||||
app.config['edit'] = config['edit']
|
||||
app.config['hidden_tabs'] = config.get('hidden_tabs', [])
|
||||
return config
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user