HTMLify

search-result.html
Views: 135 | Author: abh
<!-- search-result.html -->
<form class="search-form" action="/search" method="GET" style="margin:20p;">
<input type="text" name="q" value="{{ q }}"/>
<input type="submit" value="Search" />
</form>
{% for result in results %}
<div class="search-result" style="border:1px solid black;margin:5px;padding:5px;">
<span>{{ result.name }}</span> | <span>Owner: {{ result.owner }} | <a href="{{ result.path }}">Open</a>{% if session.get("user") and result.owner == session["user"]["username"] %} | <a href="/edit?filepath={{ result.path[result.owner|length + 1:] }}">Edit</a>{% endif %}</a></span><br>
<p>{{ result.content.replace("<", "&lt;").replace(">", "&gt;")[result.content.find(q)-100:result.content.find(q)+100].replace(q, "<b>" + q + "</b>")|safe }}</p>
</div>
{% endfor %}

Comments