url workaround

master
km0 1 year ago
parent 87f2997edb
commit 41e98babdf

@ -156,13 +156,13 @@ def init_page(padliography, description):
@app.route('/') @app.route('/')
def home(): def home():
'''Serve the homepage layout''' '''Serve the homepage layout'''
return render_template('home.html', page=DEFAULT_PAGE) return render_template('home.html', page=DEFAULT_PAGE, base_url=base_url)
@app.route('/<padliography>/') @app.route('/<padliography>/')
def page(padliography): def page(padliography):
'''Serve a specific padliography''' '''Serve a specific padliography'''
return render_template('home.html', page=padliography) return render_template('home.html', page=padliography, base_url=base_url)
@app.route('/api/<padliography>/', methods=['GET', 'POST']) @app.route('/api/<padliography>/', methods=['GET', 'POST'])

@ -40,7 +40,7 @@ export default {
pad.categories = pad.categories.join(", "); pad.categories = pad.categories.join(", ");
fetch(`api/${currentPage.value}`, { fetch(`${baseUrl.value}/api/${currentPage.value}`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify(pad), body: JSON.stringify(pad),

@ -2,7 +2,8 @@ const { ref } = Vue;
const padStore = ref([]); const padStore = ref([]);
const currentPage = ref(""); const currentPage = ref("");
const baseUrl = ref("")
export default function padliographyStore() { export default function padliographyStore() {
return { padStore, currentPage }; return { padStore, currentPage, baseUrl };
} }

@ -7,13 +7,13 @@ export default {
const loaded = ref(false); const loaded = ref(false);
const { padStore, currentPage } = padliographyStore(); const { padStore, currentPage, baseUrl } = padliographyStore();
const newPage = ref(""); const newPage = ref("");
const initPage = ref(""); const initPage = ref("");
const pageDescription = ref(""); const pageDescription = ref("");
const initialize = function () { const initialize = function () {
fetch(`/api/${initPage.value}/init`, { fetch(`${baseUrl.value}/api/${initPage.value}/init`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ body: JSON.stringify({
@ -37,7 +37,7 @@ export default {
}; };
watchEffect(() => { watchEffect(() => {
fetch(`/api/${currentPage.value}`) fetch(`${baseUrl.value}/api/${currentPage.value}`)
.then((res) => res.json()) .then((res) => res.json())
.then((data) => { .then((data) => {
pads.value = data.pads; pads.value = data.pads;

@ -15,6 +15,7 @@
<pad-table></pad-table> <pad-table></pad-table>
</div> </div>
<div id="current-page" class="hidden">{{page}}</div> <div id="current-page" class="hidden">{{page}}</div>
<div id="base-url" class="hidden">{{base_url}}</div>
<script type="module"> <script type="module">
import PadForm from "{{url_for('static', filename='js/PadForm.js')}}"; import PadForm from "{{url_for('static', filename='js/PadForm.js')}}";
import PadTable from "{{url_for('static', filename='js/PadTable.js')}}"; import PadTable from "{{url_for('static', filename='js/PadTable.js')}}";
@ -22,8 +23,9 @@
const { createApp } = Vue; const { createApp } = Vue;
import PadStore from "{{url_for('static', filename='js/PadStore.js')}}"; import PadStore from "{{url_for('static', filename='js/PadStore.js')}}";
const { currentPage } = PadStore() const { currentPage, baseUrl } = PadStore()
currentPage.value = document.querySelector('#current-page').textContent currentPage.value = document.querySelector('#current-page').textContent
baseUrl.value = document.querySelector('#base-url').textContent
createApp({ createApp({
components: { PadForm, PadTable }, components: { PadForm, PadTable },

Loading…
Cancel
Save