single.html 9.1 KB
Newer Older
1
2
{{ define "main" }}

3
{{ $articles := slice }}
4
{{ range $index, $article := $.Site.Data.c19dpes_literature.publications }}
5
6
  {{ $articles = $articles | append $article}}
{{ end }}
7
8

<main class="container">
9
  <h1>{{ .Title }}</h1>
10
11
  <article>{{ .Content }}</article>
  <div class="d-flex">
12
    {{ partial "last-update.html" (dict "context" . "last_update" (substr $.Site.Data.c19dpes_literature.timestamp 0 10)) }}
13
  </div>
14
15
  <div id="loading">
    <div class="d-flex justify-content-center">
16
      <div class="spinner-grow dp-background-color--primary" style="width: 10rem; height: 10rem;" role="status">
17
        <span class="sr-only">{{ i18n "loading" }}</span>
18
19
20
      </div>
    </div>
  </div>
21
22
23
24
25
26
  <div id="table-wrapper" class="row d-none">
    <section class="col-md-2">
      <h5>{{ i18n "funder" }}</h5>
      <div class="mb-2 ml-3 form-check">
        <div class="row">
          <input type="checkbox" class="form-check-input" name="funder" value="fondo-covid">
27
          <span>Fondo COVID19</span>
28
        </div>
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
      </div>
      <h5 class="mt-4">{{ i18n "type" }}</h5>
      <div class="mb-2 ml-3 form-check">
        <div class="row">
          <input type="checkbox" class="form-check-input" name="publication_type" value="article">
          <span>{{ i18n "articles" }}</span>
        </div>
        <div class="row">
          <input type="checkbox" class="form-check-input" name="publication_type" value="preprint">
          <span>{{ i18n "preprints" }}</span>
        </div>
      </div>
      <h5 class="mt-4">{{ i18n "availability_of" }}</h5>
      <div class="mb-2 ml-3 form-check">
        <div class="row">
          <input type="checkbox" class="form-check-input" name="abstract_available" value="abstract-available">
          <span>{{ i18n "abstract" }}</span>
        </div>
        <div class="row">
          <input type="checkbox" class="form-check-input" name="data_available" value="data-available">
          <span>{{ i18n "related_data" }}</span>
        </div>
      </div>
      <h5 class="mt-4">{{ i18n "year" }}</h5>
      <div class="mb-2 ml-3 form-check">
        <div class="row">
          <input type="checkbox" class="form-check-input" name="year" value="2020">
          <span>2020</span>
        </div>
        <div class="row">
          <input type="checkbox" class="form-check-input" name="year" value="2021">
          <span>2021</span>
        </div>
      </div>
    </section>
64
    <section class="col-md-10">
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
      <div class="container-fluid">
        <div class="row mb-2" id="actions">
          <div class="ml-auto">{{ partial "europepmc.html" }}</div>
        </div>
      </div>
      <table id="literature-table" class="table w-100">
        <thead class="thead-light">
          <tr>
            <th scope="col">{{ i18n "publication" }}</th>
            <th scope="col">{{ i18n "published"}}</th>

            <!-- This columns are not visible by DataTables but they are necessary for filtering and CSV downloading -->
            <th scope="col">{{ i18n "year" }}</th>
            <th scope="col">{{ i18n "funder" }}</th>
            <th scope="col">{{ i18n "publication_type" }}</th>
            <th scope="col">{{ i18n "available_abstract" }}</th>
            <th scope="col">{{ i18n "available_related_data" }}</th>
            <th scope="col">{{ i18n "doi" }}</th>
            <th scope="col">{{ i18n "title" }}</th>
            <th scope="col">{{ i18n "authors" }}</th>
            <th scope="col">{{ i18n "journal" }}</th>
          </tr>
        </thead>
        <tbody>
          {{ range $index, $article := $articles }}
          <tr>

            <!-- Mega column -->
            <td>

              <!-- Title with link to its DOI -->
              <a target="_blank" href="https://doi.org/{{ .doi }}"><b>{{ safeHTML .title }}</b></a>

              <!-- Authors comma-separated list -->
              <br>
              <span class="text-muted">
                {{ with .authors }}
                  {{ if gt (len .) 4}}
                    {{ range first 4 . }}
                      {{ . }},
                    {{ end }}
                  {{ range last 1 . }}
                    [...], {{ . }}
                  {{ end }}
                  {{ else }}
                    {{ $n := sub (len .) 1}}
                    {{ range first $n . }}
                      {{ . }},
113
                    {{ end }}
114
115
                    {{ range last 1 . }}
                      {{ . }}
116
                    {{ end }}
