Remove axios and commit backend changes to sitemap
This commit is contained in:
parent
55debc539c
commit
6900fd572f
|
@ -9,62 +9,24 @@ use App\Models\Template;
|
||||||
|
|
||||||
class SitemapController extends Controller
|
class SitemapController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Contains route name and the associated priority
|
public function index(Request $request)
|
||||||
*
|
{
|
||||||
* @var array
|
return [
|
||||||
*/
|
...$this->getTemplatesUrls()
|
||||||
protected $urls = [
|
|
||||||
['/', 1],
|
|
||||||
['/pricing', 0.9],
|
|
||||||
['/privacy-policy', 0.5],
|
|
||||||
['/terms-conditions', 0.5],
|
|
||||||
['/login', 0.4],
|
|
||||||
['/register', 0.4],
|
|
||||||
['/password/reset', 0.3],
|
|
||||||
['/form-templates', 0.9],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getSitemap(Request $request)
|
|
||||||
{
|
|
||||||
$sitemap = Sitemap::create();
|
|
||||||
foreach ($this->urls as $url) {
|
|
||||||
$sitemap->add($this->createUrl($url[0], $url[1]));
|
|
||||||
}
|
|
||||||
$this->addTemplatesUrls($sitemap);
|
|
||||||
$this->addTemplatesTypesUrls($sitemap);
|
|
||||||
$this->addTemplatesIndustriesUrls($sitemap);
|
|
||||||
|
|
||||||
return $sitemap->toResponse($request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createUrl($url, $priority, $frequency = 'daily')
|
private function getTemplatesUrls()
|
||||||
{
|
{
|
||||||
return Url::create($url)->setPriority($priority)->setChangeFrequency($frequency);
|
$urls = [];
|
||||||
}
|
Template::where('publicly_listed', true)->chunk(100, function ($templates) use (&$urls) {
|
||||||
|
|
||||||
private function addTemplatesUrls(Sitemap $sitemap)
|
|
||||||
{
|
|
||||||
Template::where('publicly_listed', true)->chunk(100, function ($templates) use ($sitemap) {
|
|
||||||
foreach ($templates as $template) {
|
foreach ($templates as $template) {
|
||||||
$sitemap->add($this->createUrl('/form-templates/' . $template->slug, 0.8));
|
$urls[] = [
|
||||||
|
'loc' => '/templates/' . $template->slug
|
||||||
|
];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
return $urls;
|
||||||
|
|
||||||
private function addTemplatesTypesUrls(Sitemap $sitemap)
|
|
||||||
{
|
|
||||||
$types = json_decode(file_get_contents(resource_path('data/forms/templates/types.json')), true);
|
|
||||||
foreach ($types as $type) {
|
|
||||||
$sitemap->add($this->createUrl('/form-templates/types/' . $type['slug'], 0.7));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function addTemplatesIndustriesUrls(Sitemap $sitemap)
|
|
||||||
{
|
|
||||||
$industries = json_decode(file_get_contents(resource_path('data/forms/templates/industries.json')), true);
|
|
||||||
foreach ($industries as $industry) {
|
|
||||||
$sitemap->add($this->createUrl('/form-templates/industries/' . $industry['slug'], 0.7));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import {defineStore} from 'pinia'
|
import {defineStore} from 'pinia'
|
||||||
import axios from 'axios'
|
|
||||||
|
|
||||||
export const useAuthStore = defineStore('auth', {
|
export const useAuthStore = defineStore('auth', {
|
||||||
state: () => {
|
state: () => {
|
||||||
|
@ -88,8 +87,8 @@ export const useAuthStore = defineStore('auth', {
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchOauthUrl(provider) {
|
async fetchOauthUrl(provider) {
|
||||||
const {data} = await axios.post(`/api/oauth/${provider}`)
|
// const {data} = await axios.post(`/api/oauth/${provider}`)
|
||||||
return data.url
|
// return data.url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -167,6 +167,8 @@ Route::prefix('content')->name('content.')->group(function () {
|
||||||
Route::get('changelog/entries', [\App\Http\Controllers\Content\ChangelogController::class, 'index'])->name('changelog.entries');
|
Route::get('changelog/entries', [\App\Http\Controllers\Content\ChangelogController::class, 'index'])->name('changelog.entries');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::get('/sitemap-urls', [\App\Http\Controllers\SitemapController::class, 'index'])->name('sitemap.index');
|
||||||
|
|
||||||
// Templates
|
// Templates
|
||||||
Route::prefix('templates')->group(function () {
|
Route::prefix('templates')->group(function () {
|
||||||
Route::get('/', [TemplateController::class, 'index'])->name('templates.index');
|
Route::get('/', [TemplateController::class, 'index'])->name('templates.index');
|
||||||
|
|
|
@ -28,6 +28,7 @@ Route::post(
|
||||||
'/upload-file',
|
'/upload-file',
|
||||||
[\App\Http\Controllers\Content\FileUploadController::class, 'upload']
|
[\App\Http\Controllers\Content\FileUploadController::class, 'upload']
|
||||||
)->middleware([]);
|
)->middleware([]);
|
||||||
|
|
||||||
Route::get('local/temp/{path}', function (Request $request, string $path){
|
Route::get('local/temp/{path}', function (Request $request, string $path){
|
||||||
if (!$request->hasValidSignature()) {
|
if (!$request->hasValidSignature()) {
|
||||||
abort(401);
|
abort(401);
|
||||||
|
@ -37,7 +38,5 @@ Route::get('local/temp/{path}', function (Request $request, string $path){
|
||||||
return $response;
|
return $response;
|
||||||
})->where('path', '(.*)')->name('local.temp');
|
})->where('path', '(.*)')->name('local.temp');
|
||||||
|
|
||||||
Route::get('/sitemap.xml', [\App\Http\Controllers\SitemapController::class, 'getSitemap'])->name('sitemap');
|
|
||||||
|
|
||||||
Route::get('caddy/ask-certificate/{secret?}', [\App\Http\Controllers\CaddyController::class, 'ask'])
|
Route::get('caddy/ask-certificate/{secret?}', [\App\Http\Controllers\CaddyController::class, 'ask'])
|
||||||
->name('caddy.ask')->middleware(\App\Http\Middleware\CaddyRequestMiddleware::class);
|
->name('caddy.ask')->middleware(\App\Http\Middleware\CaddyRequestMiddleware::class);
|
||||||
|
|
Loading…
Reference in New Issue