fetch

package
v0.7.1-beta Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsURL

func IsURL(input string) bool

IsURL checks if the input looks like a URL

func ValidateFilename

func ValidateFilename(name string) error

ValidateFilename checks if a generated filename is acceptable Returns an error if the filename looks like an ID or is otherwise unsuitable

Types

type CVResult

type CVResult struct {
	URL        string `json:"url"`
	OutputPath string `json:"output_path"`
	Name       string `json:"name,omitempty"`
	Label      string `json:"label,omitempty"`
	Size       int    `json:"content_size"`
}

CVResult contains the result of a CV fetch operation

type FetchResult

type FetchResult struct {
	URL         string `json:"url"`
	OutputPath  string `json:"output_path"`
	Company     string `json:"company"`
	Position    string `json:"position"`
	ContentSize int    `json:"content_size"`
}

FetchResult contains the result of a fetch operation

type FetchType

type FetchType int

FetchType indicates what kind of content to fetch

const (
	FetchTypeJobPosting FetchType = iota
	FetchTypeCV
)

func DetectFetchType

func DetectFetchType(input string) FetchType

DetectFetchType determines whether the input should be fetched as a CV or job posting. Rules: - Bare domain (no path after domain) → CV fetch - Explicit /cv.json path → CV fetch - Everything else → Job posting fetch

type Fetcher

type Fetcher struct {
	Client    *http.Client
	OutputDir string
}

Fetcher handles fetching and saving job postings from URLs

func NewFetcher

func NewFetcher(outputDir string) *Fetcher

NewFetcher creates a new Fetcher instance

func (*Fetcher) ExtractJobPosting

func (f *Fetcher) ExtractJobPosting(html string, parsedURL *url.URL) (content, company, position string)

ExtractJobPosting extracts job posting content from HTML based on the job board

func (*Fetcher) Fetch

func (f *Fetcher) Fetch(rawURL string, outputName string) (*FetchResult, error)

Fetch downloads a job posting from a URL and saves it to the output directory

func (*Fetcher) FetchCV

func (f *Fetcher) FetchCV(input string) (*CVResult, error)

FetchCV downloads a CV (JSON Resume) from a domain and saves it to local/cv.json The input can be: - A bare domain: "cello.design" → fetches https://cello.design/cv.json - A full URL: "https://example.com/cv.json" → fetches as-is

func (*Fetcher) FormatOutput

func (f *Fetcher) FormatOutput(content, sourceURL, company, position string) string

FormatOutput creates the final markdown output with metadata

func (*Fetcher) GenerateFilename

func (f *Fetcher) GenerateFilename(company, position string, parsedURL *url.URL) (string, error)

GenerateFilename creates a filename from company and position Returns an error if no valid descriptive filename can be generated

Jump to

Keyboard shortcuts

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