New mastodon post feature

This commit is contained in:
Edward Betts 2025-11-15 12:48:36 +00:00
parent 1180c0817f
commit eada9049fa
13 changed files with 746 additions and 23 deletions

View file

@ -9,7 +9,13 @@
<body>
<header class="site-header">
<div class="container">
<h1><a href="{{ url_for('main.index') }}">Immich Alt Text Helper</a></h1>
<div class="header-bar">
<h1><a href="{{ url_for('main.index') }}">Immich Alt Text Helper</a></h1>
<nav class="nav-links">
<a href="{{ url_for('main.index') }}">Recent photos</a>
<a href="{{ url_for('main.compose_select') }}">Compose Mastodon post</a>
</nav>
</div>
</div>
</header>
<main class="container">
@ -24,5 +30,6 @@
{% endwith %}
{% block content %}{% endblock %}
</main>
<script src="{{ url_for('static', filename='app.js') }}"></script>
</body>
</html>

View file

@ -0,0 +1,59 @@
{% extends "base.html" %}
{% block content %}
<section class="intro">
<h2>Draft Mastodon post</h2>
<p>Review alt text, edit your caption, and ask ChatGPT for phrasing help before posting.</p>
</section>
{% if not mastodon_ready %}
<div class="warning">Mastodon access token missing. You can refine content, but posting is disabled.</div>
{% endif %}
{% if error_message %}
<div class="error">{{ error_message }}</div>
{% endif %}
<form method="post" class="compose-form">
<div class="asset-list">
{% for asset in assets %}
<article class="compose-asset" data-asset-id="{{ asset.id }}">
<input type="hidden" name="asset_ids" value="{{ asset.id }}">
<div class="order-controls">
<span class="order-badge">Photo {{ loop.index }}</span>
<div class="move-buttons">
<button type="button" data-move="up" aria-label="Move photo up"></button>
<button type="button" data-move="down" aria-label="Move photo down"></button>
</div>
</div>
<div class="image">
<img src="{{ asset.preview_url }}" alt="{{ asset.file_name }}">
</div>
<div class="fields">
<h3>{{ asset.file_name }}</h3>
{% if asset.captured_display %}
<p class="date">{{ asset.captured_display }}</p>
{% endif %}
<label for="alt_text_{{ asset.id }}">Alt text</label>
<textarea id="alt_text_{{ asset.id }}" name="alt_text_{{ asset.id }}" rows="4">{{ asset.alt_text }}</textarea>
</div>
</article>
{% endfor %}
</div>
<div class="post-text">
<label for="post_text">Mastodon post text</label>
<textarea id="post_text" name="post_text" rows="6" placeholder="Compose your post here.">{{ post_text }}</textarea>
</div>
<div class="post-instructions">
<label for="post_instructions">Instructions for ChatGPT (optional)</label>
<textarea id="post_instructions" name="post_instructions" rows="3" placeholder="Mention tone, audience, hashtags, etc.">{{ instructions }}</textarea>
</div>
<div class="compose-actions">
<button type="submit" name="action" value="refine">Improve text with ChatGPT</button>
<button type="submit" name="action" value="post" {% if not mastodon_ready %}disabled{% endif %}>Post to Mastodon</button>
</div>
</form>
{% endblock %}

View file

@ -0,0 +1,44 @@
{% extends "base.html" %}
{% block content %}
<section class="intro">
<h2>Select photos for your Mastodon post</h2>
<p>Choose between 1 and {{ max_photos }} recent Immich photos. We'll pull in cached alt text where possible.</p>
</section>
{% if error_message %}
<div class="error">{{ error_message }}</div>
{% endif %}
{% if assets %}
<form method="post" class="selection-form">
<div class="actions top-actions">
<button type="submit">Use selected photos</button>
</div>
<div class="select-grid">
{% for asset in assets %}
<label class="select-card">
<input type="checkbox" name="asset_ids" value="{{ asset.id }}" {% if selected_ids and asset.id in selected_ids %}checked{% endif %}>
<div class="thumbnail">
<img src="{{ url_for('main.asset_proxy', asset_id=asset.id, variant='thumbnail') }}" alt="{{ asset.file_name }}">
</div>
<div class="meta">
<div class="file-name">{{ asset.file_name }}</div>
{% if asset.captured_display %}
<div class="date">{{ asset.captured_display }}</div>
{% endif %}
{% if asset.alt_text %}
<div class="alt-text-sample">{{ asset.alt_text }}</div>
{% endif %}
</div>
</label>
{% endfor %}
</div>
<div class="actions">
<button type="submit">Use selected photos</button>
</div>
</form>
{% else %}
<p>No assets available right now.</p>
{% endif %}
{% endblock %}

View file

@ -3,6 +3,7 @@
{% block content %}
<section class="intro">
<p>Choose a recent Immich photo to request Mastodon-friendly alt text.</p>
<p><a class="button-link" href="{{ url_for('main.compose_select') }}">Compose a Mastodon post</a></p>
</section>
{% if error_message %}