Skip to content

Commit

Permalink
transcluded wiki index into user dashboard
Browse files Browse the repository at this point in the history
similar to the front page (a377c26),
but drawn from the user's personal wiki instead of a central bag

note that currently this wiki is not being created automatically upon
registration; it should though
  • Loading branch information
FND committed Sep 22, 2013
1 parent 7a96691 commit 582f3b8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
17 changes: 15 additions & 2 deletions test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ def test_root():

assert 'Log in' in content
assert 'Register' in content
uri = "https://github.com/FND/tiddlywebplugins.bfw"
uri = 'https://github.com/FND/tiddlywebplugins.bfw'
assert '<a href="%s">BFW</a>' % uri in content

frontpage = Tiddler('index', 'meta')
frontpage = STORE.delete(frontpage)
frontpage = STORE.delete(frontpage) # XXX: side-effecty
response, content = _req('GET', '/')
assert response.status == 200
assert '<a href="%s">BFW</a>' % uri not in content
Expand All @@ -109,6 +109,19 @@ def test_user_home():
assert '<a href="/bravo">bravo</a>' in content
assert not 'charlie' in content

bag = Bag('admin')
index = Tiddler('index', bag.name)
index.text = 'hello world'
STORE.put(bag)
STORE.put(index)
response, content = _req('GET', '/~', headers={ 'Cookie': ADMIN_COOKIE })
assert response.status == 200
assert 'hello world' in content

response, content = _req('GET', '/', headers={ 'Cookie': ADMIN_COOKIE })
assert response.status == 302
assert response['location'] == '/~'


def test_wiki_page():
response, content = _req('GET', '/alpha/index')
Expand Down
10 changes: 9 additions & 1 deletion tiddlywebplugins/bfw/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def user_home(environ, start_response):
raise HTTP401('unauthorized')

store = environ['tiddlyweb.store']

wikis = []
for bag in store.list_bags():
try:
Expand All @@ -67,12 +68,19 @@ def user_home(environ, start_response):
except ForbiddenError, exc:
pass

tiddler = Tiddler('index', current_user)
try:
tiddler = store.get(tiddler)
except NoTiddlerError: # this should never occur
pass

uris = {
'create_wiki': _uri(environ, 'wikis'),
'create_page': _uri(environ, 'pages')
}
return _render_template(environ, start_response, 'user_home.html',
user=current_user, wikis=wikis, uris=uris)
user=current_user, wikis=wikis,
contents=render_wikitext(tiddler, environ), uris=uris)


def wiki_home(environ, start_response):
Expand Down
4 changes: 4 additions & 0 deletions tiddlywebplugins/templates/user_home.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ <h3>Your Wikis</h3>
{% endif %}
</aside>

<article>
{{ contents }}
</article>

<script src="/static/widearea.js"></script>
<script src="/static/editor.js"></script>
{% endblock %}

0 comments on commit 582f3b8

Please sign in to comment.