Compare commits

...

15 Commits
0.2.6 ... main

Author SHA1 Message Date
31b373b34a Bump version: 0.2.13 → 0.2.14 2025-07-10 17:12:23 +01:00
8665ab431c rework version 2025-07-10 17:12:14 +01:00
1b528a4277 new version 2025-07-10 17:11:09 +01:00
6210b5de7d updated toml 2025-07-10 17:10:00 +01:00
ab32c8032c add and update version to docker image 2025-07-10 17:08:58 +01:00
43ce8e1b89 Bump version: 0.2.10 → 0.2.11 2025-07-10 16:59:03 +01:00
826e91e7e2 Bump version: 0.2.9 → 0.2.10 2025-07-10 16:58:56 +01:00
98f7a87005 revert to 0.2.9 2025-07-10 16:58:50 +01:00
bc933c2308 Bump version: 0.2.9 → 0.2.10 2025-07-10 16:25:14 +01:00
d5c4d54041 Bump version: 0.2.8 → 0.2.9 2025-07-10 16:25:09 +01:00
ba9b4b8bd4 fix(favorites): preserve favorite status after image rename
Previously, if a user favorited a newly generated image (named 'image.png'), the favorite status would be lost once the image was automatically renamed to its final timestamped filename.

This change modifies the renaming logic to check the `favourites.json` file. If 'image.png' is found, its entry is updated with the new filename, ensuring the favorite status is preserved.
2025-07-10 16:24:57 +01:00
7f78912829 Bump version: 0.2.7 → 0.2.8 2025-06-30 14:28:42 +01:00
33404c7a37 keyboard support in the lightbox 2025-06-30 14:28:27 +01:00
0b7e0ca59d Bump version: 0.2.6 → 0.2.7 2025-06-30 13:16:55 +01:00
eeb82a9a3a switch title based on the page 2025-06-30 13:16:45 +01:00
5 changed files with 73 additions and 40 deletions

View File

@ -1,19 +1,24 @@
[tool.bumpversion]
current_version = "0.2.6"
current_version = "0.2.14"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
serialize = ["{major}.{minor}.{patch}"]
search = "{current_version}"
replace = "{new_version}"
regex = false
ignore_missing_version = false
ignore_missing_files = false
tag = true
sign_tags = false
tag_name = "{new_version}"
tag_message = "Bump version: {current_version} → {new_version}"
allow_dirty = false
commit = true
message = "Bump version: {current_version} → {new_version}"
tag_name = "{new_version}"
tag_message = "Bump version: {current_version} → {new_version}"
[[tool.bumpversion.files]]
filename = ".bumpversion.toml"
search = 'current_version = "{current_version}"'
replace = 'current_version = "{new_version}"'
[[tool.bumpversion.files]]
filename = "Dockerfile"
search = 'ARG VERSION="{current_version}"'
replace = 'ARG VERSION="{new_version}"'
moveable_tags = []
commit_args = ""
setup_hooks = []

View File

@ -3,10 +3,14 @@ FROM python:3.11-slim
# Set the working directory in the container
WORKDIR /app
# Set version label
ARG VERSION="0.2.14"
LABEL version=$VERSION
# Copy project files into the container
COPY . /app
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

View File

@ -51,10 +51,22 @@ def load_config() -> configparser.ConfigParser:
def rename_image() -> str | None:
"""Renames 'image.png' in the output folder to a timestamped filename if it exists."""
old_path = os.path.join(user_config["comfyui"]["output_dir"], "image.png")
favourites_file = "./favourites.json"
if os.path.exists(old_path):
new_filename = f"{str(time.time())}.png"
new_path = os.path.join(user_config["comfyui"]["output_dir"], new_filename)
# Check if image.png is a favourite
if os.path.exists(favourites_file):
with open(favourites_file, 'r') as f:
favourites = json.load(f)
if "image.png" in favourites:
favourites.remove("image.png")
favourites.append(new_filename)
with open(favourites_file, 'w') as f:
json.dump(favourites, f)
os.rename(old_path, new_path)
generate_thumbnail(new_path)
print(f"Renamed 'image.png' to '{new_filename}'")

View File

