config

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2021 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package config provides access to the configuration models required by the rest of the modules.

Index

Constants

View Source
const (
	MetaDataFolderName     = ".allmark"
	FilesDirectoryName     = "files"
	ConfigurationFileName  = "config"
	ThemeFolderName        = "theme"
	TemplatesFolderName    = "templates"
	ThumbnailIndexFileName = "thumbnail.index"
	ThumbnailsFolderName   = "thumbnails"
	SSLCertsFolderName     = "certs"
)

Global configuration constants.

View Source
const (
	DefaultDomainName                = "localhost"
	DefaultHTTPPortEnabled           = true
	DefaultHTTPSPortEnabled          = false
	DefaultHTTPSCertName             = "cert.pem"
	DefaultHTTPSKeyName              = "cert.key"
	DefaultForceHTTPS                = false
	DefaultLanguage                  = "en"
	DefaultLogLevel                  = loglevel.Error
	DefaultIndexingEnabled           = false
	DefaultIndexingIntervalInSeconds = 60
	DefaultLiveReloadEnabled         = false
	DefaultConversionDocxEnabled     = true
	DefaultAuthenticationEnabled     = false
	DefaultUserStoreFileName         = "users.htpasswd"
)

Global default values.

View Source
const (
	DefaultConversionToolPath = "pandoc"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Analytics

type Analytics struct {
	Enabled         bool
	GoogleAnalytics GoogleAnalytics
}

Analytics defines the web-analytics parameters of the web-server.

type Authentication

type Authentication struct {
	// Enabled is flag indicating whether authentication is enabled.
	Enabled bool

	// UserStoreFileName defines the file name for the authentication user-store file (e.g. "users.htpasswd").
	UserStoreFileName string
}

Authentication contains authentication settings.

type Config

type Config struct {
	Server     Server
	Web        Web
	Conversion Conversion
	LogLevel   string
	Indexing   Indexing
	LiveReload LiveReload
	Analytics  Analytics
	// contains filtered or unexported fields
}

Config is the main configuration model for all parts of allmark.

func Default

func Default(baseFolder string) *Config

Default returns a configuration with default values for the given baseFolder.

func Get

func Get(baseFolder string) *Config

Get tries to locate a Config in the specified baseFolder and return it. If no configuration was found in the specified folder it will check the users home-directory for a Config. If no configuration was found in the supplied baseFolder and no global config in the users home-directory Get will return a default configuration.

func New

func New(baseFolder string) *Config

New creates a new configuration for the given baseFolder.

func (*Config) AuthenticationFilePath

func (config *Config) AuthenticationFilePath() string

AuthenticationFilePath returns the path of the authentication file.

func (*Config) AuthenticationIsEnabled

func (config *Config) AuthenticationIsEnabled() bool

AuthenticationIsEnabled get a flag indicating if authentication is enabled.

func (*Config) BaseFolder

func (config *Config) BaseFolder() string

BaseFolder returns the path of the base folder of the current configuration model.

func (*Config) CertificateDirectory

func (config *Config) CertificateDirectory() string

CertificateDirectory returns the path of the SSL certificates directory in the meta-data folder.

func (*Config) CertificateFilePaths

func (config *Config) CertificateFilePaths() (certificateFilePath, keyFilePath string, created bool)

CertificateFilePaths returns the SSL certificate and key file paths. If none are configured or the configured ones don't exist it will create new ones and return the paths of the newly generates certificate/key pair.

func (*Config) Filepath

func (config *Config) Filepath() string

Filepath returns the path of the serialized version of the current configuration model.

func (*Config) GetAuthenticationUserStore

func (config *Config) GetAuthenticationUserStore() auth.SecretProvider

GetAuthenticationUserStore returns a digest-access authentication secret provider function that uses the configured authentication file.

func (*Config) Load

func (config *Config) Load() (*Config, error)

Load reads the configuration-model from disk.

func (*Config) MetaDataFolder

func (config *Config) MetaDataFolder() string

MetaDataFolder returns the path of the meta-data folder.

func (*Config) Save

func (config *Config) Save() (*Config, error)

Save persists the current state of the configuration-model to disk.

func (*Config) TemplatesFolder

func (config *Config) TemplatesFolder() string

TemplatesFolder returns the path of the templates folder.

func (*Config) ThemeFolder

func (config *Config) ThemeFolder() string

ThemeFolder returns the path of the theme folder.

func (*Config) ThumbnailFolder

func (config *Config) ThumbnailFolder() string

ThumbnailFolder returns the path of the thumbnail folder.

func (*Config) ThumbnailIndexFilePath

func (config *Config) ThumbnailIndexFilePath() string

ThumbnailIndexFilePath returns the path of the thumbnail index file.

type Conversion

type Conversion struct {
	DOCX       DOCXConversion
	Thumbnails ThumbnailConversion
}

Conversion defines the rich-text and thumbnail conversion paramters.

func (Conversion) EndpointBinding

func (c Conversion) EndpointBinding() *TCPBinding

EndpointBinding returns the TCPBinding of the conversion endpoint

type DOCXConversion

type DOCXConversion struct {
	Enabled bool
}

DOCXConversion contains rich-text (DOCX) conversion parameters.

func (DOCXConversion) IsEnabled

func (docx DOCXConversion) IsEnabled() bool

IsEnabled returns a flag indicating if rich-text conversion is enabled or not. Rich-text conversion can only be enabled if the conversion tool was found in the PATH on startup.

func (DOCXConversion) Tool

func (docx DOCXConversion) Tool() string

Tool returns the path of the external rich-text conversion tool (pandoc) used to create Rich-text documents from repository items.

type GoogleAnalytics

type GoogleAnalytics struct {
	Enabled    bool
	TrackingID string
}

GoogleAnalytics contains the Google Analytics realted parameters for the web-analytics section.

type HTTP

type HTTP struct {
	Enabled  bool
	Bindings []*TCPBinding
}

HTTP contains the configuration parameters for HTTP server endpoint.

type HTTPS

type HTTPS struct {
	HTTP

	CertFileName string
	KeyFileName  string

	Force bool
}

HTTPS contains the configuration parameters for a HTTPS server endpoint.

func (*HTTPS) HTTPSIsForced

func (https *HTTPS) HTTPSIsForced() bool

HTTPSIsForced indicates whether HTTPS is forced or not.

type Indexing

type Indexing struct {
	Enabled           bool
	IntervalInSeconds int
}

Indexing defines the reindexing parameters of the repository.

type JSONSerializer

type JSONSerializer struct{}

func NewJSONSerializer

func NewJSONSerializer() *JSONSerializer

func (JSONSerializer) DeserializeConfig

func (JSONSerializer) DeserializeConfig(reader io.Reader) (*Config, error)

func (JSONSerializer) SerializeConfig

func (JSONSerializer) SerializeConfig(writer io.Writer, config *Config) error

type LiveReload

type LiveReload struct {
	Enabled bool
}

LiveReload defines the live-reload capabilities.

type Server

type Server struct {
	ThemeFolderName string
	DomainName      string
	HTTP            HTTP
	HTTPS           HTTPS
	Authentication  Authentication
}

Server contains web-server related parameters such as the domain-name, theme-folder and HTTP/HTTPs bindings.

type TCPBinding

type TCPBinding struct {
	Network string

	IP   string
	Zone string
	Port int
}

TCPBinding contains all required parameters for a tcp4 or tcp6 address binding.

func (*TCPBinding) AssignFreePort

func (binding *TCPBinding) AssignFreePort()

AssignFreePort locates a free port and assigns it the the current binding.

func (*TCPBinding) GetTCPAddress

func (binding *TCPBinding) GetTCPAddress() net.TCPAddr

GetTCPAddress returns a net.TCPAddress object of the current TCP binding.

func (*TCPBinding) String

func (binding *TCPBinding) String() string

type ThumbnailConversion

type ThumbnailConversion struct {
	Enabled       bool
	IndexFileName string
	FolderName    string
}

ThumbnailConversion defines the image-thumbnail conversion capabilities.

type UserInformation

type UserInformation struct {
	Name  string
	Email string
	URL   string

	GooglePlusHandle string
	TwitterHandle    string
	FacebookHandle   string
}

UserInformation contains user-related properties such as the Name and Email address.

type Web

type Web struct {
	DefaultLanguage string
	DefaultAuthor   string
	Publisher       UserInformation
	Authors         map[string]UserInformation
}

Web contains all web-site related properties such as the language, authors and publisher information.

Jump to

Keyboard shortcuts

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