Skip to content

PlantUML example from documentation stopped working in Gitea 1.25 #35923

@smartYSC

Description

@smartYSC

Description

We updated out Gitea instance from 1.24.7 to 1.25.1.

This broke our PlantUML customization. We did it exactly like stated in the documentation.

We are seeing this error in the browser console:

Uncaught ReferenceError: $ is not defined

Browser is pointing to this line in the footer.tmpl:

$(async () => {

In the browser console $ is available and window.jQuery is defined.

This looks like a race condition that jQuery is not available yet, when the PlantUML code runs.

I modified the example code like this and it works:

<script>
  function waitForJQuery(callback) {
    if (window.jQuery) {
      callback();
    } else {
      setTimeout(function() { waitForJQuery(callback); }, 50);
    }
  }

  async function initializePlantUMLCodeBlocks() {
    if (!$('.language-plantuml').length) return;
    await Promise.all([
      $.getScript('https://your-gitea-server.com/assets/plantuml-code-highlight/deflate.js'),
      $.getScript('https://your-gitea-server.com/assets/plantuml-code-highlight/encode.js'),
      $.getScript('https://your-gitea-server.com/assets/plantuml-code-highlight/plantuml_codeblock_parse.js'),
    ]);
    parsePlantumlCodeBlocks("https://www.plantuml.com/plantuml");
  }

  waitForJQuery(initializePlantUMLCodeBlocks);
</script>

I am no JavaScript developer by trade, so there might be a better solution out there. Maybe some experienced person can work off this and provide a fixed example in the documentation.

Gitea Version

1.25.1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Docker

Database

SQLite

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions