Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dot nav refacoring #227

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ semantic/dist/themes/*
!semantic/dist/*.css
!semantic/dist/themes/default/
wbcore/static/semantic/dist/components/
wbcore/locale/*/LC_MESSAGES/*.mo
.vscode
Binary file removed wbcore/locale/de/LC_MESSAGES/django.mo
Binary file not shown.
Binary file removed wbcore/locale/de/LC_MESSAGES/djangojs.mo
Binary file not shown.
Binary file removed wbcore/locale/en/LC_MESSAGES/django.mo
Binary file not shown.
Binary file removed wbcore/locale/en/LC_MESSAGES/djangojs.mo
Binary file not shown.
Binary file removed wbcore/locale/es/LC_MESSAGES/django.mo
Binary file not shown.
Binary file removed wbcore/locale/es/LC_MESSAGES/djangojs.mo
Binary file not shown.
Binary file removed wbcore/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
Binary file removed wbcore/locale/fr/LC_MESSAGES/djangojs.mo
Binary file not shown.
56 changes: 12 additions & 44 deletions wbcore/templates/wbcore/dot_nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,26 @@

<div class="six wide column">
<div class="ui fluid vertical menu">
{% if host %}
<a class="item" href="{% url 'news' host.slug %}">{% trans "News" %}</a>
<a class="item" href="{% url 'blog' host.slug %}">{% trans "Blog" %}</a>
{% else %}
<a class="item" href="{% url 'news' %}">{% trans "News" %}</a>
<a class="item" href="{% url 'blog' %}">{% trans "Blog" %}</a>
{% endif %}
<a class="item" href="{{ dot_nav.news.link }}">{{ dot_nav.news.name }}</a>
<a class="item" href="{{ dot_nav.blog.link }}">{{ dot_nav.blog.name }}</a>
</div>
</div>
<div class="six wide column">
<div class="ui fluid vertical menu">
{% if host %}
<a class="item" href="{% url 'about' host.slug %}">{% trans "About" %}</a>
<div class="ui vertical fluid menu">
<a class="item" href="{% url 'history' host.slug %}">{% trans "History" %}</a>
<a class="item" href="{% url 'teams' host.slug %}">{% trans "Team" %}</a>
<a class="item" href="{% url 'partners' host.slug %}">{% trans "Partners" %}</a>
<a class="item" href="{% url 'donate' host.slug %}">{% trans "Donate" %}</a>
<a class="item" href="{% url 'contact' host.slug %}">{% trans "Contact" %}</a>
</div>
{% else %}
<a class="item" href="{% url 'about' %}">{% trans "About" %}</a>
<div class="ui vertical fluid menu">
<a class="item" href="{% url 'history' %}">{% trans "History" %}</a>
<a class="item" href="{% url 'teams' %}">{% trans "Team" %}</a>
<a class="item" href="{% url 'partners' %}">{% trans "Partners" %}</a>
<a class="item" href="{% url 'donate' %}">{% trans "Donate" %}</a>
<a class="item" href="{% url 'contact' %}">{% trans "Contact" %}</a>
</div>
{% endif %}
<a class="item" href="{{dot_nav.about.link}}">{{dot_nav.about.name}}</a>
{% for key, entry in dot_nav.about.entries.items %}
{% if key != 'idea' %}
<a class="item" href="{{ entry.link }}">{{ entry.name }}</a>
{% endif %}
{% endfor %}
</div>
</div>
<div class="six wide column">
<div class="ui fluid vertical menu">
{% if host %}
<a class="item" href="{% url 'facts' host.slug %}">{% trans "Facts" %}</a>
<div class="ui vertical fluid menu">
<a class="item" href="{% url 'transparency' host.slug %}">{% trans "Transparency" %}</a>
<a class="item" href="{% url 'charter' host.slug %}">{% trans "Charter" %}</a>
<a class="item" href="{% url 'reports' host.slug %}">{% trans "Reports" %}</a>
<a class="item" href="{% url 'faq' host.slug %}">{% trans "FAQ" %}</a>
</div>
{% else %}
<a class="item" href="{% url 'facts' %}">{% trans "Facts" %}</a>
<div class="ui vertical fluid menu">
<a class="item" href="{% url 'transparency' %}">{% trans "Transparency" %}</a>
<a class="item" href="{% url 'charter' %}">{% trans "Charter" %}</a>
<a class="item" href="{% url 'reports' %}">{% trans "Reports" %}</a>
<a class="item" href="{% url 'faq' %}">{% trans "FAQ" %}</a>
</div>
{% endif %}

<a class="item" href="{{dot_nav.facts.link}}">{{dot_nav.facts.name}}</a>
{% for key, entry in dot_nav.facts.entries.items %}
<a class="item" href="{{ entry.link }}">{{ entry.name }}</a>
{% endfor %}
</div>
</div>

Expand Down
65 changes: 21 additions & 44 deletions wbcore/templates/wbcore/dot_nav_columns.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,38 @@
{% load humanize %}

<div class="ui {% language 'en' %}{{ about_width | apnumber }}{% endlanguage %} wide column unstackable items">
{% if host %}
<a class="ui item header" href="{% url 'about' host.slug %}">{% trans "About" %}</a>
<div class="ui item"><a href="{% url 'idea' host.slug %}"><i class="lightbulb outline icon"></i> {% trans "Idea" %}</a></div>
<div class="ui item"><a href="{% url 'history' host.slug %}"><i class="history icon"></i> {% trans "History" %}</a></div>
<div class="ui item"><a href="{% url 'teams' host.slug %}"><i class="users icon"></i> {% trans "Team" %}</a></div>
<div class="ui item"><a href="{% url 'partners' host.slug %}"><i class="handshake icon"></i> {% trans "Partners" %}</a></div>
<div class="ui item"><a href="{% url 'donate' host.slug %}"><i class="donate icon"></i> {% trans "Donate" %}</a></div>
<div class="ui item"><a href="{% url 'contact' host.slug %}"><i class="address book outline icon"></i> {% trans "Contact" %}</a></div>
{% else %}
<a class="ui item header" href="{% url 'about' %}">{% trans "About" %}</a>
<div class="ui item"><a href="{% url 'idea' %}"><i class="lightbulb outline icon"></i> {% trans "Idea" %}</a></div>
<div class="ui item"><a href="{% url 'history' %}"><i class="history icon"></i> {% trans "History" %}</a></div>
<div class="ui item"><a href="{% url 'teams' %}"><i class="users icon"></i> {% trans "Team" %}</a></div>
<div class="ui item"><a href="{% url 'partners' %}"><i class="handshake icon"></i> {% trans "Partners" %}</a></div>
<div class="ui item"><a href="{% url 'donate' %}"><i class="donate icon"></i> {% trans "Donate" %}</a></div>
<div class="ui item"><a href="{% url 'contact' %}"><i class="address book outline icon"></i> {% trans "Contact" %}</a></div>
{% endif %}
<a class="ui item header" href="{{ dot_nav.about.link }}">{{ dot_nav.about.name }}</a>
{% for key, entry in dot_nav.about.entries.items %}
<div class="ui item"><a href="{{ entry.link }}"><i class="{{ entry.icon }}"></i> {{ entry.name }}</a></div>
{% endfor %}
</div>

<div class="ui {% language 'en' %}{{ news_width | apnumber }}{% endlanguage %} wide column unstackable items">
{% if host %} <a class="ui item header" href="{% url 'news' host.slug %}">{% trans "News" %}</a>
{% else %} <a class="ui item header" href="{% url 'news' %}">{% trans "News" %}</a>
{% endif %}
{% for entry in dot_nav.news %}
{% include 'wbcore/dot_nav_item.html' with image=entry.get_title_image type='news-post' id=entry.pk title=entry.title desc=entry.teaser|truncatewords:7 %}
<a class="ui item header" href="{{ dot_nav.news.link }}">{{ dot_nav.news.name }}</a>
{% for item in dot_nav.news.items %}
{% include 'wbcore/dot_nav_item.html' with item=item type='news-post' %}
{% endfor %}
</div>

{% if blog_width != 0 %}
<div class="ui {% language 'en' %}{{ blog_width | apnumber }}{% endlanguage %} wide column unstackable items">
{% if host %} <a class="ui item header"href="{% url 'blog' host.slug %}" >{% trans "Blog" %}</a>
{% else %} <a class="ui item header"href="{% url 'blog' %}" >{% trans "Blog" %}</a>
{% endif %}
{% for entry in dot_nav.blog %}
{% include 'wbcore/dot_nav_item.html' with image=entry.get_title_image type='blog-post' id=entry.pk title=entry.title desc=entry.teaser|truncatewords:7 %}
<a class="ui item header"href="{{ dot_nav.blog.link }}" >{{ dot_nav.blog.name }}</a>
{% for item in dot_nav.blog.items %}
{% include 'wbcore/dot_nav_item.html' with item=item type='blog-post' %}
{% endfor %}
</div>
{% endif %}

<div class="ui {% language 'en' %}{{ facts_width | apnumber }}{% endlanguage %} wide column unstackable items">
{% if host %}
<a class="ui item header" href="{% url 'facts' host.slug %}">{% trans "Facts" %}</a>
<div class="ui item"><a href="{% url 'transparency' host.slug %}"><i class="eye outline icon"></i> {% trans "Transparency" %}</a></div>
<div class="ui item"><a href="{% url 'charter' host.slug %}"><i class="file alternate outline icon"></i> {% trans "Charter" %}</a></div>
<div class="ui item"><a href="{% url 'reports' host.slug %}"><i class="chart line icon"></i> {% trans "Reports" %}</a></div>
<div class="ui item"><a href="{% url 'faq' host.slug %}"><i class="question icon"></i> {% trans "FAQ" %}</a></div>
{% else %}
<a class="ui item header" href="{% url 'facts' %}">{% trans "Facts" %}</a>
<div class="ui item"><a href="{% url 'transparency' %}"><i class="eye outline icon"></i> {% trans "Transparency" %}</a></div>
<div class="ui item"><a href="{% url 'charter' %}"><i class="file alternate outline icon"></i> {% trans "Charter" %}</a></div>
<div class="ui item"><a href="{% url 'reports' %}"><i class="chart line icon"></i> {% trans "Reports" %}</a></div>
<div class="ui item"><a href="{% url 'faq' %}"><i class="question icon"></i> {% trans "FAQ" %}</a></div>
{% endif %}
<a class="ui item header" href="{{ dot_nav.facts.link }}">{{ dot_nav.facts.name }}</a>
{% for key, entry in dot_nav.facts.entries.items %}
<div class="ui item"><a href="{{ entry.link }}"><i class="{{ entry.icon }}"></i> {{ entry.name }}</a></div>
{% endfor %}
</div>

<div class="ui {% language 'en' %}{{ events_width | apnumber }}{% endlanguage %} wide column unstackable items">
{% if host %} <a class="ui item header" href="{% url 'events' host.slug %}">{% trans "Events" %}</a>
{% else %} <a class="ui item header" href="{% url 'events' %}">{% trans "Events" %}</a>
{% endif %}
{% include 'wbcore/dot_nav_event.html' %}
<a class="ui item header" href="{{ dot_nav.events.link }}">{{ dot_nav.events.name }}</a>
{% for item in dot_nav.events.items %}
{% include 'wbcore/dot_nav_item.html' with type='event' %}
{% endfor %}
</div>
35 changes: 0 additions & 35 deletions wbcore/templates/wbcore/dot_nav_event.html

This file was deleted.

66 changes: 38 additions & 28 deletions wbcore/templates/wbcore/dot_nav_item.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
{% load static %}
{% load humanize %}
{% load martortags %}
<div class="item">
{% if image %}
{% if host %}
<a href="{% url type post_id=id host_slug=host.slug %}" class="ui top aligned image">
<img src="{{ image.get_menusize_url }}" class="thumbnail" alt="{{ image.title }}">
</a>
{% else %}
<a href="{% url type post_id=id %}" class="ui top aligned image">
<img src="{{ image.get_menusize_url }}" class="thumbnail" alt="{{ image.title }}">

{% if type == 'event' %}

<div class="item">
<div class="content">
<div class="date">
<i class="clock outline icon"></i>
{{ item.start | naturalday:"d. M" }} {{ item.start | time:"H:i" }}
{% if item.recurring %}
<i class="redo alternate icon"></i>
{% if item.frequency_short %} {{ item.frequency_short }} {% endif %}
{% endif %}
</div>
<div class="title">
<a href="{{ item.link }}">{{ item.title | truncatechars:20 }}</a>
</div>
{% if item.location %}
<div class="location">
<i class="map marker alternate icon"></i>{{ item.location }}
</div>
{% endif %}
</div>
</div>

{% else %}

<div class="item">
{% if item.image %}
<a href="{{ item.link }}" class="ui top aligned image">
<img src="{{ item.image.get_menusize_url }}" class="thumbnail" alt="{{ item.image.title }}">
</a>
{% endif %}
{% elif type == 'event' %}
<i class="clock outline icon"></i>
{% endif %}

<div class="content">
{% if type == 'event'%}
{% if host %}
<a href="{% url type event_slug=slug host_slug=host.slug %}">{{ title }}</a>
{% else %}
<a href="{% url type event_slug=slug %}">{{ title }}</a>
{% endif %}
<p>{{ show_date | safe }}</p>
{% else %}
{% if host %}
<a href="{% url type post_id=id host_slug=host.slug %}">{{ title }}</a>
{% else %}
<a href="{% url type post_id=id %}">{{ title }}</a>
<div class="content">
<a href="{{ item.link }}">{{ item.title }}</a>
{% if not item.image %}
<p>{{ item.teaser | safe_markdown | striptags | truncatewords:7 }}</p>
{% endif %}
<p>{{ desc | safe_markdown | striptags }}</p>
{% endif %}
</div>
</div>
</div>

{% endif %}
97 changes: 89 additions & 8 deletions wbcore/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,26 +122,107 @@ def get_main_nav(host=None, active=None):
def get_dot_nav(host=None):
if host:
host_slug = host.slug
link_args = [host.slug]
news = NewsPost.objects.filter(host=host).order_by('-published')[:3]
blog = BlogPost.objects.filter(host=host).order_by('-published')[:3]
events = Event.objects.filter(host=host)
else:
host_slug = None
link_args = []
news = NewsPost.objects.all().order_by('-published')[:3]
blog = BlogPost.objects.all().order_by('-published')[:3]
events = Event.objects.all()

for post in news:
if not post.teaser and post.text:
post.teaser = post.text

for post in blog:
if not post.teaser and post.text:
post.teaser = post.text
news = item_list_from_posts(news, host_slug=host_slug, post_type='news-post')
blog = item_list_from_posts(blog, host_slug=host_slug, post_type='blog-post')

occurrences = item_list_from_events(events, start=datetime.now(), host_slug=host_slug, text=False, show_only_first_occ=True, max_num_items=3)
return {'news': news, 'blog': blog, 'occurrences': occurrences}

about_entries = OrderedDict([
('idea', {
'name': _('Idea'),
'link': reverse('idea', args=link_args),
'icon': 'lightbulb outline icon',
}),
('history', {
'name': _('History'),
'link': reverse('history', args=link_args),
'icon': 'history icon',
}),
('teams', {
'name': _('Team'),
'link': reverse('teams', args=link_args),
'icon': 'users icon',
}),
('partners', {
'name': _('Partners'),
'link': reverse('partners', args=link_args),
'icon': 'handshake icon',
}),
('donate', {
'name': _('Donate'),
'link': reverse('donate', args=link_args),
'icon': 'donate icon',
}),
('contact', {
'name': _('Contact'),
'link': reverse('contact', args=link_args),
'icon': 'address book outline icon',
}),
])

facts_entries = OrderedDict([
('transparency', {
'name': _('Transparency'),
'link': reverse('transparency', args=link_args),
'icon': 'eye outline icon',
}),
('charter', {
'name': _('Charter'),
'link': reverse('charter', args=link_args),
'icon': 'file alternate outline icon',
}),
('reports', {
'name': _('Reports'),
'link': reverse('reports', args=link_args),
'icon': 'chart line icon',
}),
('faq', {
'name': _('FAQ'),
'link': reverse('faq', args=link_args),
'icon': 'question icon',
}),
])

dot_nav = OrderedDict([
('about', {
'name': _('About'),
'link': reverse('about', args=link_args),
'entries': about_entries,
}),
('news', {
'name': _('News'),
'link': reverse('news', args=link_args),
'items': news,
}),
('blog', {
'name': _('Blog'),
'link': reverse('blog', args=link_args),
'items': blog,
}),
('facts', {
'name': _('Facts'),
'link': reverse('facts', args=link_args),
'entries': facts_entries,
}),
('events', {
'name': _('Events'),
'link': reverse('events', args=link_args),
'items': occurrences,
}),
])

return dot_nav

def get_meta(title=None, description=None, robots=None):
meta = {
Expand Down