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

pull/26/head
Jurij Podgoršek 2023-11-12 23:46:57 +01:00
parent 8621c8f6f3
commit 333560ff41
6 changed files with 13 additions and 10 deletions

View File

@ -1,5 +1,6 @@
BASE_URL="https://yufu-manifest.ddev.site" BASE_URL="https://yufu-manifest.ddev.site"
JSONAPI_PATH="/jsonapi" JSONAPI_PATH="/jsonapi"
FILE_PATH="/sites/default/files" 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-" ETHERPAD_PREFIX="yufu-"

View File

@ -1,12 +1,17 @@
<script setup="setup"> <script setup="setup">
const { etherpadApiUrl, etherpadPrefix } = useRuntimeConfig().public
const prikazi = ref(false) const prikazi = ref(false)
const revisionId = ref(null) const revisionId = ref(null)
const dodajPojem = () => { const dodajPojem = async () => {
revisionId.value = crypto.randomUUID() 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 prikazi.value = true
console.log('NOV POJEM!', revisionId.value)
} }
</script> </script>

View File

@ -14,7 +14,7 @@ const embed = ref(null)
onMounted(() => { onMounted(() => {
// Ce ni revisionId propertyja, se random generira. // Ce ni revisionId propertyja, se random generira.
const uuid = props.revisionId ? props.revisionId : crypto.randomUUID() 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 embed.value.src = padUrl
}) })

View File

@ -26,10 +26,6 @@ const oddajPredlog = data => {
} }
const etherNalozen = ev => { 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 window.location.hash = props.revisionId
} }

View File

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

View File

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