public-release phases 1-3: read-only public mode, gunicorn container, demo bootstrap, CI, README

- before_request guard: visitors browse + explore; writes need PHYSCOM_ADMIN_TOKEN login
- SameSite=Lax/HttpOnly cookies, persisted secret key, debug off unless FLASK_DEBUG=1
- non-root gunicorn container with healthcheck; physcom demo --if-empty on first start
- landing page Top Concepts, write controls hidden from visitors
- CI workflow, pyproject metadata, compose Ollama parity, README rewrite
- tests/test_web_access.py: access control + GET smoke test of every page

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-09-25 15:40:02 -05:00
parent 2e38a6cf73
commit 8171fc023e
23 changed files with 510 additions and 112 deletions

View File

@@ -8,7 +8,7 @@
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
</head>
<body>
<body{% if not is_admin() %} class="readonly"{% endif %}>
<nav>
<a href="{{ url_for('index') }}" class="nav-brand">
<img src="{{ url_for('static', filename='logo.svg') }}" alt="">
@@ -17,9 +17,14 @@
<ul>
<li><a href="{{ url_for('entities.entity_list') }}">Entities</a></li>
<li><a href="{{ url_for('domains.domain_list') }}">Domains</a></li>
<li><a href="{{ url_for('pipeline.pipeline_form') }}">Pipeline</a></li>
<li><a href="{{ url_for('results.results_index') }}">Results</a></li>
{% if is_admin() %}
<li><a href="{{ url_for('pipeline.pipeline_form') }}">Pipeline</a></li>
<li><a href="{{ url_for('admin.admin_index') }}">Admin</a></li>
{% if not config.OPEN_ACCESS %}
<li><form method="post" action="{{ url_for('logout') }}" class="nav-logout"><button type="submit">Log out</button></form></li>
{% endif %}
{% endif %}
</ul>
</nav>

View File

@@ -4,7 +4,7 @@
{% block content %}
<div class="page-header">
<h1>Domains</h1>
<a href="{{ url_for('domains.domain_new') }}" class="btn btn-primary">New Domain</a>
{% if is_admin() %}<a href="{{ url_for('domains.domain_new') }}" class="btn btn-primary">New Domain</a>{% endif %}
</div>
{% if not domains %}

View File

@@ -4,7 +4,7 @@
{% block content %}
<div class="page-header">
<h1>Entities</h1>
<a href="{{ url_for('entities.entity_new') }}" class="btn btn-primary">+ Add Entity</a>
{% if is_admin() %}<a href="{{ url_for('entities.entity_new') }}" class="btn btn-primary">+ Add Entity</a>{% endif %}
</div>
{% if not grouped %}

View File

@@ -14,11 +14,41 @@
entity combinations against real-world physics.
</p>
<div class="hero-actions">
{% if is_admin() %}
<a href="{{ url_for('pipeline.pipeline_form') }}" class="btn btn-primary">Run Pipeline</a>
<a href="{{ url_for('results.results_index') }}" class="btn">View Results</a>
{% endif %}
<a href="{{ url_for('results.results_index') }}" class="btn{% if not is_admin() %} btn-primary{% endif %}">View Results</a>
</div>
</div>
{% if top_concepts %}
<!-- Best concept per domain -->
<h2 class="section-heading">Top Concepts</h2>
<p class="section-desc">
The highest-scoring surviving combination in each domain, out of
{{ stats.combinations }} generated.
</p>
<div class="card">
<table>
<thead><tr><th>Domain</th><th>Concept</th><th>Score</th><th></th></tr></thead>
<tbody>
{% for domain, r in top_concepts %}
<tr>
<td>{{ domain.name }}</td>
<td>{{ r.combination.entities|map(attribute='name')|join(' + ') }}</td>
<td class="score-cell">{{ "%.4f"|format(r.composite_score) }}</td>
<td>
<a href="{{ url_for('results.result_detail', domain_name=domain.name, combo_id=r.combination.id) }}"
class="btn btn-sm">View</a>
<a href="{{ url_for('results.results_domain', domain_name=domain.name) }}" class="btn btn-sm">All</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
<!-- How It Works -->
<h2 class="section-heading">How It Works</h2>
<p class="section-desc">

View File

@@ -0,0 +1,16 @@
{% extends "base.html" %}
{% block title %}Admin login — PhysCom{% endblock %}
{% block content %}
<h1>Admin login</h1>
<div class="card">
{% if error %}<div class="flash flash-error">{{ error }}</div>{% endif %}
<form method="post" class="public">
<div class="form-group">
<label for="token">Admin token</label>
<input type="password" id="token" name="token" required autofocus autocomplete="current-password">
</div>
<button type="submit" class="btn btn-primary">Log in</button>
</form>
</div>
{% endblock %}

View File

@@ -58,7 +58,7 @@
{% if status_filter or rating_filter %}
<p class="empty">No results matching that filter in this domain.</p>
{% else %}
<p class="empty">No results for this domain yet. <a href="{{ url_for('pipeline.pipeline_form') }}">Run the pipeline</a> first.</p>
<p class="empty">No results for this domain yet.{% if is_admin() %} <a href="{{ url_for('pipeline.pipeline_form') }}">Run the pipeline</a> first.{% endif %}</p>
{% endif %}
{% else %}
<table>