utils

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanUpBuildFiles

func CleanUpBuildFiles() error

deletes the files specified in FILES_TO_DELETE from the build directory

func DeleteBuildDirectory

func DeleteBuildDirectory(outputPath string) error

func DownloadLatestRelease

func DownloadLatestRelease(versionTag string) error

func EnsureDirExists

func EnsureDirExists(dirPath string) error

checks if a directory exists and creates it if it doesn't.

func GenerateHTML

func GenerateHTML(links *Links) error

GenerateHTML generates HTML from the template and JSON configuration

func GenerateRedirects

func GenerateRedirects(links *Links) error

GenerateRedirects generates a _redirects file based on the redirects in the links JSON

func ParseConfig

func ParseConfig(links *Links)

func ReadIndexHTML

func ReadIndexHTML() ([]byte, error)

func ReplaceFile

func ReplaceFile(srcFile, destFile string) error

func ValidateAndCopyLinksAssets

func ValidateAndCopyLinksAssets(links *Links, assetsPath string) error

verifies if the icon URLs in the links struct point to files and copies them to the build directory

func ValidateButtonClass

func ValidateButtonClass(name string) (bool, error)

validates if the given button class exists in the brands.css file

func ValidateButtonImage

func ValidateButtonImage(name string) (bool, error)

func WriteRedirectsToFile

func WriteRedirectsToFile(redirects []string) error

WriteRedirectsToFile writes redirects to a _redirects file in the build directory

Types

type Bio

type Bio struct {
	IconURL     string `json:"ICON_URL"`
	Title       string `json:"TITLE"`
	Description string `json:"DESCRIPTION"`
	Footer      string `json:"FOOTER"`
}

Bio represents the bio section of the JSON

type Link struct {
	Brand     string `json:"brand"`
	Icon      string `json:"icon"`
	Name      string `json:"name"`
	Link      string `json:"link"`
	Redirects []struct {
		Src  string `json:"src"`
		Dest string `json:"dest"`
		Code int    `json:"code"`
	} `json:"redirects"`
}

Link represents a single link entry

type Links struct {
	DownloadTagVer  string `json:"DOWNLOAD_TAG_VER"`
	Meta            Meta   `json:"META"`
	Bio             Bio    `json:"BIO"`
	BaseShortURL    string `json:"BASE_SHORT_URL"`
	EnableRedirects bool   `json:"ENABLE_REDIRECTS"`
	Links           []Link `json:"LINKS"`
}

Links represents the entire JSON structure

func ParseLinksJSON

func ParseLinksJSON(assetsPath string) (*Links, error)

ParseLinksJSON parses the JSON file at the given path and returns the Links structure

type Meta

type Meta struct {
	Title       string `json:"TITLE"`
	Author      string `json:"AUTHOR"`
	Description string `json:"DESCRIPTION"`
	IconURL     string `json:"ICON_URL"`
	Theme       string `json:"THEME"`
}

Meta represents the meta section of the JSON

Jump to

Keyboard shortcuts

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