Skip to content

Commit a0c1da5

Browse files
authored
Merge pull request #9 from BinarCode/feature/docs-editor-ui
feat(ui): add --base-path and version bump to 0.20.0
2 parents 8e7231d + 81b9ce4 commit a0c1da5

5 files changed

Lines changed: 25 additions & 13 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "aidocs"
3-
version = "0.18.0"
3+
version = "0.20.0"
44
description = "AI-powered documentation generator for web applications. Install docs commands into your Claude Code project."
55
readme = "README.md"
66
license = { text = "MIT" }

src/aidocs_cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""AI-powered documentation generator CLI for Claude Code projects."""
22

3-
__version__ = "0.17.0"
3+
__version__ = "0.20.0"
44

55
from .cli import app
66

src/aidocs_cli/cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,11 @@ def ui(
12591259
"--reconfigure",
12601260
help="Re-run the setup prompts even if config exists.",
12611261
),
1262+
base_path: str = typer.Option(
1263+
"",
1264+
"--base-path",
1265+
help="Base URL path when served behind a reverse proxy (e.g. /admin/docs).",
1266+
),
12621267
) -> None:
12631268
"""Launch the web-based docs editor UI.
12641269
@@ -1350,13 +1355,17 @@ def ui(
13501355
from .ui.app import create_app
13511356

13521357
full_repo = f"{github_owner}/{github_repo}"
1358+
# Strip trailing slash from base_path
1359+
base_path = base_path.rstrip("/")
1360+
13531361
fastapi_app = create_app(
13541362
docs_dir=target_dir.resolve(),
13551363
github_token=github_token,
13561364
github_repo=full_repo,
13571365
base_branch=github_branch,
13581366
media_path=media_path or None,
13591367
docs_prefix=docs_path,
1368+
base_path=base_path,
13601369
)
13611370

13621371
url = f"http://{host}:{port}"

src/aidocs_cli/ui/app.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def create_app(
3636
base_branch: str = "main",
3737
media_path: str | None = None,
3838
docs_prefix: str | None = None,
39+
base_path: str = "",
3940
) -> FastAPI:
4041
"""Create and configure the FastAPI application."""
4142
owner, repo = github_repo.split("/", 1)
@@ -137,6 +138,7 @@ async def index(request: Request):
137138
template = (TEMPLATE_DIR / "index.html").read_text(encoding="utf-8")
138139
rendered = template.replace("{{ tree }}", tree_html)
139140
rendered = rendered.replace("{{ docs_prefix }}", str(docs_dir))
141+
rendered = rendered.replace("{{ base_path }}", base_path)
140142

141143
success_html = ""
142144
if "success" in flash:
@@ -208,7 +210,7 @@ async def api_store(request: Request):
208210
except Exception as e:
209211
_flash(request, "error", f"Failed: {e}")
210212

211-
return RedirectResponse("/", status_code=303)
213+
return RedirectResponse(f"{base_path}/", status_code=303)
212214

213215
@app.post("/api/update")
214216
async def api_update(request: Request):
@@ -243,7 +245,7 @@ async def api_update(request: Request):
243245
except Exception as e:
244246
_flash(request, "error", f"Failed to create PR: {e}")
245247

246-
return RedirectResponse("/", status_code=303)
248+
return RedirectResponse(f"{base_path}/", status_code=303)
247249

248250
@app.post("/api/delete")
249251
async def api_delete(request: Request):
@@ -263,7 +265,7 @@ async def api_delete(request: Request):
263265
except Exception as e:
264266
_flash(request, "error", f"Failed to create delete PR: {e}")
265267

266-
return RedirectResponse("/", status_code=303)
268+
return RedirectResponse(f"{base_path}/", status_code=303)
267269

268270
@app.post("/api/upload-image")
269271
async def api_upload_image(

src/aidocs_cli/ui/templates/index.html

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<div class="max-w-[1600px] mx-auto px-6 py-3 flex items-center justify-between">
3333
<div class="flex items-center gap-2">
3434
<svg class="w-5 h-5 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/></svg>
35-
<a href="/" class="text-base font-semibold text-gray-800">Docs Editor</a>
35+
<a href="{{ base_path }}/" class="text-base font-semibold text-gray-800">Docs Editor</a>
3636
</div>
3737
<button type="button" id="sync-btn"
3838
class="flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-gray-600 border border-gray-200 rounded-lg hover:bg-gray-50 transition">
@@ -46,7 +46,7 @@
4646
{{ flash_messages }}
4747

4848
<!-- Hidden delete form -->
49-
<form id="delete-form" action="/api/delete" method="POST" class="hidden">
49+
<form id="delete-form" action="{{ base_path }}/api/delete" method="POST" class="hidden">
5050
<input type="hidden" name="path" id="d-path">
5151
</form>
5252

@@ -86,7 +86,7 @@
8686
</div>
8787

8888
<!-- Edit Form -->
89-
<form action="/api/update" method="POST"
89+
<form action="{{ base_path }}/api/update" method="POST"
9090
class="hidden flex-1 flex flex-col" id="edit-form">
9191
<input type="hidden" name="path" id="f-path">
9292
<input type="hidden" name="uploaded_images" id="f-uploaded-images">
@@ -181,7 +181,7 @@ <h2 class="text-sm font-semibold text-gray-800 truncate capitalize" id="editor-t
181181
</form>
182182

183183
<!-- Create Form -->
184-
<form action="/api/store" method="POST"
184+
<form action="{{ base_path }}/api/store" method="POST"
185185
class="hidden flex-1 flex flex-col" id="create-form">
186186

187187
<div class="bg-white rounded-t-xl border border-gray-200 px-5 py-3 flex items-center justify-between shadow-sm">
@@ -265,6 +265,7 @@ <h2 class="text-sm font-semibold text-gray-800">New Page</h2>
265265

266266
<script>
267267
const docsPrefix = '{{ docs_prefix }}';
268+
const basePath = '{{ base_path }}';
268269
const md = window.markdownit({ html: true, linkify: true, typographer: true });
269270
let currentTab = localStorage.getItem('docs-editor-tab') || 'editor';
270271
let previewTimer = null;
@@ -418,7 +419,7 @@ <h2 class="text-sm font-semibold text-gray-800">New Page</h2>
418419

419420
showPanel('loading-state');
420421

421-
fetch('/api/edit?path=' + encodeURIComponent(this.dataset.path), {
422+
fetch(basePath + '/api/edit?path=' + encodeURIComponent(this.dataset.path), {
422423
headers: { 'Accept': 'application/json' }
423424
})
424425
.then(r => r.json())
@@ -462,7 +463,7 @@ <h2 class="text-sm font-semibold text-gray-800">New Page</h2>
462463
setDirty(false);
463464
showPanel('loading-state');
464465

465-
fetch('/api/folders', { headers: { 'Accept': 'application/json' } })
466+
fetch(basePath + '/api/folders', { headers: { 'Accept': 'application/json' } })
466467
.then(r => r.json())
467468
.then(data => {
468469
const select = document.getElementById('c-folder');
@@ -543,7 +544,7 @@ <h2 class="text-sm font-semibold text-gray-800">New Page</h2>
543544
checkDirty();
544545
schedulePreview();
545546

546-
fetch('/api/upload-image', {
547+
fetch(basePath + '/api/upload-image', {
547548
method: 'POST',
548549
body: formData,
549550
})
@@ -657,7 +658,7 @@ <h2 class="text-sm font-semibold text-gray-800">New Page</h2>
657658
btn.classList.add('opacity-50');
658659
icon.classList.add('animate-spin');
659660

660-
fetch('/api/sync', { method: 'POST' })
661+
fetch(basePath + '/api/sync', { method: 'POST' })
661662
.then(r => r.json())
662663
.then(data => {
663664
if (data.success) {

0 commit comments

Comments
 (0)