Skip to content

Commit 9d77b2a

Browse files
committed
feat(references): Format references on posts
1 parent 92a9301 commit 9d77b2a

7 files changed

+112
-6
lines changed

_plugins/reference-tag.rb

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
module Jekyll
2+
class ReferenceTag < Liquid::Tag
3+
def initialize(tag_name, markup, tokens)
4+
super
5+
@params = parse_params(markup)
6+
end
7+
8+
def parse_params(markup)
9+
params = {}
10+
markup.scan(/(\w+)\s*=\s*"([^"]*)"/) do |key, value|
11+
params[key] = value
12+
end
13+
params
14+
end
15+
16+
def render(context)
17+
type = @params["type"] || "book"
18+
image = @params["image"] || ""
19+
title = @params["title"] || ""
20+
author = @params["author"] || ""
21+
summary = @params["summary"] || ""
22+
collection = @params["collection"] || ""
23+
publisher = @params["publisher"] || ""
24+
date = @params["date"] || ""
25+
pages = @params["pages"] || ""
26+
format = @params["format"] || ""
27+
language = @params["language"] || ""
28+
isbn = @params["isbn"] || ""
29+
30+
if type == "book"
31+
render_book(image, title, author, collection, publisher, date, pages, format, language, isbn)
32+
elsif type == "author"
33+
render_author(image, title, summary)
34+
else
35+
"<p>Type inconnu</p>"
36+
end
37+
end
38+
39+
def render_book(image, title, author, collection, publisher, date, pages, format, language, isbn)
40+
<<~HTML
41+
<div class="reference">
42+
<img src="#{image}" alt="#{title}" class="reference-image">
43+
<div class="reference-details">
44+
<div class="reference-title"><i>#{title}</i></div>
45+
<p><strong>#{author}</strong></p>
46+
<p><i>#{[collection, publisher].reject(&:empty?).join(", ")}</i></p>
47+
<p>#{[date, ("#{pages} pages" unless pages.empty?), format, language].reject(&:empty?).join(", ")}</p>
48+
<p>#{isbn.empty? ? "" : "ISBN: #{isbn}"}</p>
49+
</div>
50+
</div>
51+
HTML
52+
end
53+
54+
def render_author(image, name, bio)
55+
<<~HTML
56+
<div class="reference">
57+
<img src="#{image}" alt="#{name}" class="reference-image">
58+
<div class="reference-details">
59+
<div class="reference-title">#{name}</div>
60+
<p><i>#{bio}</i></p>
61+
</div>
62+
</div>
63+
HTML
64+
end
65+
end
66+
end
67+
68+
Liquid::Template.register_tag('reference', Jekyll::ReferenceTag)

_posts/2025-01-31-edgar-morin-devops-complexity-thinking.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,6 @@ En appliquant les enseignements d’Edgar Morin sur la pensée complexe, nous po
185185

186186
## *Références*
187187

188-
- **Edgar Morin**, [*Introduction à la pensée complexe*](https://www.editionspoints.com/ouvrage/introduction-a-la-pensee-complexe-edgar-morin/9782757842003){:target="_blank" rel="noopener noreferrer nofollow"}, Éditions **Points**, Collection **Points Essais**, 2014, 160 pages.
189-
- **EAN** : 9782757842003
190-
- **Format** : Broché (Poche)
188+
{% reference type="book" image="/assets/img/introduction-a-la-pensee-complexe-edgar-morin.jpg" title="Introduction à la pensée complexe" author="Edgar Morin" collection="Collection Points Essais" publisher="Éditions Points" date="2014" pages="160" format="Broché (Poche)" isbn="978-2757842003" %}
189+
190+
{% reference type="author" image="/assets/img/edgar-morin.jpg" title="Edgar Morin" summary="Philosophe et sociologue français, né à Paris en 1921 sous le nom d'Edgar Nahoum, dans une famille d'origine juive grecque de Salonique, il prend le pseudonyme de Morin en 1942 en rejoignant la résistance communiste. L'année suivante, il devient commandant des Forces françaises combattantes. Après la guerre, il s’éloigne du Parti communiste et intègre le CNRS en 1950. Directeur de recherche émérite, docteur honoris causa de vingt-sept universités à travers le monde, il est l’auteur d’une œuvre transdisciplinaire abondamment commentée et traduite, dont l’ambitieuse Méthode, en six tomes, publiée au Seuil." %}

_posts/en/2025-01-31-edgar-morin-devops-complexity-thinking.markdown

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ By applying Edgar Morin’s insights on complexity thinking, we can strengthen D
185185

186186
## *References*
187187

188-
- **Edgar Morin**, [*Introduction à la pensée complexe*](https://www.editionspoints.com/ouvrage/introduction-a-la-pensee-complexe-edgar-morin/9782757842003){:target="_blank" rel="noopener noreferrer nofollow"}, **Points** Editions, **Points Essais** Collection, 2014, 160 pages.
189-
- **EAN**: 9782757842003
190-
- **Format**: Paperback (Pocket Edition)
188+
{% reference type="book" image="/assets/img/introduction-a-la-pensee-complexe-edgar-morin.jpg" title="Introduction à la pensée complexe" author="Edgar Morin" collection="Collection Points Essais" publisher="Éditions Points" language="French" date="2014" pages="160" format="Paperback" isbn="978-2757842003" %}
189+
190+
{% reference type="book" image="/assets/img/on-complexity.jpg" title="On Complexity" author="Edgar Morin" publisher="Hampton Press" language="English" format="Paperback" date="2008" pages="127" isbn="978-1572738010" %}
191+
192+
{% reference type="author" image="/assets/img/edgar-morin.jpg" title="Edgar Morin" summary="French philosopher and sociologist, born in Paris in 1921 under the name Edgar Nahoum, into a family of Greek Jewish origin from Salonika. He adopted the pseudonym Morin in 1942 when he joined the communist resistance. The following year, he became a commander of the Fighting French Forces. After the war, he distanced himself from the Communist Party and joined the CNRS in 1950. As an emeritus research director and honorary doctor of twenty-seven universities worldwide, he is the author of a widely commented and translated transdisciplinary work, including the ambitious Method, a six-volume series published by Seuil." %}

_sass/_premonition.scss

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,39 @@ $svg-citation-color: "495057";
269269
}
270270

271271
}
272+
273+
// Reference
274+
.reference {
275+
display: flex;
276+
align-items: flex-start;
277+
gap: 20px;
278+
margin: 20px 0;
279+
color: (--emphasis-color);
280+
background-color: var(--inset-background);
281+
padding: 15px;
282+
border-radius: 10px;
283+
}
284+
285+
.reference-image {
286+
width: 120px;
287+
height: auto;
288+
border-radius: 5px;
289+
object-fit: contain;
290+
margin-top: 5px;
291+
}
292+
293+
.reference-title {
294+
font-size: 1.4em;
295+
font-weight: bold;
296+
margin-bottom: 10px;
297+
}
298+
299+
.reference-details {
300+
flex-grow: 1;
301+
}
302+
303+
.reference-details p {
304+
margin: 4px 0;
305+
line-height: 1.6;
306+
}
307+

assets/img/edgar-morin.jpg

79.9 KB
Loading
52.2 KB
Loading

assets/img/on-complexity.jpg

12.6 KB
Loading

0 commit comments

Comments
 (0)