Skip to content

Commit

Permalink
Add BibTeX citation box (#1325) (#3718)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Nov 10, 2024
1 parent 9029dc6 commit 673a3ea
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/static/css/page.css
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@
}

.authors,
.citation-box h2,
.authors h2,
.chapter-links,
.chapter-links h2,
Expand Down Expand Up @@ -382,6 +383,18 @@
margin-right: 0.25rem;
}

.citation-box pre {
padding: 16px;
border: 1px solid #e0e0e0;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
font-family: monospace;
background-color: #f9f9f9;
overflow-x: auto;
white-space: pre-wrap; /* Allow wrapping of long lines */
margin: 0;
}

#chapter-navigation {
padding: 16px 36px 50px 36px;
padding: 1rem 2.25rem 3.125rem 2.25rem;
Expand Down
34 changes: 34 additions & 0 deletions src/templates/base/base_chapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,37 @@ <h2 id="authors">
</ul>
{% endmacro %}

{% macro render_bibtex() %}
<h2 id="cite">
<a href="#cite" class="anchor-link">{{ self.citation() }}</a>
</h2>
<details>
<summary>BibTeX</summary>
<pre id="bibtex-citation">
@inbook{WebAlmanac.{{ year }}.{{ metadata.get('title').replace(' ', '') }},
author = "{% for author in metadata.get('authors') -%}
{%- set authordata = config.contributors.get(author, None) -%}
{%- if authordata %}
{%- set full_name = authordata.name.split(' ') -%}
{{ 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 %}
{%- else %}
{%- set full_name = author.split(' ') -%}
{{ 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 %}
{%- endif %}
{%- endfor %}",
title = "{{ metadata.get('title') }}",
booktitle = "{{ self.citation_journal_title() }}",
chapter = {{ chapter_config.chapter_number }},
publisher = "HTTP Archive",
year = "{{ year }}",
language = "{{ language }}",
{%- if metadata.get('doi') %}
doi = "{{ metadata.get('doi')}}",{%- endif %}
url = "https://almanac.httparchive.org/en/{{ year }}/{{ metadata.get('chapter') }}"
}</pre>
</details>
{% endmacro %}

{% macro render_prevnext() %}
{% if prev_chapter %}
{% if chapter_lang_exists(lang, year, prev_chapter['slug']) %}
Expand Down Expand Up @@ -442,6 +473,9 @@ <h1 class="title title-lg">
<section class="authors">
{{ render_authors() }}
</section>
<section class="citation-box">
{{ render_bibtex() }}
</section>
<div id="cta-container" class="invisible">
{% if metadata.get('discuss') %}
<a class="alt btn chapter-cta comment-cta discuss-cta hidden" hreflang="en" href="https://discuss.httparchive.org/t/{{ metadata.get('discuss') }}">
Expand Down
2 changes: 2 additions & 0 deletions src/templates/en/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
{% macro onLinkedIn(authorName) %}{{authorName}} on LinkedIn{% endmacro %}
{% macro website(authorName) %}{{authorName}} website{% endmacro %}

{% block citation %}Citation{% endblock %}

{% macro edition(year) %}{{ year }} Edition{% endmacro %}

{% block footer_title %}Footer navigation{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions src/templates/es/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
{% macro onLinkedIn(authorName) %}{{authorName}} en LinkedIn{% endmacro %}
{% macro website(authorName) %}{{authorName}} sitio web{% endmacro %}

{% block citation %}Citación{% endblock %}

{% macro edition(year) %}Edición {{ year }}{% endmacro %}

{% block footer_title %}Navegación de pie de página{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions src/templates/fr/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
{% macro onLinkedIn(authorName) %}{{authorName}} sur LinkedIn{% endmacro %}
{% macro website(authorName) %}site web de {{authorName}}{% endmacro %}

{% block citation %}Citation{% endblock %}

{% macro edition(year) %}Édition {{ year }}{% endmacro %}

{% block footer_title %}Navigation dans le pied de page{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions src/templates/hi/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
{% macro onLinkedIn(authorName) %}{{authorName}} LinkedIn पर{% endmacro %}
{% macro website(authorName) %}{{authorName}} वेबसाइट{% endmacro %}

{% block citation %}उद्धरण{% endblock %}

{% macro edition(year) %}{{ year }} संस्करण{% endmacro %}

{% block footer_title %}फुटर नेविगेशन{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions src/templates/it/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
{% macro onLinkedIn(authorName) %}{{authorName}} su LinkedIn{% endmacro %}
{% macro website(authorName) %}{{authorName}} sito web{% endmacro %}

{% block citation %}Citazione{% endblock %}

{% macro edition(year) %}Edizione {{ year }}{% endmacro %}

{% block footer_title %}Navigazione nel footer di pagina{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions src/templates/ja/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
{% macro onLinkedIn(authorName) %}LinkedInの{{authorName}}{% endmacro %}
{% macro website(authorName) %}{{authorName}} ウェブサイト{% endmacro %}

{% block citation %}引用{% endblock %}

{% macro edition(year) %}{{ year }} 版{% endmacro %}

{% block footer_title %}フッターナビゲーション{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions src/templates/nl/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
{% macro onLinkedIn(authorName) %}{{authorName}} op LinkedIn{% endmacro %}
{% macro website(authorName) %}website van {{authorName}} {% endmacro %}

{% block citation %}Citaat{% endblock %}

{% macro edition(year) %}{{ year }} Editie{% endmacro %}

{% block footer_title %}Voettekst navigatie{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions src/templates/pt/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
{% macro onLinkedIn(authorName) %}{{authorName}} no LinkedIn{% endmacro %}
{% macro website(authorName) %}{{authorName}} website{% endmacro %}

{% block citation %}Citaat{% endblock %}

{% macro edition(year) %}{{ year }} Edição{% endmacro %}

{% block footer_title %}Navegação no rodapé{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions src/templates/ru/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
{% macro onLinkedIn(authorName) %}{{authorName}} на LinkedIn{% endmacro %}
{% macro website(authorName) %}Сайт {{authorName}}{% endmacro %}

{% block citation %}Цитата{% endblock %}

{% macro edition(year) %}Издание от {{ year }} года{% endmacro %}

{% block footer_title %}Навигация по футеру{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions src/templates/tr/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
{% macro onLinkedIn(authorName) %}{{authorName}} LinkedIn üzerinde {% endmacro %}
{% macro website(authorName) %}{{authorName}} website{% endmacro %}

{% block citation %}Alıntı{% endblock %}

{% macro edition(year) %}{{ year }} Baskısı{% endmacro %}

{% block footer_title %}Footer navigasyon{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions src/templates/uk/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
{% macro onLinkedIn(authorName) %}{{authorName}} у LinkedIn{% endmacro %}
{% macro website(authorName) %}вебсайт {{authorName}}{% endmacro %}

{% block citation %}Цитування{% endblock %}

{% macro edition(year) %}Видання {{ year }} року{% endmacro %}

{% block footer_title %}Підвальна навігація{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions src/templates/zh-CN/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
{% macro onLinkedIn(authorName) %}{{authorName}} 在 LinkedIn{% endmacro %}
{% macro website(authorName) %}{{authorName}} 网站{% endmacro %}

{% block citation %}引用{% endblock %}

{% macro edition(year) %}{{ year }} 版{% endmacro %}

{% block footer_title %}页脚导航{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions src/templates/zh-TW/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
{% macro onLinkedIn(authorName) %}{{authorName}} LinkedIn{% endmacro %}
{% macro website(authorName) %}{{authorName}} 網站{% endmacro %}

{% block citation %}引文{% endblock %}

{% macro edition(year) %}{{ year }} 版{% endmacro %}

{% block footer_title %}註腳導覽{% endblock %}
Expand Down

0 comments on commit 673a3ea

Please sign in to comment.