added tags and groups pages and routes

This commit is contained in:
Elia Bellavista 2024-07-29 19:23:26 +02:00
parent d75622f167
commit 0c6f2bdd1a
10 changed files with 166 additions and 20 deletions

View File

@ -1,6 +1,6 @@
# Roadmap
- [ ] Fix Filters in search pages
- [ ] fix tags page and popular tags section in homepage
- [ ] fix tags page(home sees tags, but "all tags" does not)
- [ ] check if all requested plugins are working
- [ ]

View File

@ -495,6 +495,8 @@ def get_list_of_groups(limit=10, sort='package_count'):
ordered_groups = []
ordered_groups = logic.get_action('group_list')({}, data)
log.debug("group_list: "+ ", ".join(ordered_groups))
for group in ordered_groups:
# print "\n\ngroup %s" %group
try:

View File

@ -406,11 +406,21 @@ class D4Science_ThemePlugin(plugins.SingletonPlugin, toolkit.DefaultDatasetForm)
d4sHC = d4SHomeController()
d4sTC = d4STypeController()
d4sOC = OrganizationVREController()
blueprint = Blueprint('d4s', self.__module__)
def tags():
return render_template('tag/index.html')
def groups():
return render_template('group/index.html')
rules = [
('/', 'index', d4sHC.index),
('/type', 'type', d4sTC.index),
('/types', 'types', d4sTC.index),
('/organization_vre', 'organization_vre', d4sOC.index),
('/tags', 'tags', tags),
('/groups', 'groups', groups),
]
for rule in rules:
blueprint.add_url_rule(*rule)

View File

@ -76,8 +76,6 @@
#}
<div class="hero home-popular">
<div class="container">
<div class="row row-1">

View File

