tool

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

+build embed

Package tool is a reference implementation for generation of fotoDen-based websites.

Index

Constants

This section is empty.

Variables

View Source
var NameFlag string

NameFlag sets the name for a folder/album. If this is not set, fotoDen will automatically use the folder's name.

View Source
var Recurse bool

Recurse toggles recursive functions on directories. This is primarily used for the update command.

View Source
var ThumbSrc string

ThumbSrc represents the source of a thumbnail for a fotoDen folder. This is meant to be used with the command line tool.

View Source
var URLFlag string

URLFlag sets the URL for functions that require a URL. This is mostly used in initialization.

View Source
var Verbose bool

Verbose toggles the verbosity of the command line tool.

View Source
var WizardFlag bool

WizardFlag specifies if fotoDen tool functions should have interactive input or not.

Functions

func ConfigureWebFile added in v0.3.0

func ConfigureWebFile(source string, dest string, vars interface{}) error

ConfigureWebFile configures the web variables in a template by putting it through Go's template system. Outputs to a destination location. Can be used for any fotoDen-compatible web file.

This should only be done once, ideally, and copied over to a configuration directory for fotoDen to use (in essence, CurrentConfig.WebSourceDirectory)

func DeleteImage

func DeleteImage(folder string, files ...string) error

DeleteImage deletes an image from the folder.

DeleteImage goes through the ItemsInFolder array of folderInfo.json, and deletes the name of the image from the array, and then updates it accordingly.

If the items in the folder are sorted, it uses sort.SearchStrings to find it in O(log n) time. Otherwise, it will go through it in O(n) time.

func GenerateFolder

func GenerateFolder(meta FolderMeta, fpath string, options GeneratorOptions) error

func GenerateItems added in v0.1.0

func GenerateItems(fpath string, options GeneratorOptions) (int, error)

GenerateItems generates the album part of a fotoDen folder in fpath.

It takes an options struct (which is just a set of options condensed into one struct) and generates an image folder based on the options given (e.g., source, etc.)

BUG: The progress bar is continually over-written in verbose mode. This is more likely a cmdio-go problem than a fotoDen problem. The only solution to this right now is to not show a progress bar in verbose mode, which is not preferrable.

func GeneratePage added in v0.3.0

func GeneratePage(src string, title string) error

GeneratePage generates a page using a markdown document as a source. It will use the 'page' HTML template in the theme in order to generate a web page. Takes a source location, and places it at the root of the current site.

The page template must have {{.PageVars.PageContent}} in the location of where you want the parsed document to go.

func GenerateWebRoot added in v0.3.0

func GenerateWebRoot(fpath string) error

GenerateWebRoot generates the root of a fotoDen website in fpath. Creates the folders for JS and CSS placement.

It is up to the fotoDen tool to copy over the relevant files, and folder configuration.

func InitializefotoDenRoot

func InitializefotoDenRoot(rootpath string, webconfig WebsiteConfig) error

InitializefotoDenRoot sets up the root directory for fotoDen, including a folderInfo.json file. Creates the folder structure, copies over the folder page as well as the theme.css file, and copies over fotoDen.js, and then generates a folderInfo.json file according to the name given in the command line, otherwise generates with a blank name.

By default, the root of a generated fotoDen website should be specifically a folder. A fotoDen page can be anything, as long as the required tags are there, but if it is being generated via this tool, it is, by default, a folder.

TODO: Break this apart into smaller chunks, holy fuck

  • Done, technically. Disabling several pieces and replacing them with more efficient, (hopefully?) user friendly methods of managing website resources should help with readability.

func InsertImage

func InsertImage(folder string, mode string, options GeneratorOptions, files ...string) error

InsertImage inserts an image into a fotoDen folder. Otherwise, it updates an already existing image.

func MakeAlbumDirectoryStructure added in v0.3.0

func MakeAlbumDirectoryStructure(rootDirectory string) error

MakeAlbumDirectoryStructure makes a fotoDen-suitable album structure in the given rootDirectory (string). The directory must exist beforehand.

func RecursiveVisit added in v0.1.0

func RecursiveVisit(folder string, fn fvisitFunction) error

RecursiveVisit recursively visits folders, and performs a function inside of them. To ensure safety, this only works with fotoDen folders.

It detects if a folder is a fotoDen folder in a lazy way, by seeing if a folder contains a folderInfo.json. If it does not, it terminates

TODO: Replace this with the new fs library function in Go 1.16

func UpdateFolder added in v0.2.0

func UpdateFolder(folder string, name string, desc string) error

func UpdateFolderSubdirectories

func UpdateFolderSubdirectories(fpath string) error

UpdateFolderSubdirectories is a function to easily update a folder's subdirectories.

Takes the path of the fotoDen folder.

func UpdateFolderThumbnail added in v0.2.0

func UpdateFolderThumbnail(folder string, file string) error

func UpdateImages added in v0.1.0

func UpdateImages(folder string, options GeneratorOptions) error

UpdateImages updates all the images in a fotoDen folder.

func UpdateWeb added in v0.1.0

func UpdateWeb(folder string) error

UpdateWeb takes a folder, and updates the webpages inside of that folder.

Types

type BuildFile added in v0.2.0

type BuildFile struct {
	Name     string   `yaml:"name"`
	Dir      string   `yaml:"dir"`
	Desc     string   `yaml:"desc"`
	Type     string   `yaml:"type"`
	Thumb    string   `yaml:"thumb"`
	Static   bool     `yaml:"static"`
	ImageDir string   `yaml:"imageDir"`
	Images   []string `yaml:"images,flow"`
	Options  struct {
		Copy     bool `yaml:"copy"`
		Sort     bool `yaml:"sort"`
		Meta     bool `yaml:"metadata"`
		Gensizes bool `yaml:"generateSizes"`
	} `yaml:"imageOptions,flow"`
	Subfolders []*BuildFile `yaml:"subfolders,flow"`
}

BuildFile represents a fotoDen build file.

func (*BuildFile) Build added in v0.2.0

func (b *BuildFile) Build(folder string) error

BuildFromYAML is the entry point to the fotoDen website build system. It takes a YAML file, with the correct structure, and creates a website in the given folder.

func (*BuildFile) OpenBuildYAML added in v0.2.0

func (b *BuildFile) OpenBuildYAML(file string) error

OpenYAML opens a build file into a new BuildFile object.

type FolderMeta added in v0.2.0

type FolderMeta struct {
	Name string
	Desc string
}

type GeneratorOptions

type GeneratorOptions struct {
	Source   string
	Copy     bool
	Gensizes bool
	ImageGen bool
	Sort     bool
	Meta     bool
	Static   bool
}

GeneratorOptions is a set of options for the generator.

Includes: - source - copy - thumb - large

from the flags.

var Genoptions GeneratorOptions

Genoptions is a global variable for functions that use GeneratorOptions.

type StaticWebVars added in v0.3.0

type StaticWebVars struct {
	IsStatic   bool
	PageName   string // the current name of the page, e.g. 'My album', or 'Photo name'
	PageDesc   string // the current description of the page
	PageFolder string // the folder this is contained in
	PageAuthor string // the author of the page, i.e. the photographer
}

StaticWebVars are fields that a page can take in order to allow for static page generation. If a folder is marked for dynamic generation, these will all automatically be blank. Otherwise, these will have the relevant information inside. This only applies to folders.

type WebsiteConfig added in v0.2.0

type WebsiteConfig struct {
	Name            string
	RootLocation    string
	Theme           string
	URL             string
	GeneratorConfig generator.Config
}

WebsiteConfig represents a struct that contains everything needed for the fotoDen generator to work.

var CurrentConfig *WebsiteConfig

CurrentConfig represents the current site configuration file being used by fotoDen's tool.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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