Your ROOT_URL in app.ini is https://git.cloudchain.link/ but you are visiting https://dash.bss.nz/open-source-mirrors/podgrab/commit/ca8a118702ae48df42801cae23ce474c6aa5a695
You should set ROOT_URL correctly, otherwise the web may not work correctly.
7 changed files with
95 additions and
1 deletions
@ -7,6 +7,7 @@
/>
< link rel = "stylesheet" href = "/webassets/fa/fontawesome.min.css" / >
< link rel = "stylesheet" href = "/webassets/fa/solid.min.css" / >
< link rel = "stylesheet" href = "/webassets/fa/regular.min.css" / >
{{if .setting.DarkMode}}
< style >
@ -109,7 +109,26 @@
onclick="changePlayedStatus('{{.ID}}',{{ not .IsPlayed }})"
>< i class = "fas fa-envelope-open" > < /i
>< / a >
{{ end }} {{if .DownloadPath}}
{{ end }}
{{if isDateNull .BookmarkDate }}
< a
class="button button"
title="Bookmark Episode"
onclick="changeBookmarkStatus('{{.ID}}',true)"
>< i class = "far fa-bookmark" > < /i
>< / a >
{{ else }}
< a
class="button button"
title="Remove Bookmark"
onclick="changeBookmarkStatus('{{.ID}}',false)"
>< i class = "fas fa-bookmark" > < /i
>< / a >
{{ end }}
{{if .DownloadPath}}
< a
class="button"
href="{{ .DownloadPath }}"
@ -268,6 +287,36 @@
.then(function () {});
return false;
}
function changeBookmarkStatus(id, status) {
let endpoint = status ? "bookmark" : "unbookmark";
axios
.get("/podcastitems/" + id + "/" + endpoint, {
isPlayed: status,
})
.then(function (response) {
msg= status?"Bookmark Added": "Bookmark removed";
Vue.toasted.show(msg, {
theme: "bubble",
type: "info",
position: "top-right",
duration: 5000,
});
var row = document.getElementById("podcast-" + id);
row.remove();
})
.catch(function (error) {
if (error.response) {
Vue.toasted.show(error.response.data?.message, {
theme: "bubble",
type: "error",
position: "top-right",
duration: 5000,
});
}
})
.then(function () {});
return false;
}
< / script >
< script >
@ -204,6 +204,24 @@ func MarkPodcastItemAsPlayed(c *gin.Context) {
c . JSON ( http . StatusBadRequest , gin . H { "error" : "Invalid request" } )
}
}
func BookmarkPodcastItem ( c * gin . Context ) {
var searchByIdQuery SearchByIdQuery
if c . ShouldBindUri ( & searchByIdQuery ) == nil {
service . SetPodcastItemBookmarkStatus ( searchByIdQuery . Id , true )
} else {
c . JSON ( http . StatusBadRequest , gin . H { "error" : "Invalid request" } )
}
}
func UnbookmarkPodcastItem ( c * gin . Context ) {
var searchByIdQuery SearchByIdQuery
if c . ShouldBindUri ( & searchByIdQuery ) == nil {
service . SetPodcastItemBookmarkStatus ( searchByIdQuery . Id , false )
} else {
c . JSON ( http . StatusBadRequest , gin . H { "error" : "Invalid request" } )
}
}
func PatchPodcastItemById ( c * gin . Context ) {
var searchByIdQuery SearchByIdQuery
@ -50,6 +50,8 @@ type PodcastItem struct {
DownloadStatus DownloadStatus ` gorm:"default:0" `
IsPlayed bool ` gorm:"default:false" `
BookmarkDate time . Time
}
type DownloadStatus int
@ -34,6 +34,9 @@ func main() {
r . Use ( setupSettings ( ) )
funcMap := template . FuncMap {
"isDateNull" : func ( raw time . Time ) bool {
return raw == ( time . Time { } )
} ,
"formatDate" : func ( raw time . Time ) string {
if raw == ( time . Time { } ) {
return ""
@ -117,6 +120,8 @@ func main() {
router . GET ( "/podcastitems/:id" , controllers . GetPodcastItemById )
router . GET ( "/podcastitems/:id/markUnplayed" , controllers . MarkPodcastItemAsUnplayed )
router . GET ( "/podcastitems/:id/markPlayed" , controllers . MarkPodcastItemAsPlayed )
router . GET ( "/podcastitems/:id/bookmark" , controllers . BookmarkPodcastItem )
router . GET ( "/podcastitems/:id/unbookmark" , controllers . UnbookmarkPodcastItem )
router . PATCH ( "/podcastitems/:id" , controllers . PatchPodcastItemById )
router . GET ( "/podcastitems/:id/download" , controllers . DownloadPodcastItem )
router . GET ( "/podcastitems/:id/delete" , controllers . DeletePodcastItem )
@ -301,6 +301,20 @@ func SetPodcastItemAsQueuedForDownload(id string) error {
return db . UpdatePodcastItem ( & podcastItem )
}
func SetPodcastItemBookmarkStatus ( id string , bookmark bool ) error {
var podcastItem db . PodcastItem
err := db . GetPodcastItemById ( id , & podcastItem )
if err != nil {
return err
}
if bookmark {
podcastItem . BookmarkDate = time . Now ( )
} else {
podcastItem . BookmarkDate = time . Time { }
}
return db . UpdatePodcastItem ( & podcastItem )
}
func SetPodcastItemAsDownloaded ( id string , location string ) error {
var podcastItem db . PodcastItem
err := db . GetPodcastItemById ( id , & podcastItem )
@ -0,0 +1,5 @@
/ * !
* Font Awesome Free 5 . 15 . 2 by @ fontawesome - https : / / fontawesome . com
* License - https : / / fontawesome . com / license / free ( Icons : CC BY 4 . 0 , Fonts : SIL OFL 1 . 1 , Code : MIT License )
* /
@ font-face { font-family : "Font Awesome 5 Free" ; font-style : normal ; font-weight : 400 ; font-display : block ; src : url ( . . / webfonts / fa-regular-400 . eot ) ; src : url ( . . / webfonts / fa-regular-400 . eot ? # iefix ) format ( "embedded-opentype" ) , url ( . . / webfonts / fa-regular-400 . woff2 ) format ( "woff2" ) , url ( . . / webfonts / fa-regular-400 . woff ) format ( "woff" ) , url ( . . / webfonts / fa-regular-400 . ttf ) format ( "truetype" ) , url ( . . / webfonts / fa-regular-400 . svg # fontawesome ) format ( "svg" ) } . far { font-family : "Font Awesome 5 Free" ; font-weight : 400 }