Skip to content

Commit

Permalink
So I heard you like zips, so I put a zip in you zip in your zip in yo…
Browse files Browse the repository at this point in the history
…ur zip
  • Loading branch information
EduardoOliveira committed Sep 22, 2024
1 parent abef050 commit 71331dd
Show file tree
Hide file tree
Showing 25 changed files with 367 additions and 599 deletions.
3 changes: 2 additions & 1 deletion cmd/command/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"flag"
"fmt"
"log"
Expand Down Expand Up @@ -71,7 +72,7 @@ func main() {

r.Mount("/lib", libH)

l.ScanAsync()
l.ScanAsync(context.Background())

slog.Info("Starting agent")

Expand Down
3 changes: 2 additions & 1 deletion cmd/desktop/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"embed"
"flag"
"log"
Expand Down Expand Up @@ -70,7 +71,7 @@ func main() {

r.Mount("/lib", libH)

l.ScanAsync()
l.ScanAsync(context.Background())

slog.Info("Starting agent")

Expand Down
218 changes: 109 additions & 109 deletions frontend/public/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,113 @@
*, ::before, ::after {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
--tw-contain-size: ;
--tw-contain-layout: ;
--tw-contain-paint: ;
--tw-contain-style: ;
}

::backdrop {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
--tw-contain-size: ;
--tw-contain-layout: ;
--tw-contain-paint: ;
--tw-contain-style: ;
}

/*
! tailwindcss v3.4.10 | MIT License | https://tailwindcss.com
! tailwindcss v3.4.12 | MIT License | https://tailwindcss.com
*/

/*
Expand Down Expand Up @@ -650,114 +758,6 @@ html {
--bc: 74.6477% 0.0216 264.435964;
}

*, ::before, ::after {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
--tw-contain-size: ;
--tw-contain-layout: ;
--tw-contain-paint: ;
--tw-contain-style: ;
}

::backdrop {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
--tw-contain-size: ;
--tw-contain-layout: ;
--tw-contain-paint: ;
--tw-contain-style: ;
}

.alert {
display: grid;
width: 100%;
Expand Down
11 changes: 7 additions & 4 deletions v2/library/discovery/discovery.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package discovery

import (
"context"
"io/fs"
"log/slog"
"path/filepath"
Expand All @@ -18,6 +19,7 @@ type discProc struct {
discoverer *Discoverer
l *slog.Logger
fs libfs.LibFS
ctx context.Context
}

type Discoverer struct {
Expand All @@ -34,11 +36,12 @@ func New(p *process.Processor, r *repo.AssetRepo) *Discoverer {
}
}

func (d Discoverer) DiscoverFS(fs libfs.LibFS) *discProc {
func (d Discoverer) DiscoverFS(ctx context.Context, fs libfs.LibFS) *discProc {
dp := &discProc{
discoverer: &d,
l: d.l.With("fs", fs.GetName()),
fs: fs,
ctx: ctx,
}

return dp
Expand All @@ -55,7 +58,7 @@ func (d *discProc) processPath(currFS libfs.LibFS, path string, parent *entities
return nil, err
}

asset = entities.NewAsset(currFS, path, pathInfo.IsDir(), parent)
asset = entities.NewAsset(currFS.(entities.LibFS), path, pathInfo.IsDir(), parent)

asset.SeenOnScan = utils.Ptr(true)

Expand All @@ -69,7 +72,7 @@ func (d *discProc) processPath(currFS libfs.LibFS, path string, parent *entities
innerFS := currFS
var files []fs.DirEntry
if libfs.IsBundle(path) {
innerFS, err = libfs.GetBundleFS(currFS, path)
innerFS, err = libfs.GetBundleFS(d.ctx, currFS, *asset)
if err != nil {
return nil, err
}
Expand All @@ -93,7 +96,7 @@ func (d *discProc) processPath(currFS libfs.LibFS, path string, parent *entities
}
}
if !pathInfo.IsDir() || (!libfs.IsBundle(path) || config.Cfg.Library.RenderBundles) {
d.discoverer.processor.Process(asset)
d.discoverer.processor.Process(d.ctx, asset)
}

return asset, nil
Expand Down
4 changes: 3 additions & 1 deletion v2/library/downloader/downloader.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package downloader

import (
"context"
"strings"

"github.com/eduardooliveira/stLib/v2/library/downloader/thingiverse"
Expand All @@ -10,6 +11,7 @@ import (
)

type DownloadInput struct {
Ctx context.Context
Parent entities.Asset
URL string
Repo *repo.AssetRepo
Expand All @@ -23,7 +25,7 @@ func Download(input DownloadInput) error {

for _, url := range urls {
if strings.Contains(url, "thingiverse.com") || strings.Contains(url, "thing:") {
td, err := thingiverse.New(input.Repo, input.Processor)
td, err := thingiverse.New(input.Ctx, input.Repo, input.Processor)
if err != nil {
return err
}
Expand Down
10 changes: 6 additions & 4 deletions v2/library/downloader/thingiverse/thingiverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
)

type ThingyDownloader struct {
ctx context.Context
l *slog.Logger
token string
r *repo.AssetRepo
Expand All @@ -36,8 +37,9 @@ type ThingyDownloader struct {

var matcher = regexp.MustCompile(`thing:(\d+)`)

func New(r *repo.AssetRepo, p *process.Processor) (*ThingyDownloader, error) {
func New(ctx context.Context, r *repo.AssetRepo, p *process.Processor) (*ThingyDownloader, error) {
rtn := &ThingyDownloader{
ctx: ctx,
l: slog.With("module", "thingiverse"),
token: config.Cfg.Integrations.Thingiverse.Token,
r: r,
Expand Down Expand Up @@ -76,7 +78,7 @@ func (t *ThingyDownloader) Fetch(url string, parent entities.Asset) error {
return fmt.Errorf("creating folder: %v", err)
}

t.asset = entities.NewAsset(t.fSys, path, true, &parent)
t.asset = entities.NewAsset(t.fSys.(entities.LibFS), path, true, &parent)
t.asset.Label = utils.Ptr(t.thing.Name)
t.asset.Description = utils.Ptr(t.thing.Description)

Expand Down Expand Up @@ -204,11 +206,11 @@ func (t ThingyDownloader) fetchImages() error {
}

func (t ThingyDownloader) processFile(name string) error {
i := entities.NewAsset(t.fSys, filepath.Join(*t.asset.Path, name), false, t.asset)
i := entities.NewAsset(t.fSys.(entities.LibFS), filepath.Join(*t.asset.Path, name), false, t.asset)
if err := t.r.SaveAsset(*i); err != nil {
return fmt.Errorf("saving asset: %v", err)
}
return t.p.Process(i).Wait()
return t.p.Process(t.ctx, i).Wait()
}

type ThingImage struct {
Expand Down
Loading

0 comments on commit 71331dd

Please sign in to comment.