photos in config order, always modify config if new files appear
This commit is contained in:
@@ -24,39 +24,42 @@ class Mirva:
|
||||
self.create_config()
|
||||
print("Exiting. Check config.")
|
||||
return
|
||||
self.create_config()
|
||||
self.get_config()
|
||||
self.create_posts()
|
||||
self.write_index()
|
||||
self.write_mediums()
|
||||
|
||||
def create_config(self):
|
||||
print("Creating config: {}".format(os.path.join(self.options.folder,self.config_file)))
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read(self.config_file)
|
||||
config_changed = False
|
||||
if not "SITE" in config:
|
||||
config["SITE"] = {
|
||||
"title": "",
|
||||
"sub_title": "",
|
||||
"intro": "",
|
||||
}
|
||||
config_changed = True
|
||||
|
||||
for f in self.file_list:
|
||||
if not f in config:
|
||||
config[f] = {"title": f, "description": ""}
|
||||
config_changed = True
|
||||
|
||||
if config_changed:
|
||||
print("Modified config: {}".format(os.path.join(self.options.folder,self.config_file)))
|
||||
with open(self.config_file, "wt") as fp:
|
||||
config.write(fp)
|
||||
|
||||
def create_posts(self):
|
||||
|
||||
self.posts = []
|
||||
for f in self.file_list:
|
||||
if not f in self.config:
|
||||
post = self.get_post(f, f, "")
|
||||
else:
|
||||
for c in self.config:
|
||||
if c in self.file_list:
|
||||
post = self.get_post(
|
||||
f, self.config[f]["title"], self.config[f]["description"]
|
||||
c, self.config[c]["title"], self.config[c]["description"]
|
||||
)
|
||||
self.posts.append(post)
|
||||
|
||||
@@ -218,6 +221,8 @@ function create_button(direction, to) {{
|
||||
pass
|
||||
|
||||
for f in ("style.css", "arrow_up.png", "arrow_down.png", "banner.jpg", "mirva.ico"):
|
||||
if os.path.exists(os.path.join(self.resource_dir, f)):
|
||||
continue
|
||||
shutil.copy(
|
||||
os.path.join(self.resource_src, f), os.path.join(self.resource_dir, f)
|
||||
)
|
||||
@@ -251,6 +256,8 @@ function create_button(direction, to) {{
|
||||
"85",
|
||||
outfile,
|
||||
]
|
||||
sys.stdout.write(".")
|
||||
subprocess.call(convargs)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user