From 6795c5cd0ad44526571c24f211c2e6fefbbe5dcf Mon Sep 17 00:00:00 2001 From: gmemstr Date: Sun, 8 Oct 2017 10:54:48 -0700 Subject: [PATCH] Starting on episode editing interface --- assets/web/static/app.js | 49 ++++++++++++++++++++++++++++++++++++++-- generate_rss.go | 4 +++- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/assets/web/static/app.js b/assets/web/static/app.js index ededadf..efe7a1f 100644 --- a/assets/web/static/app.js +++ b/assets/web/static/app.js @@ -3,7 +3,7 @@ const episodepublishform = { } const episodemanagement = { - template: '
TitleURLActions
{{ item.title }}{{ item.url }}Remove Edit
', + template: '
TitleURLActions
{{ item.title }}{{ item.url }}Edit
', data() { return { loading: false, @@ -30,8 +30,52 @@ const episodemanagement = { if (err) { this.error = err.toString() } else { + console.log(items); var t = JSON.parse(items).items for (var i = t.length - 1; i >= 0; i--) { + this.items.push({ + title: t[i].title, + url: t[i].url, + id: t[i].id + }) + } + } + }) + } + } +} + +const episodeedit = { + template: '

Edit Episode

', + data() { + return { + loading: false, + episode: null, + error: null + } + }, + created() { + // fetch the data when the view is created and the data is + // already being observed + this.fetchData() + }, + watch: { + // call again the method if the route changes + '$route': 'fetchData' + }, + methods: { + fetchData() { + this.error = this.items = [] + this.loading = true + + getEpisodes((err, items) => { + this.loading = false + if (err) { + this.error = err.toString() + } else { + var t = JSON.parse(items).items + for (var i = t.length - 1; i >= 0; i--) { + if (t[i].id == route.params.id) this.items.push({ title: t[i].title, url: t[i].url @@ -82,7 +126,8 @@ const customcss = { const routes = [ { path: '/publish', component: episodepublishform }, { path: '/manage', component: episodemanagement }, - { path: '/theme', component: customcss } + { path: '/theme', component: customcss }, + { path: '/edit/:id', component: episodeedit} ] const router = new VueRouter({ diff --git a/generate_rss.go b/generate_rss.go index 13a57e6..78a5762 100644 --- a/generate_rss.go +++ b/generate_rss.go @@ -92,7 +92,7 @@ func GenerateRss() { Created: now, Image: &feeds.Image{Url: config.Image}, } - + i := 0 for _, file := range files { if strings.Contains(file.Name(), ".mp3") { s := strings.Split(file.Name(), "_") @@ -110,6 +110,7 @@ func GenerateRss() { link := podcasturl + "/download/" + file.Name() feed.Add( &feeds.Item{ + Id: string(i), Title: title, Link: &feeds.Link{Href: link, Length: size, Type: "audio/mpeg"}, Enclosure: &feeds.Enclosure{Url: link, Length: size, Type: "audio/mpeg"}, @@ -119,6 +120,7 @@ func GenerateRss() { }, ) } + i = i + 1; } // Translate the feed to both RSS and JSON,