webapp

package
v3.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: MIT Imports: 51 Imported by: 0

Documentation

Overview

Package webapp implements the web interface

Index

Constants

View Source
const (
	// LabelViewerPrefix is used to denote the annotations that describe viewers.  The part after the "/" in the key is used as the name. The value must be a JSON document representing ViewerSpec.
	LabelViewerPrefix = "viewer.data.act3-ace.io"

	// HubBottleName is the name of the bottle that is used when mounting in ACE Hub
	// This must not include any special characters because it needs to be used as an env var in ACE Hub.
	HubBottleName = "dataset"
)

Variables

This section is empty.

Functions

func GetAncestryGraphHTML

func GetAncestryGraphHTML(ctx context.Context, con *gorm.DB, bottle *db.BottleRelative, numGenAncestors, numGenDescendents uint, templates *template.Template) (template.HTML, error)

GetAncestryGraphHTML renders an HTML graph of ancestry and returns it as a string. numGenAncestors and numGenDescendents determine the number of generations in each direction to render. templates is a pointer to the templates that include the needed html templates to be used in the graph rendering.

Types

type ViewerLink struct {
	Location string
	Viewer   string
	URL      string
}

ViewerLink represents a viewer that will be presented to the user.

type ViewerSpecList

type ViewerSpecList []v1alpha2.ViewerSpec

ViewerSpecList is just a list of ViewerSpecs.

func (*ViewerSpecList) FilterAndSort

func (vsl *ViewerSpecList) FilterAndSort(mediaType string) ViewerSpecList

FilterAndSort returns only viewers supporting mediaType in sorted order (best first).

type WebApp

type WebApp struct {
	// contains filtered or unexported fields
}

WebApp implements the HTML web application.

func NewWebApp

func NewWebApp(conf v1alpha2.WebApp, log *slog.Logger, version string) (*WebApp, error)

NewWebApp creates the WebApp.

func (*WebApp) FindViewers

func (a *WebApp) FindViewers(specs []v1alpha2.ViewerSpec, bottle digest.Digest, partSelectors []string, artifact *db.PublicArtifact) []ViewerLink

FindViewers computes the viewers for each ACE Hub instance and provided spec. Each ViewerLink will mount the bottle using the selectors.

func (*WebApp) GetArtifactViewers

func (a *WebApp) GetArtifactViewers(specs ViewerSpecList, bottle digest.Digest, partSelectors []string, artifacts []db.PublicArtifact) map[string][]ViewerLink

GetArtifactViewers finds the viewers for each artifact by matching viewerSpecs to artifact's media type.

func (*WebApp) GetViewerSpecList

func (a *WebApp) GetViewerSpecList(bottle db.Bottle) ViewerSpecList

GetViewerSpecList will find annotations that denote viewers and parse them.

func (*WebApp) Initialize

func (a *WebApp) Initialize(serveMux *http.ServeMux)

Initialize the routes.

Jump to

Keyboard shortcuts

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