@ -31,28 +31,20 @@ def gallery():
def get_favourites_route():
return jsonify(get_favourites())
@bp.route("/favourites/add", methods=["POST"])
def add_favourite():
data = request.get_json()
filename = data.get("filename")
if not filename:
return jsonify({"status": "error", "message": "Filename missing"}), 400
favourites = get_favourites()
if filename not in favourites:
favourites.append(filename)
save_favourites(favourites)
return jsonify({"status": "success"})
@bp.route("/favourites/remove", methods=["POST"])
def remove_favourite():
@bp.route("/favourites/toggle", methods=["POST"])
def toggle_favourite():
data = request.get_json()
filename = data.get("filename")
if not filename:
return jsonify({"status": "error", "message": "Filename missing"}), 400
favourites = get_favourites()
is_favourited = False
if filename in favourites:
favourites.remove(filename)
save_favourites(favourites)
return jsonify({"status": "success"})
else:
favourites.append(filename)
is_favourited = True
save_favourites(favourites)
return jsonify({"status": "success", "favourited": is_favourited})

View File

@ -198,13 +198,13 @@
<a href="/" class="button-link home-button">Home</a>
<button class="button-link favourites-button" id="favourites-button" onclick="toggleFavouritesView()">Show Favourites</button>
<h1>Image Archive</h1>
<h1 id="page-title">Image Archive</h1>
<!-- Empty gallery container; images will be loaded incrementally -->
<div class="gallery" id="gallery"></div>
<!-- Lightbox -->
<div class="lightbox" id="lightbox">
<div class="lightbox" id="lightbox" tabindex="-1" onkeyup="handleLightboxKeys(event)">
<span class="close" onclick="closeLightbox()">&times;</span>
<span class="favourite-heart" id="favourite-heart" onclick="toggleFavourite()">&#9825;</span>
<span class="arrow left" onclick="prevImage()">&#10094;</span>
@ -215,11 +215,11 @@
<!-- Pass image filenames from Flask to JS -->
<script>
let allImages = [
let allImages = JSON.parse(`[
{% for image in images %}
{ filename: "{{ image.filename }}", favourited: {{ 'true' if image.favourited else 'false' }} },
{ "filename": "{{ image.filename }}", "favourited": {{ 'true' if image.favourited else 'false' }} }{% if not loop.last %},{% endif %}
{% endfor %}
];
]`);
</script>
<script>
@ -263,12 +263,15 @@
function toggleFavouritesView() {
showingFavourites = !showingFavourites;
const button = document.getElementById('favourites-button');
const pageTitle = document.getElementById('page-title');
if (showingFavourites) {
filteredImages = allImages.filter(img => img.favourited);
button.textContent = 'Show All';
pageTitle.textContent = 'Favourites';
} else {
filteredImages = allImages;
button.textContent = 'Show Favourites';
pageTitle.textContent = 'Image Archive';
}
renderGallery();
}
@ -294,7 +297,9 @@
const images = getGalleryImages();
currentIndex = images.indexOf(imgEl);
showImageAndLoadDetails(currentIndex);
document.getElementById("lightbox").style.display = "flex";
const lightbox = document.getElementById("lightbox");
lightbox.style.display = "flex";
lightbox.focus();
}
function updateFavouriteHeart(isFavourited) {
@ -307,10 +312,8 @@
const images = getGalleryImages();
const imgEl = images[currentIndex];
const filename = imgEl.dataset.filename;
let isFavourited = imgEl.dataset.favourited === 'true';
const url = isFavourited ? '/favourites/remove' : '/favourites/add';
fetch(url, {
fetch('/favourites/toggle', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ filename: filename })
@ -318,17 +321,22 @@
.then(response => response.json())
.then(data => {
if (data.status === 'success') {
isFavourited = !isFavourited;
const isFavourited = data.favourited;
imgEl.dataset.favourited = isFavourited;
updateFavouriteHeart(isFavourited);
// Update the main image list
const originalImage = allImages.find(img => img.filename === filename);
if (originalImage) {
originalImage.favourited = isFavourited;
}
}
});
}
}
if (showingFavourites) {
filteredImages = allImages.filter(img => img.favourited);
renderGallery();
}
}
});
}
function showImageAndLoadDetails(index) {
const images = getGalleryImages();
@ -401,6 +409,18 @@
}
}
}
function handleLightboxKeys(e) {
if (e.key === 'f') {
toggleFavourite();
} else if (e.key === 'Escape') {
closeLightbox();
} else if (e.key === 'ArrowLeft') {
prevImage();
} else if (e.key === 'ArrowRight') {
nextImage();
}
}
</script>
</body>