diff --git a/config.toml b/config.toml index 4538c6a..91ac8fa 100644 --- a/config.toml +++ b/config.toml @@ -200,6 +200,17 @@ fediverse_creator = { handle = "zloy_linux", domain = "zlinux.ru" } show_previous_next_article_links = true invert_previous_next_article_links = true + +# Enable iine like buttons on all posts: https://iine.to/ +# Can be set at page or section levels, following the hierarchy: page > section > config. See: https://welpo.github.io/tabi/blog/mastering-tabi-settings/#settings-hierarchy +iine = true +iine_icon = "thumbs_up" # See https://iine.to/#customise +# Unify like counts across all language versions of the same page. +# When enabled, likes on /es/blog/hello/ will count towards /blog/hello/ (default language). +iine_unified_languages = true + + + enable_csp = false diff --git a/themes/tabi/i18n/ru.toml b/themes/tabi/i18n/ru.toml index 96b9fb7..431f410 100644 --- a/themes/tabi/i18n/ru.toml +++ b/themes/tabi/i18n/ru.toml @@ -79,6 +79,9 @@ load_comments = "Загрузить комментарии" copied = "Скопировано!" copy_code_to_clipboard = "Скопировать код в буфер обмена" +# iine appreciation button. +like_this_post = "Мне нравится эта статья" + # Footer: Powered by Zola and tabi. powered_by = "Под управлением" and = "&" diff --git a/themes/tabi/sass/main.scss b/themes/tabi/sass/main.scss index d3f6e5d..6aeb5df 100644 --- a/themes/tabi/sass/main.scss +++ b/themes/tabi/sass/main.scss @@ -8,6 +8,7 @@ @use 'parts/_header-anchor.scss'; @use 'parts/_header.scss'; @use 'parts/_home-banner.scss'; +@use 'parts/_iine.scss'; @use 'parts/_image-hover.scss'; @use 'parts/_image-toggler.scss'; @use 'parts/_image.scss'; @@ -22,8 +23,8 @@ @use 'parts/_table.scss'; @use 'parts/_tags.scss'; @use 'parts/_theme-switch.scss'; -@use 'parts/_zola-error.scss'; @use 'parts/_webmention.scss'; +@use 'parts/_zola-error.scss'; @font-face { src: local('Open Sans'), diff --git a/themes/tabi/sass/parts/_iine.scss b/themes/tabi/sass/parts/_iine.scss new file mode 100644 index 0000000..9ac95c4 --- /dev/null +++ b/themes/tabi/sass/parts/_iine.scss @@ -0,0 +1,37 @@ +.iine-button { + display: inline-flex; + align-items: center; + gap: 5px; + transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease; + cursor: pointer; + border: none; + background: transparent; + color: inherit; + font-family: var(--sans-serif-font); + -webkit-tap-highlight-color: transparent; + appearance: none; + margin: 0; + padding: 0; + font-size: inherit; + line-height: inherit; + + .icon { + display: inline-flex; + align-items: center; + } + + .counter { + margin-left: .2rem; + font-size: 0.8rem; + } + + svg { + width: 1em; + height: 1em; + } +} + +.iine-auto-buttons { + margin-top: 2rem; + padding: 1rem 0; +} diff --git a/themes/tabi/templates/page.html b/themes/tabi/templates/page.html index eb6979a..4768cbd 100644 --- a/themes/tabi/templates/page.html +++ b/themes/tabi/templates/page.html @@ -57,6 +57,8 @@ Current section extra: {% if current_section %}{{ current_section.extra | json_e {% set settings_to_test = [ + "iine", + "iine_icon", "enable_cards_tag_filtering", "footnote_backlinks", "add_src_to_code_block", @@ -98,6 +100,7 @@ Current section extra: {% if current_section %}{{ current_section.extra | json_e #} + {# {{ __tera_context }} #} {# End debugging #} @@ -272,6 +275,11 @@ Current section extra: {% if current_section %}{{ current_section.extra | json_e {{ processed_content | replace(from="", to=macros_toc::toc(page=page, header=false, language_strings=language_strings)) | safe }} + {#- iine button -#} + {%- if macros_settings::evaluate_setting_priority(setting="iine", page=page, default_global_value=false) == "true" -%} + {% include "partials/iine_button.html" %} + {%- endif -%} + {% if macros_settings::evaluate_setting_priority(setting="show_previous_next_article_links", page=page, default_global_value=true) == "true" %} {%- if page.lower or page.higher -%} {% set next_label = macros_translate::translate(key="next", default="Next", language_strings=language_strings) %} diff --git a/themes/tabi/templates/partials/content_security_policy.html b/themes/tabi/templates/partials/content_security_policy.html index 8ac2d0d..f8ec611 100644 --- a/themes/tabi/templates/partials/content_security_policy.html +++ b/themes/tabi/templates/partials/content_security_policy.html @@ -7,6 +7,9 @@ content="default-src 'self' {%- set giscus_enabled = config.extra.giscus.enabled_for_all_posts or page.extra.giscus -%} {%- set hyvortalk_enabled = config.extra.hyvortalk.enabled_for_all_posts or page.extra.hyvortalk -%} {%- set isso_enabled = config.extra.isso.enabled_for_all_posts or page.extra.isso -%} + {%- if page -%} + {%- set iine_enabled = macros_settings::evaluate_setting_priority(setting="iine", page=page, default_global_value=false) == "true" -%} + {%- endif -%} {%- if page -%} {%- set mermaid_enabled = macros_settings::evaluate_setting_priority(setting="mermaid", page=page, default_global_value=false) == "true" -%} {%- endif -%} @@ -50,7 +53,7 @@ content="default-src 'self' {%- set script_src = script_src ~ " " ~ " utteranc.es" -%} {%- endif -%} - {%- if mermaid_enabled and not serve_local_mermaid -%} + {%- if (mermaid_enabled and not serve_local_mermaid) or iine_enabled -%} {%- set script_src = script_src ~ " " ~ " cdn.jsdelivr.net" -%} {%- endif -%} @@ -59,6 +62,12 @@ content="default-src 'self' {%- set connect_src = connect_src ~ " webmention.io" -%} {%- endif -%} + {#- Check if iine like buttons are enabled to allow the necessary domains -#} + {%- if iine_enabled -%} + {%- set connect_src = connect_src ~ " vhiweeypifbwacashxjz.supabase.co" -%} + {%- endif -%} + + {#- Append WebSocket for Zola serve mode -#} {%- if config.mode == "serve" -%} {%- set connect_src = connect_src ~ " ws:" -%} diff --git a/themes/tabi/templates/partials/extra_features.html b/themes/tabi/templates/partials/extra_features.html index b8d5f83..0a2cfa8 100644 --- a/themes/tabi/templates/partials/extra_features.html +++ b/themes/tabi/templates/partials/extra_features.html @@ -81,3 +81,8 @@ {%- if macros_settings::evaluate_setting_priority(setting="footnote_backlinks", page=page_s, section=section_s, default_global_value=false) == "true" -%} {%- endif -%} + +{# Add iine.js for the like button #} +{%- if macros_settings::evaluate_setting_priority(setting="iine", page=page_s, section=section_s, default_global_value=false) == "true" -%} + +{%- endif -%} diff --git a/themes/tabi/templates/partials/iine_button.html b/themes/tabi/templates/partials/iine_button.html new file mode 100644 index 0000000..508fd3a --- /dev/null +++ b/themes/tabi/templates/partials/iine_button.html @@ -0,0 +1,33 @@ +{% import "macros/settings.html" as macros_settings %} +{%- set button_icon = button_icon | default(value=macros_settings::evaluate_setting_priority(setting="iine_icon", page=page | default(value=""), section=section | default(value=""), default_global_value="heart")) -%} +{%- if config.extra.iine_unified_languages and lang != config.default_language -%} + {%- set unified_slug = page.path | replace(from='/' ~ lang ~ '/', to='/') -%} + {%- set slug = slug | default(value=unified_slug) -%} +{%- else -%} + {%- set slug = slug | default(value=page.path) -%} +{%- endif -%} +{%- if label -%} + {%- set final_label = label -%} +{%- elif language_strings -%} + {%- set final_label = macros_translate::translate(key="like_this_post", default="Like this post", language_strings=language_strings) -%} +{%- else -%} + {%- set final_label = "Like this post" -%} +{%- endif -%} + +{%- if button_icon == "heart" -%} + {%- set icon_display = "♥️" -%} +{%- elif button_icon == "thumbs_up" -%} + {%- set icon_display = "👍" -%} +{%- elif button_icon == "upvote" -%} + {%- set icon_display = "⬆️" -%} +{%- else -%} + {%- set icon_display = button_icon -%} +{%- endif -%} + +
+ + +
diff --git a/themes/tabi/templates/shortcodes/iine.html b/themes/tabi/templates/shortcodes/iine.html new file mode 100644 index 0000000..d37211d --- /dev/null +++ b/themes/tabi/templates/shortcodes/iine.html @@ -0,0 +1,5 @@ +{% set button_icon = icon | default(value="heart") %} +{% set label = label | default(value="Like this post") %} +{% set slug = slug | default(value=page.path) %} + +{% include "partials/iine_button.html" %} diff --git a/themes/tabi/theme.toml b/themes/tabi/theme.toml index c3e195b..d9278aa 100644 --- a/themes/tabi/theme.toml +++ b/themes/tabi/theme.toml @@ -114,6 +114,15 @@ show_date = true # "both" - Show both the original date and the last updated date. post_listing_date = "date" +# Enable iine like buttons on all posts: https://iine.to/ +# Can be set at page or section levels, following the hierarchy: page > section > config. See: https://welpo.github.io/tabi/blog/mastering-tabi-settings/#settings-hierarchy +iine = false +iine_icon = "heart" # See https://iine.to/#customise +# Unify like counts across all language versions of the same page. +# When enabled, likes on /es/blog/hello/ will count towards /blog/hello/ (default language). +iine_unified_languages = true + + # Show "Jump to posts" link next to series' title. # By default, the link appears automatically when a series description exceeds 2000 characters. # Can be set at page or section levels, following the hierarchy: page > section > config. See: https://welpo.github.io/tabi/blog/mastering-tabi-settings/#settings-hierarchy