42 Commits

Author SHA1 Message Date
068000515a refactor: simplify cookie handling in middleware
- Updated LanguageMiddleware and UserIdentityMiddleware to always set cookies for language and user ID, respectively, removing conditional checks for existing cookies. This streamlines the cookie management process and ensures consistent behavior across sessions.
2025-06-18 13:33:39 +08:00
1bd19235e0 feat: add Content-Disposition header for file downloads in download_scale_results
- Enhanced the download_scale_results function to include a Content-Disposition header, specifying the filename for the "psychoscales.db" file download. This improves the user experience by prompting the correct file name during downloads.
2025-06-17 16:10:19 +08:00
3eb477161e feat: enhance file download response headers in download_scale_results endpoint
- Updated the download_scale_results function to return additional cache control headers for the "psychoscales.db" file download, improving client-side caching behavior.
- Ensured consistent response headers for CSV file downloads, enhancing the overall file handling experience.
2025-06-17 16:04:23 +08:00
cfb7ddedd3 feat: implement user identity middleware for session management
- Added UserIdentityMiddleware to manage user sessions by generating a unique user ID stored in a cookie.
- Implemented logic to update the last seen timestamp for existing users in the database.
- Enhanced ScaleResult model to associate responses with users, improving data tracking and user experience.
2025-06-17 15:44:10 +08:00
27f2479108 feat: enhance language handling in middleware
- Updated LanguageMiddleware in app.py to retrieve the user's language preference from cookies if not provided in query parameters.
- Added logic to set a cookie for the language, ensuring consistent language detection and user experience across sessions.
2025-06-17 14:01:48 +08:00
d9d6dfcdc0 refactor: streamline load_all_scales calls in scale endpoints
- Updated scale and result endpoints in app.py to consistently call load_all_scales with the language parameter, improving code clarity and maintaining uniformity in scale data retrieval.
2025-06-17 08:42:00 +08:00
0f2416089c refactor: simplify load_all_scales calls in scale endpoints
- Updated scale and result endpoints in app.py to call load_all_scales without the language parameter, streamlining the function usage.
- This change enhances code clarity and maintains consistency in scale data retrieval.
2025-06-17 08:33:47 +08:00
6c905dc3ce feat: implement dynamic README loading based on user language
- Updated app.py to load the README content from language-specific markdown files located in the templates directory.
- Added new index.md files for English and Chinese, providing localized information about PsychoScales.Org and its resources.
2025-06-17 08:27:01 +08:00
e46d17eaf2 feat: enhance load_all_scales function for language support
- Updated load_all_scales to accept an optional language parameter, allowing for the loading of scales based on the specified language.
- Modified calls to load_all_scales in various endpoints to pass the user's detected language, ensuring consistent language handling across the application.
2025-06-17 08:23:10 +08:00
27794895c9 feat: implement multilingual template support
- Updated app.py to dynamically load Jinja2 templates based on the detected language.
- Created new template files for English and Chinese, including base, index, list, scale, and result pages.
- Modified template rendering logic to utilize the appropriate language-specific templates based on user preferences.
2025-06-17 08:08:18 +08:00
8f202262ee feat: add language detection middleware for request handling
- Implemented LanguageMiddleware to determine the user's language based on query parameters, Accept-Language header, or IP address.
- Updated the FastAPI app to include the middleware and pass the detected language to templates.
- Modified base.html to dynamically set the HTML language attribute based on the detected language.
2025-06-17 07:48:38 +08:00
eb4d670ee0 fix: update sitemap URLs to use the www subdomain
- Modified the sitemap generation logic in app.py to prepend 'www.' to the base URL for static routes, tag routes, and scale routes.
- This change ensures consistency in URL formatting and improves SEO by standardizing the domain used in the sitemap.
2025-06-16 17:53:22 +08:00
f7895dc2fe fix: update scale ID check in download_scale_results endpoint
- Changed the scale ID check in the download_scale_results function from "database" to "psychoscales.db" for improved clarity and accuracy in file retrieval.
- This adjustment ensures the correct database file is accessed when downloading scale results.
2025-06-16 10:26:49 +08:00
e50dc7a9d4 fix: remove token parameter from download_scale_results endpoint
- Updated the download_scale_results function to eliminate the token parameter, simplifying the endpoint's signature.
- This change enhances clarity and aligns with the current requirements for accessing scale results.
2025-06-16 10:23:44 +08:00
319844e55c feat: add CSV download endpoint for scale results
- Implemented a new endpoint to download scale results as a CSV file.
- The endpoint retrieves responses based on the scale ID and formats the data, including question IDs and subscale scores, into a CSV format.
- Updated database URL to remove the public directory reference for better file access.
2025-06-16 10:19:52 +08:00
d99d7f7c12 fix: correct public file path handling in get_public_file function
- Moved the public_path assignment to ensure it is set before checking for the file's existence.
- This change resolves potential issues when accessing files in the public directory.
2025-06-16 09:32:23 +08:00
fc9d439cf9 feat: add created_at timestamp to ScaleResult model and response handling
- Introduced created_at field in the ScaleResult model to track response creation time.
- Updated result handling logic in app.py to populate created_at with the current UTC time when saving responses.
2025-06-16 09:08:21 +08:00
90720b3cec refactor: rename RawResponse to ScaleResult for improved clarity
- Updated the database model from RawResponse to ScaleResult to better reflect its purpose.
- Adjusted the result handling logic in app.py to utilize the new ScaleResult model for storing user responses.
2025-06-16 06:50:25 +08:00
ce020a5674 refactor: update response model and location handling
- Renamed RawResponse model to Response for clarity.
- Changed location field type from String to JSON in the Response model.
- Updated result handling logic to store location as a JSON object instead of a string.
2025-06-16 06:47:40 +08:00
e3b3b5a1f6 feat: 添加异常处理以增强数据库保存逻辑
- 在结果处理逻辑中添加try-except块,以捕获保存用户响应到数据库时的异常
- 确保在发生错误时能够打印异常信息,提升系统的稳定性和可调试性
2025-06-16 06:29:46 +08:00
ee9e6a5cca feat: 增强IP地址记录功能以支持地理位置获取
- 在app.py中新增GeoIP2数据库支持,获取用户IP的地理位置信息
- 更新RawResponse模型,新增location、raw_response、sum_response和avg_response字段以存储更多用户响应数据
- 修改结果处理逻辑,保存用户的地理位置信息和响应数据
- 更新.gitignore以排除GeoLite2-City.mmdb文件
2025-06-16 06:13:11 +08:00
e08909eacd feat: 更新IP地址记录逻辑以支持代理头
- 修改结果处理逻辑以获取真实IP地址,考虑代理头的影响
- 更新RawResponse模型中的ip_address字段以保存用户的真实IP
2025-06-16 05:33:40 +08:00
ff44ce6264 feat: 增加IP地址记录功能以保存用户响应
- 在RawResponse模型中新增ip_address字段
- 更新结果处理逻辑以记录用户的IP地址
2025-06-16 05:27:45 +08:00
7989c8ed4e feat: 添加数据库支持以保存问卷响应
- 新增数据库模型和连接配置,使用SQLite存储问卷响应
- 更新结果处理逻辑,将用户响应保存到数据库
- 更新.gitignore以排除数据库文件和缓存目录
2025-06-16 05:17:49 +08:00
6e49fadbab feat: 添加网站地图生成功能并优化公共文件访问
- 新增生成sitemap.xml的功能,包含静态和动态路由
- 优化公共文件访问接口,支持直接返回sitemap.xml
2025-06-16 04:15:44 +08:00
345c571dda feat: 增加公共文件访问功能并添加favicon和robots.txt
- 新增公共文件访问接口,允许从public目录获取文件
- 添加favicon.ico以改善网站标识
- 新增robots.txt以指导搜索引擎爬虫行为
2025-06-16 03:50:28 +08:00
df77a10735 添加均分计算 2025-05-17 20:03:45 +08:00
mxr612
6b41b8e096 refactor: 重构标签处理和界面文本
- 删除tagmap.yml文件,简化标签处理逻辑
- 将标签存储方式从字典改为列表,减少复杂性
- 更新界面文本,将"PsychoScales"替换为"心尺"
- 修改README.md中的项目描述,使其更简洁清晰
2025-04-26 20:44:29 +08:00
mxr612
72db5c8b83 feat: 新增中庸实践思维量表和SCL90量表
新增中文版中庸实践思维量表和英文版SCL90量表,用于心理评估。同时优化了加载问卷数据的逻辑,支持递归遍历文件夹以加载所有问卷文件。
2025-04-22 21:19:22 +08:00
mxr612
7fe421368e 说明、样式和一点优化 2025-03-15 20:35:33 +08:00
mxr612
74546fc2fb 更改了两处量表配置命名,优化了一处css 2025-03-14 23:52:54 +08:00
mxr612
4fc9660f8b 修复了量表计算逻辑,修复了量表required提示 2025-03-10 12:48:42 +00:00
mxr612
f817765913 优化了list页面样式 2025-03-09 10:38:10 +00:00
mxr612
4a99a7b9d1 将tag目录置为/tag/{tag},避免与其他目录冲突。 2025-03-08 07:55:25 +00:00
mxr612
441768dab0 使用了html模板;增加了导航栏;将lang改为看起来更加通用的tag 2025-03-07 12:47:41 +00:00
mxr612
4954abfca4 增加了首页语言分类及语言二级菜单,美化了结果路径,添加了内容层级及content居中 2025-03-07 03:54:04 +00:00
mxr612
22c222813b 完善了样例量表,增加了描述中数学公式的支持。 2025-03-05 11:49:52 +00:00
mxr612
9356c13339 替换json为yml加载,简化了编辑。同时优化了数据结构 2025-03-05 10:08:57 +00:00
mxr612
1566a795eb 添加了CSS样式 2025-03-05 03:34:45 +00:00
mxr612
f0440a21a2 增添了首页加载README.md 2025-03-05 03:09:51 +00:00
mxr612
f65e26e093 更换成FastAPI架构,修正了一处量表描述。 2025-03-04 23:51:03 +08:00
mxr612
97a3b7b7bf 使用Flask和PyScript构建了一个简单的量表网站框架,实现了:
1. 纯json的量表编辑
2. 任意区间的Ratio填写
3. 可选的Reverse item
4. 可按照子量表计算结果
2025-03-04 19:29:43 +08:00