mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-06 23:05:10 +01:00
Templates are more complete, working navigation, tags overview page
This commit is contained in:
40
digimarks.py
40
digimarks.py
@@ -94,24 +94,41 @@ class Bookmark(db.Model):
|
||||
return result
|
||||
|
||||
|
||||
def get_tags_for_user(userkey):
|
||||
""" Extract all tags from the bookmarks """
|
||||
bookmarks = Bookmark.select(Bookmark.userkey==userkey)
|
||||
for bookmark in bookmarks:
|
||||
these_tags = bookmark.tags.split(',')
|
||||
print these_tags
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
""" Homepage, point visitors to project page """
|
||||
return object_list('index.html', Bookmark.select())
|
||||
return render_template('index.html')
|
||||
|
||||
|
||||
@app.route('/<userkey>/')
|
||||
@app.route('/<userkey>')
|
||||
def bookmarks(userkey):
|
||||
""" User homepage, list their (unfiltered) bookmarks """
|
||||
return object_list('bookmarks.html', Bookmark.select())
|
||||
#return object_list('bookmarks.html', Bookmark.select())
|
||||
#user = User.select(key=userkey)
|
||||
#if user:
|
||||
# bookmarks = Bookmark.select(User=user)
|
||||
# return render_template('bookmarks.html', bookmarks)
|
||||
#else:
|
||||
# abort(404)
|
||||
bookmarks = Bookmark.select(Bookmark.userkey==userkey)
|
||||
return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey)
|
||||
|
||||
|
||||
|
||||
@app.route('/<userkey>/<urlhash>')
|
||||
def viewbookmark(urlhash):
|
||||
""" Bookmark detail view """
|
||||
# bookmark = getbyurlhash()
|
||||
return render_template('viewbookmark.html')
|
||||
return render_template('viewbookmark.html', userkey=userkey)
|
||||
|
||||
|
||||
@app.route('/<userkey>/<urlhash>/json')
|
||||
@@ -122,17 +139,17 @@ def viewbookmarkjson(urlhash):
|
||||
|
||||
|
||||
@app.route('/<userkey>/edit/<urlhash>')
|
||||
def editbookmark(urlhash):
|
||||
def editbookmark(userkey, urlhash):
|
||||
""" Bookmark edit form """
|
||||
# bookmark = getbyurlhash()
|
||||
return render_template('edit.html')
|
||||
bookmark = Bookmark(Bookmark.url_hash==urlhash)
|
||||
return render_template('edit.html', userkey=userkey)
|
||||
|
||||
|
||||
@app.route('/<userkey>/add')
|
||||
def addbookmark():
|
||||
def addbookmark(userkey):
|
||||
""" Bookmark add form """
|
||||
bookmark = Bookmark()
|
||||
return render_template('edit.html')
|
||||
return render_template('edit.html', userkey=userkey)
|
||||
|
||||
|
||||
@app.route('/<userkey>/add/')
|
||||
@@ -153,6 +170,13 @@ def adding(userkey):
|
||||
abort(404)
|
||||
|
||||
|
||||
@app.route('/<userkey>/tags')
|
||||
def tags(userkey):
|
||||
""" Overview of all tags used by user """
|
||||
tags = get_tags_for_user(userkey)
|
||||
return render_template('tags.html', tags=tags, userkey=userkey)
|
||||
|
||||
|
||||
@app.route('/<systemkey>/adduser')
|
||||
def adduser(systemkey):
|
||||
""" Add user endpoint, convenience """
|
||||
|
||||
@@ -19,22 +19,24 @@
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/css/materialize.min.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
||||
<link href="{{ url_for('static', filename='css/digimarks.css') }}" type="text/css" rel="stylesheet" media="screen,projection"/>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="light-blue lighten-1" role="navigation">
|
||||
<div class="nav-wrapper container"><a id="logo-container" href="#" class="brand-logo">digimarks</a>
|
||||
<body class="grey darken-2">
|
||||
<nav class="green darken-3" role="navigation">
|
||||
<div class="nav-wrapper container"><a id="logo-container" href="{{ url_for('index') }}" class="brand-logo">digimarks</a>
|
||||
<ul class="right hide-on-med-and-down">
|
||||
<li><a href="#">Add bookmark</a></li>
|
||||
<li><a href="{{ url_for('tags', userkey=userkey) }}">Tags</a></li>
|
||||
<li><a href="{{ url_for('addbookmark', userkey=userkey) }}">Add bookmark</a></li>
|
||||
</ul>
|
||||
|
||||
<ul id="nav-mobile" class="side-nav">
|
||||
<li><a href="#">Add bookmark</a></li>
|
||||
<li><a href="{{ url_for('tags', userkey=userkey) }}">Tags</a></li>
|
||||
<li><a href="{{ url_for('addbookmark', userkey=userkey) }}">Add bookmark</a></li>
|
||||
</ul>
|
||||
<a href="#" data-activates="nav-mobile" class="button-collapse"><i class="material-icons">menu</i></a>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="section no-pad-bot" id="index-banner">
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div class="header grey-text lighten-5">
|
||||
<h1>{% block pageheader %}Bookmarks{% endblock %}</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Bookmarks{% endblock %}
|
||||
{% block pagetitle %}Bookmarks{% endblock %}
|
||||
{% block pageheader %}Bookmarks{% endblock %}
|
||||
{% block pagecontent %}
|
||||
<div class="row">
|
||||
{% for bookmark in object_list %}
|
||||
@@ -21,9 +21,11 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{#
|
||||
<div class="pagination">
|
||||
{% if page > 1 %}<a href="./?page={{ page - 1 }}">Previous</a>{% endif %}
|
||||
{% if pagination.get_pages() > page %}<a href="./?page={{ page + 1 }}">Next</a>{% endif %}
|
||||
</div>
|
||||
#}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}digimarks{% endblock %}
|
||||
{% block pagetitle %}digimarks{% endblock %}
|
||||
{% block pageheader %}digimarks{% endblock %}
|
||||
{% block pagecontent %}
|
||||
<p>Please visit your personal url, or <a href="https://github.com/aquatix/digimarks">see the digimarks project page</a>.</p>
|
||||
{% endblock %}
|
||||
|
||||
8
templates/tags.html
Normal file
8
templates/tags.html
Normal file
@@ -0,0 +1,8 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Tags{% endblock %}
|
||||
{% block pageheader %}Tags{% endblock %}
|
||||
{% block pagecontent %}
|
||||
<div class="row">
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user