@ -1,4 +1,3 @@
{#{% set tags = h.get_facet_items_dict('tags', limit=30) %} #}
{% set tags = h.get_facet_items_dict('tags', c.search_facets, limit=3) %}
<style>
@ -20,9 +19,9 @@
<a href="{{ h.url_for('dataset.search', tags=tag['name']) }}" rel="{{ weight }}">{{ h.truncate(tag['display_name'], 26) }}</a>
{% endfor %}
</div>
{# <p style="float: right; margin-bottom: 15px;">
<a href="{{ h.url_for('tag.index') }}">See All {{ _('Tags') }}</a>
</p> #}
<p style="float: right; margin-bottom: 15px;">
<a href="/tags">See All {{_('Tags')}}</a>
</p>
</div>
<script type="text/javascript">

View File

@ -1,14 +1,35 @@
{% extends "base.html" %}
{% extends "page.html" %}
{% block page_title %}
All Tags
{% block subtitle %}{{ _('Tags') }}{% endblock %}
{% block breadcrumb_content %}
<li class="active">{% link_for _('Tags'), controller='d4s', action='tags' %}</li>
{% endblock %}
{% block page_header %}{% endblock %}
{# {% set tags = h.get_facet_items_dict('tags', c.search_facets, limit=3) %} #}
{% block primary_content_inner %}
{% set tags = h.get_facet_items_dict('tags', c.search_facets, limit=None) %}
<h1 class="hide-heading">{{ _('Tags') }}</h1>
{% block tag_form %}
{% snippet "tag/snippets/tag_form.html", tags=tags, sorting_selected=sortby %}
{% endblock %}
{% block tag_list %}
{% if tags|length >= 1 %}
{% snippet "tag/snippets/tag_list.html", tags=tags %}
{% else %}
<p class="empty">There are no {{ _('Tags') }}</p>
{% endif %}
{% endblock %}
{% endblock %}
{% block secondary_content %}
{% snippet "tag/snippets/helper.html" %}
{% endblock %}
{% block content %}
<h1>All Tags</h1>
<ul>
{% for tag in tags %}
<li>{{ tag }}</li>
{% endfor %}
</ul>
{% endblock %}

View File

@ -0,0 +1,13 @@
<div class="module module-narrow module-shallow">
<h2 class="module-heading">
<i class="icon-info-sign"></i>
{{ _('What are Tags?') }}
</h2>
<div class="module-content">
<p>
{% trans %}
Tags are keywords or labels that help categorize and filter datasets within the catalogue. They provide a way to quickly identify the main topics, themes, or attributes of a dataset. By tagging datasets with relevant keywords, users can easily search and find datasets that match their interests or needs. Tags improve discoverability and make it easier to organize and manage the datasets in the catalogue.
{% endtrans %}
</p>
</div>
</div>

View File

@ -0,0 +1,52 @@
{% import 'macros/form.html' as form %}
{% set sorting = [(_('Name Ascending'), 'name_asc'), (_('Name Descending'), 'name_desc'), (_('Number Of Ascending'), 'count_asc'), (_('Number Of Descending'), 'count_desc')] %}
{% set search_class = search_class if search_class else 'search-giant' %}
{% set no_bottom_border = no_bottom_border if no_bottom_border else false %}
{% set form_id = form_id if form_id else false %}
<form {% if form_id %}id="{{ form_id }}" {% endif %}class="search-form{% if no_bottom_border %} no-bottom-border{% endif %}" method="get" data-module="select-switch">
{% block search_sortby %}
{% if sorting %}
<div class="form-select control-group control-order-by">
<label for="field-order-by">{{ _('Order by') }}</label>
<select id="field-order-by" name="sort">
{% for label, value in sorting %}
{% if label and value %}
<option value="{{ value }}"{% if sorting_selected == value %} selected="selected"{% endif %}>{{ label }}</option>
{% endif %}
{% endfor %}
</select>
{% block search_sortby_button %}
<button class="btn js-hide" type="submit">{{ _('Go') }}</button>
{% endblock %}
</div>
{% endif %}
{% endblock %}
{% block search_title %}
<h2>
{{ tags|length }}
{% if tags|length > 1 %}
{{ _('Tags') }}
{% else %}
{{ _('Tag') }}
{% endif %}
found
</h2>
{% endblock %}
</form>
{% if show_empty and count == 0 and not error %}
{% trans %}
<p class="extra">Please try another search.</p>
{% endtrans %}
{% endif %}
{% if error %}
{% trans %}
<p id="search-error"><strong>There was an error while searching.</strong> Please try again.</p>
{% endtrans %}
{% endif %}

View File

@ -0,0 +1,9 @@
{% block tag_list %}
<ul class="media-grid" data-module="media-grid">
{% block tag_list_inner %}
{% for tag in tags %}
{% snippet "tag/snippets/tag_item.html", tag=tag, position=loop.index %}
{% endfor %}
{% endblock %}
</ul>
{% endblock %}

View File

@ -1,5 +1,47 @@
{% extends "page.html" %}
{% block subtitle %}{{ _('Tags') }}{% endblock %}
{% block breadcrumb_content %}
<li class="active">{% link_for _('Tags'), controller='d4s', action='tags' %}</li>
{% endblock %}
{% block page_header %}{% endblock %}
{% set tags = h.get_facet_items_dict('tags', c.search_facets, limit=3) %}
{% set sortby = h.get_request_param('sort') %}
{% if sortby %}
{% set list = sortby.split('_') %}
{% else %}
{% set list = ['name', 'asc'] %}
{% endif %}
{% set tags = h.d4science_get_ordered_dictionary(tags, list[0], list[1]) %}
{% block primary_content_inner %}
<h1 class="hide-heading">{{ _('Tags') }}</h1>
{% block tag_form %}
{% snippet "tag/snippets/tag_form.html", tags=tags, sorting_selected=sortby %}
{% endblock %}
{% block tag_list %}
{% if tags|length >= 1 %}
{% snippet "tag/snippets/tag_list.html", tags=tags %}
{% else %}
<p class="empty">There are no {{ _('Tags') }}</p>
{% endif %}
{% endblock %}
{% endblock %}
{% block secondary_content %}
{% snippet "tag/snippets/helper.html" %}
{% endblock %}
{# {% extends "page.html" %}
{% block subtitle %}{{ _('Types') }}{% endblock %}
{% block breadcrumb_content %}
@ -38,4 +80,4 @@
{% block secondary_content %}
{% snippet "type/snippets/helper.html" %}
{% endblock %}
{% endblock %} #}