webgui

package
v0.0.0-...-1dc401f Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package webgui provides plugin functionality to the Web GUI.

Package webgui defines the Web GUI helpers.

Index

Constants

This section is empty.

Variables

View Source
var (

	// PluginsMatch is used for matching author and plugin name in the url path
	PluginsMatch = regexp.MustCompile(`^plugins\/([^\/]*)\/([^\/\?]+)[\/]?(.*)$`)
	// PluginsPath is the base path where webgui plugins are stored
	PluginsPath string
)

Functions

func CheckAndDownloadWebGUIRelease

func CheckAndDownloadWebGUIRelease(checkUpdate bool, forceUpdate bool, fetchURL string, cacheDir string) (err error)

CheckAndDownloadWebGUIRelease is a helper function to download and setup latest release of rclone-webui-react

func CreatePathIfNotExist

func CreatePathIfNotExist(path string) (err error)

CreatePathIfNotExist creates the path to a folder if it does not exist

func DownloadFile

func DownloadFile(filepath string, url string) (err error)

DownloadFile is a helper function to download a file from url to the filepath

func GetLatestReleaseURL

func GetLatestReleaseURL(fetchURL string) (string, string, int, error)

GetLatestReleaseURL returns the latest release details of the rclone-webui-react

func ServePluginOK

func ServePluginOK(w http.ResponseWriter, r *http.Request, pluginsMatchResult []string) (ok bool)

ServePluginOK checks the plugin url and uses reverse proxy to allow redirection for content not being served by rclone

func ServePluginWithReferrerOK

func ServePluginWithReferrerOK(w http.ResponseWriter, r *http.Request, path string) (ok bool)

ServePluginWithReferrerOK check if redirectReferrer is set for the referred a plugin, if yes, sends a redirect to actual url. This function is useful for plugins to refer to absolute paths when the referrer in http.Request is set

func Unzip

func Unzip(src, dest string) (err error)

Unzip is a helper function to Unzip a file specified in src to path dest

Types

type PackageJSON

type PackageJSON struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	Description string `json:"description"`
	Author      string `json:"author"`
	Copyright   string `json:"copyright"`
	License     string `json:"license"`
	Private     bool   `json:"private"`
	Homepage    string `json:"homepage"`
	TestURL     string `json:"testUrl"`
	Repository  struct {
		Type string `json:"type"`
		URL  string `json:"url"`
	} `json:"repository"`
	Bugs struct {
		URL string `json:"url"`
	} `json:"bugs"`
	Rclone RcloneConfig `json:"rclone"`
}

PackageJSON is the structure of package.json of a plugin

type Plugins

type Plugins struct {
	LoadedPlugins map[string]PackageJSON `json:"loadedPlugins"`
	// contains filtered or unexported fields
}

Plugins represents the structure how plugins are saved onto disk

func (*Plugins) GetPluginByName

func (p *Plugins) GetPluginByName(name string) (out *PackageJSON, err error)

GetPluginByName returns the plugin object for the key (author/plugin-name)

type RcloneConfig

type RcloneConfig struct {
	HandlesType      []string `json:"handlesType"`
	PluginType       string   `json:"pluginType"`
	RedirectReferrer bool     `json:"redirectReferrer"`
	Test             bool     `json:"-"`
}

RcloneConfig represents the rclone specific config

Jump to

Keyboard shortcuts

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