API klic za ustvarit nov pad, manjsi popravki (trailing /)

Jurij Podgoršek 2023-11-12 23:46:57 +01:00
parent 323c1bc694
commit 5837d4cb26
6 changed files with 13 additions and 10 deletions

View File

@ -1,5 +1,6 @@
BASE_URL="https://yufu-manifest.ddev.site"
JSONAPI_PATH="/jsonapi"
FILE_PATH="/sites/default/files"
ETHERPAD_URL="https://pisi.kompot.si/"
ETHERPAD_URL="https://pisi.kompot.si"
ETHERPAD_API_URL="https://yufu-manifest.ddev.site/etherpad-api"
ETHERPAD_PREFIX="yufu-"

View File

@ -1,12 +1,17 @@
<script setup="setup">
const { etherpadApiUrl, etherpadPrefix } = useRuntimeConfig().public
const prikazi = ref(false)
const revisionId = ref(null)
const dodajPojem = () => {
const dodajPojem = async () => {
revisionId.value = crypto.randomUUID()
// Ustvari nov, prazen pad
const padId = etherpadPrefix + revisionId.value
const resp = await $fetch(`${etherpadApiUrl}/createPad?padID=${padId}&text=`)
prikazi.value = true
console.log('NOV POJEM!', revisionId.value)
}
</script>

View File

@ -14,7 +14,7 @@ const embed = ref(null)
onMounted(() => {
// Ce ni revisionId propertyja, se random generira.
const uuid = props.revisionId ? props.revisionId : crypto.randomUUID()
const padUrl = `${etherpadUrl}p/${etherpadPrefix}${uuid}?showChat=false&showLineNumbers=false&toc=false`
const padUrl = `${etherpadUrl}/p/${etherpadPrefix}${uuid}?showChat=false&showLineNumbers=false&toc=false`
embed.value.src = padUrl
})

View File

@ -26,10 +26,6 @@ const oddajPredlog = data => {
}
const etherNalozen = ev => {
// @TODO DRY
const padUrl = `${etherpadUrl}p/${etherpadPrefix}${props.revisionId}?showChat=false&showLineNumbers=false&toc=false`
// Izprazni pad!
console.log('etherpad nalozen!')
window.location.hash = props.revisionId
}

View File

@ -36,6 +36,7 @@ export default defineNuxtConfig({
baseUrl: process.env.BASE_URL,
jsonapiPath: process.env.JSONAPI_PATH,
etherpadUrl: process.env.ETHERPAD_URL,
etherpadApiUrl: process.env.ETHERPAD_API_URL,
etherpadPrefix: process.env.ETHERPAD_PREFIX
}
},

View File

@ -46,14 +46,14 @@ class Client {
}
public function checkToken() {
return $this->request('get', '/checkToken');
return $this->request('get', 'checkToken');
}
/**
* Method description.
*/
public function request($method, $url) {
$uri = "{$this->baseUrl}/" . self::API_VERSION . $url;
$uri = "{$this->baseUrl}/" . self::API_VERSION . '/' . $url;
if (str_contains($uri, '?')) {
$uri .= "&apikey={$this->apiKey}";