Add non-root url path support

This commit is contained in:
hcl
2021-01-25 17:52:15 +08:00
committed by nkanaev
parent 63b265fa04
commit 4f79c919f0
6 changed files with 97 additions and 54 deletions

View File

@@ -90,12 +90,12 @@
Import
</label>
</b-dropdown-form>
<b-dropdown-item href="/opml/export">
<b-dropdown-item href="./opml/export">
<span class="icon mr-1">{% inline "upload.svg" %}</span>
Export
</b-dropdown-item>
<b-dropdown-divider v-if="authenticated"></b-dropdown-divider>
<b-dropdown-item-button v-if="authenticated">
<b-dropdown-item-button v-if="authenticated" @click="logout()">
<span class="icon mr-1">{% inline "log-out.svg" %}</span>
Log out
</b-dropdown-item-button>
@@ -137,7 +137,7 @@
<input type="radio" name="feed" :value="'feed:'+feed.id" v-model="feedSelected">
<div class="selectgroup-label d-flex align-items-center w-100">
<span class="icon mr-2" v-if="!feed.has_icon">{% inline "rss.svg" %}</span>
<span class="icon mr-2" v-else><img v-lazy="'/api/feeds/'+feed.id+'/icon'" alt=""></span>
<span class="icon mr-2" v-else><img v-lazy="'./api/feeds/'+feed.id+'/icon'" alt=""></span>
<span class="flex-fill text-left text-truncate">{{ feed.title }}</span>
<span class="counter text-right">{{ filteredFeedStats[feed.id] || '' }}</span>
</div>
@@ -334,7 +334,7 @@
<div v-for="feed in folder.feeds" class="list-row d-flex align-items-center" :key="feed.id">
<div class="w-100 text-truncate">
<span class="icon mr-2" v-if="!feed.has_icon">{% inline "rss.svg" %}</span>
<span class="icon mr-2" v-else><img v-lazy="'/api/feeds/'+feed.id+'/icon'" alt=""></span>
<span class="icon mr-2" v-else><img v-lazy="'./api/feeds/'+feed.id+'/icon'" alt=""></span>
{{ feed.title }}
</div>
<span class="icon flex-shrink-0 mx-2"

View File

@@ -26,74 +26,74 @@
window.api = {
feeds: {
list: function() {
return api('get', '/api/feeds').then(json)
return api('get', './api/feeds').then(json)
},
create: function(data) {
return api('post', '/api/feeds', data).then(json)
return api('post', './api/feeds', data).then(json)
},
update: function(id, data) {
return api('put', '/api/feeds/' + id, data)
return api('put', './api/feeds/' + id, data)
},
delete: function(id) {
return api('delete', '/api/feeds/' + id)
return api('delete', './api/feeds/' + id)
},
list_items: function(id) {
return api('get', '/api/feeds/' + id + '/items').then(json)
return api('get', './api/feeds/' + id + '/items').then(json)
},
refresh: function() {
return api('post', '/api/feeds/refresh')
return api('post', './api/feeds/refresh')
},
list_errors: function() {
return api('get', '/api/feeds/errors').then(json)
return api('get', './api/feeds/errors').then(json)
},
},
folders: {
list: function() {
return api('get', '/api/folders').then(json)
return api('get', './api/folders').then(json)
},
create: function(data) {
return api('post', '/api/folders', data).then(json)
return api('post', './api/folders', data).then(json)
},
update: function(id, data) {
return api('put', '/api/folders/' + id, data)
return api('put', './api/folders/' + id, data)
},
delete: function(id) {
return api('delete', '/api/folders/' + id)
return api('delete', './api/folders/' + id)
},
list_items: function(id) {
return api('get', '/api/folders/' + id + '/items').then(json)
return api('get', './api/folders/' + id + '/items').then(json)
}
},
items: {
list: function(query) {
return api('get', '/api/items' + param(query)).then(json)
return api('get', './api/items' + param(query)).then(json)
},
update: function(id, data) {
return api('put', '/api/items/' + id, data)
return api('put', './api/items/' + id, data)
},
mark_read: function(query) {
return api('put', '/api/items' + param(query))
return api('put', './api/items' + param(query))
},
},
settings: {
get: function() {
return api('get', '/api/settings').then(json)
return api('get', './api/settings').then(json)
},
update: function(data) {
return api('put', '/api/settings', data)
return api('put', './api/settings', data)
},
},
status: function() {
return api('get', '/api/status').then(json)
return api('get', './api/status').then(json)
},
upload_opml: function(form) {
return fetch('/opml/import', {
return fetch('./opml/import', {
method: 'post',
body: new FormData(form),
})
},
crawl: function(url) {
return fetch('/page?url=' + url).then(function(res) {
return fetch('./page?url=' + url).then(function(res) {
return res.text()
})
}