removed 'source' link from image results & fixed dynamic scrolling on image page

This commit is contained in:
partisan 2024-12-01 01:12:31 +01:00
parent ac7b468d71
commit 44e9d3356f
4 changed files with 18 additions and 21 deletions

View file

@ -273,6 +273,7 @@ func handleImageServe(w http.ResponseWriter, r *http.Request) {
resp, err := http.Get(imageURL) resp, err := http.Get(imageURL)
if err != nil { if err != nil {
printWarn("Error fetching image: %v", err) printWarn("Error fetching image: %v", err)
recordInvalidImageID(imageID)
serveMissingImage(w, r) serveMissingImage(w, r)
return return
} }
@ -311,7 +312,18 @@ func handleImageStatus(w http.ResponseWriter, r *http.Request) {
continue continue
} }
// Check for cached full or thumbnail images // Check if the image ID is marked as invalid
invalidImageIDsMu.Lock()
_, isInvalid := invalidImageIDs[id]
invalidImageIDsMu.Unlock()
if isInvalid {
// Image is invalid; inform the frontend by setting the missing image URL
statusMap[id] = "/static/images/missing.svg"
continue
}
// Existing code to check for cached images
extensions := []string{"webp", "svg"} // Extensions without leading dots extensions := []string{"webp", "svg"} // Extensions without leading dots
imageReady := false imageReady := false
@ -341,15 +353,13 @@ func handleImageStatus(w http.ResponseWriter, r *http.Request) {
} }
} }
// If neither is ready // If neither is ready and image is not invalid
if !imageReady { if !imageReady {
if !config.DriveCacheEnabled { if !config.DriveCacheEnabled {
// Hard cache is disabled; use the proxy URL // Hard cache is disabled; use the proxy URL
statusMap[id] = fmt.Sprintf("/image/%s_thumb", id) statusMap[id] = fmt.Sprintf("/image/%s_thumb", id)
} else {
// Hard cache is enabled; image is not yet cached
// Do not set statusMap[id]; the frontend will keep checking
} }
// Else, do not set statusMap[id]; the frontend will keep checking
} }
} }

View file

@ -263,7 +263,7 @@ html {
.image { .image {
flex-grow: 1; flex-grow: 1;
padding: .5rem .5rem 3rem .5rem; padding: .5rem .5rem 2rem .5rem;
margin: .25rem; margin: .25rem;
border: 1px solid #00000000; border: 1px solid #00000000;
border-radius: 12px; border-radius: 12px;
@ -311,8 +311,7 @@ html {
box-shadow: 0 14px 28px var(--view-image-color); box-shadow: 0 14px 28px var(--view-image-color);
} }
.img_title, .img_title {
.img_source {
display: block; display: block;
position: absolute; position: absolute;
width: 100%; width: 100%;
@ -328,11 +327,6 @@ html {
color: var(--blue); color: var(--blue);
} }
.img_source {
padding: 1.8rem 0 0 0;
font-size: .7rem;
}
.image img { .image img {
margin: 0; margin: 0;
padding: 0; padding: 0;
@ -726,6 +720,7 @@ hr {
background: var(--html-bg); background: var(--html-bg);
cursor: pointer; cursor: pointer;
transition: all .3s ease; transition: all .3s ease;
text-align: left;
} }
.torrent-cat:hover, .torrent-cat:hover,

View file

@ -116,7 +116,6 @@
<div class="resolution">{{ $result.Width }} × {{ $result.Height }}</div> <div class="resolution">{{ $result.Width }} × {{ $result.Height }}</div>
<div class="details"> <div class="details">
<span class="img_title clickable">{{ $result.Title }}</span> <span class="img_title clickable">{{ $result.Title }}</span>
<a href="{{ $result.Source }}" target="_blank" class="img_source">{{ translate "source" }}</a>
</div> </div>
</div> </div>
{{ end }} {{ end }}

View file

@ -1,12 +1,6 @@
{{ range $index, $result := .Results }} {{ range $index, $result := .Results }}
<div class="image"> <div class="image">
{{ if $.HardCacheEnabled }} {{ if $.HardCacheEnabled }}
<noscript>
<!-- JavaScript is disabled; serve actual images -->
<img src="{{ $result.ProxyFull }}" alt="{{ $result.Title }}" class="clickable" />
</noscript>
<!-- JavaScript is enabled; use placeholders -->
<img <img
src="/static/images/placeholder.svg" src="/static/images/placeholder.svg"
data-id="{{ $result.ID }}" data-id="{{ $result.ID }}"
@ -22,7 +16,6 @@
<div class="resolution">{{ $result.Width }} × {{ $result.Height }}</div> <div class="resolution">{{ $result.Width }} × {{ $result.Height }}</div>
<div class="details"> <div class="details">
<span class="img_title clickable">{{ $result.Title }}</span> <span class="img_title clickable">{{ $result.Title }}</span>
<a href="{{ $result.Source }}" target="_blank" class="img_source">{{ translate "source" }}</a>
</div> </div>
</div> </div>
{{ end }} {{ end }}