assets

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: Apache-2.0, MIT Imports: 16 Imported by: 4

README

Required Assets for the Gateway

HTTP Gateway Templates.

Updating

To update the templates, make changes to .html and .css files in the current directory.

Testing

  1. Make sure you have Go installed.
  2. From the assets/ directory, start the test server: go run test/main.go.

This will listen on localhost:3000 and reload the template every time you refresh the page. Here you have three pages:

Every time you refresh, the template will be reloaded.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DirectoryTemplate *template.Template
	DagTemplate       *template.Template
	ErrorTemplate     *template.Template
)
View Source
var AssetHash string

AssetHash a non-cryptographic hash of all embedded assets

View Source
var KnownIcons = map[string]bool{
	".aac":  true,
	".ai":   true,
	".aiff": true,
	".avi":  true,
	".bmp":  true,
	".c":    true,
	".cpp":  true,
	".css":  true,
	".dat":  true,
	".dmg":  true,
	".doc":  true,
	".docx": true,
	".dotx": true,
	".dwg":  true,
	".dxf":  true,
	".eps":  true,
	".exe":  true,
	".flv":  true,
	".gif":  true,
	".h":    true,
	".hpp":  true,
	".html": true,
	".ics":  true,
	".iso":  true,
	".java": true,
	".jpg":  true,
	".jpeg": true,
	".js":   true,
	".key":  true,
	".less": true,
	".mid":  true,
	".mkv":  true,
	".mov":  true,
	".mp3":  true,
	".mp4":  true,
	".mpg":  true,
	".odf":  true,
	".ods":  true,
	".odt":  true,
	".ott":  true,
	".pdf":  true,
	".php":  true,
	".png":  true,
	".ppt":  true,
	".psd":  true,
	".py":   true,
	".qt":   true,
	".rar":  true,
	".rb":   true,
	".rtf":  true,
	".sass": true,
	".scss": true,
	".sql":  true,
	".tga":  true,
	".tgz":  true,
	".tiff": true,
	".txt":  true,
	".wav":  true,
	".wmv":  true,
	".xls":  true,
	".xlsx": true,
	".xml":  true,
	".yml":  true,
	".zip":  true,
}

Functions

func BuildTemplate added in v0.9.0

func BuildTemplate(fs fs.FS, filename string) (*template.Template, error)

func HasDNSLinkOrigin

func HasDNSLinkOrigin(gwURL string, path string) bool

helper to detect DNSLink website context (when hostname from gwURL is matching /ipns/<fqdn> in path)

func ShortHash

func ShortHash(hash string) string

Types

type Breadcrumb struct {
	Name string
	Path string
}
func Breadcrumbs(urlPath string, dnslinkOrigin bool) []Breadcrumb

type DagTemplateData

type DagTemplateData struct {
	GlobalData
	Path      string
	CID       string
	CodecName string
	CodecHex  string
	Node      *ParsedNode
}

type DirectoryItem

type DirectoryItem struct {
	Size      string
	Name      string
	Path      string
	Hash      string
	ShortHash string
}

type DirectoryTemplateData

type DirectoryTemplateData struct {
	GlobalData
	Listing     []DirectoryItem
	Size        string
	Path        string
	Breadcrumbs []Breadcrumb
	BackLink    string
	Hash        string
}

type ErrorTemplateData added in v0.9.0

type ErrorTemplateData struct {
	GlobalData
	StatusCode int
	StatusText string
	Error      string
}

type GlobalData added in v0.9.0

type GlobalData struct {
	Menu       []MenuItem
	GatewayURL string
	DNSLink    bool
}
type MenuItem struct {
	URL   string
	Title string
}

type ParsedNode added in v0.9.0

type ParsedNode struct {
	Keys   []*ParsedNode
	Values []*ParsedNode
	Value  string
	CID    string
	Long   bool
}

func ParseNode added in v0.9.0

func ParseNode(node datamodel.Node) (*ParsedNode, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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