prism

package
v0.0.0-...-ecdd364 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2022 License: MIT Imports: 4 Imported by: 1

README

prism

Package prism is an Ambient plugin that provides syntax highlighting using Prism (https://prismjs.com/).

Import: github.com/ambientkit/plugin/generic/prism

Version: 1.0.0

Plugin Type

The plugin can be used as the following core types:

  • Logger: false
  • Storage System: false
  • Router: false
  • Template Engine: false
  • Session Manager: false

Grants

The plugin request the following grants (3):

  • Name: site.asset:write
    • Description: Access to add stylesheets and javascript to each page.
  • Name: router.route:write
    • Description: Access to create routes for accessing stylesheets.
  • Name: plugin.setting:read
    • Description: Read own plugin settings.

Settings

The plugin has the follow settings (2):

Routes

The plugin has the following routes (2):

  • Method: GET | Path: /plugins/prism/css/style.css
  • Method: GET | Path: /plugins/prism/css/clean.css

Middleware

The plugin does not have any middleware.

FuncMap

The plugin does not have a FuncMap.

Assets

The plugin injects the following assets (3):

Embedded Files

The plugin has embedded files.

Example Usage

package main

import (
	"log"

	"github.com/ambientkit/ambient"
	"github.com/ambientkit/ambient/pkg/ambientapp"
	"github.com/ambientkit/plugin/generic/prism"
	"github.com/ambientkit/plugin/logger/zaplogger"
	"github.com/ambientkit/plugin/storage/memorystorage"
)

func main() {
	plugins := &ambient.PluginLoader{
		// Core plugins are implicitly trusted.
		Router:         nil,
		TemplateEngine: nil,
		SessionManager: nil,
		// Trusted plugins are those that are typically needed to boot so they
		// will be enabled and given full access.
		TrustedPlugins: map[string]bool{},
		Plugins: []ambient.Plugin{
			prism.New(),
		},
		Middleware: []ambient.MiddlewarePlugin{
			// Middleware - executes top to bottom.
		},
	}
	_, _, err := ambientapp.NewApp("myapp", "1.0",
		zaplogger.New(),
		ambient.StoragePluginGroup{
			Storage: memorystorage.New(),
		},
		plugins)
	if err != nil {
		log.Fatalln(err.Error())
	}
}

Docgen by Ambient

Documentation

Overview

Package prism is an Ambient plugin that provides syntax highlighting using Prism (https://prismjs.com/).

Index

Examples

Constants

View Source
const (
	// Version allows user to set the library version.
	Version = "Version"
	// Styles allows user to set the styles.
	Styles = "Styles"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Plugin

type Plugin struct {
	*ambient.PluginBase
}

Plugin represents an Ambient plugin.

func New

func New() *Plugin

New returns an Ambient plugin that provides syntax highlighting using Prism (https://prismjs.com/).

Example
package main

import (
	"log"

	"github.com/ambientkit/ambient"
	"github.com/ambientkit/ambient/pkg/ambientapp"
	"github.com/ambientkit/plugin/generic/prism"
	"github.com/ambientkit/plugin/logger/zaplogger"
	"github.com/ambientkit/plugin/storage/memorystorage"
)

func main() {
	plugins := &ambient.PluginLoader{
		// Core plugins are implicitly trusted.
		Router:         nil,
		TemplateEngine: nil,
		SessionManager: nil,
		// Trusted plugins are those that are typically needed to boot so they
		// will be enabled and given full access.
		TrustedPlugins: map[string]bool{},
		Plugins: []ambient.Plugin{
			prism.New(),
		},
		Middleware: []ambient.MiddlewarePlugin{
			// Middleware - executes top to bottom.
		},
	}
	_, _, err := ambientapp.NewApp("myapp", "1.0",
		zaplogger.New(),
		ambient.StoragePluginGroup{
			Storage: memorystorage.New(),
		},
		plugins)
	if err != nil {
		log.Fatalln(err.Error())
	}
}
Output:

func (*Plugin) Assets

func (p *Plugin) Assets() ([]ambient.Asset, ambient.FileSystemReader)

Assets returns a list of assets and an embedded filesystem.

func (*Plugin) GrantRequests

func (p *Plugin) GrantRequests() []ambient.GrantRequest

GrantRequests returns a list of grants requested by the plugin.

func (*Plugin) PluginName

func (p *Plugin) PluginName() string

PluginName returns the plugin name.

func (*Plugin) PluginVersion

func (p *Plugin) PluginVersion() string

PluginVersion returns the plugin version.

func (*Plugin) Routes

func (p *Plugin) Routes()

Routes sets routes for the plugin.

func (*Plugin) Settings

func (p *Plugin) Settings() []ambient.Setting

Settings returns a list of user settable fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL