Reftagger Theme-Komponente

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 „Gefällt mir“

@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 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

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

3 „Gefällt mir“

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

2 „Gefällt mir“

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 „Gefällt mir“

What Discourse version are you running?

1 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

There it is, thank you sir :slightly_smiling_face:

1 „Gefällt mir“

Hallo Richard,

Ich greife einen älteren Thread auf. Ich habe diese Theme-Komponente installiert und es passieren zwei Dinge.

Erstens die Meldung, dass die Komponente aktualisiert werden muss.
[Admin-Hinweis] Das Theme ‘Reftagger’ enthält Code, der aktualisiert werden muss. (id:discourse.script-tag-discourse-plugin) (Mehr erfahren)

Zweitens hängt dies möglicherweise mit dem ersten Hinweis zusammen, dass die Komponente aktualisiert werden muss. Referenzen werden nicht markiert und Seiten scheinen zu hängen und zeigen den Ladekreis im Browser-Tab an.

Wäre es möglich, diese Komponente zu aktualisieren?

Ich habe mit ChatGPT einige Fortschritte gemacht und funktionierende RefTagger für beide, Logos RefTagger und Blue Letter Bible, erstellt.

Wenn diese in eine Theme-Komponente für die allgemeine Nutzung gebündelt werden könnten, wäre das großartig. Wenn nicht, ist die Theme-Komponente einfach zu erstellen. Sie müssen nur den Code für die von Ihnen bevorzugte Option nehmen und in den JS-Tab einer neuen Theme-Komponente einfügen. Sie müssen den Standardcode im JS-Tab von Discourse entfernen.

Wenn jemand Feedback zur Verbesserung hat, ist dies willkommen. Meine Fähigkeiten reichen nur bis zur Anleitung des LLM.

Verwendung von Logos RefTagger:

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

export default apiInitializer("0.1", (api) => {
  // 1. Define RefTagger settings on window BEFORE loading the script
  window.refTagger = {
    settings: {
      bibleVersion: "ESV", // e.g. default Bible version
      tagChapters: true, // tag chapter references as well
      convertHyperlinks: false, // don’t retag existing links
      roundCorners: true,
      socialSharing: [],
    },
  };

  // 2. Hook into Discourse post rendering:
  api.decorateCooked((element) => {
    // Load the external RefTagger script (if not already loaded)
    loadScript("https://api.reftagger.com/v2/RefTagger.js").then(() => {
      // Run the tagging on the new content element
      window.refTagger.tag(element);
    });
  });
});

Verwendung von BLB ScriptTagger:

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

export default apiInitializer("0.1", (api) => {
  // Optionally set BLB ScriptTagger settings before loading (defaults shown)
  window.BLB ||= {}; // ensure global BLB object exists
  window.BLB.Tagger ||= {};
  window.BLB.Tagger.Translation = "NKJV"; // default translation version
  window.BLB.Tagger.HyperLinks = "all"; // tag even already-linked refs
  window.BLB.Tagger.TargetNewWindow = true; // links open in new tab
  // … (other settings like DarkTheme, etc., as needed)

  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(); // re-scan new content for verses:contentReference[oaicite:6]{index=6}
        }
      });
  });
});

Dies wurde nun behoben.

Dies kann ich nicht reproduzieren, selbst bevor das obige Problem behoben wurde – was nur eine Warnung und kein Fehler war.

3 „Gefällt mir“

Vielen Dank für das Update!

2 „Gefällt mir“