Skip to content

Commit

Permalink
#78 - proper page titles and favicon (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofrewak authored Aug 20, 2024
1 parent 0950781 commit 44c446f
Show file tree
Hide file tree
Showing 28 changed files with 96 additions and 23 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ DB_DATABASE=keating
DB_USERNAME=keating
DB_PASSWORD=password

CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-and-lint-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
coverage: none

- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-suggest
run: composer install --prefer-dist --no-interaction

- name: Run PHP linter
run: composer cs
Expand Down
19 changes: 19 additions & 0 deletions app/Console/Commands/FlushCachedPageTitle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands;

use Illuminate\Cache\CacheManager;
use Illuminate\Console\Command;

class FlushCachedPageTitle extends Command
{
protected $signature = "cache:title:flush";
protected $description = "Flush cached page title";

public function handle(CacheManager $cache): void
{
$cache->forget("pageTitle");
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Public/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __invoke(): Response
"email" => $settings->teacher_email,
"department" => $settings->department_name,
"university" => $settings->university_name,
"universityLogo" => "https://irg2023.collegiumwitelona.pl/assets/logos/cwup.png",
"universityLogo" => asset("cwup-full.png"),
"sectionSettings" => $sectionSettings,
"about" => $sectionSettings->about_enabled ? Section::query()->about()->orderBy("created_at")->get() : [],
"counters" => $sectionSettings->counters_enabled ? Section::query()->counter()->orderBy("created_at")->get() : [],
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Public/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LoginController extends Controller
public function create(): Response
{
return inertia("Public/Login", [
"universityLogo" => "https://irg2023.collegiumwitelona.pl/assets/logos/cwup.png",
"universityLogo" => asset("cwup-full.png"),
]);
}

Expand Down
35 changes: 35 additions & 0 deletions app/Providers/ViewServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace App\Providers;

use App\Models\Setting;
use Illuminate\Cache\CacheManager;
use Illuminate\Database\QueryException;
use Illuminate\Support\ServiceProvider;
use Illuminate\View\Factory;

class ViewServiceProvider extends ServiceProvider
{
public function boot(CacheManager $cache, Factory $view): void
{
$title = $cache->get("pageTitle", function () use ($cache): string {
try {
$settings = Setting::query()->first();
} catch (QueryException) {
$settings = null;
}

$title = $settings
? "{$settings->teacher_titles} {$settings->teacher_name}, {$settings->university_name}"
: config("app.name");

$cache->put("pageTitle", $title);

return $title;
});

$view->share("pageTitle", $title);
}
}
2 changes: 2 additions & 0 deletions bootstrap/providers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
declare(strict_types=1);

use App\Providers\BuilderServiceProvider;
use App\Providers\ViewServiceProvider;

return [
BuilderServiceProvider::class,
ViewServiceProvider::class,
];
6 changes: 0 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
],
"test": [
"@putenv XDEBUG_MODE=off",
"@php artisan test"
Expand Down
2 changes: 1 addition & 1 deletion config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Support\Str;

return [
"default" => env("CACHE_DRIVER", "redis"),
"default" => env("CACHE_DRIVER", "array"),
"stores" => [
"apc" => [
"driver" => "apc",
Expand Down
3 changes: 2 additions & 1 deletion environment/prod/deployment/scripts/post-deploy-actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ php ${ARTISAN_PATH} migrate --force && \
php ${ARTISAN_PATH} route:cache && \
php ${ARTISAN_PATH} view:cache && \
php ${ARTISAN_PATH} event:cache && \
php ${ARTISAN_PATH} config:cache
php ${ARTISAN_PATH} config:cache && \
php ${ARTISAN_PATH} cache:title:flush
Binary file added public/cwup-full.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/cwup-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file removed public/favicon.ico
Empty file.
3 changes: 3 additions & 0 deletions resources/js/Layouts/DashboardLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from '@heroicons/vue/24/outline'
import { ref, watch } from 'vue'
import { useToast } from 'vue-toastification'
import { Head } from '@inertiajs/inertia-vue3'
const toast = useToast()
const props = defineProps({
Expand Down Expand Up @@ -77,6 +78,8 @@ watch(() => props.flash, (flash) => {
</script>

<template>
<Head title="Panel administracyjny" />

<div>
<TransitionRoot as="template" :show="sidebarOpen">
<Dialog as="div" class="relative z-50 lg:hidden" @close="sidebarOpen = false">
Expand Down
4 changes: 3 additions & 1 deletion resources/js/Pages/Public/Grade.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import PublicLayout from '@/Layouts/PublicLayout.vue'
import BackgroundGrid from '@/Components/BackgroundGrid.vue'
import SectionHeader from '@/Components/SectionHeader.vue'
import { Link } from '@inertiajs/inertia-vue3'
import { Head, Link } from '@inertiajs/inertia-vue3'
import SubmitButton from '@/Shared/Components/Buttons/SubmitButton.vue'
import TableWrapper from '@/Shared/Components/Table/TableWrapper.vue'
import TableHeader from '@/Shared/Components/Table/TableHeader.vue'
Expand Down Expand Up @@ -36,6 +36,8 @@ function getIndex() {
</script>

<template>
<Head title="Oceny" />

<PublicLayout>
<div class="relative isolate bg-gradient-to-r from-gray-50 to-gray-100 py-24 sm:py-32">
<BackgroundGrid mask-direction="left" />
Expand Down
3 changes: 3 additions & 0 deletions resources/js/Pages/Public/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import BackgroundGrid from '@/Components/BackgroundGrid.vue'
import SectionHeader from '@/Components/SectionHeader.vue'
import DOMPurify from 'dompurify'
import { Head } from '@inertiajs/inertia-vue3'
defineProps({
title: String,
Expand All @@ -21,6 +22,8 @@ defineProps({
</script>

<template>
<Head title="/" />

<PublicLayout>
<div v-if="sectionSettings.banner_enabled" class="relative isolate bg-white pt-14">
<BackgroundGrid />
Expand Down
4 changes: 3 additions & 1 deletion resources/js/Pages/Public/Login.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup>
import PublicLayout from '@/Layouts/PublicLayout.vue'
import BackgroundGrid from '@/Components/BackgroundGrid.vue'
import { useForm } from '@inertiajs/inertia-vue3'
import { Head, useForm } from '@inertiajs/inertia-vue3'
defineProps({
university: String,
Expand All @@ -19,6 +19,8 @@ function attemptLogin() {
</script>

<template>
<Head title="Logowanie" />

<PublicLayout>
<div class="relative isolate bg-white pt-14">
<BackgroundGrid />
Expand Down
3 changes: 3 additions & 0 deletions resources/js/Pages/Public/News/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import SectionHeader from '../../../Components/SectionHeader.vue'
import Pagination from '../../../Components/Pagination.vue'
import sanitizeHtml from 'sanitize-html'
import { NoSymbolIcon } from '@heroicons/vue/24/outline'
import { Head } from '@inertiajs/inertia-vue3'
defineProps({
paginator: Object,
Expand All @@ -13,6 +14,8 @@ defineProps({
</script>

<template>
<Head title="Aktualności" />

<PublicLayout>
<div class="relative isolate bg-white">
<BackgroundGrid />
Expand Down
3 changes: 3 additions & 0 deletions resources/js/Pages/Public/News/News.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import PublicLayout from '@/Layouts/PublicLayout.vue'
import BackgroundGrid from '../../../Components/BackgroundGrid.vue'
import SectionHeader from '../../../Components/SectionHeader.vue'
import sanitizeHtml from 'sanitize-html'
import { Head } from '@inertiajs/inertia-vue3'
defineProps({
news: Object,
})
</script>

<template>
<Head :title="news.title + ' - Aktualności'" />

<PublicLayout>
<div class="relative isolate bg-white">
<BackgroundGrid />
Expand Down
6 changes: 5 additions & 1 deletion resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import { autoAnimatePlugin } from '@formkit/auto-animate/vue'
import Toast from 'vue-toastification'
import '../css/app.css'

const pageTitle = document.getElementsByName('title')[0].content ?? 'Keating'

createInertiaApp({
progress: {
delay: 50,
color: '#14b8a6',
},
title: (title) => title ? `${title} - Keating` : 'Keating',
title: function(title) {
return title && title !== '/' ? `${title} - ${pageTitle}` : pageTitle
},
resolve: name => {
const pages = import.meta.glob('./Pages/**/*.vue', { eager: true })

Expand Down
5 changes: 3 additions & 2 deletions resources/views/app.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<!DOCTYPE html>
<html class="h-full bg-gray-100" lang="en">
<html class="h-full bg-gray-100" lang="pl">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title></title>
<link rel="icon" type="image/x-icon" href="{{ asset("cwup-icon.png") }}">
<meta name="title" content="{{ $pageTitle }}">
@vite("resources/js/app.js")
@inertiaHead
</head>
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/CourseSemesterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Feature;
namespace Tests\Feature;

use App\Models\Course;
use App\Models\CourseSemester;
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/CourseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Feature;
namespace Tests\Feature;

use App\Models\Course;
use App\Models\User;
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Feature;
namespace Tests\Feature;

use App\Models\Field;
use App\Models\User;
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/GradeColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Feature;
namespace Tests\Feature;

use App\Models\GradeColumn;
use App\Models\Group;
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/GradeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Feature;
namespace Tests\Feature;

use App\Models\Grade;
use App\Models\GradeColumn;
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Feature;
namespace Tests\Feature;

use App\Models\CourseSemester;
use App\Models\Group;
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/SectionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Feature;
namespace Tests\Feature;

use App\Models\Section;
use App\Models\SectionSettings;
Expand Down

0 comments on commit 44c446f

Please sign in to comment.