Page: Allow public pages - refs BT#21600

pull/5456/head
Angel Fernando Quiroz Campos 7 months ago
parent a96b386e8d
commit da4d4a5d1c
  1. 2
      assets/vue/router/index.js
  2. 5
      assets/vue/router/publicPage.js
  3. 17
      assets/vue/services/pageService.js
  4. 38
      assets/vue/views/page/PagePublic.vue
  5. 8
      src/CoreBundle/Component/Utils/CreateDefaultPages.php
  6. 1
      src/CoreBundle/Controller/IndexController.php
  7. 1
      src/CoreBundle/Entity/Page.php

@ -10,6 +10,7 @@ import userRelUserRoutes from "./userreluser"
import calendarEventRoutes from "./ccalendarevent"
import toolIntroRoutes from "./ctoolintro"
import pageRoutes from "./page"
import publicPageRoutes from "./publicPage"
import socialNetworkRoutes from "./social"
import termsRoutes from "./terms"
import fileManagerRoutes from "./filemanager"
@ -162,6 +163,7 @@ const router = createRouter({
calendarEventRoutes,
toolIntroRoutes,
pageRoutes,
publicPageRoutes,
],
})

@ -0,0 +1,5 @@
export default {
path: "/p/:slug",
name: "PublicPage",
component: () => import("../views/page/PagePublic.vue"),
}

@ -1,6 +1,23 @@
import api from "../config/api"
import baseService from "./baseService"
/**
* @param {string} slug
* @returns {Promise<Object|null>}
*/
async function getBySlug(slug) {
const { items } = await baseService.getCollection("/api/pages", { slug })
if (items.length) {
return items[0]
}
return null
}
export default {
getBySlug,
/**
* @param {Object} params
* @returns {Promise<Object>}

@ -0,0 +1,38 @@
<script setup>
import { ref } from "vue"
import { useRoute } from "vue-router"
import { useI18n } from "vue-i18n"
import SectionHeader from "../../components/layout/SectionHeader.vue"
import pageService from "../../services/pageService"
import { useNotification } from "../../composables/notification"
import Loading from "../../components/Loading.vue"
const route = useRoute()
const { t } = useI18n()
const { showWarningNotification } = useNotification()
const isLoading = ref(true)
const page = ref()
pageService
.getBySlug(route.params.slug)
.then((result) => {
if (result) {
page.value = result
return
}
showWarningNotification(t("Not found"))
})
.finally(() => (isLoading.value = false))
</script>
<template>
<div v-if="page">
<SectionHeader :title="page.title" />
<div v-html="page.content"></div>
</div>
<Loading :visible="isLoading" />
</template>

@ -110,6 +110,14 @@ class CreateDefaultPages
$this->pageCategoryRepository->update($usersAdminBlock);
}
$publicCategory = (new PageCategory())
->setTitle('public')
->setType('grid')
->setCreator($user)
;
$this->pageCategoryRepository->update($publicCategory);
return true;
}

@ -30,6 +30,7 @@ class IndexController extends BaseController
#[Route('/account/home', name: 'chamilo_core_account_home', options: ['expose' => true])]
#[Route('/social', name: 'chamilo_core_socialnetwork', options: ['expose' => true])]
#[Route('/admin', name: 'admin', options: ['expose' => true])]
#[Route('/p/{slug}', name: 'public_page')]
public function index(): Response
{
return $this->render('@ChamiloCore/Index/vue.html.twig');

@ -46,6 +46,7 @@ use Symfony\Component\Validator\Constraints as Assert;
'url' => 'exact',
'category' => 'exact',
'category.title' => 'partial',
'slug' => 'exact',
]
)]
#[ApiFilter(filterClass: OrderFilter::class, properties: ['title'])]

Loading…
Cancel
Save