Commit 0e0f80fb authored by berumuron's avatar berumuron
Browse files

add: #5 Provide a link to event projects

parent a2225c97
import re
import unicodedata
from datetime import datetime
from flask import Markup
......@@ -39,7 +41,21 @@ def markdown_filter(text):
return Markup(sanitized_html)
_punct_re = re.compile(r'[\t !"#$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+')
def slugify_filter(text):
# Reference: http://flask.pocoo.org/snippets/5/
result = []
for word in _punct_re.split(text.lower()):
word = unicodedata.normalize("NFKD", word).encode("ascii", "ignore")
if word:
result.append(word.decode("utf8"))
return "-".join(result)
def init_app(app):
"""Register filters to the application Jinja."""
app.jinja_env.filters["to_month"] = to_month_filter
app.jinja_env.filters["markdown"] = markdown_filter
app.jinja_env.filters["slugify"] = slugify_filter
......@@ -58,6 +58,9 @@ class Event:
self.project_id = project_id
self.description = description
# yep, that's pretty inefficient... MR are opened :)
self.project = Project.find_by_id(self.project_id)
@classmethod
def items(cls):
database = db.get_db()
......
......@@ -336,6 +336,17 @@ button.button-ghost {
text-align: left;
}
.events .event .event-project {
display: inline-block;
margin-left: .5rem;
padding: 0 .25rem;
text-decoration: none;
border: 1px solid var(--secondary-color);
border-radius: .25rem;
}
.events .event .event-description {
max-width: 35rem;
margin-left: 5.25rem;
......@@ -383,6 +394,11 @@ button.button-ghost {
padding: 1rem;
}
.project:target {
box-shadow: 0 0 0 .25rem var(--secondary-color);
border-radius: .25rem;
}
.project .project-header {
display: flex;
......
......@@ -48,14 +48,16 @@
<button class="folder-toggle">
{{ event.title }}
</button>
<div class="event-description folder-container">
{{ event.description|markdown }}
</div>
{% else %}
{{ event.title }}
{% endif %}
{% if event.project and (g.current_user or not event.project.is_private) %}
<a class="event-project" href="{{ url_for('projects.index') }}#{{ event.project.name|slugify }}">
{{ event.project.name }}
</a>
{% endif %}
{% if g.current_user %}
<button
class="button-ghost event-delete"
......@@ -66,6 +68,12 @@
Supprimer
</button>
{% endif %}
{% if event.description %}
<div class="event-description folder-container">
{{ event.description|markdown }}
</div>
{% endif %}
</li>
{% endfor %}
</ul>
......
......@@ -19,7 +19,10 @@
{% include "alerts.html" %}
{% for project in projects|sort(attribute="name") %}
<section class="project {{ 'project-private' if project.is_private }} {{ 'folder folder-folded' if project.description }}">
<section
id="{{ project.name|slugify }}"
class="project {{ 'project-private' if project.is_private }} {{ 'folder folder-folded' if project.description }}"
>
{% if project.description %}
<header class="project-header">
<h2 class="project-name">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment