- Defer polling_service.start() and FilterEngine init to a one-shot before_request hook so importing app.py no longer spawns a scheduler thread (also fixes migrate_*.py import side effects). - Fix migrate_bookmarks.py: init_db returns None, so use the shared `db` instead of assigning its None return. - Enforce MIN_PASSWORD_LENGTH (8) in the password-reset route for consistency with signup (was hardcoded 6). - post_detail.html: replace undefined moment(...).fromNow() (always "Recently") with a new timeago Jinja filter + data-timestamp attrs that also drive the existing JS updater; make nl2br escape-then-Markup and drop | safe from comment/post content to close the XSS hole. - filter_pipeline: when AI is disabled but a filterset requires it, pass posts through with status=FAILED + explicit error instead of silently degrading to no_filter. No source-file mojibake found; content-encoding ingest is a Phase 3 concern. Co-Authored-By: Claude <noreply@anthropic.com>
41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Migration script to create the bookmarks table.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
from database import init_db, db
|
|
from flask import Flask
|
|
|
|
# Add the current directory to Python path
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
def create_app():
|
|
"""Create minimal Flask app for migration"""
|
|
app = Flask(__name__)
|
|
app.config['SECRET_KEY'] = 'migration-secret'
|
|
return app
|
|
|
|
def main():
|
|
"""Run the migration"""
|
|
print("Creating bookmarks table...")
|
|
|
|
app = create_app()
|
|
|
|
with app.app_context():
|
|
# Initialize database (init_db binds the shared `db` extension; it
|
|
# returns None, so use the module-level `db` directly).
|
|
init_db(app)
|
|
|
|
# Import models to register them
|
|
from models import User, Session, PollSource, PollLog, Bookmark
|
|
|
|
# Create all tables (will only create missing ones)
|
|
db.create_all()
|
|
|
|
print("✓ Bookmarks table created successfully!")
|
|
print("Migration completed.")
|
|
|
|
if __name__ == '__main__':
|
|
main() |