Skip to content

Commit

Permalink
add tutorials section, update docs and compress images
Browse files Browse the repository at this point in the history
  • Loading branch information
agordn52 committed Nov 8, 2023
1 parent 8503ffc commit 6463b93
Show file tree
Hide file tree
Showing 18 changed files with 1,114 additions and 50 deletions.
24 changes: 22 additions & 2 deletions app/Console/Commands/GenerateSitemapCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function handle(DocService $docService)
{
$sitemap = Sitemap::create(config('app.url'));
$sitemap->add(Url::create('/')->setPriority(0.95));

$sitemap->add(Url::create('resources')->setPriority(0.90));
$sitemap->add(Url::create('privacy-policy')->setPriority(0.90));
$sitemap->add(Url::create('terms-and-conditions')->setPriority(0.90));
Expand All @@ -56,11 +56,31 @@ public function handle(DocService $docService)
$arrayLinks = $flattenedCollection->toArray();

foreach ($arrayLinks as $link) {
$urlLink = route('landing.docs', ['version' => $version, 'page' => $link]);
$urlLink = route('landing.docs', ['version' => $version, 'page' => $link]);
$sitemap->add(Url::create($urlLink)->setPriority(0.8));
}
}

$docsTutorials = config('project.doc-tutorials');
if (empty($docsTutorials['versions'])) {
return;
}

foreach ($docsTutorials['versions'] as $version => $versionLinks) {
if ($version != $latestVersionOfNylo) {
continue;
}

foreach ($versionLinks as $tutorial) {
collect($tutorial)->map(function ($data) {
return $data['label'];
})->each(function ($label) use ($version, &$sitemap) {
$urlLink = route('tutorials.index', ['version' => $version, 'page' => $label]);
$sitemap->add(Url::create($urlLink)->setPriority(0.70));
});
}
}

$sitemap->writeToFile(public_path('sitemap.xml'));
}
}
23 changes: 23 additions & 0 deletions app/Http/Controllers/LandingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,29 @@ public function resources()
return view('pages.resources', compact('resourceData'));
}

/**
* Tutorials page for Nylo.
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function tutorials($version = null, $page = 'introduction')
{
$this->seoService->setTitle('Tutorials');

$latestVersionOfNylo = $this->docService->getLastestVersionNylo();

if ($version == null) {
$version = $latestVersionOfNylo;
}
$this->docService->containsTutorialsForVersion($version);
$section = $this->docService->findTutorialSection($version, $page);
$viewingOldDocs = $this->docService->isViewingOldDocs($version);
$tutorial = $this->docService->getTutorial($version, $page);
abort_if(empty($tutorial), 404);

return view('docs.tutorials', compact('page', 'tutorial', 'version', 'section', 'latestVersionOfNylo', 'viewingOldDocs'));
}

/**
* Documentation page for Nylo.
*
Expand Down
64 changes: 63 additions & 1 deletion app/Http/Services/DocService.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function isViewingOldDocs($version) : bool
}

/**
* Finds the correct section that a page belongs to.
* Finds the correct section that a page belongs too.
*
* @param string $version
* @param string $page
Expand All @@ -62,7 +62,36 @@ public function findDocSection($version, $page) : string
}
}
return '';
}

/**
* Finds the correct Tutorial section that a page belongs too.
*
* @param string $version
* @param string $page
* @return string
*/
public function findTutorialSection($version, $page) : string
{
foreach (config('project.doc-tutorials')['versions'][$version] as $key => $docLink) {
$docLabels = collect($docLink)->map(function ($doc) {
return $doc['label'];
})->toArray();
if (in_array($page, $docLabels)) {
return $key;
}
}
return '';
}

/**
* Checks if doc-tutorials contains a valid $version
*
* @param string $version
*/
public function containsTutorialsForVersion($version)
{
abort_if(array_key_exists($version, config('project.doc-tutorials')['versions']) == false, 403, "No tutorials found for $version");
}

/**
Expand All @@ -79,6 +108,39 @@ public function checkIfDocExists($version, $page) : string
return $mdDocPage;
}

/**
* Checks if the tutorials docs page exists in the resource path and then returns the path.
*
* @param string $version
* @param string $page
* @return string
*/
public function checkIfTutorialsExists($version, $page) : string
{
return 'docs/' . $version . '/tutorials/' . $page;
}

/**
* Returns the tutorial meta data
*
* @param string $version
* @param string $page
* @return array
*/
public function getTutorial($version, $page) : array
{
$docsIndex = config('project.doc-tutorials');
$versions = $docsIndex['versions'][$version];
foreach ($versions as $docs) {
$results = collect($docs)->where('label', $page);
if ($results->isEmpty()) {
continue;
}
return collect($docs)->where('label', $page)->first();
}
return [];
}

/**
* Returns the zipball_url to download a project from GitHub.
*
Expand Down
48 changes: 48 additions & 0 deletions config/project/doc-tutorials.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

return [
'versions' => [
'5.x' => [
'Getting Started' => [
[
'label' => 'introduction',
'link' => 'https://www.youtube.com/embed/lVvsKfftiKU?si=ZFgk5xvavDMX1yZ_'
],
[
'label' => 'routing',
'link' => 'https://www.youtube.com/embed/qaCDJjjYdQs?si=LkONz1stkjHtT9Os'
],
[
'label' => 'localization',
'link' => 'https://www.youtube.com/embed/RJyI8vFRimQ?si=msezPj4-7gUsZXHL'
],
[
'label' => 'networking',
'link' => 'https://www.youtube.com/embed/PJ-u5mE3yT4?si=AdjyxjREvq4p2diI'
],
],
'Deeper Dive' => [
[
'label' => 'validation',
'link' => 'https://www.youtube.com/embed/7RUNT8b0LUI?si=pLLtrpstKao4ZO_m'
],
[
'label' => 'logging',
'link' => 'https://www.youtube.com/embed/rpEMTGxTfkk?si=BR-RLl2ef9pATvjx'
],
[
'label' => 'authentication',
'link' => 'https://www.youtube.com/embed/kYYCMfxeIQg?si=xw4qi14G16l_o42V'
],
[
'label' => 'events',
'link' => 'https://www.youtube.com/embed/MRppCAvPEXQ?si=sQOBhMJ7z8VEBIHl'
],
[
'label' => 'providers',
'link' => 'https://www.youtube.com/embed/0Y13JyV6Cc4?si=ibgLXBiw9x6GqXKn'
],
],
]
]
];
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6463b93

Please sign in to comment.