mirror of
https://github.com/karl0ss/ai_image_frame_server.git
synced 2025-07-17 10:38:26 +01:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
31b373b34a | |||
8665ab431c | |||
1b528a4277 | |||
6210b5de7d | |||
ab32c8032c | |||
43ce8e1b89 | |||
826e91e7e2 | |||
98f7a87005 | |||
bc933c2308 | |||
d5c4d54041 | |||
ba9b4b8bd4 | |||
7f78912829 | |||
33404c7a37 |
@ -1,19 +1,24 @@
|
|||||||
[tool.bumpversion]
|
[tool.bumpversion]
|
||||||
current_version = "0.2.7"
|
current_version = "0.2.14"
|
||||||
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
||||||
serialize = ["{major}.{minor}.{patch}"]
|
serialize = ["{major}.{minor}.{patch}"]
|
||||||
search = "{current_version}"
|
|
||||||
replace = "{new_version}"
|
replace = "{new_version}"
|
||||||
regex = false
|
regex = false
|
||||||
ignore_missing_version = false
|
|
||||||
ignore_missing_files = false
|
|
||||||
tag = true
|
tag = true
|
||||||
sign_tags = false
|
|
||||||
tag_name = "{new_version}"
|
|
||||||
tag_message = "Bump version: {current_version} → {new_version}"
|
|
||||||
allow_dirty = false
|
|
||||||
commit = true
|
commit = true
|
||||||
message = "Bump version: {current_version} → {new_version}"
|
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 = []
|
moveable_tags = []
|
||||||
commit_args = ""
|
commit_args = ""
|
||||||
setup_hooks = []
|
setup_hooks = []
|
||||||
|
@ -3,9 +3,13 @@ FROM python:3.11-slim
|
|||||||
|
|
||||||
# Set the working directory in the container
|
# Set the working directory in the container
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
# Set version label
|
||||||
|
ARG VERSION="0.2.14"
|
||||||
|
LABEL version=$VERSION
|
||||||
|
|
||||||
# Copy project files into the container
|
# Copy project files into the container
|
||||||
COPY . /app
|
COPY . /app
|
||||||
|
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
@ -51,10 +51,22 @@ def load_config() -> configparser.ConfigParser:
|
|||||||
def rename_image() -> str | None:
|
def rename_image() -> str | None:
|
||||||
"""Renames 'image.png' in the output folder to a timestamped filename if it exists."""
|
"""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")
|
old_path = os.path.join(user_config["comfyui"]["output_dir"], "image.png")
|
||||||
|
favourites_file = "./favourites.json"
|
||||||
|
|
||||||
if os.path.exists(old_path):
|
if os.path.exists(old_path):
|
||||||
new_filename = f"{str(time.time())}.png"
|
new_filename = f"{str(time.time())}.png"
|
||||||
new_path = os.path.join(user_config["comfyui"]["output_dir"], new_filename)
|
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)
|
os.rename(old_path, new_path)
|
||||||
generate_thumbnail(new_path)
|
generate_thumbnail(new_path)
|
||||||
print(f"Renamed 'image.png' to '{new_filename}'")
|
print(f"Renamed 'image.png' to '{new_filename}'")
|
||||||
|
@ -31,28 +31,20 @@ def gallery():
|
|||||||
def get_favourites_route():
|
def get_favourites_route():
|
||||||
return jsonify(get_favourites())
|
return jsonify(get_favourites())
|
||||||
|
|
||||||
@bp.route("/favourites/add", methods=["POST"])
|
@bp.route("/favourites/toggle", methods=["POST"])
|
||||||
def add_favourite():
|
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()
|
|
||||||
if filename not in favourites:
|
|
||||||
favourites.append(filename)
|
|
||||||
save_favourites(favourites)
|
|
||||||
return jsonify({"status": "success"})
|
|
||||||
|
|
||||||
@bp.route("/favourites/remove", methods=["POST"])
|
|
||||||
def remove_favourite():
|
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
filename = data.get("filename")
|
filename = data.get("filename")
|
||||||
if not filename:
|
if not filename:
|
||||||
return jsonify({"status": "error", "message": "Filename missing"}), 400
|
return jsonify({"status": "error", "message": "Filename missing"}), 400
|
||||||
|
|
||||||
favourites = get_favourites()
|
favourites = get_favourites()
|
||||||
|
is_favourited = False
|
||||||
if filename in favourites:
|
if filename in favourites:
|
||||||
favourites.remove(filename)
|
favourites.remove(filename)
|
||||||
save_favourites(favourites)
|
else:
|
||||||
return jsonify({"status": "success"})
|
favourites.append(filename)
|
||||||
|
is_favourited = True
|
||||||
|
|
||||||
|
save_favourites(favourites)
|
||||||
|
return jsonify({"status": "success", "favourited": is_favourited})
|
||||||
|
@ -204,7 +204,7 @@
|
|||||||
<div class="gallery" id="gallery"></div>
|
<div class="gallery" id="gallery"></div>
|
||||||
|
|
||||||
<!-- Lightbox -->
|
<!-- Lightbox -->
|
||||||
<div class="lightbox" id="lightbox">
|
<div class="lightbox" id="lightbox" tabindex="-1" onkeyup="handleLightboxKeys(event)">
|
||||||
<span class="close" onclick="closeLightbox()">×</span>
|
<span class="close" onclick="closeLightbox()">×</span>
|
||||||
<span class="favourite-heart" id="favourite-heart" onclick="toggleFavourite()">♡</span>
|
<span class="favourite-heart" id="favourite-heart" onclick="toggleFavourite()">♡</span>
|
||||||
<span class="arrow left" onclick="prevImage()">❮</span>
|
<span class="arrow left" onclick="prevImage()">❮</span>
|
||||||
@ -297,7 +297,9 @@
|
|||||||
const images = getGalleryImages();
|
const images = getGalleryImages();
|
||||||
currentIndex = images.indexOf(imgEl);
|
currentIndex = images.indexOf(imgEl);
|
||||||
showImageAndLoadDetails(currentIndex);
|
showImageAndLoadDetails(currentIndex);
|
||||||
document.getElementById("lightbox").style.display = "flex";
|
const lightbox = document.getElementById("lightbox");
|
||||||
|
lightbox.style.display = "flex";
|
||||||
|
lightbox.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateFavouriteHeart(isFavourited) {
|
function updateFavouriteHeart(isFavourited) {
|
||||||
@ -310,10 +312,8 @@
|
|||||||
const images = getGalleryImages();
|
const images = getGalleryImages();
|
||||||
const imgEl = images[currentIndex];
|
const imgEl = images[currentIndex];
|
||||||
const filename = imgEl.dataset.filename;
|
const filename = imgEl.dataset.filename;
|
||||||
let isFavourited = imgEl.dataset.favourited === 'true';
|
|
||||||
|
|
||||||
const url = isFavourited ? '/favourites/remove' : '/favourites/add';
|
fetch('/favourites/toggle', {
|
||||||
fetch(url, {
|
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ filename: filename })
|
body: JSON.stringify({ filename: filename })
|
||||||
@ -321,17 +321,22 @@
|
|||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (data.status === 'success') {
|
if (data.status === 'success') {
|
||||||
isFavourited = !isFavourited;
|
const isFavourited = data.favourited;
|
||||||
imgEl.dataset.favourited = isFavourited;
|
imgEl.dataset.favourited = isFavourited;
|
||||||
updateFavouriteHeart(isFavourited);
|
updateFavouriteHeart(isFavourited);
|
||||||
// Update the main image list
|
|
||||||
const originalImage = allImages.find(img => img.filename === filename);
|
const originalImage = allImages.find(img => img.filename === filename);
|
||||||
if (originalImage) {
|
if (originalImage) {
|
||||||
originalImage.favourited = isFavourited;
|
originalImage.favourited = isFavourited;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
if (showingFavourites) {
|
||||||
}
|
filteredImages = allImages.filter(img => img.favourited);
|
||||||
|
renderGallery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function showImageAndLoadDetails(index) {
|
function showImageAndLoadDetails(index) {
|
||||||
const images = getGalleryImages();
|
const images = getGalleryImages();
|
||||||
@ -404,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>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user