Adding new paging support.
This commit is contained in:
parent
ef6beb77b4
commit
b8b3f2e1b8
4 changed files with 116 additions and 51 deletions
|
|
@ -1,10 +1,14 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
from flask import Flask
|
||||
from jinja_markdown import MarkdownExtension
|
||||
from pathlib import Path
|
||||
from sqlalchemy.engine import Engine
|
||||
from sqlalchemy import event
|
||||
from sqlalchemy.pool import Pool
|
||||
from werkzeug.middleware.profiler import ProfilerMiddleware
|
||||
|
||||
import crudkit
|
||||
|
||||
|
|
@ -85,4 +89,21 @@ def create_app(config_cls=crudkit.DevConfig) -> Flask:
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
return app
|
||||
if app.config.get("PROFILE", True):
|
||||
# Use an absolute dir under the instance path (always writable)
|
||||
inst_dir = Path(app.instance_path)
|
||||
inst_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
prof_dir = inst_dir / "profiler"
|
||||
prof_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# If you're using the dev reloader, guard so you don't wrap twice
|
||||
if not app.debug or os.environ.get("WERKZEUG_RUN_MAIN") == "true":
|
||||
app.wsgi_app = ProfilerMiddleware(
|
||||
app.wsgi_app,
|
||||
sort_by=("cumtime", "tottime"),
|
||||
restrictions=[50],
|
||||
profile_dir=str(prof_dir), # absolute path
|
||||
)
|
||||
|
||||
return app
|
||||
|
|
|
|||
|
|
@ -25,15 +25,6 @@
|
|||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<div class="mt-3">
|
||||
<button type="button" class="btn btn-outline-primary btn-sm" onclick="addNewUpdate()">
|
||||
Add update
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="updates" id="updatesPayload">
|
||||
<input type="hidden" name="delete_update_ids" id="deleteUpdatesPayload">
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@5/github-markdown.min.css">
|
||||
<style>
|
||||
textarea.auto-md {
|
||||
|
|
@ -54,16 +45,6 @@
|
|||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/dompurify/dist/purify.min.js"></script>
|
||||
<script>
|
||||
// Track deletions for existing notes
|
||||
const deletedUpdateIds = new Set();
|
||||
|
||||
function addNewUpdate() {
|
||||
// Create a temporary client-only id so we can manage the DOM before saving
|
||||
const tempId = `new_${Date.now()}`;
|
||||
const li = document.createElement('li');
|
||||
li.className = 'list-group-item';
|
||||
}
|
||||
|
||||
// Initial render
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const ids = [ {% for n in items %} {{ n.id }}{% if not loop.last %}, {% endif %}{% endfor %} ];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue