Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat(webmentions): add webmentions support templates #485

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
84f3301
✨ feat(webmentions): add webmentions support templates
gortavoher Feb 10, 2025
cab76ee
✨ feat(config): add webmention support
gortavoher Feb 11, 2025
b930658
✨ feat(webmention): add webmention.js for embedding webmentions
gortavoher Feb 11, 2025
426a50f
✨ feat(styles): add webmention styling
gortavoher Feb 11, 2025
3247305
💄 style(header): improve formatting for theme scripts
gortavoher Feb 11, 2025
e9cfbdc
✨ feat(shortcodes): add webmentions section
gortavoher Feb 11, 2025
f2d13b9
📝 docs(blog): add webmentions section to mastering tabi settings
gortavoher Feb 11, 2025
ee88359
💄 style(blog): remove trailing space in markdown text
gortavoher Feb 11, 2025
30819dd
💄 style(sass): enhance webmention styling with variables
gortavoher Feb 11, 2025
6c6996b
Merge github.com:jerusdp/tabi into webmentions
gortavoher Feb 11, 2025
51f3684
📝 docs(blog): remove duplicate updated date in blog metadata
gortavoher Feb 11, 2025
74ca55d
Merge pull request #1 from jerusdp/webmentions
gortavoher Feb 11, 2025
1509eff
Update theme.toml
jerusdp Feb 11, 2025
4f6b641
💄 style(theme): comment out page_url setting
gortavoher Feb 11, 2025
a663de6
✨ feat(csp): add webmention support to content security policy
gortavoher Feb 12, 2025
afbf2aa
🐛 fix(config): update webmentions configuration
gortavoher Feb 12, 2025
2bc1f64
📝 docs(blog): update webmentions configuration details
gortavoher Feb 12, 2025
e83cef7
🐛 fix(blog): correct webmention config typo
gortavoher Feb 12, 2025
9ee3f7c
Merge branch 'main' into webmentions
gortavoher Feb 12, 2025
79ed74b
Merge pull request #2 from jerusdp/webmentions
gortavoher Feb 12, 2025
f18207b
📝 docs(config): fix typo in config documentation
gortavoher Feb 13, 2025
108dfcd
🔧 chore(config): update page_url in config.toml
gortavoher Feb 20, 2025
c903689
✨ feat(blog): add webmention images and section enhancements
gortavoher Feb 20, 2025
e19725b
📝 docs(shortcodes): add example for webmentions section
gortavoher Feb 20, 2025
ba4d3b8
🌐 i18n(html): add microformats2 classes for semantic markup
gortavoher Feb 20, 2025
cf59175
Merge pull request #3 from jerusdp/webmentions
jerusdp Feb 20, 2025
89ebc6d
Merge branch 'main' of github.com:welpo/tabi
gortavoher Feb 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ include_content = true
# At which character to truncate the content to. Useful if you have a lot of pages and the index would
# become too big to load on the site. Defaults to not being set.
# truncate_content_length = 100
# Wether to produce the search index as a javascript file or as a JSON file.
# Whether to produce the search index as a javascript file or as a JSON file.
# Accepted value "elasticlunr_javascript" or "elasticlunr_json".
index_format = "elasticlunr_json"

Expand Down Expand Up @@ -372,6 +372,47 @@ service = "goatcounter"
# Leave this field empty if you're using the service's default hosting.
self_hosted_url = "https://tabi-stats.osc.garden"

[extra.webmentions]
enabled = true
# Specify the domain registered with webmention.io.
domain = "www.example.com"

# The HTML ID for the object to fill in with the webmention data.
# Defaults to "webmentions"
# id = "webmentions"

# data configuration for the webmention.min.js script
# The base URL to use for this page. Defaults to window.location
page_url = "https://www.jrussell.ie/blog/update-and-release/10-update-and-release/"

# Additional URLs to check, separated by |s
# add_urls

# The maximum number of words to render in reply mentions.
wordcount = 20

# The maximum number of mentions to retrieve. Defaults to 30.
# max_webmentions

# By default, Webmentions render using the mf2 'url' element, which plays
# nicely with webmention bridges (such as brid.gy and telegraph)
# but allows certain spoofing attacks. If you would like to prevent
# spoofing, set this to a non-empty string (e.g. "true").
# prevent_spoofing

# What to order the responses by; defaults to 'published'. See
# https://github.com/aaronpk/webmention.io#api
# sort_by

# The order to sort the responses by; defaults to 'up' (i.e. oldest
# first). See https://github.com/aaronpk/webmention.io#api
# sort_dir

# If set to a non-empty string (e.g. "true"), will display comment-type responses
# (replies/mentions/etc.) as being part of the reactions
# (favorites/bookmarks/etc.) instead of in a separate comment list.
# comments_are_reactions = "true"

# giscus support for comments. https://giscus.app
# Setup instructions: https://welpo.github.io/tabi/blog/comments/#setup
[extra.giscus]
Expand Down
2 changes: 1 addition & 1 deletion content/blog/javascript/index.ca.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Sense JavaScript obligatori"
date = 2023-01-06
updated = 2025-02-15
updated = 2025-02-21
description = "JavaScript només s'utilitza quan HTML i CSS no són suficients."

[taxonomies]
Expand Down
2 changes: 1 addition & 1 deletion content/blog/javascript/index.es.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Sin JavaScript obligatorio"
date = 2023-01-06
updated = 2025-02-15
updated = 2025-02-21
description = "JavaScript solo se utiliza cuando HTML y CSS no son suficientes."

[taxonomies]
Expand Down
2 changes: 1 addition & 1 deletion content/blog/javascript/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "No mandatory JavaScript"
date = 2023-01-06
updated = 2025-02-15
updated = 2025-02-21
description = "JavaScript is only used when HTML and CSS aren't enough."

[taxonomies]
Expand Down
2 changes: 1 addition & 1 deletion content/blog/markdown/index.ca.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Exemples de Markdown"
date = 2023-01-31
updated = 2024-11-23
updated = 2025-02-21
description = "Aquesta publicació mostra alguns exemples de format en Markdown, incloent-hi una taula, blocs de codi i etiquetes, citacions, taules i notes a peu de pàgina."

[taxonomies]
Expand Down
2 changes: 1 addition & 1 deletion content/blog/markdown/index.es.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Ejemplos de Markdown"
date = 2023-01-31
updated = 2024-11-23
updated = 2025-02-21
description = "Esta publicación muestra algunos ejemplos de formato Markdown, incluyendo una tabla, bloques de código y etiquetas, citas, tablas y notas al pie de página."

[taxonomies]
Expand Down
2 changes: 1 addition & 1 deletion content/blog/markdown/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Markdown examples"
date = 2023-01-31
updated = 2024-11-23
updated = 2025-02-21
description = "This post showcases some examples of Markdown formatting, including a table, code blocks and tags, quotes, tables, and footnotes."

[taxonomies]
Expand Down
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion content/blog/mastering-tabi-settings/index.ca.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Domina la configuració de tabi: guia completa"
date = 2023-09-18
updated = 2025-02-16
updated = 2025-02-21
description = "Descobreix les múltiples maneres en què pots personalitzar tabi."

[taxonomies]
Expand Down
2 changes: 1 addition & 1 deletion content/blog/mastering-tabi-settings/index.es.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Domina la configuración de tabi: guía completa"
date = 2023-09-18
updated = 2025-02-16
updated = 2025-02-21
description = "Descubre las múltiples maneras en que puedes personalizar tabi."

[taxonomies]
Expand Down
32 changes: 30 additions & 2 deletions content/blog/mastering-tabi-settings/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Mastering tabi Settings: A Comprehensive Guide"
date = 2023-09-18
updated = 2025-02-16
updated = 2025-02-21
description = "Discover the many ways you can customise your tabi site."

[taxonomies]
Expand Down Expand Up @@ -113,7 +113,7 @@ The description is regular Markdown content, set outside the front matter.

#### Listing Recent Posts

To show posts on your main page, you first need to decide where these posts will be served from: the root path (`/`) or a subdirectory (e.g., `/blog`).
To show posts on your main page, you first need to decide where these posts will be served from: the root path (`/`) or a subdirectory (e.g., `/blog`).

**Option A: Serve posts from the root path (`/`)**

Expand Down Expand Up @@ -789,6 +789,34 @@ If you have enabled a system globally, but want to disable it on a specific page

Read [the docs](@/blog/comments/index.md) for more information on the available systems and their setup.

### Webmentions {#adding-webmentions}

As described by the recommended W3C standard [Webmention][1] is a simple way to notify any URL when you mention it on your site. From the receiver's perspective, it's a way to request notifications when other sites mention it.

For static sites [webmention.io][2] hosts a webmention endpoint that can be used to receive webmentions. This feature fetches the webmentions stored at webmention.io and displays them for a page. You will need to have setup an account for your website at webmention.io. When you enable the webmention feature it will advertise your webmention.io endpoint and display the webmentions for any post using the webmention shortcut.

Enable webmentions for your site by adding the following to your `config.toml` file.

```
[extra.webmentions]
enable = true
# Specify the domain registered with webmention.io.
domain = "www.example.com"
```

Add the shortcut on the page where you want to display the webmentions:

```
{{/* webmentions() */}}
```

The webmentions section will then be displayed where you added it on the page as follows:

{{ dual_theme_image(light_src="blog/mastering-tabi-settings/img/webmention_light.webp", dark_src="blog/mastering-tabi-settings/img/webmention_dark.webp" alt="Page footer, showing a 'Site source' link") }}

[1]: https://www.w3.org/TR/webmention/#abstract-p-1
[2]: https://webmention.io/

### Analytics

| Page | Section | `config.toml` | Follows Hierarchy | Requires JavaScript |
Expand Down
2 changes: 1 addition & 1 deletion content/blog/security/index.ca.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Seguretat per defecte"
date = 2023-02-22
updated = 2024-08-28
updated = 2025-02-21
description = "tabi té una Política de Seguretat de Contingut (CSP) fàcilment personalitzable amb valors segurs per defecte. Obtingues tranquil·litat i un A+ en l'Observatori de Mozilla."

[taxonomies]
Expand Down
2 changes: 1 addition & 1 deletion content/blog/security/index.es.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Seguro por defecto"
date = 2023-02-22
updated = 2024-08-28
updated = 2025-02-21
description = "tabi tiene una Política de Seguridad de Contenido (CSP) fácilmente personalizable con configuraciones seguras. Obtén tranquilidad y una calificación de A+ en Mozilla Observatory."

[taxonomies]
Expand Down
2 changes: 1 addition & 1 deletion content/blog/security/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Secure by default"
date = 2023-02-22
updated = 2024-08-28
updated = 2025-02-21
description = "tabi has an easily customizable Content Security Policy (CSP) with safe defaults. Get peace of mind and an A+ on Mozilla Observatory."

[taxonomies]
Expand Down
2 changes: 1 addition & 1 deletion content/blog/series/index.ca.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Guia completa sobre sèries"
date = 2024-11-08
updated = 2025-02-15
updated = 2025-02-21
description = "Aprèn a organitzar les teves publicacions en sèries seqüencials, perfectes per a tutorials, cursos i històries de diverses parts."

[taxonomies]
Expand Down
2 changes: 1 addition & 1 deletion content/blog/series/index.es.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Guía completa sobre series"
date = 2024-11-08
updated = 2025-02-15
updated = 2025-02-21
description = "Aprende a organizar tus publicaciones en series secuenciales, perfectas para tutoriales, cursos e historias de varias partes."

[taxonomies]
Expand Down
2 changes: 1 addition & 1 deletion content/blog/series/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "A Complete Guide to Series"
date = 2024-11-08
updated = 2025-02-15
updated = 2025-02-21
description = "Learn how to organize your posts into sequential series, perfect for tutorials, courses, and multi-part stories."

[taxonomies]
Expand Down
2 changes: 1 addition & 1 deletion content/blog/shortcodes/index.ca.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Shortcodes personalitzats"
date = 2023-02-19
updated = 2025-02-15
updated = 2025-02-21
description = "Aquest tema inclou alguns shortcodes personalitzats útils que pots utilitzar per millorar les teves publicacions. Ja sigui per mostrar imatges que s'adapten als temes clar i fosc, o per donar format a una secció de referències amb un aspecte professional, aquests shortcodes personalitzats t'ajudaran."

[taxonomies]
Expand Down
2 changes: 1 addition & 1 deletion content/blog/shortcodes/index.es.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Shortcodes personalizados"
date = 2023-02-19
updated = 2025-02-15
updated = 2025-02-21
description = "Este tema incluye algunos shortcodes personalizados útiles que puedes utilizar para mejorar tus publicaciones. Puedes mostrar imágenes que se adapten a los temas claro y oscuro, dar formato a una sección de referencias con un aspecto profesional, y más."

[taxonomies]
Expand Down
63 changes: 50 additions & 13 deletions content/blog/shortcodes/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Custom shortcodes"
date = 2023-02-19
updated = 2025-02-15
updated = 2025-02-21
description = "This theme includes some useful custom shortcodes that you can use to enhance your posts. Whether you want to display images that adapt to light and dark themes, or format a professional-looking reference section, these custom shortcodes have got you covered."

[taxonomies]
Expand Down Expand Up @@ -79,9 +79,9 @@ classDiagram
+MakeAssumptions()
}
CognitiveDistortions *-- AllOrNothingThinking
CognitiveDistortions *-- Overgeneralization
CognitiveDistortions*-- Overgeneralization
CognitiveDistortions *-- MentalFilter
CognitiveDistortions *-- JumpingToConclusions
CognitiveDistortions*-- JumpingToConclusions
{% end %}

The Mermaid shortcode supports two parameters:
Expand Down Expand Up @@ -121,6 +121,7 @@ Useful if you want to use a different image for the light and dark themes:
{{ dual_theme_image(light_src="img/paris_day.webp", dark_src="img/paris_night.webp" alt="The Eiffel tower") }}

#### Usage

```
{{/* dual_theme_image(light_src="img/paris_day.webp", dark_src="img/paris_night.webp" alt="The Eiffel tower") */}}
```
Expand Down Expand Up @@ -151,7 +152,7 @@ Images with too much brightness or contrast can be jarring against a dark backgr

### Swap image on hover

Povides an interaction where the image displayed changes as the user hovers over it. Useful for before-after comparisons, for example.
Provides an interaction where the image displayed changes as the user hovers over it. Useful for before-after comparisons, for example.

{{ image_hover(default_src="img/edited.webp", hovered_src="img/raw.webp", default_alt="Edited picture", hovered_alt="Original shot") }}

Expand Down Expand Up @@ -312,19 +313,19 @@ Display lines 3 to 7 (both inclusive) of a local file:

Bring attention to information with these admonition shortcodes. They come in five `type`s: `note`, `tip`, `info`, `warning`, and `danger`.

{{ admonition(type="note", text="Some **content** with _Markdown_ `syntax`. Check [this `api`](#).") }}
{{ admonition(type="note", text="Some **content** with *Markdown* `syntax`. Check [this `api`](#).") }}

{{ admonition(type="tip", text="Some **content** with _Markdown_ `syntax`. Check [this `api`](#).") }}
{{ admonition(type="tip", text="Some **content** with *Markdown* `syntax`. Check [this `api`](#).") }}

{{ admonition(type="info", text="Some **content** with _Markdown_ `syntax`. Check [this `api`](#).") }}
{{ admonition(type="info", text="Some **content** with *Markdown* `syntax`. Check [this `api`](#).") }}

{{ admonition(type="warning", text="Some **content** with _Markdown_ `syntax`. Check [this `api`](#).") }}
{{ admonition(type="warning", text="Some **content** with *Markdown* `syntax`. Check [this `api`](#).") }}

{{ admonition(type="danger", text="Some **content** with _Markdown_ `syntax`. Check [this `api`](#).") }}
{{ admonition(type="danger", text="Some **content** with *Markdown* `syntax`. Check [this `api`](#).") }}

You can change the `title` and `icon` of the admonition. Both parameters take a string and default to the type of admonition. `icon` can be any of the available admonition types.

{{ admonition(type="note", icon="tip", title="Custom title and icon", text="Some **content** with _Markdown_ `syntax`. Check [this `api`](#).") }}
{{ admonition(type="note", icon="tip", title="Custom title and icon", text="Some **content** with *Markdown* `syntax`. Check [this `api`](#).") }}

#### Usage

Expand Down Expand Up @@ -352,12 +353,12 @@ Both methods support the same parameters (`type`, `icon`, and `title`), with the

This shortcode allows you to display both the translated and original text for a quote. The quotation marks will be added automatically:

{{ multilingual_quote(original="Qué sosiego, ir por la vida en silencio, saludando sólo a los amigos.", translated="What tranquility, to go through life in silence, greeting only friends.", author="Francisco Umbral") }}
{{ multilingual_quote(original="Qué sosiego, ir por la vida en silencio, saludando sólo a los amigos.", translated="What tranquillity, to go through life in silence, greeting only friends.", author="Francisco Umbral") }}

#### Usage

```
{{/* multilingual_quote(original="Qué sosiego, ir por la vida en silencio, saludando sólo a los amigos.", translated="What tranquility, to go through life in silence, greeting only friends.", author="Francisco Umbral") */}}
{{/* multilingual_quote(original="Qué sosiego, ir por la vida en silencio, saludando sólo a los amigos.", translated="What tranquillity, to go through life in silence, greeting only friends.", author="Francisco Umbral") */}}
```

### References with hanging indent
Expand Down Expand Up @@ -414,7 +415,7 @@ Use this shortcode if you want to have a wider table, paragraph, code block… O

| Title | Year | Director | Cinematographer | Genre | IMDb | Duration |
|-------------------|-------|----------------------|-----------------------|---------------|-------|--------------|
| Beoning | 2018 | Lee Chang-dong | Hong Kyung-pyo | Drama/Mystery | 7.5 | 148 min |
| Burning | 2018 | Lee Chang-dong | Hong Kyung-pyo | Drama/Mystery | 7.5 | 148 min |
| The Master | 2012 | Paul Thomas Anderson | Mihai Mălaimare Jr. | Drama/History | 7.1 | 137 min |
| The Tree of Life | 2011 | Terrence Malick | Emmanuel Lubezki | Drama | 6.8 | 139 min |

Expand All @@ -439,10 +440,12 @@ Force the text direction of a content block. Overrides both the global `force_co
Accepts the parameter `direction`: the desired text direction. This can be either "ltr" (left-to-right) or "rtl" (right-to-left). Defaults to "ltr".

{% force_text_direction(direction="rtl") %}

```python
def مرحبا_بالعالم():
print("مرحبا بالعالم!")
```

{% end %}

#### Usage
Expand All @@ -459,3 +462,37 @@ def مرحبا_بالعالم():

{%/* end */%}
````

## Displaying webmentions for your posts

As described by the recommended W3C standard [Webmention][1] is a simple way to notify any URL when you mention it on your site. From the receiver's perspective, it's a way to request notifications when other sites mention it.

For static sites [webmention.io][2] hosts a webmention endpoint that can be used to receive webmentions. This feature fetches the webmentions stored at webmention.io and displays them for a page. You will need to have setup an account for your website at webmention.io. When you enable the webmention feature it will advertise your webmention.io endpoint and display the webmentions for any post using the webmention shortcut.

### Configuration and Usage

Enable webmentions for your site, add the following to your `config.toml` file:

```toml
[extra.webmentions]
enabled = true
# Specify the domain registered with webmention.io.
domain = "www.example.com"
```

Add the shortcut on the page where you want to display the webmentions:

```
{{/* webmentions() */}}
```

The webmentions section will then be displayed where you added it on the page as follows:

{{ dual_theme_image(light_src="blog/mastering-tabi-settings/img/webmention_light.webp", dark_src="blog/mastering-tabi-settings/img/webmention_dark.webp" alt="Page footer, showing a 'Site source' link") }}

The following is a live example based on the specific page_url configured in the template config.toml.

{{ webmentions() }}

[1]: https://www.w3.org/TR/webmention/#abstract-p-1
[2]: https://webmention.io/
Loading