Skip to content

Commit

Permalink
fix: vips stacktrase printing and navigation path items truncating
Browse files Browse the repository at this point in the history
  • Loading branch information
alxarno committed Dec 19, 2024
1 parent 454e098 commit 0789f52
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 4 deletions.
2 changes: 1 addition & 1 deletion e2e/dir.fixture
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<li class="breadcrumb-item"><a href="/">Home</a></li>

<li class="breadcrumb-item active" aria-current="page">video</li>
<li class="breadcrumb-item active" aria-current="page"><span>video</span></li>

</ol>
</li>
Expand Down
2 changes: 1 addition & 1 deletion e2e/search.fixture
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<li class="breadcrumb-item"><a href="/">Home</a></li>

<li class="breadcrumb-item active" aria-current="page">Search</li>
<li class="breadcrumb-item active" aria-current="page"><span>Search</span></li>

</ol>
</li>
Expand Down
2 changes: 1 addition & 1 deletion internal/crawler_os_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ func TestCrawlerOS(t *testing.T) {

files, err := NewCrawlerOS("../test").Scan("../test/index.tinytune")
require.NoError(err)
require.Len(files, 17)
require.Len(files, 20)
}
8 changes: 8 additions & 0 deletions pkg/preview/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log/slog"
"runtime"
"strings"

"github.com/davidbyttow/govips/v2/vips"
)
Expand Down Expand Up @@ -76,6 +77,13 @@ func downScale(image *vips.ImageRef, imageType int) ([]byte, error) {

bytes, _, err := image.ExportWebp(ep)
if err != nil {
// vips return stack traces for some corrupted files, so let's just hide stack trace
if strings.Contains(err.Error(), "Stack") {
errorMsg := strings.Split(err.Error(), "\n")
//nolint:err113
return nil, fmt.Errorf("%w: %w", ErrImageExport, errors.New(errorMsg[0]))
}

return nil, fmt.Errorf("%w: %w", ErrImageExport, err)
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions web/scss/_navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,59 @@
margin-bottom: 2px;
}

#navbarSupportedContent{
min-width: 0;

> :first-child{
min-width: inherit;

> :first-child{
min-width: inherit;
}
}

}

.breadcrumb{
padding-right: 1rem;
flex-direction: row;
flex-wrap: nowrap;
flex-shrink: 0;

> :first-child {
flex-shrink: 1;
}
> :not(:first-child){
flex-shrink: 2;

> a,
> span {
text-overflow: ellipsis;
white-space: nowrap;
overflow:hidden;
}
}
}


.breadcrumb-item{
display: contents;
flex-basis: auto;
width: auto;
}

@include media-breakpoint-down(lg) {
.breadcrumb{
margin: 1rem 0;
flex-direction: column;

> .breadcrumb-item{
display: flex;
-webkit-box-orient: horizontal;
padding-left: 0;
}
}

.additional-actions{
margin: 1rem auto;
margin-top: 1.5rem;
Expand Down
2 changes: 1 addition & 1 deletion web/templates/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{ $length := len .Path }}{{ if eq $length 0 }}<li class="breadcrumb-item active" aria-current="page">Home</li>{{ else }}
<li class="breadcrumb-item"><a href="/">Home</a></li>{{ end }}
{{ range $i, $e := .Path }}
{{if eqMinusOne $i $length}}<li class="breadcrumb-item active" aria-current="page">{{ $e.Name }}</li> {{ else }}<li class="breadcrumb-item"><a href="/d/{{ $e.ID }}">{{ $e.Name }}</a></li> {{ end }}
{{if eqMinusOne $i $length}}<li class="breadcrumb-item active" aria-current="page"><span>{{ $e.Name }}</span></li> {{ else }}<li class="breadcrumb-item"><a href="/d/{{ $e.ID }}">{{ $e.Name }}</a></li> {{ end }}
{{ end }}
</ol>
</li>
Expand Down

0 comments on commit 0789f52

Please sign in to comment.