9 Commits

Author SHA1 Message Date
mae
93673cb359 cmd/pkgserver: api versioning 2026-03-10 02:47:29 -05:00
mae
5267455e59 cmd/pkgserver: add get endpoint 2026-03-10 02:47:29 -05:00
mae
15d8780d7a cmd/pkgserver: add count endpoint and restructure 2026-03-10 02:47:29 -05:00
mae
7641e1baa7 cmd/pkgserver: add status endpoint 2026-03-10 02:47:29 -05:00
mae
18e0cd1b0a cmd/pkgserver: add createPackageIndex 2026-03-10 02:47:29 -05:00
mae
11069bd103 cmd/pkgserver: add command handler 2026-03-10 02:47:29 -05:00
mae
02de87f9aa cmd/pkgserver: replace favicon 2026-03-05 01:12:17 -06:00
mae
5b8c7a87a9 cmd/pkgserver: pagination 2026-03-05 00:32:25 -06:00
mae
8d6ad63e5e cmd/pkgserver: basic web ui 2026-03-04 22:50:58 -06:00
3 changed files with 105 additions and 0 deletions

View File

69
internal/azalea/azalea.go Normal file
View File

@@ -0,0 +1,69 @@
//go:generate gocc -a azalea.bnf
package azalea
import (
"io"
"io/fs"
"os"
"path/filepath"
"strconv"
"strings"
"hakurei.app/container/check"
)
type Parser struct {
Generator
}
func NewParser(gen Generator) *Parser {
return &Parser{
Generator: gen,
}
}
func (p Parser) Initialise() {
}
func (p Parser) Consume(ns string, file io.Reader) error {
return nil
}
// ConsumeDir walks a directory and consumes all Azalea source files within it and all its subdirectories, as long as they end with the .az extension.
func (p Parser) ConsumeDir(dir *check.Absolute) error {
ds := dir.String()
return filepath.WalkDir(ds, func(path string, d fs.DirEntry, err error) (e error) {
if err != nil {
return err
}
if d.IsDir() || !strings.HasSuffix(d.Name(), ".az") {
return
}
rel, e := filepath.Rel(ds, path)
ns := strings.TrimSuffix(rel, ".az")
f, e := os.Open(path)
return p.Consume(ns, f)
})
}
// ConsumeAll consumes all provided readers as Azalea source code, each given the namespace `r%d` where `%d` is the index of the reader in the provided arguments.
func (p Parser) ConsumeAll(in ...io.Reader) error {
for i, r := range in {
err := p.Consume("r"+strconv.FormatInt(int64(i), 10), r)
if err != nil {
return err
}
}
return nil
}
// ConsumeStrings consumes all provided strings as Azalea source code, each given the namespace `s%d` where `%d` is the index of the string in the provided arugments.
func (p Parser) ConsumeStrings(in ...string) error {
for i, s := range in {
err := p.Consume("s"+strconv.FormatInt(int64(i), 10), strings.NewReader(s))
if err != nil {
return err
}
}
return nil
}

View File

@@ -0,0 +1,36 @@
package azalea
import (
"io"
)
type Generator interface {
Finalise() (error, io.Writer)
}
type JsonGenerator struct {
t any
}
func NewJsonGenerator[T any]() JsonGenerator {
t := new(T)
return JsonGenerator{
t,
}
}
func (j *JsonGenerator) Finalise() (error, io.Writer) {
}
type PkgIRGenerator struct {
}
func NewPkgIRGenerator() PkgIRGenerator {
return PkgIRGenerator{}
}
func (p *PkgIRGenerator) Finalise() (error, io.Writer) {
}