ai-first-cli 1.3.1 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ai-dev/index.db +0 -0
- package/CHANGELOG.md +241 -0
- package/PHASE1_USER_SIMULATION.md +56 -0
- package/PHASE2_USER_SIMULATION.md +81 -0
- package/PHASE3_USER_SIMULATION.md +176 -0
- package/README.es.md +73 -0
- package/README.md +119 -15
- package/ai/graph/knowledge-graph.json +10 -0
- package/ai-context/ai_context.md +130 -0
- package/{test-projects/react-app/.ai-dev → ai-context}/ai_rules.md +10 -5
- package/ai-context/architecture.md +136 -0
- package/ai-context/context/features/src.json +69 -0
- package/ai-context/context/features/test-projects.json +69 -0
- package/ai-context/context/flows/ai-first.json +9 -0
- package/ai-context/context/flows/auth.json +13 -0
- package/ai-context/context/flows/doctor.json +9 -0
- package/ai-context/context/flows/explore.json +9 -0
- package/ai-context/context/flows/routes.json +15 -0
- package/ai-context/context/flows/user.json +23 -0
- package/ai-context/context/flows/views.json +12 -0
- package/{test-projects/react-app/.ai-dev → ai-context}/conventions.md +3 -2
- package/ai-context/dependencies.json +3360 -0
- package/ai-context/entrypoints.md +45 -0
- package/ai-context/index-state.json +196 -0
- package/ai-context/modules.json +901 -0
- package/ai-context/project.json +33 -0
- package/ai-context/repo_map.json +8857 -0
- package/ai-context/repo_map.md +2002 -0
- package/{test-projects/flask-app/.ai-dev → ai-context}/schema.json +1 -1
- package/ai-context/summary.md +46 -0
- package/ai-context/symbols.json +82467 -0
- package/{test-projects/react-app/.ai-dev → ai-context}/tech_stack.md +15 -7
- package/ai-context-evaluation-report-1774223059505.md +206 -0
- package/dist/analyzers/architecture.d.ts.map +1 -1
- package/dist/analyzers/architecture.js +78 -5
- package/dist/analyzers/architecture.js.map +1 -1
- package/dist/analyzers/entrypoints.d.ts.map +1 -1
- package/dist/analyzers/entrypoints.js +358 -0
- package/dist/analyzers/entrypoints.js.map +1 -1
- package/dist/analyzers/symbols.d.ts.map +1 -1
- package/dist/analyzers/symbols.js +119 -3
- package/dist/analyzers/symbols.js.map +1 -1
- package/dist/analyzers/techStack.d.ts +8 -0
- package/dist/analyzers/techStack.d.ts.map +1 -1
- package/dist/analyzers/techStack.js +118 -0
- package/dist/analyzers/techStack.js.map +1 -1
- package/dist/utils/fileUtils.d.ts.map +1 -1
- package/dist/utils/fileUtils.js +5 -0
- package/dist/utils/fileUtils.js.map +1 -1
- package/package.json +1 -1
- package/scripts/ai-context-evaluator.ts +440 -0
- package/src/analyzers/architecture.ts +83 -6
- package/src/analyzers/entrypoints.ts +400 -0
- package/src/analyzers/symbols.ts +129 -3
- package/src/analyzers/techStack.ts +137 -0
- package/src/utils/fileUtils.ts +5 -0
- package/tests/apex-parser.test.ts +193 -0
- package/tests/cli-commands-batch1.test.ts +808 -0
- package/tests/cli-commands-batch2.test.ts +1113 -0
- package/tests/cli-commands-batch3.test.ts +1128 -0
- package/tests/cli-index.test.ts +1007 -0
- package/tests/cli-init.test.ts +761 -0
- package/tests/entrypoints-languages.test.ts +373 -0
- package/tests/framework-detection.test.ts +296 -0
- package/tests/salesforce-apex-classes.test.ts +713 -0
- package/tests/salesforce-apex-triggers.test.ts +871 -0
- package/tests/salesforce-custom-objects.test.ts +918 -0
- package/tests/salesforce-flows.test.ts +710 -0
- package/tests/salesforce-lwc.test.ts +963 -0
- package/tests/salesforce-sfdx-integration.test.ts +1125 -0
- package/ANALISIS_COMPLETO.md +0 -424
- package/ANALISIS_MEJORAS.md +0 -327
- package/CONTRIBUTING.md +0 -89
- package/FLOW.md +0 -129
- package/TEST_RESULTS.md +0 -198
- package/TEST_RESULTS_COMPARATIVE.md +0 -159
- package/TEST_RESULTS_COMPLETE.md +0 -127
- package/TEST_RESULTS_COMPREHENSIVE.md +0 -208
- package/install.sh +0 -188
- package/run-all-tests.sh +0 -184
- package/test-ai-context-understanding.sh +0 -21
- package/test-projects/django-app/.ai-dev/ai_context.md +0 -92
- package/test-projects/django-app/.ai-dev/ai_rules.md +0 -47
- package/test-projects/django-app/.ai-dev/architecture.md +0 -57
- package/test-projects/django-app/.ai-dev/cache.json +0 -169
- package/test-projects/django-app/.ai-dev/context/flows/views.json +0 -10
- package/test-projects/django-app/.ai-dev/conventions.md +0 -51
- package/test-projects/django-app/.ai-dev/dependencies.json +0 -312
- package/test-projects/django-app/.ai-dev/entrypoints.md +0 -4
- package/test-projects/django-app/.ai-dev/files.json +0 -209
- package/test-projects/django-app/.ai-dev/graph/knowledge-graph.json +0 -36
- package/test-projects/django-app/.ai-dev/graph/module-graph.json +0 -145
- package/test-projects/django-app/.ai-dev/graph/symbol-graph.json +0 -1488
- package/test-projects/django-app/.ai-dev/graph/symbol-references.json +0 -1
- package/test-projects/django-app/.ai-dev/index-state.json +0 -294
- package/test-projects/django-app/.ai-dev/modules.json +0 -35
- package/test-projects/django-app/.ai-dev/project.json +0 -11
- package/test-projects/django-app/.ai-dev/repo_map.json +0 -412
- package/test-projects/django-app/.ai-dev/repo_map.md +0 -105
- package/test-projects/django-app/.ai-dev/schema.json +0 -5
- package/test-projects/django-app/.ai-dev/summary.md +0 -15
- package/test-projects/django-app/.ai-dev/symbols.json +0 -1
- package/test-projects/django-app/.ai-dev/tech_stack.md +0 -32
- package/test-projects/django-app/README.md +0 -91
- package/test-projects/django-app/blog/__init__.py +0 -0
- package/test-projects/django-app/blog/admin.py +0 -31
- package/test-projects/django-app/blog/models.py +0 -55
- package/test-projects/django-app/blog/serializers.py +0 -69
- package/test-projects/django-app/blog/urls.py +0 -14
- package/test-projects/django-app/blog/views.py +0 -96
- package/test-projects/django-app/django_app/__init__.py +0 -0
- package/test-projects/django-app/django_app/settings.py +0 -90
- package/test-projects/django-app/django_app/urls.py +0 -11
- package/test-projects/django-app/django_app/wsgi.py +0 -9
- package/test-projects/django-app/manage.py +0 -23
- package/test-projects/django-app/requirements.txt +0 -3
- package/test-projects/django-app/users/__init__.py +0 -0
- package/test-projects/django-app/users/admin.py +0 -42
- package/test-projects/django-app/users/models.py +0 -54
- package/test-projects/django-app/users/serializers.py +0 -113
- package/test-projects/django-app/users/urls.py +0 -13
- package/test-projects/django-app/users/views.py +0 -135
- package/test-projects/express-api/.ai-dev/ai_context.md +0 -112
- package/test-projects/express-api/.ai-dev/ai_rules.md +0 -50
- package/test-projects/express-api/.ai-dev/architecture.md +0 -62
- package/test-projects/express-api/.ai-dev/context/features/controllers.json +0 -13
- package/test-projects/express-api/.ai-dev/context/features/services.json +0 -13
- package/test-projects/express-api/.ai-dev/context/flows/auth.json +0 -12
- package/test-projects/express-api/.ai-dev/context/flows/user.json +0 -13
- package/test-projects/express-api/.ai-dev/conventions.md +0 -51
- package/test-projects/express-api/.ai-dev/dependencies.json +0 -54
- package/test-projects/express-api/.ai-dev/entrypoints.md +0 -17
- package/test-projects/express-api/.ai-dev/modules.json +0 -30
- package/test-projects/express-api/.ai-dev/project.json +0 -15
- package/test-projects/express-api/.ai-dev/repo_map.json +0 -100
- package/test-projects/express-api/.ai-dev/repo_map.md +0 -36
- package/test-projects/express-api/.ai-dev/schema.json +0 -5
- package/test-projects/express-api/.ai-dev/summary.md +0 -14
- package/test-projects/express-api/.ai-dev/symbols.json +0 -7
- package/test-projects/express-api/.ai-dev/tech_stack.md +0 -38
- package/test-projects/express-api/.ai-dev/tools.json +0 -10
- package/test-projects/express-api/controllers/authController.js +0 -32
- package/test-projects/express-api/controllers/userController.js +0 -51
- package/test-projects/express-api/index.js +0 -30
- package/test-projects/express-api/middleware/authMiddleware.js +0 -30
- package/test-projects/express-api/models/userRepository.js +0 -25
- package/test-projects/express-api/package.json +0 -18
- package/test-projects/express-api/services/authService.js +0 -17
- package/test-projects/express-api/services/userService.js +0 -28
- package/test-projects/fastapi-app/.ai-dev/ai_context.md +0 -89
- package/test-projects/fastapi-app/.ai-dev/ai_rules.md +0 -47
- package/test-projects/fastapi-app/.ai-dev/architecture.md +0 -39
- package/test-projects/fastapi-app/.ai-dev/cache.json +0 -125
- package/test-projects/fastapi-app/.ai-dev/conventions.md +0 -51
- package/test-projects/fastapi-app/.ai-dev/dependencies.json +0 -244
- package/test-projects/fastapi-app/.ai-dev/entrypoints.md +0 -4
- package/test-projects/fastapi-app/.ai-dev/files.json +0 -154
- package/test-projects/fastapi-app/.ai-dev/graph/knowledge-graph.json +0 -15
- package/test-projects/fastapi-app/.ai-dev/graph/module-graph.json +0 -78
- package/test-projects/fastapi-app/.ai-dev/graph/symbol-graph.json +0 -1724
- package/test-projects/fastapi-app/.ai-dev/graph/symbol-references.json +0 -51
- package/test-projects/fastapi-app/.ai-dev/index-state.json +0 -217
- package/test-projects/fastapi-app/.ai-dev/modules.json +0 -16
- package/test-projects/fastapi-app/.ai-dev/project.json +0 -9
- package/test-projects/fastapi-app/.ai-dev/repo_map.json +0 -298
- package/test-projects/fastapi-app/.ai-dev/repo_map.md +0 -74
- package/test-projects/fastapi-app/.ai-dev/schema.json +0 -5
- package/test-projects/fastapi-app/.ai-dev/summary.md +0 -12
- package/test-projects/fastapi-app/.ai-dev/symbols.json +0 -1
- package/test-projects/fastapi-app/.ai-dev/tech_stack.md +0 -32
- package/test-projects/fastapi-app/.ai-dev/tools.json +0 -10
- package/test-projects/fastapi-app/README.md +0 -118
- package/test-projects/fastapi-app/app/database.py +0 -21
- package/test-projects/fastapi-app/app/dependencies.py +0 -107
- package/test-projects/fastapi-app/app/main.py +0 -47
- package/test-projects/fastapi-app/app/models.py +0 -149
- package/test-projects/fastapi-app/app/routers/auth.py +0 -117
- package/test-projects/fastapi-app/app/routers/posts.py +0 -272
- package/test-projects/fastapi-app/app/schemas.py +0 -191
- package/test-projects/fastapi-app/requirements.txt +0 -10
- package/test-projects/flask-app/.ai-dev/ai_context.md +0 -94
- package/test-projects/flask-app/.ai-dev/ai_rules.md +0 -47
- package/test-projects/flask-app/.ai-dev/architecture.md +0 -49
- package/test-projects/flask-app/.ai-dev/cache.json +0 -157
- package/test-projects/flask-app/.ai-dev/context/features/app.json +0 -25
- package/test-projects/flask-app/.ai-dev/context/flows/routes.json +0 -14
- package/test-projects/flask-app/.ai-dev/conventions.md +0 -51
- package/test-projects/flask-app/.ai-dev/dependencies.json +0 -298
- package/test-projects/flask-app/.ai-dev/entrypoints.md +0 -4
- package/test-projects/flask-app/.ai-dev/files.json +0 -194
- package/test-projects/flask-app/.ai-dev/graph/knowledge-graph.json +0 -60
- package/test-projects/flask-app/.ai-dev/graph/module-graph.json +0 -95
- package/test-projects/flask-app/.ai-dev/graph/symbol-graph.json +0 -1448
- package/test-projects/flask-app/.ai-dev/graph/symbol-references.json +0 -45
- package/test-projects/flask-app/.ai-dev/index-state.json +0 -273
- package/test-projects/flask-app/.ai-dev/modules.json +0 -21
- package/test-projects/flask-app/.ai-dev/project.json +0 -13
- package/test-projects/flask-app/.ai-dev/repo_map.json +0 -400
- package/test-projects/flask-app/.ai-dev/repo_map.md +0 -98
- package/test-projects/flask-app/.ai-dev/summary.md +0 -13
- package/test-projects/flask-app/.ai-dev/symbols.json +0 -1
- package/test-projects/flask-app/.ai-dev/tech_stack.md +0 -32
- package/test-projects/flask-app/.ai-dev/tools.json +0 -10
- package/test-projects/flask-app/README.md +0 -129
- package/test-projects/flask-app/app/__init__.py +0 -46
- package/test-projects/flask-app/app/api/__init__.py +0 -7
- package/test-projects/flask-app/app/api/routes.py +0 -122
- package/test-projects/flask-app/app/auth/__init__.py +0 -7
- package/test-projects/flask-app/app/auth/forms.py +0 -52
- package/test-projects/flask-app/app/auth/routes.py +0 -68
- package/test-projects/flask-app/app/blog/__init__.py +0 -7
- package/test-projects/flask-app/app/blog/forms.py +0 -35
- package/test-projects/flask-app/app/blog/routes.py +0 -140
- package/test-projects/flask-app/app/main/__init__.py +0 -7
- package/test-projects/flask-app/app/main/routes.py +0 -88
- package/test-projects/flask-app/app/models.py +0 -177
- package/test-projects/flask-app/config.py +0 -64
- package/test-projects/flask-app/requirements.txt +0 -10
- package/test-projects/laravel-app/.ai-dev/ai_context.md +0 -97
- package/test-projects/laravel-app/.ai-dev/ai_rules.md +0 -47
- package/test-projects/laravel-app/.ai-dev/architecture.md +0 -60
- package/test-projects/laravel-app/.ai-dev/cache.json +0 -161
- package/test-projects/laravel-app/.ai-dev/context/features/app.json +0 -21
- package/test-projects/laravel-app/.ai-dev/context/flows/.json +0 -9
- package/test-projects/laravel-app/.ai-dev/context/flows/category.json +0 -12
- package/test-projects/laravel-app/.ai-dev/context/flows/comment.json +0 -12
- package/test-projects/laravel-app/.ai-dev/context/flows/post.json +0 -12
- package/test-projects/laravel-app/.ai-dev/context/flows/unnamed.json +0 -9
- package/test-projects/laravel-app/.ai-dev/conventions.md +0 -51
- package/test-projects/laravel-app/.ai-dev/dependencies.json +0 -6
- package/test-projects/laravel-app/.ai-dev/entrypoints.md +0 -4
- package/test-projects/laravel-app/.ai-dev/files.json +0 -199
- package/test-projects/laravel-app/.ai-dev/graph/knowledge-graph.json +0 -98
- package/test-projects/laravel-app/.ai-dev/graph/module-graph.json +0 -30
- package/test-projects/laravel-app/.ai-dev/graph/symbol-graph.json +0 -5
- package/test-projects/laravel-app/.ai-dev/graph/symbol-references.json +0 -1
- package/test-projects/laravel-app/.ai-dev/index-state.json +0 -280
- package/test-projects/laravel-app/.ai-dev/modules.json +0 -29
- package/test-projects/laravel-app/.ai-dev/project.json +0 -17
- package/test-projects/laravel-app/.ai-dev/repo_map.json +0 -419
- package/test-projects/laravel-app/.ai-dev/repo_map.md +0 -106
- package/test-projects/laravel-app/.ai-dev/schema.json +0 -5
- package/test-projects/laravel-app/.ai-dev/summary.md +0 -15
- package/test-projects/laravel-app/.ai-dev/symbols.json +0 -1
- package/test-projects/laravel-app/.ai-dev/tech_stack.md +0 -34
- package/test-projects/laravel-app/.ai-dev/tools.json +0 -10
- package/test-projects/laravel-app/README.md +0 -107
- package/test-projects/laravel-app/app/Http/Controllers/Api/CategoryController.php +0 -88
- package/test-projects/laravel-app/app/Http/Controllers/Api/CommentController.php +0 -56
- package/test-projects/laravel-app/app/Http/Controllers/Api/PostController.php +0 -174
- package/test-projects/laravel-app/app/Http/Controllers/Controller.php +0 -12
- package/test-projects/laravel-app/app/Models/Category.php +0 -34
- package/test-projects/laravel-app/app/Models/Comment.php +0 -51
- package/test-projects/laravel-app/app/Models/Post.php +0 -108
- package/test-projects/laravel-app/app/Models/User.php +0 -85
- package/test-projects/laravel-app/bootstrap/app.php +0 -25
- package/test-projects/laravel-app/composer.json +0 -35
- package/test-projects/laravel-app/routes/api.php +0 -40
- package/test-projects/nestjs-backend/.ai-dev/ai_context.md +0 -111
- package/test-projects/nestjs-backend/.ai-dev/ai_rules.md +0 -52
- package/test-projects/nestjs-backend/.ai-dev/architecture.md +0 -49
- package/test-projects/nestjs-backend/.ai-dev/cache.json +0 -169
- package/test-projects/nestjs-backend/.ai-dev/context/features/src.json +0 -23
- package/test-projects/nestjs-backend/.ai-dev/context/flows/auth.controller.json +0 -14
- package/test-projects/nestjs-backend/.ai-dev/context/flows/auth.json +0 -10
- package/test-projects/nestjs-backend/.ai-dev/context/flows/users..json +0 -10
- package/test-projects/nestjs-backend/.ai-dev/context/flows/users.controller.json +0 -14
- package/test-projects/nestjs-backend/.ai-dev/context/flows/users.json +0 -10
- package/test-projects/nestjs-backend/.ai-dev/conventions.md +0 -52
- package/test-projects/nestjs-backend/.ai-dev/dependencies.json +0 -152
- package/test-projects/nestjs-backend/.ai-dev/entrypoints.md +0 -18
- package/test-projects/nestjs-backend/.ai-dev/files.json +0 -209
- package/test-projects/nestjs-backend/.ai-dev/graph/knowledge-graph.json +0 -132
- package/test-projects/nestjs-backend/.ai-dev/graph/module-graph.json +0 -29
- package/test-projects/nestjs-backend/.ai-dev/graph/symbol-graph.json +0 -304
- package/test-projects/nestjs-backend/.ai-dev/graph/symbol-references.json +0 -5
- package/test-projects/nestjs-backend/.ai-dev/index-state.json +0 -294
- package/test-projects/nestjs-backend/.ai-dev/modules.json +0 -19
- package/test-projects/nestjs-backend/.ai-dev/project.json +0 -18
- package/test-projects/nestjs-backend/.ai-dev/repo_map.json +0 -427
- package/test-projects/nestjs-backend/.ai-dev/repo_map.md +0 -104
- package/test-projects/nestjs-backend/.ai-dev/schema.json +0 -5
- package/test-projects/nestjs-backend/.ai-dev/summary.md +0 -13
- package/test-projects/nestjs-backend/.ai-dev/symbols.json +0 -1
- package/test-projects/nestjs-backend/.ai-dev/tech_stack.md +0 -38
- package/test-projects/nestjs-backend/.ai-dev/tools.json +0 -10
- package/test-projects/nestjs-backend/package.json +0 -22
- package/test-projects/nestjs-backend/src/app.module.ts +0 -8
- package/test-projects/nestjs-backend/src/auth/auth.controller.ts +0 -22
- package/test-projects/nestjs-backend/src/auth/auth.module.ts +0 -11
- package/test-projects/nestjs-backend/src/auth/auth.service.ts +0 -28
- package/test-projects/nestjs-backend/src/auth/dto/login.dto.ts +0 -4
- package/test-projects/nestjs-backend/src/auth/strategies/jwt.strategy.ts +0 -18
- package/test-projects/nestjs-backend/src/main.ts +0 -9
- package/test-projects/nestjs-backend/src/users/users.controller.ts +0 -32
- package/test-projects/nestjs-backend/src/users/users.module.ts +0 -10
- package/test-projects/nestjs-backend/src/users/users.service.ts +0 -42
- package/test-projects/nestjs-backend/tsconfig.json +0 -21
- package/test-projects/python-cli/.ai-dev/ai_context.md +0 -95
- package/test-projects/python-cli/.ai-dev/ai_rules.md +0 -47
- package/test-projects/python-cli/.ai-dev/architecture.md +0 -55
- package/test-projects/python-cli/.ai-dev/cache.json +0 -149
- package/test-projects/python-cli/.ai-dev/context/features/cli.json +0 -16
- package/test-projects/python-cli/.ai-dev/context/flows/list_.json +0 -9
- package/test-projects/python-cli/.ai-dev/context/flows/remove_.json +0 -9
- package/test-projects/python-cli/.ai-dev/conventions.md +0 -51
- package/test-projects/python-cli/.ai-dev/dependencies.json +0 -66
- package/test-projects/python-cli/.ai-dev/entrypoints.md +0 -4
- package/test-projects/python-cli/.ai-dev/files.json +0 -184
- package/test-projects/python-cli/.ai-dev/graph/knowledge-graph.json +0 -83
- package/test-projects/python-cli/.ai-dev/graph/module-graph.json +0 -31
- package/test-projects/python-cli/.ai-dev/graph/symbol-graph.json +0 -358
- package/test-projects/python-cli/.ai-dev/graph/symbol-references.json +0 -11
- package/test-projects/python-cli/.ai-dev/index-state.json +0 -259
- package/test-projects/python-cli/.ai-dev/modules.json +0 -21
- package/test-projects/python-cli/.ai-dev/project.json +0 -15
- package/test-projects/python-cli/.ai-dev/repo_map.json +0 -367
- package/test-projects/python-cli/.ai-dev/repo_map.md +0 -93
- package/test-projects/python-cli/.ai-dev/schema.json +0 -5
- package/test-projects/python-cli/.ai-dev/summary.md +0 -14
- package/test-projects/python-cli/.ai-dev/symbols.json +0 -1
- package/test-projects/python-cli/.ai-dev/tech_stack.md +0 -32
- package/test-projects/python-cli/.ai-dev/tools.json +0 -10
- package/test-projects/python-cli/__init__.py +0 -1
- package/test-projects/python-cli/cli/__init__.py +0 -1
- package/test-projects/python-cli/cli/add_command.py +0 -6
- package/test-projects/python-cli/cli/list_command.py +0 -7
- package/test-projects/python-cli/cli/remove_command.py +0 -6
- package/test-projects/python-cli/main.py +0 -34
- package/test-projects/python-cli/models/__init__.py +0 -2
- package/test-projects/python-cli/models/task.py +0 -19
- package/test-projects/python-cli/models/task_repository.py +0 -44
- package/test-projects/rails-app/.ai-dev/ai_context.md +0 -94
- package/test-projects/rails-app/.ai-dev/ai_rules.md +0 -47
- package/test-projects/rails-app/.ai-dev/architecture.md +0 -49
- package/test-projects/rails-app/.ai-dev/cache.json +0 -193
- package/test-projects/rails-app/.ai-dev/context/features/app.json +0 -24
- package/test-projects/rails-app/.ai-dev/context/features/config.json +0 -13
- package/test-projects/rails-app/.ai-dev/context/flows/application.json +0 -9
- package/test-projects/rails-app/.ai-dev/context/flows/application_.json +0 -9
- package/test-projects/rails-app/.ai-dev/context/flows/comments.json +0 -11
- package/test-projects/rails-app/.ai-dev/context/flows/comments_.json +0 -11
- package/test-projects/rails-app/.ai-dev/context/flows/posts.json +0 -11
- package/test-projects/rails-app/.ai-dev/context/flows/posts_.json +0 -11
- package/test-projects/rails-app/.ai-dev/context/flows/routes.json +0 -9
- package/test-projects/rails-app/.ai-dev/context/flows/users.json +0 -11
- package/test-projects/rails-app/.ai-dev/context/flows/users_.json +0 -11
- package/test-projects/rails-app/.ai-dev/conventions.md +0 -51
- package/test-projects/rails-app/.ai-dev/dependencies.json +0 -6
- package/test-projects/rails-app/.ai-dev/entrypoints.md +0 -4
- package/test-projects/rails-app/.ai-dev/files.json +0 -239
- package/test-projects/rails-app/.ai-dev/graph/knowledge-graph.json +0 -130
- package/test-projects/rails-app/.ai-dev/graph/module-graph.json +0 -27
- package/test-projects/rails-app/.ai-dev/graph/symbol-graph.json +0 -5
- package/test-projects/rails-app/.ai-dev/graph/symbol-references.json +0 -1
- package/test-projects/rails-app/.ai-dev/index-state.json +0 -336
- package/test-projects/rails-app/.ai-dev/modules.json +0 -26
- package/test-projects/rails-app/.ai-dev/project.json +0 -22
- package/test-projects/rails-app/.ai-dev/repo_map.json +0 -486
- package/test-projects/rails-app/.ai-dev/repo_map.md +0 -117
- package/test-projects/rails-app/.ai-dev/schema.json +0 -5
- package/test-projects/rails-app/.ai-dev/summary.md +0 -13
- package/test-projects/rails-app/.ai-dev/symbols.json +0 -1
- package/test-projects/rails-app/.ai-dev/tech_stack.md +0 -32
- package/test-projects/rails-app/.ai-dev/tools.json +0 -10
- package/test-projects/rails-app/Gemfile +0 -38
- package/test-projects/rails-app/README.md +0 -140
- package/test-projects/rails-app/Rakefile +0 -8
- package/test-projects/rails-app/app/controllers/api/comments_controller.rb +0 -75
- package/test-projects/rails-app/app/controllers/api/posts_controller.rb +0 -68
- package/test-projects/rails-app/app/controllers/api/users_controller.rb +0 -54
- package/test-projects/rails-app/app/controllers/application_controller.rb +0 -31
- package/test-projects/rails-app/app/models/comment.rb +0 -34
- package/test-projects/rails-app/app/models/post.rb +0 -36
- package/test-projects/rails-app/app/models/user.rb +0 -28
- package/test-projects/rails-app/app/services/post_service.rb +0 -92
- package/test-projects/rails-app/app/services/user_service.rb +0 -76
- package/test-projects/rails-app/config/application.rb +0 -27
- package/test-projects/rails-app/config/environment.rb +0 -7
- package/test-projects/rails-app/config/routes.rb +0 -15
- package/test-projects/react-app/.ai-dev/ai_context.md +0 -96
- package/test-projects/react-app/.ai-dev/architecture.md +0 -39
- package/test-projects/react-app/.ai-dev/cache.json +0 -153
- package/test-projects/react-app/.ai-dev/context/features/src.json +0 -18
- package/test-projects/react-app/.ai-dev/context/flows/UsersPage.json +0 -14
- package/test-projects/react-app/.ai-dev/context/flows/dashboard.json +0 -9
- package/test-projects/react-app/.ai-dev/context/flows/login.json +0 -9
- package/test-projects/react-app/.ai-dev/context/flows/users.json +0 -9
- package/test-projects/react-app/.ai-dev/dependencies.json +0 -128
- package/test-projects/react-app/.ai-dev/entrypoints.md +0 -4
- package/test-projects/react-app/.ai-dev/files.json +0 -189
- package/test-projects/react-app/.ai-dev/graph/knowledge-graph.json +0 -112
- package/test-projects/react-app/.ai-dev/graph/module-graph.json +0 -31
- package/test-projects/react-app/.ai-dev/graph/symbol-graph.json +0 -868
- package/test-projects/react-app/.ai-dev/graph/symbol-references.json +0 -31
- package/test-projects/react-app/.ai-dev/index-state.json +0 -266
- package/test-projects/react-app/.ai-dev/modules.json +0 -17
- package/test-projects/react-app/.ai-dev/project.json +0 -16
- package/test-projects/react-app/.ai-dev/repo_map.json +0 -391
- package/test-projects/react-app/.ai-dev/repo_map.md +0 -94
- package/test-projects/react-app/.ai-dev/schema.json +0 -5
- package/test-projects/react-app/.ai-dev/summary.md +0 -13
- package/test-projects/react-app/.ai-dev/symbols.json +0 -1
- package/test-projects/react-app/.ai-dev/tools.json +0 -10
- package/test-projects/react-app/package.json +0 -16
- package/test-projects/react-app/src/App.tsx +0 -21
- package/test-projects/react-app/src/context/AuthContext.tsx +0 -41
- package/test-projects/react-app/src/hooks/useAuth.ts +0 -10
- package/test-projects/react-app/src/main.tsx +0 -10
- package/test-projects/react-app/src/pages/DashboardPage.tsx +0 -17
- package/test-projects/react-app/src/pages/LoginPage.tsx +0 -41
- package/test-projects/react-app/src/pages/UsersPage.tsx +0 -36
- package/test-projects/react-app/src/services/userService.ts +0 -37
- package/test-projects/salesforce-cli/.ai-dev/ai_context.md +0 -89
- package/test-projects/salesforce-cli/.ai-dev/ai_rules.md +0 -47
- package/test-projects/salesforce-cli/.ai-dev/architecture.md +0 -39
- package/test-projects/salesforce-cli/.ai-dev/cache.json +0 -125
- package/test-projects/salesforce-cli/.ai-dev/context/features/force-app.json +0 -14
- package/test-projects/salesforce-cli/.ai-dev/context/flows/account.json +0 -9
- package/test-projects/salesforce-cli/.ai-dev/context/flows/opportunity.json +0 -9
- package/test-projects/salesforce-cli/.ai-dev/conventions.md +0 -51
- package/test-projects/salesforce-cli/.ai-dev/dependencies.json +0 -6
- package/test-projects/salesforce-cli/.ai-dev/entrypoints.md +0 -4
- package/test-projects/salesforce-cli/.ai-dev/files.json +0 -154
- package/test-projects/salesforce-cli/.ai-dev/graph/knowledge-graph.json +0 -64
- package/test-projects/salesforce-cli/.ai-dev/graph/module-graph.json +0 -13
- package/test-projects/salesforce-cli/.ai-dev/graph/symbol-graph.json +0 -148
- package/test-projects/salesforce-cli/.ai-dev/graph/symbol-references.json +0 -1
- package/test-projects/salesforce-cli/.ai-dev/index-state.json +0 -217
- package/test-projects/salesforce-cli/.ai-dev/modules.json +0 -12
- package/test-projects/salesforce-cli/.ai-dev/project.json +0 -14
- package/test-projects/salesforce-cli/.ai-dev/repo_map.json +0 -328
- package/test-projects/salesforce-cli/.ai-dev/repo_map.md +0 -80
- package/test-projects/salesforce-cli/.ai-dev/schema.json +0 -5
- package/test-projects/salesforce-cli/.ai-dev/summary.md +0 -13
- package/test-projects/salesforce-cli/.ai-dev/symbols.json +0 -1
- package/test-projects/salesforce-cli/.ai-dev/tech_stack.md +0 -31
- package/test-projects/salesforce-cli/.ai-dev/tools.json +0 -10
- package/test-projects/salesforce-cli/.forceignore +0 -27
- package/test-projects/salesforce-cli/force-app/main/default/classes/AccountController.cls +0 -24
- package/test-projects/salesforce-cli/force-app/main/default/classes/OpportunityController.cls +0 -25
- package/test-projects/salesforce-cli/force-app/main/default/objects/Project__c.object.xml +0 -45
- package/test-projects/salesforce-cli/force-app/main/default/triggers/AccountTrigger.trigger +0 -33
- package/test-projects/salesforce-cli/sfdx-project.json +0 -11
- package/test-projects/spring-boot-app/.ai-dev/ai_context.md +0 -91
- package/test-projects/spring-boot-app/.ai-dev/ai_rules.md +0 -48
- package/test-projects/spring-boot-app/.ai-dev/architecture.md +0 -39
- package/test-projects/spring-boot-app/.ai-dev/cache.json +0 -173
- package/test-projects/spring-boot-app/.ai-dev/context/features/src.json +0 -26
- package/test-projects/spring-boot-app/.ai-dev/context/flows/PostController.json +0 -19
- package/test-projects/spring-boot-app/.ai-dev/context/flows/UserController.json +0 -19
- package/test-projects/spring-boot-app/.ai-dev/context/flows/comment.json +0 -11
- package/test-projects/spring-boot-app/.ai-dev/context/flows/post.json +0 -14
- package/test-projects/spring-boot-app/.ai-dev/context/flows/user.json +0 -14
- package/test-projects/spring-boot-app/.ai-dev/conventions.md +0 -52
- package/test-projects/spring-boot-app/.ai-dev/dependencies.json +0 -326
- package/test-projects/spring-boot-app/.ai-dev/entrypoints.md +0 -4
- package/test-projects/spring-boot-app/.ai-dev/files.json +0 -214
- package/test-projects/spring-boot-app/.ai-dev/graph/knowledge-graph.json +0 -231
- package/test-projects/spring-boot-app/.ai-dev/graph/module-graph.json +0 -22
- package/test-projects/spring-boot-app/.ai-dev/graph/symbol-graph.json +0 -794
- package/test-projects/spring-boot-app/.ai-dev/graph/symbol-references.json +0 -70
- package/test-projects/spring-boot-app/.ai-dev/index-state.json +0 -301
- package/test-projects/spring-boot-app/.ai-dev/modules.json +0 -21
- package/test-projects/spring-boot-app/.ai-dev/project.json +0 -17
- package/test-projects/spring-boot-app/.ai-dev/repo_map.json +0 -461
- package/test-projects/spring-boot-app/.ai-dev/repo_map.md +0 -109
- package/test-projects/spring-boot-app/.ai-dev/schema.json +0 -5
- package/test-projects/spring-boot-app/.ai-dev/summary.md +0 -12
- package/test-projects/spring-boot-app/.ai-dev/symbols.json +0 -1
- package/test-projects/spring-boot-app/.ai-dev/tech_stack.md +0 -32
- package/test-projects/spring-boot-app/.ai-dev/tools.json +0 -10
- package/test-projects/spring-boot-app/.classpath +0 -57
- package/test-projects/spring-boot-app/.factorypath +0 -69
- package/test-projects/spring-boot-app/.project +0 -34
- package/test-projects/spring-boot-app/.settings/org.eclipse.core.resources.prefs +0 -4
- package/test-projects/spring-boot-app/.settings/org.eclipse.jdt.apt.core.prefs +0 -4
- package/test-projects/spring-boot-app/.settings/org.eclipse.jdt.core.prefs +0 -10
- package/test-projects/spring-boot-app/.settings/org.eclipse.m2e.core.prefs +0 -4
- package/test-projects/spring-boot-app/README.md +0 -122
- package/test-projects/spring-boot-app/pom.xml +0 -79
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/DemoApplication.java +0 -12
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/controllers/CommentController.java +0 -89
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/controllers/PostController.java +0 -92
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/controllers/UserController.java +0 -84
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/models/Comment.java +0 -38
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/models/Post.java +0 -56
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/models/User.java +0 -44
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/repositories/CommentRepository.java +0 -21
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/repositories/PostRepository.java +0 -18
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/repositories/UserRepository.java +0 -15
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/services/PostService.java +0 -83
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/services/UserService.java +0 -62
- package/test-projects/spring-boot-app/src/main/resources/application.properties +0 -22
- package/test-projects/spring-boot-app/target/classes/com/example/demo/DemoApplication.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/CommentController$CommentCreateRequest.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/CommentController$CommentUpdateRequest.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/CommentController.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/PostController$PostCreateRequest.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/PostController$PostUpdateRequest.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/PostController.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/UserController$UserCreateRequest.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/UserController$UserUpdateRequest.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/UserController.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/models/Comment.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/models/Post.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/models/User.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/repositories/CommentRepository.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/repositories/PostRepository.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/repositories/UserRepository.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/services/PostService.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/services/UserService.class +0 -0
- package/tests/e2e/run-e2e.sh +0 -88
- /package/{test-projects/django-app/.ai-dev → ai-context}/tools.json +0 -0
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"""Flask application factory."""
|
|
2
|
-
|
|
3
|
-
from flask import Flask
|
|
4
|
-
from flask_sqlalchemy import SQLAlchemy
|
|
5
|
-
from flask_migrate import Migrate
|
|
6
|
-
from flask_login import LoginManager
|
|
7
|
-
from config import Config
|
|
8
|
-
|
|
9
|
-
db = SQLAlchemy()
|
|
10
|
-
migrate = Migrate()
|
|
11
|
-
login_manager = LoginManager()
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def create_app(config_class=Config):
|
|
15
|
-
"""Application factory pattern."""
|
|
16
|
-
app = Flask(__name__)
|
|
17
|
-
app.config.from_object(config_class)
|
|
18
|
-
|
|
19
|
-
# Initialize extensions
|
|
20
|
-
db.init_app(app)
|
|
21
|
-
migrate.init_app(app, db)
|
|
22
|
-
login_manager.init_app(app)
|
|
23
|
-
login_manager.login_view = "auth.login"
|
|
24
|
-
login_manager.login_message = "Please log in to access this page."
|
|
25
|
-
|
|
26
|
-
# Register blueprints
|
|
27
|
-
from app.main import bp as main_bp
|
|
28
|
-
|
|
29
|
-
app.register_blueprint(main_bp)
|
|
30
|
-
|
|
31
|
-
from app.auth import bp as auth_bp
|
|
32
|
-
|
|
33
|
-
app.register_blueprint(auth_bp, url_prefix="/auth")
|
|
34
|
-
|
|
35
|
-
from app.blog import bp as blog_bp
|
|
36
|
-
|
|
37
|
-
app.register_blueprint(blog_bp, url_prefix="/blog")
|
|
38
|
-
|
|
39
|
-
from app.api import bp as api_bp
|
|
40
|
-
|
|
41
|
-
app.register_blueprint(api_bp, url_prefix="/api/v1")
|
|
42
|
-
|
|
43
|
-
return app
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
from app import models
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"""API blueprint routes."""
|
|
2
|
-
|
|
3
|
-
from flask import Blueprint, request, jsonify
|
|
4
|
-
from app import db
|
|
5
|
-
from app.models import Post, Category, Tag, User, Comment
|
|
6
|
-
|
|
7
|
-
bp = Blueprint("api", __name__)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@bp.route("/posts", methods=["GET"])
|
|
11
|
-
def api_get_posts():
|
|
12
|
-
"""API: Get all posts."""
|
|
13
|
-
page = request.args.get("page", 1, type=int)
|
|
14
|
-
per_page = request.args.get("per_page", 10, type=int)
|
|
15
|
-
|
|
16
|
-
query = Post.query.filter_by(is_published=True)
|
|
17
|
-
|
|
18
|
-
# Filter by category
|
|
19
|
-
category_slug = request.args.get("category")
|
|
20
|
-
if category_slug:
|
|
21
|
-
category = Category.query.filter_by(slug=category_slug).first()
|
|
22
|
-
if category:
|
|
23
|
-
query = query.filter_by(category_id=category.id)
|
|
24
|
-
|
|
25
|
-
# Search
|
|
26
|
-
search = request.args.get("q")
|
|
27
|
-
if search:
|
|
28
|
-
query = query.filter(
|
|
29
|
-
db.or_(Post.title.ilike(f"%{search}%"), Post.content.ilike(f"%{search}%"))
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
posts = query.order_by(Post.published_at.desc()).paginate(
|
|
33
|
-
page=page, per_page=per_page, error_out=False
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
return jsonify(
|
|
37
|
-
{
|
|
38
|
-
"posts": [
|
|
39
|
-
{
|
|
40
|
-
"id": p.id,
|
|
41
|
-
"title": p.title,
|
|
42
|
-
"slug": p.slug,
|
|
43
|
-
"summary": p.summary,
|
|
44
|
-
"author": p.author.username,
|
|
45
|
-
"published_at": p.published_at.isoformat()
|
|
46
|
-
if p.published_at
|
|
47
|
-
else None,
|
|
48
|
-
"view_count": p.view_count,
|
|
49
|
-
"category": p.category.name if p.category else None,
|
|
50
|
-
"tags": [t.name for t in p.tags],
|
|
51
|
-
}
|
|
52
|
-
for p in posts.items
|
|
53
|
-
],
|
|
54
|
-
"total": posts.total,
|
|
55
|
-
"pages": posts.pages,
|
|
56
|
-
"current_page": page,
|
|
57
|
-
}
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
@bp.route("/posts/<string:slug>", methods=["GET"])
|
|
62
|
-
def api_get_post(slug):
|
|
63
|
-
"""API: Get single post."""
|
|
64
|
-
post = Post.query.filter_by(slug=slug, is_published=True).first_or_404()
|
|
65
|
-
post.increment_view()
|
|
66
|
-
|
|
67
|
-
return jsonify(
|
|
68
|
-
{
|
|
69
|
-
"id": post.id,
|
|
70
|
-
"title": post.title,
|
|
71
|
-
"slug": post.slug,
|
|
72
|
-
"content": post.content,
|
|
73
|
-
"summary": post.summary,
|
|
74
|
-
"author": post.author.username,
|
|
75
|
-
"published_at": post.published_at.isoformat()
|
|
76
|
-
if post.published_at
|
|
77
|
-
else None,
|
|
78
|
-
"view_count": post.view_count,
|
|
79
|
-
"category": post.category.name if post.category else None,
|
|
80
|
-
"tags": [t.name for t in post.tags],
|
|
81
|
-
"comments_count": post.comments.count(),
|
|
82
|
-
}
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
@bp.route("/categories", methods=["GET"])
|
|
87
|
-
def api_get_categories():
|
|
88
|
-
"""API: Get all categories."""
|
|
89
|
-
categories = Category.query.all()
|
|
90
|
-
return jsonify(
|
|
91
|
-
{
|
|
92
|
-
"categories": [
|
|
93
|
-
{
|
|
94
|
-
"id": c.id,
|
|
95
|
-
"name": c.name,
|
|
96
|
-
"slug": c.slug,
|
|
97
|
-
"description": c.description,
|
|
98
|
-
"posts_count": c.posts.count(),
|
|
99
|
-
}
|
|
100
|
-
for c in categories
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
@bp.route("/tags", methods=["GET"])
|
|
107
|
-
def api_get_tags():
|
|
108
|
-
"""API: Get all tags."""
|
|
109
|
-
tags = Tag.query.all()
|
|
110
|
-
return jsonify(
|
|
111
|
-
{
|
|
112
|
-
"tags": [
|
|
113
|
-
{
|
|
114
|
-
"id": t.id,
|
|
115
|
-
"name": t.name,
|
|
116
|
-
"slug": t.slug,
|
|
117
|
-
"posts_count": t.posts.count(),
|
|
118
|
-
}
|
|
119
|
-
for t in tags
|
|
120
|
-
]
|
|
121
|
-
}
|
|
122
|
-
)
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"""Authentication forms."""
|
|
2
|
-
|
|
3
|
-
from flask_wtf import FlaskForm
|
|
4
|
-
from wtforms import StringField, PasswordField, BooleanField, SubmitField
|
|
5
|
-
from wtforms.validators import ValidationError, DataRequired, Email, EqualTo, Length
|
|
6
|
-
from app.models import User
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class LoginForm(FlaskForm):
|
|
10
|
-
"""Login form."""
|
|
11
|
-
|
|
12
|
-
username = StringField("Username", validators=[DataRequired()])
|
|
13
|
-
password = PasswordField("Password", validators=[DataRequired()])
|
|
14
|
-
remember_me = BooleanField("Remember Me")
|
|
15
|
-
submit = SubmitField("Sign In")
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class RegistrationForm(FlaskForm):
|
|
19
|
-
"""Registration form."""
|
|
20
|
-
|
|
21
|
-
username = StringField(
|
|
22
|
-
"Username", validators=[DataRequired(), Length(min=3, max=20)]
|
|
23
|
-
)
|
|
24
|
-
email = StringField("Email", validators=[DataRequired(), Email()])
|
|
25
|
-
full_name = StringField("Full Name", validators=[Length(max=100)])
|
|
26
|
-
password = PasswordField(
|
|
27
|
-
"Password",
|
|
28
|
-
validators=[
|
|
29
|
-
DataRequired(),
|
|
30
|
-
Length(min=8, message="Password must be at least 8 characters"),
|
|
31
|
-
],
|
|
32
|
-
)
|
|
33
|
-
password2 = PasswordField(
|
|
34
|
-
"Repeat Password",
|
|
35
|
-
validators=[
|
|
36
|
-
DataRequired(),
|
|
37
|
-
EqualTo("password", message="Passwords must match"),
|
|
38
|
-
],
|
|
39
|
-
)
|
|
40
|
-
submit = SubmitField("Register")
|
|
41
|
-
|
|
42
|
-
def validate_username(self, username):
|
|
43
|
-
"""Validate username is unique."""
|
|
44
|
-
user = User.query.filter_by(username=username.data).first()
|
|
45
|
-
if user is not None:
|
|
46
|
-
raise ValidationError("Username already taken.")
|
|
47
|
-
|
|
48
|
-
def validate_email(self, email):
|
|
49
|
-
"""Validate email is unique."""
|
|
50
|
-
user = User.query.filter_by(email=email.data).first()
|
|
51
|
-
if user is not None:
|
|
52
|
-
raise ValidationError("Email already registered.")
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"""Authentication blueprint routes."""
|
|
2
|
-
|
|
3
|
-
from flask import Blueprint, render_template, redirect, url_for, flash, request
|
|
4
|
-
from flask_login import login_user, logout_user, login_required, current_user
|
|
5
|
-
from werkzeug.urls import url_parse
|
|
6
|
-
from app import db
|
|
7
|
-
from app.models import User
|
|
8
|
-
from app.auth.forms import LoginForm, RegistrationForm
|
|
9
|
-
|
|
10
|
-
bp = Blueprint("auth", __name__)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@bp.route("/login", methods=["GET", "POST"])
|
|
14
|
-
def login():
|
|
15
|
-
"""User login."""
|
|
16
|
-
if current_user.is_authenticated:
|
|
17
|
-
return redirect(url_for("main.index"))
|
|
18
|
-
|
|
19
|
-
form = LoginForm()
|
|
20
|
-
if form.validate_on_submit():
|
|
21
|
-
user = User.query.filter_by(username=form.username.data).first()
|
|
22
|
-
if user is None or not user.check_password(form.password.data):
|
|
23
|
-
flash("Invalid username or password")
|
|
24
|
-
return redirect(url_for("auth.login"))
|
|
25
|
-
|
|
26
|
-
login_user(user, remember=form.remember_me.data)
|
|
27
|
-
next_page = request.args.get("next")
|
|
28
|
-
if not next_page or url_parse(next_page).netloc != "":
|
|
29
|
-
next_page = url_for("main.index")
|
|
30
|
-
return redirect(next_page)
|
|
31
|
-
|
|
32
|
-
return render_template("auth/login.html", title="Sign In", form=form)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@bp.route("/logout")
|
|
36
|
-
def logout():
|
|
37
|
-
"""User logout."""
|
|
38
|
-
logout_user()
|
|
39
|
-
return redirect(url_for("main.index"))
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@bp.route("/register", methods=["GET", "POST"])
|
|
43
|
-
def register():
|
|
44
|
-
"""User registration."""
|
|
45
|
-
if current_user.is_authenticated:
|
|
46
|
-
return redirect(url_for("main.index"))
|
|
47
|
-
|
|
48
|
-
form = RegistrationForm()
|
|
49
|
-
if form.validate_on_submit():
|
|
50
|
-
user = User(
|
|
51
|
-
username=form.username.data,
|
|
52
|
-
email=form.email.data,
|
|
53
|
-
full_name=form.full_name.data,
|
|
54
|
-
)
|
|
55
|
-
user.set_password(form.password.data)
|
|
56
|
-
db.session.add(user)
|
|
57
|
-
db.session.commit()
|
|
58
|
-
flash("Congratulations, you are now a registered user!")
|
|
59
|
-
return redirect(url_for("auth.login"))
|
|
60
|
-
|
|
61
|
-
return render_template("auth/register.html", title="Register", form=form)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
@bp.route("/profile")
|
|
65
|
-
@login_required
|
|
66
|
-
def profile():
|
|
67
|
-
"""User profile."""
|
|
68
|
-
return render_template("auth/profile.html", title="Profile")
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"""Blog forms."""
|
|
2
|
-
|
|
3
|
-
from flask_wtf import FlaskForm
|
|
4
|
-
from wtforms import StringField, TextAreaField, BooleanField, SubmitField, SelectField
|
|
5
|
-
from wtforms.validators import DataRequired, Length
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class PostForm(FlaskForm):
|
|
9
|
-
"""Blog post form."""
|
|
10
|
-
|
|
11
|
-
title = StringField("Title", validators=[DataRequired(), Length(min=1, max=200)])
|
|
12
|
-
summary = TextAreaField("Summary", validators=[Length(max=500)])
|
|
13
|
-
content = TextAreaField("Content", validators=[DataRequired()])
|
|
14
|
-
category_id = SelectField("Category", coerce=int, choices=[])
|
|
15
|
-
tags = StringField("Tags (comma separated)")
|
|
16
|
-
is_published = BooleanField("Publish immediately")
|
|
17
|
-
submit = SubmitField("Save Post")
|
|
18
|
-
|
|
19
|
-
def __init__(self, *args, **kwargs):
|
|
20
|
-
"""Initialize form with categories."""
|
|
21
|
-
super(PostForm, self).__init__(*args, **kwargs)
|
|
22
|
-
from app.models import Category
|
|
23
|
-
|
|
24
|
-
self.category_id.choices = [(0, "No Category")] + [
|
|
25
|
-
(c.id, c.name) for c in Category.query.all()
|
|
26
|
-
]
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class CommentForm(FlaskForm):
|
|
30
|
-
"""Comment form."""
|
|
31
|
-
|
|
32
|
-
content = TextAreaField(
|
|
33
|
-
"Comment", validators=[DataRequired(), Length(min=1, max=2000)]
|
|
34
|
-
)
|
|
35
|
-
submit = SubmitField("Post Comment")
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"""Blog blueprint routes."""
|
|
2
|
-
|
|
3
|
-
from flask import Blueprint, render_template, redirect, url_for, flash, request, abort
|
|
4
|
-
from flask_login import login_required, current_user
|
|
5
|
-
from app import db
|
|
6
|
-
from app.models import Post, Category, Tag, Comment
|
|
7
|
-
from app.blog.forms import PostForm, CommentForm
|
|
8
|
-
|
|
9
|
-
bp = Blueprint("blog", __name__)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def generate_slug(title):
|
|
13
|
-
"""Generate URL slug from title."""
|
|
14
|
-
import re
|
|
15
|
-
|
|
16
|
-
slug = re.sub(r"[^\w\s-]", "", title.lower())
|
|
17
|
-
slug = re.sub(r"[-\s]+", "-", slug)
|
|
18
|
-
return slug.strip("-")
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@bp.route("/create", methods=["GET", "POST"])
|
|
22
|
-
@login_required
|
|
23
|
-
def create_post():
|
|
24
|
-
"""Create new blog post."""
|
|
25
|
-
form = PostForm()
|
|
26
|
-
if form.validate_on_submit():
|
|
27
|
-
post = Post(
|
|
28
|
-
title=form.title.data,
|
|
29
|
-
slug=generate_slug(form.title.data),
|
|
30
|
-
content=form.content.data,
|
|
31
|
-
summary=form.summary.data,
|
|
32
|
-
is_published=form.is_published.data,
|
|
33
|
-
user_id=current_user.id,
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
# Set category
|
|
37
|
-
if form.category_id.data:
|
|
38
|
-
post.category_id = form.category_id.data
|
|
39
|
-
|
|
40
|
-
# Add tags
|
|
41
|
-
if form.tags.data:
|
|
42
|
-
tag_names = [t.strip() for t in form.tags.data.split(",")]
|
|
43
|
-
for tag_name in tag_names:
|
|
44
|
-
tag = Tag.query.filter_by(name=tag_name).first()
|
|
45
|
-
if not tag:
|
|
46
|
-
tag = Tag(name=tag_name, slug=generate_slug(tag_name))
|
|
47
|
-
db.session.add(tag)
|
|
48
|
-
post.tags.append(tag)
|
|
49
|
-
|
|
50
|
-
db.session.add(post)
|
|
51
|
-
db.session.commit()
|
|
52
|
-
|
|
53
|
-
# Publish if requested
|
|
54
|
-
if form.is_published.data:
|
|
55
|
-
post.publish()
|
|
56
|
-
|
|
57
|
-
flash("Your post has been created!")
|
|
58
|
-
return redirect(url_for("blog.post", slug=post.slug))
|
|
59
|
-
|
|
60
|
-
return render_template("blog/create.html", title="Create Post", form=form)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
@bp.route("/<string:slug>/edit", methods=["GET", "POST"])
|
|
64
|
-
@login_required
|
|
65
|
-
def edit_post(slug):
|
|
66
|
-
"""Edit blog post."""
|
|
67
|
-
post = Post.query.filter_by(slug=slug).first_or_404()
|
|
68
|
-
|
|
69
|
-
# Check ownership
|
|
70
|
-
if post.user_id != current_user.id and not current_user.is_admin:
|
|
71
|
-
abort(403)
|
|
72
|
-
|
|
73
|
-
form = PostForm(obj=post)
|
|
74
|
-
if form.validate_on_submit():
|
|
75
|
-
post.title = form.title.data
|
|
76
|
-
post.slug = generate_slug(form.title.data)
|
|
77
|
-
post.content = form.content.data
|
|
78
|
-
post.summary = form.summary.data
|
|
79
|
-
|
|
80
|
-
# Update publish status
|
|
81
|
-
if form.is_published.data and not post.is_published:
|
|
82
|
-
post.publish()
|
|
83
|
-
elif not form.is_published.data and post.is_published:
|
|
84
|
-
post.unpublish()
|
|
85
|
-
|
|
86
|
-
db.session.commit()
|
|
87
|
-
flash("Your post has been updated!")
|
|
88
|
-
return redirect(url_for("blog.post", slug=post.slug))
|
|
89
|
-
|
|
90
|
-
return render_template("blog/edit.html", title="Edit Post", form=form, post=post)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
@bp.route("/<string:slug>/delete", methods=["POST"])
|
|
94
|
-
@login_required
|
|
95
|
-
def delete_post(slug):
|
|
96
|
-
"""Delete blog post."""
|
|
97
|
-
post = Post.query.filter_by(slug=slug).first_or_404()
|
|
98
|
-
|
|
99
|
-
# Check ownership
|
|
100
|
-
if post.user_id != current_user.id and not current_user.is_admin:
|
|
101
|
-
abort(403)
|
|
102
|
-
|
|
103
|
-
db.session.delete(post)
|
|
104
|
-
db.session.commit()
|
|
105
|
-
flash("Your post has been deleted.")
|
|
106
|
-
return redirect(url_for("main.index"))
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
@bp.route("/<string:slug>")
|
|
110
|
-
def post(slug):
|
|
111
|
-
"""View blog post."""
|
|
112
|
-
post = Post.query.filter_by(slug=slug).first_or_404()
|
|
113
|
-
|
|
114
|
-
# Only show published posts to non-authors
|
|
115
|
-
if not post.is_published and (
|
|
116
|
-
not current_user.is_authenticated
|
|
117
|
-
or (current_user.id != post.user_id and not current_user.is_admin)
|
|
118
|
-
):
|
|
119
|
-
abort(404)
|
|
120
|
-
|
|
121
|
-
form = CommentForm()
|
|
122
|
-
return render_template("blog/post.html", post=post, form=form)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
@bp.route("/<string:slug>/comment", methods=["POST"])
|
|
126
|
-
@login_required
|
|
127
|
-
def add_comment(slug):
|
|
128
|
-
"""Add comment to post."""
|
|
129
|
-
post = Post.query.filter_by(slug=slug).first_or_404()
|
|
130
|
-
form = CommentForm()
|
|
131
|
-
|
|
132
|
-
if form.validate_on_submit():
|
|
133
|
-
comment = Comment(
|
|
134
|
-
content=form.content.data, post_id=post.id, user_id=current_user.id
|
|
135
|
-
)
|
|
136
|
-
db.session.add(comment)
|
|
137
|
-
db.session.commit()
|
|
138
|
-
flash("Your comment has been added.")
|
|
139
|
-
|
|
140
|
-
return redirect(url_for("blog.post", slug=post.slug))
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"""Main blueprint routes."""
|
|
2
|
-
|
|
3
|
-
from flask import Blueprint, render_template, request, current_app
|
|
4
|
-
from app.models import Post, Category, Tag
|
|
5
|
-
from app import db
|
|
6
|
-
|
|
7
|
-
bp = Blueprint("main", __name__)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@bp.route("/")
|
|
11
|
-
def index():
|
|
12
|
-
"""Home page."""
|
|
13
|
-
page = request.args.get("page", 1, type=int)
|
|
14
|
-
posts = (
|
|
15
|
-
Post.query.filter_by(is_published=True)
|
|
16
|
-
.order_by(Post.published_at.desc())
|
|
17
|
-
.paginate(
|
|
18
|
-
page=page, per_page=current_app.config["POSTS_PER_PAGE"], error_out=False
|
|
19
|
-
)
|
|
20
|
-
)
|
|
21
|
-
return render_template("index.html", posts=posts)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@bp.route("/about")
|
|
25
|
-
def about():
|
|
26
|
-
"""About page."""
|
|
27
|
-
return render_template("about.html")
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
@bp.route("/post/<string:slug>")
|
|
31
|
-
def post(slug):
|
|
32
|
-
"""Single post page."""
|
|
33
|
-
post = Post.query.filter_by(slug=slug, is_published=True).first_or_404()
|
|
34
|
-
post.increment_view()
|
|
35
|
-
return render_template("post.html", post=post)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
@bp.route("/category/<string:slug>")
|
|
39
|
-
def category(slug):
|
|
40
|
-
"""Category page."""
|
|
41
|
-
category = Category.query.filter_by(slug=slug).first_or_404()
|
|
42
|
-
page = request.args.get("page", 1, type=int)
|
|
43
|
-
posts = (
|
|
44
|
-
Post.query.filter_by(category_id=category.id, is_published=True)
|
|
45
|
-
.order_by(Post.published_at.desc())
|
|
46
|
-
.paginate(
|
|
47
|
-
page=page, per_page=current_app.config["POSTS_PER_PAGE"], error_out=False
|
|
48
|
-
)
|
|
49
|
-
)
|
|
50
|
-
return render_template("category.html", category=category, posts=posts)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
@bp.route("/tag/<string:slug>")
|
|
54
|
-
def tag(slug):
|
|
55
|
-
"""Tag page."""
|
|
56
|
-
tag = Tag.query.filter_by(slug=slug).first_or_404()
|
|
57
|
-
page = request.args.get("page", 1, type=int)
|
|
58
|
-
posts = (
|
|
59
|
-
tag.posts.filter_by(is_published=True)
|
|
60
|
-
.order_by(Post.published_at.desc())
|
|
61
|
-
.paginate(
|
|
62
|
-
page=page, per_page=current_app.config["POSTS_PER_PAGE"], error_out=False
|
|
63
|
-
)
|
|
64
|
-
)
|
|
65
|
-
return render_template("tag.html", tag=tag, posts=posts)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
@bp.route("/search")
|
|
69
|
-
def search():
|
|
70
|
-
"""Search page."""
|
|
71
|
-
q = request.args.get("q", "")
|
|
72
|
-
page = request.args.get("page", 1, type=int)
|
|
73
|
-
|
|
74
|
-
if not q:
|
|
75
|
-
return render_template("search.html", posts=None, q=q)
|
|
76
|
-
|
|
77
|
-
posts = (
|
|
78
|
-
Post.query.filter(
|
|
79
|
-
Post.is_published == True,
|
|
80
|
-
db.or_(Post.title.ilike(f"%{q}%"), Post.content.ilike(f"%{q}%")),
|
|
81
|
-
)
|
|
82
|
-
.order_by(Post.published_at.desc())
|
|
83
|
-
.paginate(
|
|
84
|
-
page=page, per_page=current_app.config["POSTS_PER_PAGE"], error_out=False
|
|
85
|
-
)
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
return render_template("search.html", posts=posts, q=q)
|