diff --git a/sok/management/commands/stats.py b/sok/management/commands/stats.py index 418f283..b725cd2 100644 --- a/sok/management/commands/stats.py +++ b/sok/management/commands/stats.py @@ -61,7 +61,7 @@ class Command(BaseCommand): self.echo(f"- relevant: {len(publications_relevant):4d}", bold=True) pubs = Publication.objects.values('title').annotate(count=Count('referenced_by')).values('title', 'year', 'count').order_by('count').reverse() - for p in pubs[:15]: print(f"{p['title']} ({p['year']}): {p['count']} citations") + for p in pubs[:50]: print(f"{p['title']} ({p['year']}): {p['count']} citations") years = Publication.objects.values('year').annotate(count=Count('year')).values('year', 'count') for y in years: print(f"{y['year']}, {y['count']}") diff --git a/sok/static/tag/style.css b/sok/static/tag/style.css new file mode 100644 index 0000000..0383601 --- /dev/null +++ b/sok/static/tag/style.css @@ -0,0 +1,3 @@ +li a { + color: green; +} diff --git a/sok/templates/tag/detail.html b/sok/templates/tag/detail.html new file mode 100644 index 0000000..eff046c --- /dev/null +++ b/sok/templates/tag/detail.html @@ -0,0 +1,21 @@ + + + + + Tagging publications + + + {% if publication %} + {% for author in publication.authors.all %} + {{ author.name }}, + {% endfor %} +

{{ publication.title }} ({{ publication.year }})

+ {% if publication.doi %} + + {{ publication.doi }} + {% endif %} + {% else %} +

No publications are available.

+ {% endif %} + + diff --git a/sok/templates/tag/index.html b/sok/templates/tag/index.html new file mode 100644 index 0000000..0c9a487 --- /dev/null +++ b/sok/templates/tag/index.html @@ -0,0 +1,21 @@ + +{% load static %} + + + + + + List for tagging publications + + + {% if newest_publications %} + + {% else %} +

No publications are available.

+ {% endif %} + + diff --git a/sok/urls.py b/sok/urls.py new file mode 100644 index 0000000..970f039 --- /dev/null +++ b/sok/urls.py @@ -0,0 +1,8 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path("", views.IndexView.as_view(), name="index"), + path("", views.detail, name="detail"), +] diff --git a/sok/views.py b/sok/views.py index 91ea44a..f32ea01 100644 --- a/sok/views.py +++ b/sok/views.py @@ -1,3 +1,31 @@ -from django.shortcuts import render +from django.db.models import F +from django.http import HttpResponseRedirect +from django.shortcuts import get_object_or_404, render +from django.urls import reverse +from django.views import generic + +from sok.models import Publication, PublicationReference + + +class IndexView(generic.ListView): + template_name = "tag/index.html" + context_object_name = "newest_publications" + + def get_queryset(self): + return Publication.objects.order_by("-year")[:10] + +def detail(request, cite_key): + try: + publication = get_object_or_404(Publication, cite_key=cite_key.strip('/')) + except Publication.DoesNotExist: + raise Http404("Publication does not exist") + return render(request, "tag/detail.html", {"publication": publication}) + + +# def overview(request): +# try: +# ps = Publication.objects.get(...) +# except Publication.DoesNotExist: +# raise Http404("Publication does not exist") +# return render(request, "publications/overview.html", {"to_tag": ps}) -# Create your views here. diff --git a/sokman/urls.py b/sokman/urls.py index aa2118c..147e406 100644 --- a/sokman/urls.py +++ b/sokman/urls.py @@ -14,8 +14,9 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), + path('tag/', include('sok.urls')), ]