2024-06-04 00:15:07 +07:00
|
|
|
package progress
|
|
|
|
|
2024-06-05 16:18:22 +07:00
|
|
|
import "time"
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
type ImageDownloadStartNotificationData struct {
|
|
|
|
ID string
|
|
|
|
Subreddit string
|
|
|
|
PostURL string
|
|
|
|
PostName string
|
|
|
|
PostTitle string
|
|
|
|
AutoRemoveDuration time.Duration
|
|
|
|
}
|
|
|
|
|
|
|
|
templ ImageDownloadStartNotification(data ImageDownloadStartNotificationData) {
|
|
|
|
<div
|
|
|
|
id={ data.ID }
|
|
|
|
if data.AutoRemoveDuration > 0 {
|
|
|
|
x-data={ fmt.Sprintf("{ init() { setTimeout(() => $el.remove(), %d) }}", data.AutoRemoveDuration.Milliseconds()) }
|
|
|
|
}
|
|
|
|
onclick="this.remove()"
|
|
|
|
class="alert alert-info hover:bg-success-content transition-all"
|
|
|
|
>
|
|
|
|
<span>
|
|
|
|
<a
|
|
|
|
target="_blank"
|
|
|
|
href={ templ.SafeURL(fmt.Sprintf("https://www.reddit.com/r/%s", data.Subreddit)) }
|
|
|
|
>{ data.Subreddit }</a>:
|
|
|
|
Start Downloading
|
|
|
|
<a href={ templ.SafeURL(data.PostURL) }>{ truncateTitle(data.PostTitle) }</a>
|
|
|
|
</span>
|
|
|
|
</div>
|
2024-06-04 00:15:07 +07:00
|
|
|
}
|
|
|
|
|
2024-06-05 16:18:22 +07:00
|
|
|
func truncateTitle(s string) string {
|
|
|
|
if len(s) > 20 {
|
|
|
|
return s[:20] + "..."
|
|
|
|
}
|
|
|
|
return s
|
2024-06-04 00:15:07 +07:00
|
|
|
}
|
|
|
|
|
2024-06-05 16:18:22 +07:00
|
|
|
type ImageDownloadEndNotificationData struct {
|
|
|
|
ID string
|
|
|
|
Subreddit string
|
|
|
|
PostURL string
|
|
|
|
PostName string
|
|
|
|
PostTitle string
|
|
|
|
AutoRemoveDuration time.Duration
|
2024-06-04 00:15:07 +07:00
|
|
|
}
|
|
|
|
|
2024-06-05 16:18:22 +07:00
|
|
|
templ ImageDownloadEndNotification(data ImageDownloadEndNotificationData) {
|
|
|
|
<div
|
|
|
|
id={ data.ID }
|
|
|
|
if data.AutoRemoveDuration > 0 {
|
|
|
|
x-data={ fmt.Sprintf("{ init() { setTimeout(() => $el.remove(), %d) }}", data.AutoRemoveDuration.Milliseconds()) }
|
|
|
|
}
|
|
|
|
onclick="this.remove()"
|
|
|
|
class="alert alert-info hover:bg-success-content transition-all"
|
|
|
|
>
|
|
|
|
<span>
|
|
|
|
<a
|
|
|
|
target="_blank"
|
|
|
|
href={ templ.SafeURL(fmt.Sprintf("https://www.reddit.com/r/%s", data.Subreddit)) }
|
|
|
|
>{ data.Subreddit }</a>:
|
|
|
|
Finished Downloading
|
|
|
|
<a href={ templ.SafeURL(data.PostURL) }>{ truncateTitle(data.PostTitle) }</a>
|
|
|
|
</span>
|
|
|
|
</div>
|
2024-06-04 00:15:07 +07:00
|
|
|
}
|