finalizing the move to user/pass auth.

This commit is contained in:
arabcoders
2025-05-15 00:10:20 +03:00
parent 44da11212e
commit 77dea258ce
12 changed files with 99 additions and 308 deletions

View File

@@ -73,7 +73,6 @@
</template>
<script setup>
import {useStorage} from '@vueuse/core'
import {marked} from 'marked'
import {baseUrl} from 'marked-base-url'
import markedAlert from 'marked-alert'
@@ -88,7 +87,6 @@ const props = defineProps({
});
const content = ref('')
const api_url = useStorage('api_url', '')
const error = ref('')
const isLoading = ref(true)
@@ -138,7 +136,7 @@ const removeListeners = () => {
onMounted(async () => {
try {
isLoading.value = true
const response = await fetch(`${api_url.value}${props.file}?_=${Date.now()}`)
const response = await fetch(`${props.file}?_=${Date.now()}`)
if (!response.ok) {
const err = await parse_api_response(response)
console.log(err)
@@ -148,36 +146,15 @@ onMounted(async () => {
const text = await response.text()
marked.use(baseUrl(api_url.value))
marked.use(baseUrl(window.origin))
marked.use(markedAlert());
marked.use({
gfm: true,
hooks: {
postprocess: (text) => {
// // -- replace GitHub [! with icon
// text = text.replace(/\[!IMPORTANT]/g, `
// <span class="is-block title mb-2 is-5">
// <span class="icon-text">
// <span class="icon"><i class="fas fa-exclamation-triangle has-text-danger"></i></span>
// <span>IMPORTANT</span>
// </span>
// </span>`)
//
// text = text.replace(/\[!NOTE]/g, `
// <span class="is-block title is-5">
// <span class="icon-text">
// <span class="icon"><i class="fas fa-info has-text-info-50"></i></span>
// <span>NOTE</span>
// </span>
// </span>`)
text = text.replace(
/<!--\s*?i:([\w.-]+)\s*?-->/gi,
(_, list) => `<span class="icon"><i class="fas ${list.split('.').map(n => n.trim()).join(' ')}"></i></span>`
);
return text
}
postprocess: (text) => text.replace(
/<!--\s*?i:([\w.-]+)\s*?-->/gi,
(_, list) => `<span class="icon"><i class="fas ${list.split('.').map(n => n.trim()).join(' ')}"></i></span>`
)
},
walkTokens: token => {
if ('link' !== token.type) {
@@ -187,16 +164,19 @@ onMounted(async () => {
if (true === token.href.startsWith('#')) {
return;
}
const urls = ['/FAQ.md', '/README.md', '/NEWS.md'];
const list = ['/guides/', ...urls];
const urls = ['FAQ.md', 'README.md', 'NEWS.md'];
const list = ['guides/', ...urls];
if (false === list.some(l => token.href.includes(l))) {
return;
}
if (urls.some(l => token.href.includes(l))) {
const url = new URL(token.href);
if (!token.href.startsWith('/')) {
token.href = '/' + token.href;
}
const url = new URL(window.origin + token.href);
url.pathname = `/guides${url.pathname}`;
token.href = url.pathname;
token.href = url.toString();
}
token.href = token.href.replace('/guides/', '/help/').replace('.md', '');

View File

@@ -11,7 +11,11 @@ try {
'/v1/api/': {
target: API_URL + '/v1/api/',
changeOrigin: true
}
},
'/guides/': {
target: API_URL + '/guides/',
changeOrigin: true
},
}
}
}
@@ -20,7 +24,7 @@ try {
export default defineNuxtConfig({
ssr: false,
devtools: { enabled: true },
devtools: {enabled: true},
devServer: {
port: 8081,
@@ -35,13 +39,13 @@ export default defineNuxtConfig({
app: {
head: {
"meta": [
{ "charset": "utf-8" },
{ "name": "viewport", "content": "width=device-width, initial-scale=1.0, maximum-scale=1.0" },
{ "name": "theme-color", "content": "#000000" }
{"charset": "utf-8"},
{"name": "viewport", "content": "width=device-width, initial-scale=1.0, maximum-scale=1.0"},
{"name": "theme-color", "content": "#000000"}
],
},
buildAssetsDir: "assets",
pageTransition: { name: 'page', mode: 'out-in' }
pageTransition: {name: 'page', mode: 'out-in'}
},
router: {

View File

@@ -8,7 +8,7 @@
<script setup>
const route = useRoute()
const slug = ref(`${route.params.slug?.length > 0 ? route.params.slug?.join('/') : ''}`)
const slug = ref(`${route.params.slug?.length > 0 ? route.params.slug.join('/') : ''}`)
const url = ref('')
onMounted(async () => {
const to_lower = String(slug.value).toLowerCase()
@@ -19,7 +19,7 @@ onMounted(async () => {
const special = ['faq', 'readme', 'news']
if (special.includes(to_lower)) {
url.value = '/' + to_lower.toUpperCase() + '.md'
url.value = '/guides/' + to_lower.toUpperCase() + '.md'
return
}