datasite

package
v0.8.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	SettingsFileName = "settings.yaml"
)

Variables

View Source
var (
	ErrSubdomainNotFound = errors.New("subdomain not found")
	ErrEmailNotFound     = errors.New("email not found")
)
View Source
var (
	ErrNoSettingsYAML = errors.New("no settings.yaml found")
)
View Source
var (
	PathSep = string(filepath.Separator)
)

Functions

func CleanPath

func CleanPath(path string) string

CleanPath returns a path with leading and trailing slashes removed

func EmailToSubdomainHash added in v0.6.1

func EmailToSubdomainHash(email string) string

EmailToSubdomainHash generates a subdomain-safe hash from an email address

func GetOwner

func GetOwner(path string) string

GetOwner extracts the owner from the datasite path

func IsOwner

func IsOwner(path string, user string) bool

IsOwner checks if the user is the owner of the path The underlying assumption here is that owner is the prefix of the path

func IsValidDatasite

func IsValidDatasite(user string) bool

func IsValidPath

func IsValidPath(path string) bool

IsValidPath checks if the path is a valid datasite path i.e. must start with a datasite email followed by a slash

func IsValidRelPath added in v0.6.1

func IsValidRelPath(path string) bool

Types

type BlobError

type BlobError struct {
	Key   string `json:"key"`
	Error string `json:"error"`
}

type BlobURL added in v0.6.1

type BlobURL struct {
	Key string `json:"key"`
	Url string `json:"url"`
}

type DatasiteService

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

func NewDatasiteService

func NewDatasiteService(blobSvc blob.Service, aclSvc *acl.ACLService, domain string) *DatasiteService

func (*DatasiteService) GetSubdomainMapping added in v0.6.1

func (d *DatasiteService) GetSubdomainMapping() *SubdomainMapping

GetSubdomainMapping returns the subdomain mapping service

func (*DatasiteService) GetView

func (d *DatasiteService) GetView(user string) []*blob.BlobInfo

func (*DatasiteService) ReloadVanityDomains added in v0.6.1

func (d *DatasiteService) ReloadVanityDomains(email string) error

ReloadVanityDomains reloads vanity domain configurations for a specific email

func (*DatasiteService) Shutdown

func (d *DatasiteService) Shutdown(ctx context.Context) error

func (*DatasiteService) Start

func (d *DatasiteService) Start(ctx context.Context) error

type SettingsYAML added in v0.6.1

type SettingsYAML struct {
	VanityDomains map[string]string `yaml:"domains"`
}

SettingsYAML represents the structure of a settings.yaml file

func ParseSettingsYAML added in v0.6.1

func ParseSettingsYAML(r io.Reader) (*SettingsYAML, error)

ParseSettingsYAML parses a settings.yaml file from a reader

type SubdomainMapping added in v0.6.1

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

SubdomainMapping handles bidirectional mapping between email hashes and emails

func NewSubdomainMapping added in v0.6.1

func NewSubdomainMapping() *SubdomainMapping

NewSubdomainMapping creates a new subdomain mapping service

func (*SubdomainMapping) AddMapping added in v0.6.1

func (s *SubdomainMapping) AddMapping(email string) string

AddMapping adds a mapping between an email and its hash

func (*SubdomainMapping) AddVanityDomain added in v0.6.1

func (s *SubdomainMapping) AddVanityDomain(domain string, email string, path string)

AddVanityDomain adds a vanity domain mapping

func (*SubdomainMapping) ClearVanityDomains added in v0.6.1

func (s *SubdomainMapping) ClearVanityDomains(email string)

ClearVanityDomains clears all vanity domain mappings for a specific email

func (*SubdomainMapping) GetAllMappings added in v0.6.1

func (s *SubdomainMapping) GetAllMappings() map[string]string

GetAllMappings returns all current mappings

func (*SubdomainMapping) GetAllVanityDomains added in v0.6.1

func (s *SubdomainMapping) GetAllVanityDomains() map[string]*VanityDomainConfig

GetAllVanityDomains returns all vanity domain mappings

func (*SubdomainMapping) GetEmailByHash added in v0.6.1

func (s *SubdomainMapping) GetEmailByHash(hash string) (string, error)

GetEmailByHash returns the email for a given hash

func (*SubdomainMapping) GetHashByEmail added in v0.6.1

func (s *SubdomainMapping) GetHashByEmail(email string) (string, error)

GetHashByEmail returns the hash for a given email

func (*SubdomainMapping) GetMapping added in v0.6.1

func (s *SubdomainMapping) GetMapping(domain string) *VanityDomainConfig

GetMapping returns the mapping for a domain (unified method for both hash and vanity domains)

func (*SubdomainMapping) GetVanityDomain added in v0.6.1

func (s *SubdomainMapping) GetVanityDomain(domain string) (*VanityDomainConfig, bool)

GetVanityDomain returns the configuration for a vanity domain

func (*SubdomainMapping) HasDatasite added in v0.6.1

func (s *SubdomainMapping) HasDatasite(email string) bool

HasDatasite checks if a datasite (email) is already in the mapping

func (*SubdomainMapping) LoadMappings added in v0.6.1

func (s *SubdomainMapping) LoadMappings(emails []string)

LoadMappings loads mappings from a list of emails (e.g., from datasites)

func (*SubdomainMapping) RemoveMapping added in v0.6.1

func (s *SubdomainMapping) RemoveMapping(email string)

RemoveMapping removes a mapping by email

func (*SubdomainMapping) RemoveVanityDomain added in v0.6.1

func (s *SubdomainMapping) RemoveVanityDomain(domain string)

RemoveVanityDomain removes a vanity domain mapping

type VanityDomainConfig added in v0.6.1

type VanityDomainConfig struct {
	Email string
	Path  string // Custom path within the datasite (e.g., "/blog", "/portfolio/2024")
}

VanityDomainConfig stores the configuration for a vanity domain

Jump to

Keyboard shortcuts

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