pdfrender

package
v0.0.0-...-e5131f1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurrentUrlState

type CurrentUrlState struct {
	// IsMD is set when the url ends with .md
	// it is set iteratively everytime a url is processed
	IsMD                 bool
	CurrentURLProperties *urlproperties.URLProperties
}

type DirVisited

type DirVisited struct {
	// the indexed path for this dir
	IndexedDirPath string
	// the no. of items currently in this dir
	ItemCount int8
	// the complex index like i01-03-01 is carried from parent directory,
	// that needs to be available for sending to create the item in this dir.
	DirIndex string
}

DirVisited allows you to save below information for multiple urls not just for caching purpose, but also for to keep track of info for created dirs

type Mod

type Mod struct {
	// a book name when compiling books
	BookName string
	// the base url to be taken away as prefix from the urls' paths
	BaseDir string
	// this file is merged with global css rules and passed to wkhtmltopdf
	CssOverrideFile string
	// a rune, to mark the current running set of files & dirs, that will be
	// differentiated from the past available files &dirs
	HistPointer string
	// these options are passed to the wkhtmltopdf object
	// could be used for overriding default ones in this repository
	ObjectOptions *json.RawMessage
	// these options are passed to the wkhtmltopdf converter
	// could be used for overriding default ones in this repository
	ConverterOptions     *json.RawMessage
	PropertiesFiles      []string
	IndexedBookmarkNames bool
	DisableBookGen       bool
	State                CurrentUrlState
	// contains filtered or unexported fields
}

func GetMod

func GetMod(modFilePath string) (m *Mod, err error)

GetMod prepares the Mod struct from mod json file provided

func (*Mod) GetDirVisited

func (m *Mod) GetDirVisited() (err error)

GetDirVisited tries a lookup for locally stored .gob file that holds the index for already existing pdf files.

func (*Mod) GetFilePath

func (m *Mod) GetFilePath(webUrl string) (filePath string, err error)

GetFilePath wraps away the logic to provide & create indexed dir from the url path or url fragment

func (*Mod) GetIndexedDir

func (m *Mod) GetIndexedDir(rawDir string) (indexedCurrentDir, indexForNewItem string, err error)

GetIndexedDir recursively iterate through each subDir in the dirPath to return the indexedPath for the respective raw input path, along with a new index to be given to a file to be created in that indexedDir. It takes care for maintaining a cache of it's results, to save calls to subDir that have already been visited and also peeks from that cache first, before doing iteration on it.

func (*Mod) GetIndexedFilePath

func (m *Mod) GetIndexedFilePath(rawPath string) (indexedCurrentFilePath string, err error)

func (*Mod) GetRawFilePath

func (m *Mod) GetRawFilePath(webPageUrl string) (filePath string, err error)

GetRawFilePath takes the Url to be rendered and extracts the final rawPath either from url path or fragment returns the dir in which the pdf be created and the name of the pdf file.

func (*Mod) SaveDirVisited

func (m *Mod) SaveDirVisited() (err error)

SaveDirVisited does exactly opposite it does the saving for the file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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