diff --git a/journals/managers.py b/journals/managers.py index 9d9bb31a1e25049162b5c0737079c214ec400723..cccc326395038fa0e309072d8d4546039fe358c2 100644 --- a/journals/managers.py +++ b/journals/managers.py @@ -57,3 +57,8 @@ class PublicationQuerySet(models.QuerySet): def drafts(self): return self.filter(status=STATUS_DRAFT) + + def for_subject(self, subject_code): + return self.filter( + models.Q(subject_area=subject_code) | + models.Q(secondary_areas__contains=[subject_code])) diff --git a/journals/models.py b/journals/models.py index b0d64fbeca8a2bb2c703b5c9e669562e89505235..f070472ee702462360dd03abb9b9ad5e25ff350c 100644 --- a/journals/models.py +++ b/journals/models.py @@ -194,7 +194,7 @@ class Issue(models.Model): text = self.issue_number if hasattr(self, 'proceedings'): return text - text += self.period_as_string() + text += ' (%s)' % self.period_as_string if self.status == STATUS_DRAFT: text += ' (In draft)' return text @@ -210,15 +210,15 @@ class Issue(models.Model): def issue_number(self): return '%s issue %s' % (self.in_volume, self.number) + @property def short_str(self): return 'Vol. %s issue %s' % (self.in_volume.number, self.number) + @property def period_as_string(self): if self.start_date.month == self.until_date.month: - return ' (%s %s)' % (self.until_date.strftime('%B'), self.until_date.strftime('%Y')) - else: - return (' (' + self.start_date.strftime('%B') + '-' + self.until_date.strftime('%B') + - ' ' + self.until_date.strftime('%Y') + ')') + return '%s %s' % (self.until_date.strftime('%B'), self.until_date.strftime('%Y')) + return '%s - %s' % (self.start_date.strftime('%B'), self.until_date.strftime('%B %Y')) def is_current(self): return self.start_date <= timezone.now().date() and\ diff --git a/journals/templates/journals/publication_list.html b/journals/templates/journals/publication_list.html new file mode 100644 index 0000000000000000000000000000000000000000..a02ac4f2e75c746dd71471050d95f8ab82d28509 --- /dev/null +++ b/journals/templates/journals/publication_list.html @@ -0,0 +1,65 @@ +{% extends 'scipost/layout_2_col.html' %} + +{% load bootstrap %} +{% load request_filters %} +{% load submissions_extras %} +{% load request_filters %} + +{% block body_class %}{{block.super}} sidebar-left{% endblock %} + +{% block pagetitle %}: Publications{% endblock pagetitle %} + +{% block page_header %}<h1 class="highlight">Recent SciPost Publications</h1>{% endblock page_header %} + +{% block breadcrumb_items %} + <a href="{% url 'journals:journals' %}" class="breadcrumb-item">Journals</a> + <span class="breadcrumb-item">Publications</span> +{% endblock %} + +{% block content %} + +<div class="row"> + <div class="col-12"> + <ul class="list-group list-group-flush"> + {% for publication in object_list %} + <li class="list-group-item"> + <div class="card-body px-0"> + {% include 'partials/journals/publication_li_content_extended.html' with publication=publication %} + </div> + </li> + {% empty %} + <h3><em>No match found for your search query.</em></h3> + {% endfor %} + </ul> + </div> + {% if is_paginated %} + <div class="col-12"> + {% include 'partials/pagination.html' with page_obj=page_obj %} + </div> + {% endif %} +</div> + +{% endblock content %} + + +{% block sidebar %} + <div class="row"> + <div class="col-12"> + <h2 class="mb-2">Recent Issues</h2> + <div class="mb-1 pl-2"> + <a href="?{% url_replace issue='' page='' %}" class="{% active_get_request 'issue' '' %}">All Issues</a> + </div> + {% for issue in recent_issues %} + <div class="mb-1 pl-2"> + <a href="?{% url_replace issue=issue.id page='' %}" class="{% active_get_request 'issue' issue.id %}">{{ issue.in_volume.in_journal }} {{ issue.short_str }}</a> + <br>{{ issue.period_as_string }} + </div> + {% endfor %} + + <h2 class="mb-2 mt-4">Subject area</h2> + {% for subject in subject_areas %} + <a href="?{% url_replace subject=subject.0 page='' %}" class="d-inline-block mb-1 ml-2 {% active_get_request 'subject' subject.0 %}">{{ subject.1 }}</a><br> + {% endfor %} + </div> + </div> +{% endblock %} diff --git a/journals/templates/partials/journals/publication_li_content_extended.html b/journals/templates/partials/journals/publication_li_content_extended.html new file mode 100644 index 0000000000000000000000000000000000000000..39a3fca47079b7231f3a0bf08e2043643b2d85e5 --- /dev/null +++ b/journals/templates/partials/journals/publication_li_content_extended.html @@ -0,0 +1,15 @@ +<h5 class="pb-0">{{publication.get_subject_area_display}}</h5> +<h3><a href="{{publication.get_absolute_url}}">{{publication.title}}</a></h3> + +<p class="mt-0 mb-2">{{ publication.author_list }}</p> +<p class="text-muted"> + {{ publication.citation }} · + <span class="font-weight-light">published {{ publication.publication_date|date:'j F Y' }}</span> · + <a href="{% url 'scipost:publication_pdf' publication.doi_label %}" target="_blank"><i class="fa fa-file-pdf-o" aria-hidden="true"></i> pdf</a> +</p> +<div class="mb-1"> + <a href="javascript:;" data-toggle="toggle" data-target="#abstract-{{ publication.id }}">+ Show abstract</a> + <div id="abstract-{{ publication.id }}" style="display: none;" class="mt-2"> + {{ publication.abstract }} + </div> +</div> diff --git a/journals/urls/general.py b/journals/urls/general.py index 0293ca0430c050edf854f57ed0956195414ce73e..2e774e944a4544ca197f1d39f2ee8bce44f85aa8 100644 --- a/journals/urls/general.py +++ b/journals/urls/general.py @@ -9,6 +9,7 @@ from journals import views as journals_views urlpatterns = [ # Journals url(r'^$', journals_views.journals, name='journals'), + url(r'^publications$', journals_views.PublicationListView.as_view(), name='publications'), url(r'scipost_physics', RedirectView.as_view(url=reverse_lazy('scipost:landing_page', args=['SciPostPhys']))), url(r'^journals_terms_and_conditions$', diff --git a/journals/views.py b/journals/views.py index 5b237c52282bca6040b796f4b9e77dbb098c3b58..81b754f2a9b91dcf943e8d76c3c57b5cc7fd1370 100644 --- a/journals/views.py +++ b/journals/views.py @@ -21,10 +21,11 @@ from django.utils import timezone from django.utils.decorators import method_decorator from django.views.generic.detail import DetailView from django.views.generic.edit import UpdateView +from django.views.generic.list import ListView from django.shortcuts import get_object_or_404, render, redirect from .constants import STATUS_DRAFT -from .helpers import paper_nr_string, issue_doi_label_from_doi_label +from .helpers import issue_doi_label_from_doi_label from .models import Journal, Issue, Publication, Deposit, DOAJDeposit,\ GenericDOIDeposit, PublicationAuthorsTable from .forms import FundingInfoForm,\ @@ -36,11 +37,12 @@ from .utils import JournalUtils from comments.models import Comment from funders.forms import FunderSelectForm, GrantSelectForm -from funders.models import Funder, Grant +from funders.models import Grant from submissions.models import Submission, Report +from scipost.constants import SCIPOST_SUBJECT_AREAS from scipost.forms import ConfirmationForm from scipost.models import Contributor -from scipost.mixins import PermissionsMixin, RequestViewMixin +from scipost.mixins import PermissionsMixin, RequestViewMixin, PaginationMixin from guardian.decorators import permission_required @@ -55,6 +57,28 @@ def journals(request): return render(request, 'journals/journals.html', context) +class PublicationListView(PaginationMixin, ListView): + """ + Show Publications filtered per subject area. + """ + queryset = Publication.objects.published() + paginate_by = 10 + + def get_queryset(self): + qs = super().get_queryset() + if self.request.GET.get('issue'): + qs = qs.filter(in_issue__id=int(self.request.GET['issue'])) + if self.request.GET.get('subject'): + qs = qs.for_subject(self.request.GET['subject']) + return qs.order_by('-publication_date') + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context['recent_issues'] = Issue.objects.published().order_by('-start_date')[:5] + context['subject_areas'] = (('', 'Show all'),) + SCIPOST_SUBJECT_AREAS[0][1] + return context + + def landing_page(request, doi_label): journal = get_object_or_404(Journal, doi_label=doi_label) diff --git a/scipost/static/scipost/assets/config/preconfig.scss b/scipost/static/scipost/assets/config/preconfig.scss index a9b5266ee232496003ad1e192a0c62ba668a0b79..514e26c059cc9ce4ab573e8891a3e0e23886b5d9 100644 --- a/scipost/static/scipost/assets/config/preconfig.scss +++ b/scipost/static/scipost/assets/config/preconfig.scss @@ -132,8 +132,7 @@ $table-cell-padding: 0.25rem 0.5rem; $navbar-light-color: $scipost-darkblue; $navbar-light-hover-color: $scipost-darkblue; $navbar-padding-x: 0.3rem; -$navbar-padding-y: 0.3rem; -// $nav-link-padding-y: 0.4rem; +$navbar-padding-y: 0.35rem; $input-border-radius: 0; $btn-border-radius: $base-border-radius; diff --git a/scipost/static/scipost/assets/css/_general.scss b/scipost/static/scipost/assets/css/_general.scss index 0b926b714fcdba25e55fbc2fd887b16e6cfc7e41..11a06c60383f6bc314ee1668fa4d6e46bfeed46c 100644 --- a/scipost/static/scipost/assets/css/_general.scss +++ b/scipost/static/scipost/assets/css/_general.scss @@ -40,10 +40,6 @@ footer .logos a { padding: 0 0.25rem; } -// body > .container { -// padding-bottom: 1.5rem; -// } - .quote-border { border-left: 3px solid $scipost-lightblue; padding-left: 1rem; diff --git a/scipost/static/scipost/assets/css/_grid.scss b/scipost/static/scipost/assets/css/_grid.scss index d601f5e6428c863f2c20c7618c5e118f66880ea1..11543412524252b7938d312d9abc49c3f0e21cf1 100644 --- a/scipost/static/scipost/assets/css/_grid.scss +++ b/scipost/static/scipost/assets/css/_grid.scss @@ -15,6 +15,18 @@ img { display: none; } +footer { + .social-media a { + padding-left: 0.25rem; + padding-right: 0.25rem; + margin-right: 0.25rem; + + &:hover { + color: $scipost-lightblue; + } + } +} + footer.secondary { color: $scipost-darkblue; background: $white; diff --git a/scipost/static/scipost/assets/css/_homepage.scss b/scipost/static/scipost/assets/css/_homepage.scss index 52cd38d0f81fd4376799cca61a20f16df4d699dd..4c78a17197bfe52a02ca026e2387eea2c48d3f65 100644 --- a/scipost/static/scipost/assets/css/_homepage.scss +++ b/scipost/static/scipost/assets/css/_homepage.scss @@ -29,6 +29,34 @@ margin-bottom: 1rem; } } + + &.sidebar-left { + .main-panel { + order: 2; + } + .sidebar { + order: 1; + } + } +} + +.sidebar { + margin-bottom: 2rem; + + a { + &.active { + font-weight: 700; + } + } +} + +.container.header { + padding-top: 0.5rem; + margin-bottom: 1.5rem; + + .highlight { + background-color: $white; + } } .granting-institutions > a { @@ -65,6 +93,17 @@ width: 350px; padding-right: 0; } + + &.sidebar-left { + .main-panel { + padding-right: 0; + padding-left: 1rem; + } + .sidebar { + padding-right: 1rem; + padding-left: 0; + } + } } } diff --git a/scipost/static/scipost/assets/css/_navbar.scss b/scipost/static/scipost/assets/css/_navbar.scss index 8b32a2115a3afdcae2c6d4f521dbdf295a5c026e..9e32473378b7886c69242bde02468cb9b01691f8 100644 --- a/scipost/static/scipost/assets/css/_navbar.scss +++ b/scipost/static/scipost/assets/css/_navbar.scss @@ -3,12 +3,14 @@ * */ .navbar { - - .nav-item.active a, a:hover { text-decoration: underline; } + .nav-item.active a { + font-weight: 700; + } + .nav-link { color: $white; } @@ -16,9 +18,7 @@ .navbar-nav { flex-direction: row; overflow: auto; - // -ms-overflow-style: none; -webkit-overflow-scrolling: touch; - // overflow: -moz-scrollbars-none; .nav-link { padding-left: .5rem; @@ -28,19 +28,6 @@ } } -// Hide scrollbars... trying to -// ::-webkit-scrollbar, -// ::-webkit-scrollbar-button, -// ::-webkit-scrollbar-track, -// ::-webkit-scrollbar-track-piece, -// ::-webkit-scrollbar-thumb, -// ::-webkit-scrollbar-corner, -// ::-webkit-resizer { -// // display: none; -// background: rgba(0,0,0,0); -// background-color: rgba(0,0,0,0); -// } - .container-outside { &.main-nav { background-color: $scipost-lightblue; diff --git a/scipost/templates/scipost/base_for_sidebar.html b/scipost/templates/scipost/base_for_sidebar.html index 9569677b98e1c6b420dc2e92165e85252b7d626b..7d1e9d6c69adf2cd9b8a81b8c26e1d4c0916cb89 100644 --- a/scipost/templates/scipost/base_for_sidebar.html +++ b/scipost/templates/scipost/base_for_sidebar.html @@ -1,5 +1,7 @@ {% extends 'scipost/bare_base.html' %} +{% block body_class %}{{block.super}} has-sidebar{% endblock %} + {% block base %} <div class="container"> <div class="content-wrapper"> diff --git a/scipost/templates/scipost/footer.html b/scipost/templates/scipost/footer.html index f792aebbd718746f0af4c4081b2c4e0cb3a68c1b..28c00d337967d8383275d31e48bea2162fb31757 100644 --- a/scipost/templates/scipost/footer.html +++ b/scipost/templates/scipost/footer.html @@ -1,7 +1,7 @@ {% load staticfiles %} <footer class="footer"> - <div class="container-fluid py-1"> - <div class="row my-3"> + <div class="container py-4"> + <div class="row mb-0"> <div class="col-md-4 mb-3 mb-md-0"> Copyright © <a href="{% url 'scipost:foundation' %}" target="_">SciPost Foundation</a> @@ -9,20 +9,42 @@ Contact the <a href="mailto:admin@scipost.org">administrators</a> or <a href="mailto:techsupport@scipost.org">tech support</a> <br/> <a href="{% url 'scipost:terms_and_conditions' %}">Terms and conditions</a> - </div> - <div class="col-md-3 mb-3 mb-md-0"> - Follow us:<br/> - <table> + + <table class="mt-2 social-media"> <tr> - <td><a href="//www.facebook.com/scipost" target="_blank" title="Facebook"><img src="{% static 'scipost/images/FB-f-Logo__white_29.png' %}" width="20" alt="Facebook"/></a></td> - <td><a href="//twitter.com/scipost_dot_org" target="_blank" title="Twitter"><img src="{% static 'scipost/images/Twitter_Logo_Blue.png' %}" width="32" alt="Twitter"/></a></td> - <td><a style="float: right;" href="{% url 'scipost:feeds' %}"><img src="{% static 'scipost/images/feed-icon-28x28.png' %}" alt="Feed logo" width="20"></a></td> + <td> + <a href="//www.facebook.com/scipost" target="_blank" title="Facebook"> + <i class="fa fa-facebook" aria-hidden="true"></i> + </a> + </td> + <td> + <a href="//twitter.com/scipost_dot_org" target="_blank" title="Twitter"> + <i class="fa fa-twitter" aria-hidden="true"></i> + </a> + </td> + <td> + <a href="{% url 'scipost:feeds' %}" title="RSS feeds"> + <i class="fa fa-rss" aria-hidden="true"></i> + </a> + </td> </tr> </table> </div> - <div class="col-md-5"> + <div class="col-md-4 mb-3 mb-md-0"> <a rel="license" href="//creativecommons.org/licenses/by/4.0/" target="_blank"><img alt="Creative Commons License" style="border-width:0" src="//i.creativecommons.org/l/by/4.0/80x15.png" /></a><br />Except where otherwise noted, all content on SciPost is licensed under a <a rel="license" href="//creativecommons.org/licenses/by/4.0/" target="_blank">Creative Commons Attribution 4.0 International License</a>. </div> + <div class="col-md-4 mb-3 mb-md-0 text-right"> + <a href="{% url 'journals:journals' %}">Journals</a> + <br> + <a href="{% url 'submissions:submissions' %}">Submissions</a> + <br> + <a href="{% url 'commentaries:commentaries' %}">Commentaries</a> + <br> + <a href="{% url 'theses:theses' %}">Theses</a> + <br> + <a href="{% url 'scipost:about' %}">About SciPost</a> + <br> + </div> </div> </div> </footer> diff --git a/scipost/templates/scipost/index.html b/scipost/templates/scipost/index.html index fb119f746bb9f6ed95963de0b7f1d11d31360e92..838c7c0338496d97e605e5fe3694c7c2505856ce 100644 --- a/scipost/templates/scipost/index.html +++ b/scipost/templates/scipost/index.html @@ -3,7 +3,7 @@ {% load render_bundle from webpack_loader %} {% load staticfiles %} -{% block body_class %}{{block.super}} has-sidebar has-breadcrumb-submenu homepage{% endblock %} +{% block body_class %}{{block.super}} has-breadcrumb-submenu homepage{% endblock %} {% block breadcrumb %} <div class="container-outside sub-nav"> diff --git a/scipost/templates/scipost/layout_2_col.html b/scipost/templates/scipost/layout_2_col.html new file mode 100644 index 0000000000000000000000000000000000000000..fa5547e21b19e21db34474eaa011101c422811b7 --- /dev/null +++ b/scipost/templates/scipost/layout_2_col.html @@ -0,0 +1,47 @@ +{% extends 'scipost/bare_base.html' %} + +{% block body_class %}{{block.super}} has-sidebar layout-2-col{% endblock %} + +{% block breadcrumb %} + <div class="container-outside header"> + <div class="container"> + <nav class="breadcrumb hidden-sm-down"> + {% block breadcrumb_items %} + <a href="{% url 'scipost:index' %}" class="breadcrumb-item">SciPost</a> + {% endblock %} + </nav> + </div> + </div> +{% endblock %} + + +{% block base %} + <div class="container mb-4 header"> + {% block page_header %}{% endblock page_header %} + </div> + + <div class="container"> + <div class="content-wrapper"> + <div class="main-panel"> + <div class="container-inner"> + <div class="{% block container_class %}{% endblock %}"> + {% block content %}{% endblock content %} + + {% block content_footer %}{% endblock content_footer %} + </div> + + {% block secondary_footer %}{% endblock secondary_footer %} + </div> + + </div> + + <div class="sidebar {% block sidebar_class %}{% endblock %}"> + <div class="container-inner"> + {% block sidebar %}{% endblock %} + </div> + </div> + </div> + </div> + {% include 'scipost/footer.html' %} + +{% endblock base %} diff --git a/scipost/templates/scipost/navbar.html b/scipost/templates/scipost/navbar.html index 960f025f7c4c84f59f4254da00694af3e3888133..2ea2260148733e03bedea67e360d526066216c6a 100644 --- a/scipost/templates/scipost/navbar.html +++ b/scipost/templates/scipost/navbar.html @@ -10,8 +10,8 @@ <li class="nav-item{% if request.path == '/' %} active{% endif %}"> <a href="{% url 'scipost:index' %}" class="nav-link">Home</a> </li> - <li class="nav-item{% if '/journals/' in request.path %} active{% endif %}"> - <a href="{% url 'journals:journals' %}" class="nav-link">Journals</a> + <li class="nav-item{% if '/journals/publications' in request.path %} active{% endif %}"> + <a href="{% url 'journals:publications' %}" class="nav-link">Publications</a> </li> <li class="nav-item{% if '/submissions/' in request.path %} active{% endif %}"> <a class="nav-link" href="{% url 'submissions:submissions' %}">Submissions</a> diff --git a/scipost/templatetags/request_filters.py b/scipost/templatetags/request_filters.py index 124ebd9aeae4a9c3852d32ab5bccea0271b8bad5..e5602d93f8426f28e16589e2ebdd3c5660624718 100644 --- a/scipost/templatetags/request_filters.py +++ b/scipost/templatetags/request_filters.py @@ -25,3 +25,9 @@ def active(context, pattern_or_urlname): if re.search(pattern, path): return 'active' return '' + + +@register.simple_tag(takes_context=True) +def active_get_request(context, get_key, get_value): + query = context['request'].GET.dict() + return 'active' if query.get(get_key) == str(get_value) else '' diff --git a/scipost/views.py b/scipost/views.py index bf965b1f1d9323209cfcd6c94e997c279de75d3d..25b9cc0fb79ffe7d02054c02e09b18358c67c612 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -71,10 +71,6 @@ class SearchView(SearchView): ctx = super().get_context_data(*args, **kwargs) ctx['search_query'] = self.request.GET.get('q') ctx['results_count'] = kwargs['object_list'].count() - - # Methods not supported by Whoosh engine - # ctx['stats_results'] = kwargs['object_list'].stats_results() - # ctx['facet_counts'] = kwargs['object_list'].facet('text').facet_counts() return ctx