加入「拾味」:影评 / 读书随感
- 新增 reflections 应用:Work / WorkImage / Reflection 及迁移 - 条目分类(电影/书籍/其他),图片墙与随感时间线 - 浏览公开;新建、上传、写随感复用拾匣密码解锁 - 抽出 cabinet/access.py 共享解锁状态 - 首页新增「拾味」入口
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
{% comment %}拾味:写操作解锁条,与拾匣共用密码{% endcomment %}
|
||||
<section class="rf-lock{% if unlocked %} is-open{% endif %}">
|
||||
<span class="rf-lock-dot" aria-hidden="true"></span>
|
||||
<span class="rf-lock-text">{% if unlocked %}写操作已解锁{% else %}写操作未解锁{% endif %}</span>
|
||||
|
||||
{% if unlocked %}
|
||||
<button class="rf-btn rf-btn-ghost" id="rfLockBtn" type="button">锁定</button>
|
||||
{% else %}
|
||||
<form class="rf-unlock" id="rfUnlockForm">
|
||||
<input type="password" id="rfPassword" placeholder="输入密码" autocomplete="current-password">
|
||||
<button class="rf-btn rf-btn-primary" type="submit">解锁</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
<span class="rf-lock-hint">与拾匣共用密码{% if unlocked %} · 约剩 {{ minutes_left }} 分钟{% endif %}</span>
|
||||
</section>
|
||||
<div class="rf-error" id="rfError" hidden></div>
|
||||
@@ -0,0 +1,139 @@
|
||||
{% extends "base_content.html" %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}{{ work.title }} · 拾味{% endblock %}
|
||||
{% block description %}{{ work.summary|default:work.title }}{% endblock %}
|
||||
{% block brand_sub %}MIND MAP · REFLECTIONS{% endblock %}
|
||||
{% block footer %}© 2026 拾光<span class="dot"></span>看过 · 读过 · 想过{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="rf rf-detail" id="reflections"
|
||||
data-unlocked="{{ unlocked|yesno:'true,false' }}"
|
||||
data-work-id="{{ work.id }}">
|
||||
|
||||
<a class="rf-back" href="{% url 'reflections:index' %}">← 拾味</a>
|
||||
|
||||
{% include "reflections/_lock.html" %}
|
||||
|
||||
<article class="rf-work kind-{{ work.kind }}">
|
||||
<div class="rf-work-cover">
|
||||
{% with cover=work.images.all|first %}
|
||||
{% if cover %}
|
||||
<img src="{{ cover.image.url }}" alt="{{ work.title }}">
|
||||
{% else %}
|
||||
<span class="rf-cover-ph" aria-hidden="true">{{ work.kind_char }}</span>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
<div class="rf-work-info">
|
||||
<span class="rf-kind">{{ work.get_kind_display }}</span>
|
||||
<h1>{{ work.title }}</h1>
|
||||
<p class="rf-work-sub">{% if work.creator %}{{ work.creator }}{% endif %}{% if work.creator and work.year %} · {% endif %}{% if work.year %}{{ work.year }}{% endif %}</p>
|
||||
{% if work.rating %}
|
||||
<div class="rf-stars rf-stars-lg" aria-label="{{ work.rating }} 星">{% for i in "12345" %}{% if forloop.counter <= work.rating %}★{% else %}☆{% endif %}{% endfor %}</div>
|
||||
{% endif %}
|
||||
{% if work.summary %}<p class="rf-summary">{{ work.summary|linebreaksbr }}</p>{% endif %}
|
||||
<div class="rf-work-meta">
|
||||
<span>{{ work.reflections.count }} 条随感</span>
|
||||
<i aria-hidden="true"></i>
|
||||
<span>{{ work.images.count }} 张图</span>
|
||||
<i aria-hidden="true"></i>
|
||||
<span>{{ work.created_at|date:"Y-m-d" }} 建立</span>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<section class="rf-section">
|
||||
<div class="rf-section-head">
|
||||
<h2>图片</h2>
|
||||
{% if unlocked %}
|
||||
<button class="rf-btn" id="rfUploadToggle" type="button">+ 上传图片</button>
|
||||
{% else %}
|
||||
<span class="rf-write-hint">解锁后可上传</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if unlocked %}
|
||||
<form class="rf-form" id="rfImageForm" hidden>
|
||||
<div class="rf-upload-row">
|
||||
<input type="file" name="images" accept="image/*" multiple required>
|
||||
<input type="text" name="caption" maxlength="200" placeholder="图片说明(可选,应用到这一批)">
|
||||
</div>
|
||||
<div class="rf-progress" hidden><i></i></div>
|
||||
<div class="rf-form-actions">
|
||||
<button class="rf-btn rf-btn-primary" type="submit">上传</button>
|
||||
<button class="rf-btn rf-btn-ghost" type="button" id="rfUploadCancel">取消</button>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% if work.images.all %}
|
||||
<div class="rf-gallery">
|
||||
{% for image in work.images.all %}
|
||||
<figure class="rf-photo">
|
||||
<img src="{{ image.image.url }}" alt="{{ image.caption|default:work.title }}" loading="lazy" data-lightbox>
|
||||
{% if image.caption %}<figcaption>{{ image.caption }}</figcaption>{% endif %}
|
||||
{% if unlocked %}
|
||||
<button class="rf-del" type="button" data-delete-image="{{ image.id }}" aria-label="删除图片">×</button>
|
||||
{% endif %}
|
||||
</figure>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="rf-empty-line">还没有图片。{% if unlocked %}点“上传图片”放几张海报或剧照。{% endif %}</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<section class="rf-section">
|
||||
<div class="rf-section-head">
|
||||
<h2>随感</h2>
|
||||
{% if unlocked %}
|
||||
<button class="rf-btn" id="rfReflectionToggle" type="button">+ 写一条</button>
|
||||
{% else %}
|
||||
<span class="rf-write-hint">解锁后可写</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if unlocked %}
|
||||
<form class="rf-form" id="rfReflectionForm" hidden>
|
||||
<textarea name="content" rows="4" maxlength="5000" placeholder="看完 / 读完,想留下点什么……"></textarea>
|
||||
<div class="rf-form-actions">
|
||||
<button class="rf-btn rf-btn-primary" type="submit">记下</button>
|
||||
<button class="rf-btn rf-btn-ghost" type="button" id="rfReflectionCancel">取消</button>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% if work.reflections.all %}
|
||||
<div class="rf-refl-list">
|
||||
{% for note in work.reflections.all %}
|
||||
<article class="rf-refl">
|
||||
<time>{{ note.created_at|date:"Y-m-d H:i" }}</time>
|
||||
<div class="rf-refl-text">{{ note.content|linebreaksbr }}</div>
|
||||
{% if unlocked %}
|
||||
<button class="rf-del" type="button" data-delete-reflection="{{ note.id }}" aria-label="删除这条随感">×</button>
|
||||
{% endif %}
|
||||
</article>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="rf-empty-line">还没有随感。{% if unlocked %}写第一条吧。{% endif %}</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<p class="rf-note">图片与随感对所有人可见;上传、写和删除需要密码,与拾匣共用。</p>
|
||||
</div>
|
||||
|
||||
<div class="rf-lightbox" id="rfLightbox" hidden>
|
||||
<img alt="">
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
<link rel="stylesheet" href="{% static 'reflections/reflections.css' %}">
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script src="{% static 'reflections/reflections.js' %}"></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,126 @@
|
||||
{% extends "base_content.html" %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}拾味 · 影评与读书随感{% endblock %}
|
||||
{% block description %}电影、书,或任何值得记一笔的东西:放几张图,也放你的想法。{% endblock %}
|
||||
{% block brand_sub %}MIND MAP · REFLECTIONS{% endblock %}
|
||||
{% block footer %}© 2026 拾光<span class="dot"></span>看过 · 读过 · 想过{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="rf" id="reflections"
|
||||
data-unlocked="{{ unlocked|yesno:'true,false' }}">
|
||||
|
||||
<header class="rf-head">
|
||||
<p class="rf-eyebrow"><span aria-hidden="true">✦</span>拾味 · REFLECTIONS</p>
|
||||
<h1>看过、读过,<br><em>都留一点余味</em></h1>
|
||||
<p class="rf-sub">电影、书,或任何值得记一笔的东西。放几张图,也放你的想法。</p>
|
||||
</header>
|
||||
|
||||
{% include "reflections/_lock.html" %}
|
||||
|
||||
<nav class="rf-tabs" aria-label="类型筛选">
|
||||
<a class="rf-tab{% if kind == 'all' %} is-active{% endif %}" href="?kind=all">
|
||||
全部 <b>{{ counts.all }}</b>
|
||||
</a>
|
||||
{% for tab in kind_tabs %}
|
||||
<a class="rf-tab{% if kind == tab.key %} is-active{% endif %}" href="?kind={{ tab.key }}">
|
||||
{{ tab.label }} <b>{{ tab.count }}</b>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</nav>
|
||||
|
||||
<div class="rf-toolbar">
|
||||
<p class="rf-count">
|
||||
共 <b>{{ counts.all }}</b> 个条目{% if kind != 'all' %} · 当前筛选{% endif %}
|
||||
</p>
|
||||
{% if unlocked %}
|
||||
<button class="rf-btn rf-btn-primary" id="rfNewBtn" type="button">+ 新建条目</button>
|
||||
{% else %}
|
||||
<span class="rf-write-hint">解锁后可以新建</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if unlocked %}
|
||||
<form class="rf-form rf-new-form" id="rfNewForm" hidden>
|
||||
<div class="rf-form-grid">
|
||||
<label>类型
|
||||
<select name="kind">
|
||||
{% for key, label in kinds %}
|
||||
<option value="{{ key }}">{{ label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
<label>标题
|
||||
<input type="text" name="title" maxlength="200" required placeholder="电影 / 书名">
|
||||
</label>
|
||||
<label>导演 / 作者
|
||||
<input type="text" name="creator" maxlength="120" placeholder="可选">
|
||||
</label>
|
||||
<label>年份
|
||||
<input type="number" name="year" min="0" max="2100" placeholder="可选">
|
||||
</label>
|
||||
<label>评分
|
||||
<select name="rating">
|
||||
<option value="0">未评分</option>
|
||||
<option value="1">★ 1</option>
|
||||
<option value="2">★★ 2</option>
|
||||
<option value="3">★★★ 3</option>
|
||||
<option value="4">★★★★ 4</option>
|
||||
<option value="5">★★★★★ 5</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="wide">简介
|
||||
<textarea name="summary" rows="2" maxlength="2000" placeholder="一句话简介(可选)"></textarea>
|
||||
</label>
|
||||
</div>
|
||||
<div class="rf-form-actions">
|
||||
<button class="rf-btn rf-btn-primary" type="submit">创建</button>
|
||||
<button class="rf-btn rf-btn-ghost" type="button" id="rfNewCancel">取消</button>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% if works %}
|
||||
<div class="rf-grid">
|
||||
{% for work in works %}
|
||||
{% with cover=work.images.all|first %}
|
||||
<a class="rf-card kind-{{ work.kind }}" href="{% url 'reflections:detail' work.id %}">
|
||||
<span class="rf-cover">
|
||||
{% if cover %}
|
||||
<img src="{{ cover.image.url }}" alt="{{ work.title }}" loading="lazy">
|
||||
{% else %}
|
||||
<span class="rf-cover-ph" aria-hidden="true">{{ work.kind_char }}</span>
|
||||
{% endif %}
|
||||
<span class="rf-kind">{{ work.get_kind_display }}</span>
|
||||
{% if work.rating %}
|
||||
<span class="rf-stars" aria-label="{{ work.rating }} 星">{% for i in "12345" %}{% if forloop.counter <= work.rating %}★{% else %}☆{% endif %}{% endfor %}</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
<span class="rf-card-body">
|
||||
<span class="rf-card-title">{{ work.title }}</span>
|
||||
<span class="rf-card-sub">{% if work.creator %}{{ work.creator }}{% endif %}{% if work.creator and work.year %} · {% endif %}{% if work.year %}{{ work.year }}{% endif %}</span>
|
||||
<span class="rf-card-meta">{{ work.reflection_count }} 条随感 · {{ work.image_count }} 张图</span>
|
||||
</span>
|
||||
</a>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="rf-empty">
|
||||
<p class="rf-empty-mark" aria-hidden="true">✦</p>
|
||||
<h2>还没有条目</h2>
|
||||
<p>{% if unlocked %}点“新建条目”,从一部电影或一本书开始。{% else %}解锁后可以新建第一个条目。{% endif %}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<p class="rf-note">条目、图片和随感对所有人可见;新建、上传和删除需要密码,与拾匣共用。</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
<link rel="stylesheet" href="{% static 'reflections/reflections.css' %}">
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script src="{% static 'reflections/reflections.js' %}"></script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user