filter for main page(1/2)

This commit is contained in:
Alocks 2019-12-02 16:46:22 -03:00
parent 88c0c1e021
commit 0abcb048b4
4 changed files with 51 additions and 13 deletions

View File

@ -117,10 +117,11 @@ def generate_main_html(output_dir='./'):
Default output folder will be the CLI path. Default output folder will be the CLI path.
""" """
count = 0
image_html = '' image_html = ''
main = readfile('viewer/main.html') main = readfile('viewer/main.html')
css = readfile('viewer/main.css') css = readfile('viewer/main.css')
js = readfile('viewer/main.js')
element = '\n\ element = '\n\
<div class="gallery-favorite">\n\ <div class="gallery-favorite">\n\
<div class="gallery">\n\ <div class="gallery">\n\
@ -133,18 +134,24 @@ def generate_main_html(output_dir='./'):
os.chdir(output_dir) os.chdir(output_dir)
doujinshi_dirs = next(os.walk('.'))[1] doujinshi_dirs = next(os.walk('.'))[1]
database = open('data.js', 'w')
database.write("var data = JSON.parse('[")
for folder in doujinshi_dirs: for folder in doujinshi_dirs:
folder_json = ',"Folder":"'+folder+'"}'
files = os.listdir(folder) files = os.listdir(folder)
files.sort() files.sort()
if 'index.html' in files: if 'index.html' in files:
count += 1
logger.info('Add doujinshi \'{}\''.format(folder)) logger.info('Add doujinshi \'{}\''.format(folder))
else: else:
continue continue
database.write(open(output_dir + folder + '/' + files[-1], 'r').read()[:-2]+folder_json)
if folder != doujinshi_dirs[-1]:
database.write(",'+\n'")
else:
database.write("]')")
image = files[0] # 001.jpg or 001.png image = files[0] # 001.jpg or 001.png
if folder is not None: if folder is not None:
title = folder.replace('_', ' ') title = folder.replace('_', ' ')
@ -153,11 +160,12 @@ def generate_main_html(output_dir='./'):
image_html += element.format(FOLDER=folder, IMAGE=image, TITLE=title) image_html += element.format(FOLDER=folder, IMAGE=image, TITLE=title)
database.close()
if image_html == '': if image_html == '':
logger.warning('None index.html found, --gen-main paused.') logger.warning('None index.html found, --gen-main paused.')
return return
try: try:
data = main.format(STYLES=css, COUNT=count, PICTURE=image_html) data = main.format(STYLES=css, SCRIPTS=js, PICTURE=image_html)
if sys.version_info < (3, 0): if sys.version_info < (3, 0):
with open('./main.html', 'w') as f: with open('./main.html', 'w') as f:
f.write(data) f.write(data)

View File

@ -13,7 +13,7 @@ body {
h1 { h1 {
font-size: 2em; font-size: 2em;
margin: .67em 0 margin: .67em 0;
} }
a { a {
@ -130,14 +130,14 @@ blockquote {
.container { .container {
display: block; display: block;
clear: both; clear: both;
margin-left: auto; margin-left: 200px;
margin-right: auto; margin-right: auto;
margin-bottom: 10px; margin-bottom: 10px;
margin-top: 10px; margin-top: 10px;
padding: 10px; padding: 10px;
border-radius: 9px; border-radius: 9px;
background-color: #ecf0f1; background-color: #ecf0f1;
width: 100%; width: 100% - 200px;
max-width: 1200px max-width: 1200px
} }
@ -222,6 +222,35 @@ blockquote {
width: 100% width: 100%
} }
.sidenav {
height: 100%;
width: 200px;
position: absolute;
z-index: 1;
top: 0;
left: 0;
background-color: #111;
overflow-x: hidden;
padding-top: 20px;
}
.sidenav a {
padding: 6px 6px 6px 32px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
}
.sidenav a:hover {
color: #f1f1f1;
}
@media screen and (max-height: 450px) {
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
}
html.theme-black,html.theme-black body { html.theme-black,html.theme-black body {
color: #d9d9d9; color: #d9d9d9;
background-color: #0d0d0d background-color: #0d0d0d

View File

@ -6,6 +6,7 @@
<meta name="theme-color" content="#1f1f1f" /> <meta name="theme-color" content="#1f1f1f" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes, viewport-fit=cover" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes, viewport-fit=cover" />
<title>nHentai &raquo; Viewer</title> <title>nHentai &raquo; Viewer</title>
<script type="text/javascript" src="data.js"></script>
<!-- <link rel="stylesheet" href="./main.css"> --> <!-- <link rel="stylesheet" href="./main.css"> -->
<style> <style>
{STYLES} {STYLES}
@ -14,9 +15,7 @@
<body> <body>
<div id="content"> <div id="content">
<nav class="sidenav">nHentai Viewer</nav>
<h1>Main Folder({COUNT})</h1>
<div class="container" id="favcontainer"> <div class="container" id="favcontainer">
{PICTURE} {PICTURE}
@ -24,7 +23,9 @@
</div> <!-- container --> </div> <!-- container -->
</div> </div>
<script>
{SCRIPTS}
</script>
</body> </body>
</html> </html>

0
nhentai/viewer/main.js Normal file
View File