Skip to content

[Propsal] Dynamical Frontend Render Plugin #34917

Open
@lunny

Description

@lunny

Feature Description

Preface

#34794 introduced a frontend static render plugin machism. I believe we can add more plugins in the future. But that will bloat the binary size and we cannot accept all the possible plugins. So that we need a machism to allow users(instance administrator) to find/install/uninstall Gitea Render Plugins.

Design Goals

The Gitea Frontend Render Plugin system aims to introduce a flexible, modular architecture that allows instance administrators to extend Gitea’s file rendering capabilities without modifying the core binary. Inspired by modern plugin-based ecosystems (e.g., VSCode extensions, browser plugins), this mechanism empowers the community to develop, share, and deploy custom renderers for specific file types (e.g., Markdown with diagrams, PDF, AsciiDoc, Jupyter notebooks, etc.).

A render plugin is a JavaScript (or TypeScript-transpiled) module that conforms to a defined Gitea rendering interface and is dynamically loaded by the frontend at runtime. It is designed to safely extend the rendering capabilities of Gitea views, in a secure and sandboxed way.

• Pluggability: Support multiple independently developed renderers.
• Discoverability: Administrators should be able to easily discover and install plugins.
• Configurability: Allow instance-level control over which plugins are enabled or disabled.
• Lightweight core: Keep the core Gitea binary minimal by externalizing optional renderers.

Plugin Format

Each plugin could be a .zip archive or an online git url which containing the following structure:

my-plugin.zip / repository folder
├── manifest.json     # Plugin metadata
├── render.js             # Entrypoint script
├── assets/                # Optional static assets (CSS, icons, fonts, etc.)

manifest.json example:

{
  "id": "pdf-renderer", // unique for every Gitea instance
  "name": "PDF Renderer",
  "version": "1.0.0",
  "description": "Render PDF files directly in the Gitea file view.",
  "entry": "render.js",
  "filePatterns": ["*.pdf"]
}

Plugin Storage and Delivery

To ensure security, performance, and compatibility with Gitea’s deployment model, all frontend render plugins must be downloaded and stored under a specific Gitea-managed directory, and served through Gitea’s internal HTTP router. This design avoids external dependency loading (e.g., from CDN or untrusted domains), ensuring all assets are locally verifiable and cacheable.

Storage Path

Uploaded/Downloaded plugin archives (.zip) will be extracted to a designated path inside the Gitea data/ directory. For example:

<gitea-root>/data/render-plugins/
├── pdf-renderer/
│   ├── manifest.json
│   ├── render.js
│   └── assets/
└── 3d-renderer/
    ├── manifest.json
    └── render.js

This allows Gitea to:
• Serve static assets securely via router
• Perform updates or uninstalls by removing plugin directories

Storage of Plugin State

Enabled status is stored in Gitea’s database under a new table (e.g., render_plugin):

type RenderPlugin struct {
   ID int64
   Name string `xorm:"unique"`
   Source string // this could be uploaded or a url
   Version string
   Description string
   Enabled bool
   InstalledAt util.timestamp
   UpdatedAt util.timestamp
}

Serving via Gitea Router

Gitea will expose plugin files through a well-defined route, e.g.

/assets/render-plugins // list all enabled render plugins metadata, this could be generated dynamically when install/uninstall plugins

/assets/render-plugins/pdf-renderer/render.js // main entry of one plugin

/assets/render-plugins/3d-renderer/assets/style.css // possible css file of one plugin

Admin UI Flow

On the Site Administration > Render Plugins page, admins will be able to:
• See a list of all installed plugins
• View plugin details (name, description, version)
• Enable/Disable plugin via toggle switch
• Delete plugin (removes files and DB entry)

Installation Flow

1.	Admin uploads plugin ZIP file or an via Gitea Admin Panel when creating a new plugin or upgrading a plugin
2.	Gitea validates the manifest, extracts it to data/render-plugins/.
3.	Plugin assets become accessible via routes.

Delete Plugin

When delete plugin, it will be removed from disk assets/ directory and database.

Enable/Disable Plugin

When enable/disable plugins, the database will be updated and the plugins meta files will be updated.

Screenshots

No response

Metadata

Metadata

Assignees

Labels

type/proposalThe new feature has not been accepted yet but needs to be discussed first.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions