Skip to content

Commit 673a3ea

Browse files
nrllhmgiffordtunetheweb
authored
Add BibTeX citation box (#1325) (#3718)
* Add BibTeX citation box (#1325) Implemented a citation box in BibTeX format as per the discussion in issue #1325. Details: #1325 * Update page.css Fixing fff issue from linter. * Linting errors * Add DOI * Formatting * Internationalisation --------- Co-authored-by: Mike Gifford <[email protected]> Co-authored-by: Barry Pollard <[email protected]>
1 parent 9029dc6 commit 673a3ea

File tree

15 files changed

+73
-0
lines changed

15 files changed

+73
-0
lines changed

src/static/css/page.css

+13
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@
292292
}
293293

294294
.authors,
295+
.citation-box h2,
295296
.authors h2,
296297
.chapter-links,
297298
.chapter-links h2,
@@ -382,6 +383,18 @@
382383
margin-right: 0.25rem;
383384
}
384385

386+
.citation-box pre {
387+
padding: 16px;
388+
border: 1px solid #e0e0e0;
389+
border-radius: 4px;
390+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
391+
font-family: monospace;
392+
background-color: #f9f9f9;
393+
overflow-x: auto;
394+
white-space: pre-wrap; /* Allow wrapping of long lines */
395+
margin: 0;
396+
}
397+
385398
#chapter-navigation {
386399
padding: 16px 36px 50px 36px;
387400
padding: 1rem 2.25rem 3.125rem 2.25rem;

src/templates/base/base_chapter.html

+34
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,37 @@ <h2 id="authors">
336336
</ul>
337337
{% endmacro %}
338338

339+
{% macro render_bibtex() %}
340+
<h2 id="cite">
341+
<a href="#cite" class="anchor-link">{{ self.citation() }}</a>
342+
</h2>
343+
<details>
344+
<summary>BibTeX</summary>
345+
<pre id="bibtex-citation">
346+
@inbook{WebAlmanac.{{ year }}.{{ metadata.get('title').replace(' ', '') }},
347+
author = "{% for author in metadata.get('authors') -%}
348+
{%- set authordata = config.contributors.get(author, None) -%}
349+
{%- if authordata %}
350+
{%- set full_name = authordata.name.split(' ') -%}
351+
{{ full_name[-1] }}{{ self.comma() }}{{ full_name[0] }}{% if full_name|length > 2 %} {{ full_name[1:-1]|join(' ') }}{% endif %}{% if not loop.last %}{{ self.and() }}{% endif %}
352+
{%- else %}
353+
{%- set full_name = author.split(' ') -%}
354+
{{ full_name[-1] }}{{ self.comma() }}{{ full_name[0] }}{% if full_name|length > 2 %} {{ full_name[1:-1]|join(' ') }}{% endif %}{% if not loop.last %}{{ self.and() }}{% endif %}
355+
{%- endif %}
356+
{%- endfor %}",
357+
title = "{{ metadata.get('title') }}",
358+
booktitle = "{{ self.citation_journal_title() }}",
359+
chapter = {{ chapter_config.chapter_number }},
360+
publisher = "HTTP Archive",
361+
year = "{{ year }}",
362+
language = "{{ language }}",
363+
{%- if metadata.get('doi') %}
364+
doi = "{{ metadata.get('doi')}}",{%- endif %}
365+
url = "https://almanac.httparchive.org/en/{{ year }}/{{ metadata.get('chapter') }}"
366+
}</pre>
367+
</details>
368+
{% endmacro %}
369+
339370
{% macro render_prevnext() %}
340371
{% if prev_chapter %}
341372
{% if chapter_lang_exists(lang, year, prev_chapter['slug']) %}
@@ -442,6 +473,9 @@ <h1 class="title title-lg">
442473
<section class="authors">
443474
{{ render_authors() }}
444475
</section>
476+
<section class="citation-box">
477+
{{ render_bibtex() }}
478+
</section>
445479
<div id="cta-container" class="invisible">
446480
{% if metadata.get('discuss') %}
447481
<a class="alt btn chapter-cta comment-cta discuss-cta hidden" hreflang="en" href="https://discuss.httparchive.org/t/{{ metadata.get('discuss') }}">

src/templates/en/base.html

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
{% macro onLinkedIn(authorName) %}{{authorName}} on LinkedIn{% endmacro %}
119119
{% macro website(authorName) %}{{authorName}} website{% endmacro %}
120120

121+
{% block citation %}Citation{% endblock %}
122+
121123
{% macro edition(year) %}{{ year }} Edition{% endmacro %}
122124

123125
{% block footer_title %}Footer navigation{% endblock %}

src/templates/es/base.html

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
{% macro onLinkedIn(authorName) %}{{authorName}} en LinkedIn{% endmacro %}
119119
{% macro website(authorName) %}{{authorName}} sitio web{% endmacro %}
120120

121+
{% block citation %}Citación{% endblock %}
122+
121123
{% macro edition(year) %}Edición {{ year }}{% endmacro %}
122124

123125
{% block footer_title %}Navegación de pie de página{% endblock %}

