Skip to content

Latest commit

 

History

History
46 lines (29 loc) · 3.6 KB

plugins.md

File metadata and controls

46 lines (29 loc) · 3.6 KB

OCWebsite plugin development

Plugin interface

A OCWebsite plugin is a smart contract which implements the IVersionableWebsitePlugin interface.

See the interface description.

Plugin starter kit

The OCWebsite Starter Kit Plugin is a template to help you make your OCWebsite plugin. Fork it, build it, and experiment with it.

Existing plugins

The following plugins were developed in separate repositories :

The following plugins were developed inside the Ocweb repository :

  • Injected Variables : Let users add some key/values, which will be made available at the /variables.json path. Include the hardcoded address of the OCWebsite being viewed in the self value.
  • Static Frontend : A major brick: Let users upload files in a filesystem-like structure, which is then served. Useful to upload static frontend. (web3://ocweb.eth is a static website hosted via this plugin).
  • Admin interface : This add an admin interface to the OCWebsite at the /admin path. This plugin is actually proxying the request to the OCWebsite hosting web3://ocweb.eth, which detect it is called from another OCWebsite, and adapt slightly his interface.

Common patterns

Served content

So far, 2 main patterns have emerged:

  • For plugins with small basic output (such as Injected Variables), the whole output is generated in Solidity in the smart contract.
  • For plugins with larger output (such as Theme "About Me"), one or more separate OCWebsites are used to host static files (thanks to the Static Frontend plugin), and the plugin will basically proxy the requests to this OCWebsite, and expose an extra path that will contains configuration elements.

Configuration storage

So far, 2 main patterns have emerged:

  • For configuration elements that impact the output at the smart contract level (e.g. on which root path will the plugin content be served) : they are stored on the smart contract. Example :
        struct Config {
            string[] rootPath;
        }
        mapping(IVersionableWebsite => mapping(uint => Config)) private configs;
    
  • For the other configuration elements : they are stored as JSON/YAML/... in a file stored in the filesystem provided by the Static Frontend plugin. This approach offers more flexibility, and is used (alongside the first pattern) by the Theme "About Me" and VisualizeValue Mint Frontend plugin.