lots of updates

This commit is contained in:
Ville Rantanen
2021-08-20 20:53:01 +03:00
parent db1af48957
commit b606b53a48
4 changed files with 72 additions and 38 deletions

View File

@@ -10,7 +10,9 @@ Use pip or similar to install from source.
ex. ex.
`pip3 install --user --upgrade https://bitbucket.org/MoonQ/mirva/get/tip.tar.gz` `pip3 install --user --upgrade https://bitbucket.org/MoonQ/mirva/get/master.zip`
or `pipx install https://bitbucket.org/MoonQ/mirva/get/master.zip`
## Usage ## Usage

View File

@@ -30,9 +30,10 @@ class Mirva:
self.create_posts() self.create_posts()
self.write_index() self.write_index()
self.write_mediums() self.write_mediums()
print("Gallery written.")
def create_config(self): def create_config(self):
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read(self.config_file) config.read(self.config_file)
config_changed = False config_changed = False
@@ -41,13 +42,14 @@ class Mirva:
"title": "", "title": "",
"sub_title": "", "sub_title": "",
"intro": "", "intro": "",
"image_size": 850
} }
config_changed = True config_changed = True
for f in self.file_list: for f in self.file_list:
if not f in config: if not f in config:
config[f] = {"title": f, "description": ""} config[f] = {"title": f, "description": ""}
config_changed = True config_changed = True
if config_changed: if config_changed:
print("Modified config: {}".format(os.path.join(self.options.folder,self.config_file))) print("Modified config: {}".format(os.path.join(self.options.folder,self.config_file)))
@@ -86,6 +88,10 @@ class Mirva:
"--config", default=False, action="store_true", help="Write config and exit" "--config", default=False, action="store_true", help="Write config and exit"
) )
parser.add_argument(
"--force", default=False, action="store_true", help="Force regeneration of middle sized images"
)
parser.add_argument( parser.add_argument(
"folder", "folder",
type=str, type=str,
@@ -193,9 +199,9 @@ function create_button(direction, to) {{
return """ return """
<div class="post"> <div class="post">
<div class="navigation"></div> <div class="navigation">&nbsp;</div>
<div class=center><a href="{image}"><img class=post_image src=".med/{image}.jpg"></a></div> <div class=center><a href="{image}"><img class=post_image src=".med/{image}.jpg"></a></div>
<p class="meta"><span class="name">{title}</span></p> <div class="meta"><div class="name">{title}</div></div>
<div style="clear: both;">&nbsp;</div> <div style="clear: both;">&nbsp;</div>
<div class="entry">{content}</div> <div class="entry">{content}</div>
</div>""".format( </div>""".format(
@@ -235,14 +241,31 @@ function create_button(direction, to) {{
except Exception: except Exception:
pass pass
# TODO: config image res r = self.config["SITE"].get("image_size", 850)
# TODO opts: force recreation link = str(r).lower() == "link"
r = 850 if link:
force = False r = 0
force = self.options.force
for f in self.file_list: for f in self.file_list:
res = "{:d}x{:d}>".format(r, r) res = "{:d}x{:d}>".format(int(r), int(r))
outfile = os.path.join(".med", "{}.jpg".format(f)) outfile = os.path.join(".med", "{}.jpg".format(f))
if not os.path.exists(outfile) or force: if force:
try:
os.remove(outfile)
except FileNotFoundError:
pass
if not os.path.exists(outfile):
if link:
os.symlink(
"../{}".format(f),
outfile
)
continue
convargs = [ convargs = [
"convert", "convert",
"-define", "-define",

View File

@@ -109,10 +109,15 @@ a:hover {
/* Page */ /* Page */
#page { #page {
width: 90vw; width: calc(100vw - 128px);
margin: 0 auto; margin: 0 auto;
padding: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;
} }
@media only screen and (max-width: 800px) {
#page {
width: 100vw;
}
}
#page-bgtop { #page-bgtop {
padding: 20px 0px; padding: 20px 0px;
@@ -124,14 +129,14 @@ a:hover {
/* Content */ /* Content */
#content { #content {
width: 90vw; width: 100%;
padding: 30px 0px 0px 0px; padding: 30px 0px 0px 0px;
} }
.post { .post {
margin-bottom: 15px; margin-bottom: 15px;
border-top: lightgray dashed; border-top: lightgray dashed 2px;
padding-top: 5px; padding-top: 2px;
} }
.post-bgtop { .post-bgtop {
@@ -154,8 +159,7 @@ a:hover {
} }
.post .meta { .post .meta {
/* margin-bottom: 30px;*/ padding: 5px 0px 5px 0px;
padding: 5px 0px 15px 0px;
text-align: center; text-align: center;
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
font-size: 13px; font-size: 13px;
@@ -163,6 +167,7 @@ a:hover {
} }
.post .meta .name { .post .meta .name {
display: inline;
} }
.post .meta .posted { .post .meta .posted {
@@ -172,8 +177,7 @@ a:hover {
} }
.post .entry { .post .entry {
padding: 0px 0px 20px 0px; padding: 0px 5px 20px 5px;
padding-bottom: 20px;
text-align: justify; text-align: justify;
} }
@@ -184,15 +188,20 @@ a:hover {
} }
.center { .center {
display: block; display: table;
text-align: center; text-align: center;
width: 100%;
} }
.post_image { .post_image {
max-height: 95vh; max-height: calc(100vh - 60px);
max-width: 90vw; max-width: calc(100vw - 128px);
}
@media only screen and (max-width: 800px) {
.post_image {
max-width: 100vw;
}
} }
/* Footer */ /* Footer */
#footer { #footer {
@@ -221,28 +230,28 @@ a:hover {
/* navi */ /* navi */
.navigation { .navigation {
height: 20px; height: 27px;
margin-bottom: 5px; float: right;
}
@media only screen and (max-width: 800px) {
.navigation {
display: none;
}
} }
.navigation_button { .navigation_button {
cursor: pointer; cursor: pointer;
margin-left: 10px;
box-shadow: 4px 4px 5px #888888; box-shadow: 4px 4px 5px #888888;
} }
.navigation_button:hover { .navigation_button:hover {
cursor: pointer; cursor: pointer;
box-shadow: 2px 2px 2px #888888; box-shadow: 2px 2px 2px #888888;
} }
@media only screen and (max-width: 800px) {
.navigation_button {
margin-top: 20px;
margin-bottom: 20px;
}
}
.float_up { .float_up {
float: left; float: left;
} }
.float_down { .float_down {
float: right; float: left;
} }

View File

@@ -1,18 +1,18 @@
from distutils.core import setup from distutils.core import setup
setup( setup(
name = 'mirva', name = 'mirva',
packages = ['mirva'], packages = ['mirva'],
scripts = ['scripts/mirva', scripts = ['scripts/mirva',
], ],
package_data={'':['resources/*']}, package_data={'':['resources/*']},
include_package_data=True, include_package_data=True,
version = '20210819', version = '20210820',
description = 'A tool to create a web gallery from a folder of images.', description = 'A tool to create a web gallery from a folder of images.',
author = 'Ville Rantanen', author = 'Ville Rantanen',
author_email = 'ville.q.rantanen@gmail.com', author_email = 'ville.q.rantanen@gmail.com',
url = 'https://bitbucket.org/MoonQ/mirva', url = 'https://bitbucket.org/MoonQ/mirva',
download_url = 'https://bitbucket.org/MoonQ/mirva/get/tip.tar.gz', download_url = 'https://bitbucket.org/MoonQ/mirva/get/master.zip',
keywords = ['album', 'generator', 'javascript'], keywords = ['album', 'generator', 'javascript'],
classifiers = [], classifiers = [],
license = 'MIT', license = 'MIT',
) )