From 26da2cb67e58d4ca6e37b7cc3aa315f2c918cf3e Mon Sep 17 00:00:00 2001 From: "p.fherrma" Date: Sun, 24 May 2020 13:22:03 +0200 Subject: [PATCH 1/2] fix(pdf): pretty styling for generated dataset PDF --- .../templates/dddatasets/pdf_dataset.html | 76 ++++++++----- .../dddatasets/pdf_datasets_styles.css | 106 ++++++++++++++++++ 2 files changed, 153 insertions(+), 29 deletions(-) create mode 100644 discuss_data/templates/dddatasets/pdf_datasets_styles.css diff --git a/discuss_data/templates/dddatasets/pdf_dataset.html b/discuss_data/templates/dddatasets/pdf_dataset.html index 6cb8744..4204567 100644 --- a/discuss_data/templates/dddatasets/pdf_dataset.html +++ b/discuss_data/templates/dddatasets/pdf_dataset.html @@ -1,38 +1,35 @@ -{% load static %} - - +{% load static i18n compress%} - - - - - + Discuss-Data.net: {{ ds.get_fulltitle }} + - - -
-
-
-
-
-
-

{{ ds.get_fulltitle }}, {{ ds.version }}

- {{ ds.get_absolute_url }}
-
+ +
+ + Open Platform for the Interactive Discussion of Research Data Quality (on the example of area studies on the post-Soviet region) +
+
+
+

{{ ds.title }}

+

{{ ds.subtitle }}

+

Version {{ ds.version }}, {% trans "Dataset created by" %} {{ ds.creators }}

+ {{ ds.get_absolute_url }}
-

Data Citation

+

{% trans "Data Citation" %}

{{ ds.get_data_citation }}

-

Description

+

{% trans "Description" %}

{{ ds.description }}

-

Files

+

{% trans "Files" %}

    {% for elem in ds.get_datafiles %}
  • {{ elem }} ({{ elem.get_data_file_type_display }})
  • @@ -40,7 +37,7 @@
-

Metadata

+

{% trans "Metadata" %}

{% comment %} @@ -48,8 +45,8 @@ {% endcomment %} - - + + @@ -128,10 +125,6 @@ - - - - @@ -154,6 +147,31 @@
FieldContent
Title: {{ ds.title }}Title: {{ ds.title }}
Subtitle: Related datasets (text): {{ ds.related_dataset_text }}
Related Publications:{% for elem in ds.publications.all %}{{ elem }}{% if not forloop.last %}, {% endif %}{% endfor %}
Institutional Affiliation: {{ ds.institutional_affiliation }}
+ +

{% trans "Version History" %}

+
    + {% for elem in ds.get_published_versions %} +
  • {{ elem }}
  • + {% endfor %} +
+ +

{% trans "Publications" %}

+ {% if ds.get_dataset_publications %} +
    + {% for dspub in ds.get_dataset_publications %} +
  • + {{ dspub.publication.citation }}{% if dspub.publication.url %}, {{ dspub.publication.url }}{% endif %} ({{ dspub.get_pub_type_display }}) +
  • + {% endfor %} +
+ {% else %} +

{% trans "No publications were added to this Dataset." %}

+ {% endif %} + +

{% trans "Data License" %}

+

{{ ds.license.get_license_title }} ({{ ds.license.get_license_type_display }})

+ {{ ds.license.get_license_text }} +
diff --git a/discuss_data/templates/dddatasets/pdf_datasets_styles.css b/discuss_data/templates/dddatasets/pdf_datasets_styles.css new file mode 100644 index 0000000..e5ce16e --- /dev/null +++ b/discuss_data/templates/dddatasets/pdf_datasets_styles.css @@ -0,0 +1,106 @@ +@page { + /*margin: 3cm 2cm; padding-left: 1.5cm;*/ + /* + @top-center { + content: "Introduction to CSS 2.1"; + vertical-align: bottom; + border-bottom: 0.5pt solid } + */ + + @bottom-center { + content: "{{ ds.title }} v{{ ds.version}}, Page " counter(page) "/" counter(pages) + } + font-family: sans-serif; + font-size: x-small; + /* + @left-top { + content: "W3C Recommendation"; + background: #005a9c; + color: #fff; + text-align: right; + transform-origin: 100% 0; + transform: rotate(-90deg) + } + */ + +} + +@media print { + a[href]:after { + content: none !important; + } + + #metadata { + page-break-before: always; + } + +} + +body { + font-family: sans-serif; + font-size: medium; +} + +header { + position: fixed; + top: 0; + left: 0; + height: 2.5cm; + width: 100%; + border-bottom: 1px solid black; + +} + +.pdf-logo +{ + float: left; + width: auto; + height: 1.3cm; + padding-right: 3cm; +} + +.pdf-header { + text-align: justify; +} + +table { + width: 100%; + border-collapse: collapse; + table-layout: fixed; +} + +th, +td { + padding: 5px; + /*background-color: rgba(255,255,255,0.2); + color: #fff;*/ + + + +} + +th { + text-align: left; +} + +tr:nth-of-type(odd) { + background: #EEEEEE; +} + +.row-field { + width: 35%; +} + +.row-value { + width: 65%; +} + +.list-unstyled { + list-style: none; + margin-left: 0; + padding-left: 0; +} + +.list-unstyled li { + padding-bottom: .3cm; +} \ No newline at end of file -- GitLab From 4124bcde9e9a0030247a4e844758b94d4c0e2dc9 Mon Sep 17 00:00:00 2001 From: "p.fherrma" Date: Sun, 24 May 2020 13:31:23 +0200 Subject: [PATCH 2/2] fix(pdf): replace
tag with css border definition --- discuss_data/templates/dddatasets/pdf_dataset.html | 1 - discuss_data/templates/dddatasets/pdf_datasets_styles.css | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/discuss_data/templates/dddatasets/pdf_dataset.html b/discuss_data/templates/dddatasets/pdf_dataset.html index 4204567..aa9d106 100644 --- a/discuss_data/templates/dddatasets/pdf_dataset.html +++ b/discuss_data/templates/dddatasets/pdf_dataset.html @@ -15,7 +15,6 @@ Open Platform for the Interactive Discussion of Research Data Quality (on the example of area studies on the post-Soviet region)
-

{{ ds.title }}

{{ ds.subtitle }}

diff --git a/discuss_data/templates/dddatasets/pdf_datasets_styles.css b/discuss_data/templates/dddatasets/pdf_datasets_styles.css index e5ce16e..53f0553 100644 --- a/discuss_data/templates/dddatasets/pdf_datasets_styles.css +++ b/discuss_data/templates/dddatasets/pdf_datasets_styles.css @@ -56,11 +56,13 @@ header { float: left; width: auto; height: 1.3cm; - padding-right: 3cm; + padding-right: 2.8cm; } .pdf-header { text-align: justify; + border-bottom: 1px solid black; + padding-bottom: .5cm; } table { -- GitLab