117
118
                  {{ end }}
                {{ end }}
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
              </span>

              <!-- Citation with preprint indicator (if this publication is a preprint) -->
              <br>
              {{ if eq .type "preprint"}}<span class="badge badge-secondary">preprint</span>&nbsp;{{ end }}
              <i>{{ .citation }}</i>

              <!-- DOI -->
              <br>
              <span>DOI: {{ .doi }}</span>

              <!-- Abstract and/or related data availability indicators (if this publication has available abstract and/or related data) -->
              {{ if or .abstract .available_data }}
              <div class="row">
                <div class="col">
                  {{ if .abstract }}
135
                  <a class="btn btn-primary btn-link badge badge-primary" data-toggle="collapse" href="#abstract{{ $index }}" role="button" aria-expanded="false" aria-controls="abstract{{ $index }}">
136
137
138
139
140
141
142
                    {{ i18n "abstract" }} <i class="bi bi-caret-down-fill"></i>
                  </a>
                  <div class="collapse" id="abstract{{ $index }}">
                    <div class="card card-body">{{ safeHTML .abstract }}</div>
                  </div>
                  {{ end }}
                  {{ if .available_data }}
143
                  <a class="btn btn-primary btn-link badge badge-success" data-toggle="collapse" href="#data{{ $index }}" role="button" aria-expanded="false" aria-controls="abstract{{ $index }}">
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
                    {{ i18n "related_data" }} <i class="bi bi-caret-down-fill"></i>
                  </a>
                  <div class="collapse list-group" id="data{{ $index }}">
                  {{ range .available_data }}
                  <a target="_blank" href="{{ .link }}" class="list-group-item list-group-item-action dp-list-group-item">
                    {{ .label }} <i class="bi bi-box-arrow-up-right"></i>
                  </a>
                  {{ end }}
                  </div>
                  {{ end }}
                </div>
              </div>
              {{ end }}
            </td>
            <td>{{ .publication_date }}</td>

            <!-- This columns are not visible by DataTables but they are necessary for filtering and CSV downloading -->
            <td>{{ slicestr .publication_date 0 4 }}</td>
            <td>{{ .funder }}</td>
            <td>{{ .type }}</td>
            <td>{{ if .abstract }}abstract-available{{ end }}</td>
            <td>{{ if .available_data }}data-available{{ end }}</td>
            <td>{{ .doi }}</td>
            <td>{{ .title }}</td>
            <td>{{ delimit .authors ", " }}</td>
            <td>{{ .citation }}</td>
          </tr>
          {{ end }}
        </tbody>
      </table>
    </section>
175
176
177
  </div>
</main>

178
<script src="/js/dp-table-filters.js"></script>
179
180
<script>
  $(document).ready(() => {
181
    const table = $('#literature-table').DataTable({
182
183
      dom: `
        <".container-fluid"
184
          <".row my-2"
185
            <".mr-auto"i>
186
            <"#search.mr-2"f>
187
188
189
190
191
192
193
194
          >
          <".row"t>
          <".row"
            <".mr-auto"l>
            <".ml-auto"p>
          >
        >
      `,
195
      buttons: [
196
197
198
        {
          extend: 'csv',
          text: 'Download as CSV',
199
          titleAttr: 'Download table in comma-separated-values format',
200
          className: 'btn btn-primary',
201
202
203
          exportOptions: {
            columns: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ],
          },
204
        },
205
      ],
206
207
208
209
      processing: true,
      order: [[1, 'desc']],
      columnDefs: [

210
211
        // Hide columns that are present for filtering and for downloading the table as usable CSV.
        { visible: false, targets: [2, 3, 4, 5, 6, 7, 8, 9, 10] },
212
213
214
215
216

        // Remove ordering for first mega-column (sorting alphabetically by title makes no sense).
        { orderable: false, targets: 0 },
      ],
      initComplete: () => {
217
218
219
        document.querySelector('#loading').classList.add('d-none');
        document.querySelector('#table-wrapper').classList.remove('d-none');
      },
220
    });
221

222
    // When used with Bootstrap, datatables buttons must be appended to DOM to make them visible.
223
    table.buttons().container().appendTo('#actions');
224

225
    // Move datatable buttons next to filter search box.
226
227
228
    const downloadButtonGroup = document.querySelector('.dt-buttons');
    downloadButtonGroup.classList.remove('btn-group', 'flex-wrap');
    downloadButtonGroup.classList.add('d-flex');
229
    const search = document.querySelector('#search');
230
    search.insertAdjacentElement('afterend', downloadButtonGroup);
231

232
233
    // Define column indices and apply checkbox filters.
    const columnIndices = {
234
235
236
237
238
      year: 2,
      funder: 3,
      publication_type: 4,
      abstract_available: 5,
      data_available: 6,
239
240
    };
    applyFilters(table, columnIndices);
241
242
243
244
  });
</script>

{{ end }}