- 新增 SystemNotification 模型,实现系统通知的数据存储 - 管理后台新增通知相关接口,支持通知的增删改查 - 用户端新增接口,获取最新激活通知并支持标记已读 - 在前端首页添加全局通知弹窗,实现通知自动轮询及已读同步 - 生成历史记录中兼容支持图片缩略图及新旧图片格式 - 优化后台图片同步逻辑,新增缩略图生成与存储 - 支持上传参考图的拖拽、粘贴、多文件上传及排序功能 - 增加购买积分页面入口及菜单项,调整菜单结构 - 日志系统由 Redis 列表迁移为有序集合,保留 30 天日志 - 优化日志页面样式,提升可读性及滚动体验 - 调整部分模板布局为自定义滚动条容器,增强视觉一致性
84 lines
2.1 KiB
Python
84 lines
2.1 KiB
Python
#
|
|
# The Python Imaging Library.
|
|
# $Id$
|
|
#
|
|
# XV Thumbnail file handler by Charles E. "Gene" Cash
|
|
# (gcash@magicnet.net)
|
|
#
|
|
# see xvcolor.c and xvbrowse.c in the sources to John Bradley's XV,
|
|
# available from ftp://ftp.cis.upenn.edu/pub/xv/
|
|
#
|
|
# history:
|
|
# 98-08-15 cec created (b/w only)
|
|
# 98-12-09 cec added color palette
|
|
# 98-12-28 fl added to PIL (with only a few very minor modifications)
|
|
#
|
|
# To do:
|
|
# FIXME: make save work (this requires quantization support)
|
|
#
|
|
from __future__ import annotations
|
|
|
|
from . import Image, ImageFile, ImagePalette
|
|
from ._binary import o8
|
|
|
|
_MAGIC = b"P7 332"
|
|
|
|
# standard color palette for thumbnails (RGB332)
|
|
PALETTE = b""
|
|
for r in range(8):
|
|
for g in range(8):
|
|
for b in range(4):
|
|
PALETTE = PALETTE + (
|
|
o8((r * 255) // 7) + o8((g * 255) // 7) + o8((b * 255) // 3)
|
|
)
|
|
|
|
|
|
def _accept(prefix: bytes) -> bool:
|
|
return prefix.startswith(_MAGIC)
|
|
|
|
|
|
##
|
|
# Image plugin for XV thumbnail images.
|
|
|
|
|
|
class XVThumbImageFile(ImageFile.ImageFile):
|
|
format = "XVThumb"
|
|
format_description = "XV thumbnail image"
|
|
|
|
def _open(self) -> None:
|
|
# check magic
|
|
assert self.fp is not None
|
|
|
|
if not _accept(self.fp.read(6)):
|
|
msg = "not an XV thumbnail file"
|
|
raise SyntaxError(msg)
|
|
|
|
# Skip to beginning of next line
|
|
self.fp.readline()
|
|
|
|
# skip info comments
|
|
while True:
|
|
s = self.fp.readline()
|
|
if not s:
|
|
msg = "Unexpected EOF reading XV thumbnail file"
|
|
raise SyntaxError(msg)
|
|
if s[0] != 35: # ie. when not a comment: '#'
|
|
break
|
|
|
|
# parse header line (already read)
|
|
w, h = s.strip().split(maxsplit=2)[:2]
|
|
|
|
self._mode = "P"
|
|
self._size = int(w), int(h)
|
|
|
|
self.palette = ImagePalette.raw("RGB", PALETTE)
|
|
|
|
self.tile = [
|
|
ImageFile._Tile("raw", (0, 0) + self.size, self.fp.tell(), self.mode)
|
|
]
|
|
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
Image.register_open(XVThumbImageFile.format, XVThumbImageFile, _accept)
|