Componente de tema Reftagger

The Reftagger library allows you to convert bible references on your Discourse forum into links with a hover-preview.

By request of @outofthebox we made a theme component based on this code.

I’ve added a setting that allows you to select the translation you want to use, and the component extends the content security policy to allow for the reftagger library to be included.

Repository here.

13 curtidas

@RGJ, our community loves this feature. Thank you for developing in a secure and customizable manner. I appreciate your generosity in sharing this work back to the Discourse community.

5 curtidas

We’ve been using that for the last 18 months or so, and it’s worked like a charm. Happy to see it improved and made more easily available!

3 curtidas

Wow, that’s super cool.

I would love to see a similar component in which custom keywords and previews can be defined.
That would be super useful to create a glossary for example

1 curtida

There is the auto abbrify words theme component which does such a thing.

3 curtidas

I really appreciate you and everyone who contributed to the original conversation on Meta about how to make this feature work!

2 curtidas

Hello everyone, Reftagger was working swimmingly for a few months, and then it just stopped. It will still automatically generate an external link for the book/chapter/verse format, but it will not load the hover preview.

It appears to be up to date too. Any ideas?

1 curtida

What Discourse version are you running?

1 curtida

How can I find this info?

It should be somewhere in the admin dashboard at /admin

It just says that it is up to date:

1 curtida

Seems to be working fine on Discourse 2.7.7 (at least in Safari) for me.

It’s working again now.
Reftagger apparently switched to a different CDN (reftagger.bibliacdn.com) which had to be whitelisted in the content security policy. I have added it and pushed a new version of the theme component. All you need to do is update the component.

3 curtidas

There it is, thank you sir :slightly_smiling_face:

1 curtida

Olá Richard,

Revisando um tópico antigo. Instalei este componente de tema e duas coisas estão acontecendo.

Primeiro é a mensagem de que o componente precisa ser atualizado.
[Aviso do Admin] O tema ‘Reftagger’ contém código que precisa ser atualizado. (id:discourse.script-tag-discourse-plugin) (saiba mais)

Segundo pode estar relacionado à primeira notificação onde o componente precisa ser atualizado. As referências não estão sendo marcadas e as páginas parecem travar mostrando o círculo de carregamento na aba do navegador.

Seria possível atualizar este componente?

Fiz alguns progressos com isso usando o ChatGPT e tenho reftaggers funcionando para ambos usando Logos RefTagger e Blue Letter Bible.

Se isso puder ser incluído em um componente de tema para uso da comunidade, ótimo. Se não, o componente de tema é simplesmente para fazer. Você só precisa pegar o código de qualquer um que preferir e colocá-lo na aba JS de um novo componente de tema. Você precisa remover o código padrão que está na aba JS do Discourse.

Se alguém tiver feedback sobre como melhorar, é bem-vindo. Minhas habilidades vão apenas até guiar o LLM.

Usando Logos RefTagger:

import { apiInitializer } from “discourse/lib/api”;
import loadScript from “discourse/lib/load-script”;

export default apiInitializer(“0.1”, (api) => {
// 1. Defina as configurações do RefTagger na janela ANTES de carregar o script
window.refTagger = {
settings: {
bibleVersion: “ESV”, // e.g. versão padrão da Bíblia
tagChapters: true, // marcar também as referências de capítulos
convertHyperlinks: false, // não marcar links existentes
roundCorners: true,
socialSharing: ,
}
};

// 2. Enganche na renderização de posts do Discourse:
api.decorateCooked((element) => {
// Carregue o script externo RefTagger (se ainda não foi carregado)
loadScript(“https://api.reftagger.com/v2/RefTagger.js”).then(() => {
// Execute a marcação no novo elemento de conteúdo
window.refTagger.tag(element);
});
});
});

Usando BLB ScriptTagger:

import { apiInitializer } from “discourse/lib/api”;
import loadScript from “discourse/lib/load-script”;

export default apiInitializer(“0.1”, (api) => {
// Opcionalmente, defina as configurações do BLB ScriptTagger antes de carregar (padrões mostrados)
window.BLB ||= {}; // garanta que o objeto global BLB exista
window.BLB.Tagger ||= {};
window.BLB.Tagger.Translation = “NKJV”; // versão de tradução padrão
window.BLB.Tagger.HyperLinks = “all”; // marcar até mesmo referências já vinculadas
window.BLB.Tagger.TargetNewWindow = true; // links abrem em nova aba
// … (outras configurações como DarkTheme, etc., conforme necessário)

api.decorateCooked((elem) => {
loadScript(“https://www.blueletterbible.org/assets/scripts/blbToolTip/BLB_ScriptTagger-min.js”)
.then(() => {
if (window.BLB && window.BLB.Tagger) {
window.BLB.Tagger.pageInit(); // reanalisar novo conteúdo para versículos:contentReference[oaicite:6]{index=6}
}
});
});
});

Isso foi resolvido agora.

Isso eu não consigo reproduzir, mesmo antes de resolver o problema acima - que foi apenas um aviso, não um erro.

3 curtidas

Muito grato pela atualização!

2 curtidas