move all resources under one folder

This commit is contained in:
2022-01-24 15:38:43 +02:00
parent 611574efa7
commit 049f55eada
2 changed files with 8 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
__version__ = "20210920.1" __version__ = "20220124.0"
def get_version(): def get_version():

View File

@@ -15,6 +15,7 @@ class Mirva:
os.path.dirname(os.path.abspath(__file__)), "resources" os.path.dirname(os.path.abspath(__file__)), "resources"
) )
self.resource_dir = ".mirva" self.resource_dir = ".mirva"
self.medium_dir = os.path.join(self.resource_dir, "med")
self.config_file = os.path.join(self.resource_dir, "config.cfg") self.config_file = os.path.join(self.resource_dir, "config.cfg")
self.config_backup = os.path.join(self.resource_dir, "config.cfg.bkp") self.config_backup = os.path.join(self.resource_dir, "config.cfg.bkp")
self.image_match = re.compile(".*\.jpg$|.*\.jpeg$|.*\.png$|.*\.gif$|.*\.tif$", re.I) self.image_match = re.compile(".*\.jpg$|.*\.jpeg$|.*\.png$|.*\.gif$|.*\.tif$", re.I)
@@ -256,12 +257,12 @@ function create_button(direction, to) {{
return """ return """
<div class="post"> <div class="post">
<div class="navigation">&nbsp;</div> <div class="navigation">&nbsp;</div>
<div class=center><a href="{image}"><img loading=lazy class=post_image src=".med/{image}.jpg"></a></div> <div class=center><a href="{image}"><img loading=lazy class=post_image src="{med_dir}/{image}.jpg"></a></div>
<div class="meta"><div class="name">{title}</div></div> <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(
image=image, title=title, content=content image=image, title=title, content=content, med_dir=self.medium_dir
) )
@@ -313,7 +314,7 @@ function create_button(direction, to) {{
def write_mediums(self): def write_mediums(self):
try: try:
os.makedirs(".med") os.makedirs(self.medium_dir)
except Exception: except Exception:
pass pass
@@ -327,7 +328,7 @@ function create_button(direction, to) {{
for f in self.file_list: for f in self.file_list:
if self.video_match.match(f): if self.video_match.match(f):
continue continue
outfile = os.path.join(".med", "{}.jpg".format(f)) outfile = os.path.join(self.medium_dir, "{}.jpg".format(f))
if force: if force:
try: try:
os.remove(outfile) os.remove(outfile)
@@ -336,8 +337,8 @@ function create_button(direction, to) {{
if not os.path.exists(outfile): if not os.path.exists(outfile):
if link: if link:
# TODO: Get absolute path to f?
os.symlink("../{}".format(f), outfile) os.symlink("../../{}".format(f), outfile)
continue continue
convargs = [ convargs = [