webindexer

package
v0.0.0-...-41dc376 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Simple program to generate index files for a directory or S3 bucket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendSetup

type BackendSetup interface {
	Setup(indexer *Indexer) error
}

type Config

type Config struct {
	BaseURL       string   `yaml:"base_url"      mapstructure:"base_url"`
	DateFormat    string   `yaml:"date_format"   mapstructure:"date_format"`
	DirsFirst     bool     `yaml:"dirs_first"    mapstructure:"dirs_first"`
	IndexFile     string   `yaml:"index_file"    mapstructure:"index_file"`
	LinkToIndexes bool     `yaml:"link_to_index" mapstructure:"link_to_index"`
	LogLevel      string   `yaml:"log_level"     mapstructure:"log_level"`
	LogFile       string   `yaml:"log_file"      mapstructure:"log_file"`
	Minify        bool     `yaml:"minify"        mapstructure:"minify"`
	Order         string   `yaml:"order"         mapstructure:"order"`
	Quiet         bool     `yaml:"quiet"         mapstructure:"quiet"`
	Recursive     bool     `yaml:"recursive"     mapstructure:"recursive"`
	Skips         []string `yaml:"skips"         mapstructure:"skips"`
	SortBy        string   `yaml:"sort_by"       mapstructure:"sort_by"`
	Source        string   `yaml:"source"        mapstructure:"source"`
	Target        string   `yaml:"target"        mapstructure:"target"`
	Template      string   `yaml:"template"      mapstructure:"template"`
	Title         string   `yaml:"title"         mapstructure:"title"`
	CfgFile       string   `yaml:"-"`
	BasePath      string   `yaml:"-"`
}

func (Config) OrderByValue

func (c Config) OrderByValue() Order

func (Config) SortByValue

func (c Config) SortByValue() SortBy

func (Config) Validate

func (c Config) Validate() error

type Data

type Data struct {
	Title        string
	Path         string
	RootPath     string
	RelativePath string
	URL          string
	Items        []Item
	Parent       string
	HasParent    bool
}

Data holds the template data.

type FileSource

type FileSource interface {
	Read(path string) ([]Item, error)
	Write(data Data, content string) error
}

FileSource is an interface for listing the contents of a directory or S3 bucket.

type Indexer

type Indexer struct {
	Cfg    Config
	Source FileSource
	Target FileSource

	BackendSetup BackendSetup
	// contains filtered or unexported fields
}

Indexer is the main struct for the webindexer package.

func New

func New(cfg Config) (*Indexer, error)

New creates a new Indexer, taking the initial configuration and returning a updating it with the service, source and target paths.

func (Indexer) Generate

func (i Indexer) Generate(path string) error

Generate the index file for the given path.

type Item

type Item struct {
	Name         string
	Size         string
	LastModified string
	URL          string
	IsDir        bool
	Items        []Item
}

Item represents an S3 key, or a local file/directory.

type LocalBackend

type LocalBackend struct {
	// contains filtered or unexported fields
}

func (*LocalBackend) Read

func (l *LocalBackend) Read(path string) ([]Item, error)

func (*LocalBackend) Write

func (l *LocalBackend) Write(data Data, content string) error

type Order

type Order string
const (
	OrderAsc  Order = "asc"
	OrderDesc Order = "desc"
)

type S3API

type S3API interface {
	ListObjectsV2(input *s3.ListObjectsV2Input) (*s3.ListObjectsV2Output, error)
	PutObject(input *s3.PutObjectInput) (*s3.PutObjectOutput, error)
}

type S3Backend

type S3Backend struct {
	// contains filtered or unexported fields
}

func (*S3Backend) Read

func (s *S3Backend) Read(prefix string) ([]Item, error)

func (*S3Backend) Write

func (s *S3Backend) Write(data Data, content string) error

type SortBy

type SortBy string
const (
	SortByDate        SortBy = "date"
	SortByName        SortBy = "name"
	SortByNaturalName SortBy = "natural_name"
)

Jump to

Keyboard shortcuts

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