src/templates/fr/base.html

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
{% macro onLinkedIn(authorName) %}{{authorName}} sur LinkedIn{% endmacro %}
119119
{% macro website(authorName) %}site web de {{authorName}}{% endmacro %}
120120

121+
{% block citation %}Citation{% endblock %}
122+
121123
{% macro edition(year) %}Édition {{ year }}{% endmacro %}
122124

123125
{% block footer_title %}Navigation dans le pied de page{% endblock %}

src/templates/hi/base.html

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
{% macro onLinkedIn(authorName) %}{{authorName}} LinkedIn पर{% endmacro %}
119119
{% macro website(authorName) %}{{authorName}} वेबसाइट{% endmacro %}
120120

121+
{% block citation %}उद्धरण{% endblock %}
122+
121123
{% macro edition(year) %}{{ year }} संस्करण{% endmacro %}
122124

123125
{% block footer_title %}फुटर नेविगेशन{% endblock %}

src/templates/it/base.html

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
{% macro onLinkedIn(authorName) %}{{authorName}} su LinkedIn{% endmacro %}
119119
{% macro website(authorName) %}{{authorName}} sito web{% endmacro %}
120120

121+
{% block citation %}Citazione{% endblock %}
122+
121123
{% macro edition(year) %}Edizione {{ year }}{% endmacro %}
122124

123125
{% block footer_title %}Navigazione nel footer di pagina{% endblock %}

src/templates/ja/base.html

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
{% macro onLinkedIn(authorName) %}LinkedInの{{authorName}}{% endmacro %}
119119
{% macro website(authorName) %}{{authorName}} ウェブサイト{% endmacro %}
120120

121+
{% block citation %}引用{% endblock %}
122+
121123
{% macro edition(year) %}{{ year }} 版{% endmacro %}
122124

123125
{% block footer_title %}フッターナビゲーション{% endblock %}

src/templates/nl/base.html

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
{% macro onLinkedIn(authorName) %}{{authorName}} op LinkedIn{% endmacro %}
119119
{% macro website(authorName) %}website van {{authorName}} {% endmacro %}
120120

121+
{% block citation %}Citaat{% endblock %}
122+
121123
{% macro edition(year) %}{{ year }} Editie{% endmacro %}
122124

123125
{% block footer_title %}Voettekst navigatie{% endblock %}

src/templates/pt/base.html

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
{% macro onLinkedIn(authorName) %}{{authorName}} no LinkedIn{% endmacro %}
119119
{% macro website(authorName) %}{{authorName}} website{% endmacro %}
120120

121+
{% block citation %}Citaat{% endblock %}
122+
121123
{% macro edition(year) %}{{ year }} Edição{% endmacro %}
122124

123125
{% block footer_title %}Navegação no rodapé{% endblock %}

src/templates/ru/base.html

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
{% macro onLinkedIn(authorName) %}{{authorName}} на LinkedIn{% endmacro %}
119119
{% macro website(authorName) %}Сайт {{authorName}}{% endmacro %}
120120

121+
{% block citation %}Цитата{% endblock %}
122+
121123
{% macro edition(year) %}Издание от {{ year }} года{% endmacro %}
122124

123125
{% block footer_title %}Навигация по футеру{% endblock %}

src/templates/tr/base.html

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
{% macro onLinkedIn(authorName) %}{{authorName}} LinkedIn üzerinde {% endmacro %}
119119
{% macro website(authorName) %}{{authorName}} website{% endmacro %}
120120

121+
{% block citation %}Alıntı{% endblock %}
122+
121123
{% macro edition(year) %}{{ year }} Baskısı{% endmacro %}
122124

123125
{% block footer_title %}Footer navigasyon{% endblock %}

src/templates/uk/base.html

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
{% macro onLinkedIn(authorName) %}{{authorName}} у LinkedIn{% endmacro %}
119119
{% macro website(authorName) %}вебсайт {{authorName}}{% endmacro %}
120120

121+
{% block citation %}Цитування{% endblock %}
122+
121123
{% macro edition(year) %}Видання {{ year }} року{% endmacro %}
122124

123125
{% block footer_title %}Підвальна навігація{% endblock %}

src/templates/zh-CN/base.html

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
{% macro onLinkedIn(authorName) %}{{authorName}} 在 LinkedIn{% endmacro %}
119119
{% macro website(authorName) %}{{authorName}} 网站{% endmacro %}
120120

121+
{% block citation %}引用{% endblock %}
122+
121123
{% macro edition(year) %}{{ year }} 版{% endmacro %}
122124

123125
{% block footer_title %}页脚导航{% endblock %}

src/templates/zh-TW/base.html

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
{% macro onLinkedIn(authorName) %}{{authorName}} LinkedIn{% endmacro %}
119119
{% macro website(authorName) %}{{authorName}} 網站{% endmacro %}
120120

121+
{% block citation %}引文{% endblock %}
122+
121123
{% macro edition(year) %}{{ year }} 版{% endmacro %}
122124

123125
{% block footer_title %}註腳導覽{% endblock %}

0 commit comments

Comments
 (0)