toplist category to config
This commit is contained in:
parent
6c9da444da
commit
04e6d80af4
8
app.py
8
app.py
@ -249,6 +249,7 @@ def serve_sw():
|
|||||||
@app.route('/api/path/<path:subpath>')
|
@app.route('/api/path/<path:subpath>')
|
||||||
@auth.require_secret
|
@auth.require_secret
|
||||||
def api_browse(subpath):
|
def api_browse(subpath):
|
||||||
|
toplist_categories = app_config.get('toplist_categories', None)
|
||||||
|
|
||||||
if subpath == '': # root directory
|
if subpath == '': # root directory
|
||||||
foldernames = []
|
foldernames = []
|
||||||
@ -260,7 +261,8 @@ def api_browse(subpath):
|
|||||||
'directories': foldernames,
|
'directories': foldernames,
|
||||||
'files': [],
|
'files': [],
|
||||||
'folder_today': a.return_folder_today(),
|
'folder_today': a.return_folder_today(),
|
||||||
'folder_yesterday': a.return_folder_yesterday()
|
'folder_yesterday': a.return_folder_yesterday(),
|
||||||
|
'toplist_enabled': bool(toplist_categories)
|
||||||
})
|
})
|
||||||
|
|
||||||
if subpath == 'heute' or subpath == 'gestern':
|
if subpath == 'heute' or subpath == 'gestern':
|
||||||
@ -284,14 +286,12 @@ def api_browse(subpath):
|
|||||||
foldernames = []
|
foldernames = []
|
||||||
files = []
|
files = []
|
||||||
split_path = subpath.split('/')
|
split_path = subpath.split('/')
|
||||||
|
|
||||||
valid_categories = ['Predigt', 'Erzählung', 'Gedicht', 'Gemeinsamer Gesang', 'Chor', 'Kinderchor', 'Jugendchor', 'Orchester', 'Instrumental', 'Gruppenlied']
|
|
||||||
|
|
||||||
if len(split_path) == 1 and split_path[0] == 'toplist':
|
if len(split_path) == 1 and split_path[0] == 'toplist':
|
||||||
foldernames = [
|
foldernames = [
|
||||||
{
|
{
|
||||||
'name': categorie, 'path': 'toplist/' + categorie
|
'name': categorie, 'path': 'toplist/' + categorie
|
||||||
} for categorie in valid_categories
|
} for categorie in toplist_categories
|
||||||
]
|
]
|
||||||
elif len(split_path) > 1 and split_path[0] == 'toplist':
|
elif len(split_path) > 1 and split_path[0] == 'toplist':
|
||||||
files = hf.generate_top_list(split_path[1])
|
files = hf.generate_top_list(split_path[1])
|
||||||
|
|||||||
@ -113,7 +113,7 @@ function renderContent(data) {
|
|||||||
} else if (data.breadcrumbs.length === 1 && Array.isArray(data.folder_yesterday) && data.folder_yesterday.length > 0) {
|
} else if (data.breadcrumbs.length === 1 && Array.isArray(data.folder_yesterday) && data.folder_yesterday.length > 0) {
|
||||||
contentHTML += `<li class="directory-item"><a href="#" class="directory-link" data-path="gestern">📅 Gestern</a></li>`;
|
contentHTML += `<li class="directory-item"><a href="#" class="directory-link" data-path="gestern">📅 Gestern</a></li>`;
|
||||||
}
|
}
|
||||||
if (data.breadcrumbs.length === 1 ) {
|
if (data.breadcrumbs.length === 1 && data.toplist_enabled) {
|
||||||
contentHTML += `<li class="directory-item"><a href="#" class="directory-link" data-path="toplist">🔥 oft angehört</a></li>`;
|
contentHTML += `<li class="directory-item"><a href="#" class="directory-link" data-path="toplist">🔥 oft angehört</a></li>`;
|
||||||
}
|
}
|
||||||
console.log(data.folder_today, data.folder_yesterday);
|
console.log(data.folder_today, data.folder_yesterday);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user