Skip to content

Commit

Permalink
Fix broken urls in the links of headings on the pageindex (and add a …
Browse files Browse the repository at this point in the history
…test for this).

Fixes #78.
  • Loading branch information
redimp committed Jan 24, 2024
1 parent 9e6a186 commit fd808c3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion otterwiki/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def __init__(self, path=None):
pagetoc.append((
header[2], # depth
header[3], # title without formatting
url_for("view", path=get_pagename(f, full=False, header=pagename), _anchor=header[4])
url_for("view", path=get_pagename(f, full=True, header=pagename), _anchor=header[4])
))
# strip self.path from displayname
displayname = pagename
Expand Down
15 changes: 15 additions & 0 deletions tests/test_otterwiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ def save_shortcut(test_client, pagename, content, commit_message):
assert rv.status_code == 200


def test_pageindex(test_client):
save_shortcut(test_client, "Random page", "# Random page\nrandom text", "added random page")
save_shortcut(test_client, "Sub directory/Nested Page", "# Nested page\n\n## Nested header\n", "added nested page")
html = test_client.get("/-/index").data.decode()
# check captializing (from # Random page)
assert 'Random page' in html
assert 'href="/Random%20page"' in html
# Test nested page
assert '>Nested page<' in html
assert 'href="/Sub%20Directory/Nested%20page"' in html
# and nested header
assert '>Nested header<' in html
assert 'href="/Sub%20Directory/Nested%20page#nested-header"' in html


def test_page_save(test_client):
from otterwiki.server import storage

Expand Down

0 comments on commit fd808c3

Please sign in to comment.