Documentation ¶
Index ¶
- Constants
- func AnalyzeAllMediae(ctx RunContext, embedDeclarations map[string][]MediaEmbedDeclaration, ...) (map[string][]Media, error)
- func DisplayValidationErrors(errors []gojsonschema.ResultError, name string)
- func FileExists(filepath string) bool
- func FilepathBaseNoExt(pth string) string
- func FilterSlice(s []string, cond func(string) bool) []string
- func GetAudioDuration(file *os.File) uint
- func IsValidURL(URL string) bool
- func LoadConfiguration(filepath string, loadInto *Configuration) error
- func LowerCaseWithUnderscores(name string) string
- func MapKeys(m map[string]string) []string
- func ParseYAMLHeader(descriptionRaw string) (map[string]interface{}, string)
- func ReadDescriptionFile(directory string) (string, error)
- func ReadFile(filepath string) (string, error)
- func ReadFileBytes(filepath string) ([]byte, error)
- func RegexpGroups(regex string, s string) []string
- func RegexpMatches(regex string, s string) bool
- func ReplicateAll(ctx RunContext, targetDatabase string, works []Work) error
- func ReplicateDescription(work Work) (string, error)
- func ReplicateOne(targetDatabase string, work Work) error
- func ResolveConfigurationPath(databaseDirectory string, explicitlySpecifiedConfigurationFilepath string) string
- func RunCommandAdd(args docopt.Opts) error
- func RunCommandBuild(args docopt.Opts) error
- func RunCommandReplicate(args docopt.Opts) error
- func RunCommandValidate(args docopt.Opts) error
- func SetJSONNamingStrategy(translate func(string) string)
- func StepExtractColors(metadata map[string]interface{}, project ProjectTreeElement, ...) map[string]interface{}
- func StringInSlice(haystack []string, needle string) bool
- func ValidateConfiguration(configFilepath string) (bool, []gojsonschema.ResultError, error)
- func ValidateWithJSONSchema(document string, schema string) (bool, []gojsonschema.ResultError, error)
- func WriteFile(filename string, content []byte) error
- type Abbreviation
- type Configuration
- type ExtractedColors
- type Footnote
- type ImageDimensions
- type Link
- type Media
- type MediaAttributes
- type MediaEmbedDeclaration
- type Paragraph
- type ParsedDescription
- type ProjectTreeElement
- type RunContext
- type Thumbnail
- type Work
Constants ¶
const CLIUsage = `` /* 3558-byte string literal not displayed */
CLIUsage is the entire usage string for the CLI
const ConfigurationJSONSchema = `` /* 3187-byte string literal not displayed */
ConfigurationJSONSchema is the entire json string from .portfoliodb.yml.json.schema
const DatabaseJSONSchema = `` /* 3750-byte string literal not displayed */
DatabaseJSONSchema is the entire json string from database.json.schema
Variables ¶
This section is empty.
Functions ¶
func AnalyzeAllMediae ¶
func AnalyzeAllMediae(ctx RunContext, embedDeclarations map[string][]MediaEmbedDeclaration, currentDirectory string) (map[string][]Media, error)
AnalyzeAllMediae analyzes all the mediae from ParsedDescription's MediaEmbedDeclarations and returns analyzed mediae, ready for use as Work.Media
func DisplayValidationErrors ¶
func DisplayValidationErrors(errors []gojsonschema.ResultError, name string)
DisplayValidationErrors takes in a slice of json schema validation errors and displays them nicely to in the terminal
func FileExists ¶
FileExists checks if the file at “filepath“ exists, and returns “true“ if it exists or “false“ otherwise
func FilepathBaseNoExt ¶
FilepathBaseNoExt returns the basename of pth with the extension removed
func FilterSlice ¶
FilterSlice returns a slice of strings containing only the elements that return true when called with cond.
func GetAudioDuration ¶
GetAudioDuration takes in an os.File and returns the duration of the audio file in seconds. If any error occurs the duration will be 0.
func IsValidURL ¶
IsValidURL tests a string to determine if it is a well-structured url or not.
func LoadConfiguration ¶
func LoadConfiguration(filepath string, loadInto *Configuration) error
LoadConfiguration loads the .portfoliodb.yml file in “databaseFolderPath“ and puts it contents into “loadInto“.
func LowerCaseWithUnderscores ¶
LowerCaseWithUnderscores one strategy to SetNamingStrategy for. It will change HelloWorld to hello_world.
func ParseYAMLHeader ¶
ParseYAMLHeader parses the YAML header of a description markdown file and returns the rest of the content (all except the YAML header)
func ReadDescriptionFile ¶
ReadDescriptionFile reads the description.md file in directory. Returns an empty string if the file is a directory or does not exist.
func ReadFileBytes ¶
ReadFileBytes reads the content of “filepath“ and returns the contents as a byte array
func RegexpGroups ¶
RegexpGroups returns all the capture groups' contents from the first match of regex regex in s. The first element [0] is the entire match. [1] is the first capture group's content, et cætera.
func RegexpMatches ¶
RegexpMatches checks if s matches the regex regex at least once
func ReplicateAll ¶
func ReplicateAll(ctx RunContext, targetDatabase string, works []Work) error
ReplicateAll recreates a database inside targetDatabase containing all the works in `works`
func ReplicateDescription ¶
ReplicateDescription reconstructs the contents of a description.md file from a Work struct
func ReplicateOne ¶
ReplicateOne creates a description.md file in targetDatabase in the correct folder in order to replicate Work
func ResolveConfigurationPath ¶
func ResolveConfigurationPath(databaseDirectory string, explicitlySpecifiedConfigurationFilepath string) string
ResolveConfigurationPath determines the path of the configuration file to use
func RunCommandAdd ¶
func RunCommandAdd(args docopt.Opts) error
RunCommandAdd runs the command 'add' given parsed CLI args from docopt
func RunCommandBuild ¶
func RunCommandBuild(args docopt.Opts) error
RunCommandBuild runs the command 'build' given parsed CLI args from docopt
func RunCommandReplicate ¶
func RunCommandReplicate(args docopt.Opts) error
RunCommandReplicate runs the command 'replicate' given parsed CLI args from docopt
func RunCommandValidate ¶
func RunCommandValidate(args docopt.Opts) error
RunCommandValidate runs the command 'validate' given parsed CLI args from docopt
func SetJSONNamingStrategy ¶
SetJSONNamingStrategy rename struct fields uniformly
func StepExtractColors ¶
func StepExtractColors(metadata map[string]interface{}, project ProjectTreeElement, databaseDirectory string, config Configuration) map[string]interface{}
StepExtractColors executes the step "extract colors" and returns a metadata object with the `colors` entry modified accordingly.
func StringInSlice ¶
StringInSlice checks if needle is in haystack
func ValidateConfiguration ¶
func ValidateConfiguration(configFilepath string) (bool, []gojsonschema.ResultError, error)
ValidateConfiguration uses the JSON configuration schema ConfigurationJSONSchema to validate the configuration file at configFilepath
func ValidateWithJSONSchema ¶
func ValidateWithJSONSchema(document string, schema string) (bool, []gojsonschema.ResultError, error)
ValidateWithJSONSchema checks if the JSON document “document“ conforms to the JSON schema “schema“
Types ¶
type Abbreviation ¶
Abbreviation represents an abbreviation declaration in a description.md file
type Configuration ¶
type Configuration struct { Checks checks `yaml:"checks"` ReplaceMediaSources []replaceMediaSource `yaml:"replace media sources"` // contains filtered or unexported fields }
Configuration represents what the .portfoliodb.yml configuration file describes
func GetConfiguration ¶
func GetConfiguration(filepath string) (Configuration, error)
GetConfiguration reads from the .portfoliodb.yml file in “databaseFolderPath“ and returns a “Configuration“ struct
func GetConfigurationFromCLIArgs ¶
func GetConfigurationFromCLIArgs(args docopt.Opts) (Configuration, []gojsonschema.ResultError, error)
GetConfigurationFromCLIArgs gets the configuration by using the CLI arguments
type ExtractedColors ¶
ExtractedColors reprensents the object in a Work's metadata.colors
type ImageDimensions ¶
ImageDimensions represents metadata about a media as it's extracted from its file
func GetImageDimensions ¶
func GetImageDimensions(file *os.File) (ImageDimensions, error)
GetImageDimensions returns an “ImageDimensions“ object, given a pointer to a file
func GetVideoDimensionsDurationHasSound ¶
func GetVideoDimensionsDurationHasSound(filename string) (dimensions ImageDimensions, duration uint, hasSound bool, err error)
GetVideoDimensionsDurationHasSound returns an ImageDimensions struct with the video's height, width and aspect ratio and a duration in seconds.
type Media ¶
type Media struct { ID string Alt string Title string Source string ContentType string Size uint64 // In bytes Dimensions ImageDimensions Duration uint // In seconds Online bool // Whether the media is hosted online (referred to by an URL) Attributes MediaAttributes HasSound bool // The media is either an audio file or a video file that contains an audio stream }
Media represents a media object inserted in the work object's “media“ array.
func AnalyzeMediaFile ¶
func AnalyzeMediaFile(filename string, embedDeclaration MediaEmbedDeclaration, config Configuration) (Media, error)
AnalyzeMediaFile analyzes the file at filename and returns a Media struct, merging the analysis' results with information from the matching MediaEmbedDeclaration
type MediaAttributes ¶
type MediaAttributes struct { Looped bool // Controlled with attribute character ~ (adds) Autoplay bool // Controlled with attribute character > (adds) Muted bool // Controlled with attribute character > (adds) Playsinline bool // Controlled with attribute character = (adds) Controls bool // Controlled with attribute character = (removes) }
MediaAttributes stores which HTML attributes should be added to the media
type MediaEmbedDeclaration ¶
type MediaEmbedDeclaration struct { Alt string Title string Source string Attributes MediaAttributes }
MediaEmbedDeclaration represents media embeds. (abusing the ![]() syntax to extend it to any file) Only stores the info extracted from the syntax, no filesystem interactions.
type ParsedDescription ¶
type ParsedDescription struct { Metadata map[string]interface{} Title map[string]string Paragraphs map[string][]Paragraph MediaEmbedDeclarations map[string][]MediaEmbedDeclaration Links map[string][]Link Footnotes map[string][]Footnote }
ParsedDescription represents a work, but without analyzed media. All it contains is information from the description.md file
func ParseDescription ¶
func ParseDescription(ctx RunContext, markdownRaw string) ParsedDescription
ParseDescription parses the markdown string from a description.md file and returns a ParsedDescription
type ProjectTreeElement ¶
type ProjectTreeElement struct { ID string DescriptionRaw string MediaFilepaths []string ScatteredMode bool // Whether the build was run with --scattered }
ProjectTreeElement represents a project
func BuildProjectsTree ¶
func BuildProjectsTree(databaseDirectory string) ([]ProjectTreeElement, error)
BuildProjectsTree scans databaseDirectory to return a slice of ProjectTreeElement's, gathering media files and other various information
func BuildProjectsTreeScatteredMode ¶
func BuildProjectsTreeScatteredMode(projectsDirectory string) ([]ProjectTreeElement, error)
func (*ProjectTreeElement) GetProjectPath ¶
func (p *ProjectTreeElement) GetProjectPath(databaseDirectory string) string
GetProjectPath returns the project's folder path with regard to databaseDirectory
func (*ProjectTreeElement) MediaAbsoluteFilepaths ¶
func (p *ProjectTreeElement) MediaAbsoluteFilepaths(databaseDirectory string) []string
MediaAbsoluteFilepaths is like MediaFilepaths but returns absolute paths with regard to databaseDirectory
type RunContext ¶
type RunContext struct {
// contains filtered or unexported fields
}
RunContext holds several "global" references used throughout all the functions of a command
func (*RunContext) Status ¶
func (ctx *RunContext) Status(text string)
Status prints the current compilation progress