├── .dockerignore ├── .editorconfig ├── .env.example ├── .env.prod.example ├── .env.testing ├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── app ├── Console │ └── Kernel.php ├── Enums │ ├── PresentationFilter.php │ ├── SlideDelimiter.php │ └── Traits │ │ └── EnumToArray.php ├── Exceptions │ └── Handler.php ├── Filament │ ├── Pages │ │ ├── Auth │ │ │ └── Register.php │ │ └── Dashboard.php │ ├── Resources │ │ ├── ImageUploadResource.php │ │ ├── ImageUploadResource │ │ │ ├── Pages │ │ │ │ ├── CreateImageUpload.php │ │ │ │ ├── EditImageUpload.php │ │ │ │ └── ListImageUploads.php │ │ │ └── Widgets │ │ │ │ └── StatsOverview.php │ │ ├── PresentationResource.php │ │ ├── PresentationResource │ │ │ └── Pages │ │ │ │ ├── CreatePresentation.php │ │ │ │ ├── EditPresentation.php │ │ │ │ └── ListPresentations.php │ │ ├── UserResource.php │ │ └── UserResource │ │ │ └── Pages │ │ │ ├── CreateUser.php │ │ │ ├── EditUser.php │ │ │ └── ListUsers.php │ └── Widgets │ │ ├── TopViews.php │ │ ├── ViewStats.php │ │ └── ViewTrendsChart.php ├── Http │ ├── Controllers │ │ ├── AdhocSlidesController.php │ │ ├── Controller.php │ │ ├── PresentationController.php │ │ └── SettingsController.php │ ├── Kernel.php │ ├── Middleware │ │ ├── Authenticate.php │ │ ├── EncryptCookies.php │ │ ├── HandleInertiaRequests.php │ │ ├── PreventRequestsDuringMaintenance.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── TrimStrings.php │ │ ├── TrustHosts.php │ │ ├── TrustProxies.php │ │ ├── ValidateSignature.php │ │ └── VerifyCsrfToken.php │ ├── Requests │ │ └── Auth │ │ │ └── LoginRequest.php │ └── Resources │ │ └── PresentationResource.php ├── Jobs │ ├── AggregateDailyViews.php │ └── GenerateThumbnail.php ├── Livewire │ └── UsernameComponent.php ├── Models │ ├── AggregateView.php │ ├── DailyView.php │ ├── ImageUpload.php │ ├── Presentation.php │ └── User.php ├── Observers │ ├── DailyViewObserver.php │ ├── ImageUploadObserver.php │ ├── MediaObserver.php │ └── PresentationObserver.php ├── Policies │ ├── PresentationPolicy.php │ └── UserPolicy.php └── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ ├── Filament │ └── AdminPanelProvider.php │ └── RouteServiceProvider.php ├── artisan ├── bootstrap ├── app.php └── cache │ └── .gitignore ├── composer.json ├── composer.lock ├── config ├── app-upload.php ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── cors.php ├── database.php ├── filament.php ├── filesystems.php ├── hashing.php ├── logging.php ├── mail.php ├── media-library.php ├── meta.php ├── queue.php ├── sanctum.php ├── services.php ├── session.php ├── tinker.php └── view.php ├── database ├── .gitignore ├── factories │ ├── AggregateViewFactory.php │ ├── DailyViewFactory.php │ ├── ImageUploadFactory.php │ ├── PresentationFactory.php │ └── UserFactory.php ├── migrations │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2014_10_12_100000_create_password_reset_tokens_table.php │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ ├── 2019_12_14_000001_create_personal_access_tokens_table.php │ ├── 2023_11_16_052229_create_breezy_tables.php │ ├── 2023_11_16_145250_create_presentations_table.php │ ├── 2023_11_19_204221_create_media_table.php │ ├── 2023_11_23_042735_create_image_uploads_table.php │ ├── 2024_04_08_190654_create_daily_views_table.php │ ├── 2024_04_08_190703_create_aggregate_views_table.php │ └── 2024_10_26_043110_add_slide_delimiter_to_presentations.php └── seeders │ └── DatabaseSeeder.php ├── docker-compose.prod.yml ├── docker-compose.yml ├── docker ├── app │ ├── Dockerfile │ └── rootfs │ │ ├── entrypoint │ │ ├── etc │ │ ├── cron.d │ │ │ └── scheduler │ │ ├── nginx │ │ │ └── conf.d │ │ │ │ └── default.conf │ │ └── s6 │ │ │ ├── app │ │ │ ├── nginx │ │ │ │ ├── down-signal │ │ │ │ └── run │ │ │ └── php-fpm │ │ │ │ ├── down-signal │ │ │ │ └── run │ │ │ └── worker │ │ │ ├── cron │ │ │ └── run │ │ │ └── queue-runner │ │ │ └── run │ │ ├── health-check │ │ └── usr │ │ └── local │ │ └── etc │ │ └── php │ │ └── conf.d │ │ └── 99-docker-php-ext-xdebug-config.ini └── sail-extra.sh ├── package-lock.json ├── package.json ├── phpstan.neon ├── phpunit.xml ├── postcss.config.js ├── public ├── .htaccess ├── css │ └── filament │ │ ├── filament │ │ └── app.css │ │ ├── forms │ │ └── forms.css │ │ └── support │ │ └── support.css ├── favicon.ico ├── favicon │ ├── android-chrome-192x192.png │ ├── android-chrome-512x512.png │ ├── apple-touch-icon.png │ ├── browserconfig.xml │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── favicon.ico │ ├── mstile-150x150.png │ ├── safari-pinned-tab.svg │ └── site.webmanifest ├── images │ ├── clevyr.png │ ├── pun-dog.jpg │ └── simple-slides-og.jpg ├── index.php ├── instructions.md ├── js │ └── filament │ │ ├── filament │ │ ├── app.js │ │ └── echo.js │ │ ├── forms │ │ └── components │ │ │ ├── color-picker.js │ │ │ ├── date-time-picker.js │ │ │ ├── file-upload.js │ │ │ ├── key-value.js │ │ │ ├── markdown-editor.js │ │ │ ├── rich-editor.js │ │ │ ├── select.js │ │ │ ├── tags-input.js │ │ │ └── textarea.js │ │ ├── notifications │ │ └── notifications.js │ │ ├── support │ │ ├── async-alpine.js │ │ └── support.js │ │ ├── tables │ │ └── components │ │ │ └── table.js │ │ └── widgets │ │ └── components │ │ ├── chart.js │ │ └── stats-overview │ │ └── stat │ │ └── chart.js └── robots.txt ├── resources ├── css │ ├── app.css │ └── typography.css ├── js │ ├── Components │ │ ├── AppHead.vue │ │ ├── ApplicationLogo.vue │ │ ├── DraftBanner.vue │ │ ├── PreloadContent.vue │ │ ├── ProgressBar.vue │ │ ├── ProgressLabel.vue │ │ ├── SlideArrows.vue │ │ ├── SlideContent.vue │ │ ├── SlideView.vue │ │ └── icons │ │ │ ├── CogIcon.vue │ │ │ ├── GithubIcon.vue │ │ │ ├── MoonFillIcon.vue │ │ │ ├── MoonStrokeIcon.vue │ │ │ └── YoutubeIcon.vue │ ├── Layouts │ │ └── SlideLayout.vue │ ├── Pages │ │ ├── AdhocSlides.vue │ │ ├── Presentation.vue │ │ ├── Privacy.vue │ │ └── Settings.vue │ ├── app.ts │ ├── bootstrap.ts │ ├── constants │ │ ├── general.ts │ │ ├── keys.ts │ │ └── meta.ts │ ├── enums │ │ ├── progressType.ts │ │ └── visualMode.ts │ ├── interfaces │ │ ├── meta.ts │ │ ├── presentation.ts │ │ └── queryParams.ts │ ├── lib │ │ └── textFit.js │ ├── mocks │ │ ├── browser.ts │ │ └── handlers.ts │ ├── store │ │ ├── dataStore.ts │ │ └── slideStore.ts │ ├── test │ │ ├── components │ │ │ ├── DraftBanner.test.ts │ │ │ ├── PreloadContent.test.ts │ │ │ ├── ProgressBar.test.ts │ │ │ ├── ProgressLabel.test.ts │ │ │ ├── SlideArrows.test.ts │ │ │ ├── SlideView.keydown.test.ts │ │ │ ├── SlideView.loop.test.ts │ │ │ └── SlideView.test.ts │ │ ├── enums │ │ │ └── visualMode.test.ts │ │ ├── pages │ │ │ ├── AdhocSlides.test.ts │ │ │ ├── Presentation.test.ts │ │ │ ├── Privacy.test.ts │ │ │ └── Settings.test.ts │ │ ├── store │ │ │ ├── dataStore.test.ts │ │ │ └── slideStore.test.ts │ │ └── utils │ │ │ ├── handleQueryParams.test.ts │ │ │ └── handleVisualMode.test.ts │ ├── types │ │ ├── global.d.ts │ │ ├── index.d.ts │ │ └── vite-env.d.ts │ └── utils │ │ ├── handleContent.ts │ │ ├── handleQueryParams.ts │ │ └── handleVisualMode.ts └── views │ ├── app.blade.php │ ├── filament │ └── dashboard │ │ └── footer.blade.php │ ├── livewire │ └── username-component.blade.php │ └── welcome.blade.php ├── routes ├── api.php ├── auth.php ├── channels.php ├── console.php └── web.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ ├── .gitignore │ │ └── data │ │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ ├── testing │ │ └── .gitignore │ └── views │ │ └── .gitignore ├── logs │ └── .gitignore └── temp │ └── .gitignore ├── tailwind.config.js ├── tests ├── CreatesApplication.php ├── Feature │ ├── AdhocSlidesControllerTest.php │ ├── AggregateDailyViewsTest.php │ ├── Auth │ │ ├── AuthenticationTest.php │ │ ├── EmailVerificationTest.php │ │ ├── PasswordResetTest.php │ │ └── RegistrationTest.php │ ├── ExampleTest.php │ └── PresentationControllerTest.php ├── Filament │ ├── ImageUploadResourceTest.php │ ├── PresentationResourceTest.php │ └── UsernameComponentTest.php ├── Pest.php ├── TestCase.php └── Unit │ ├── AggregateViewModelTest.php │ ├── DailyViewModelTest.php │ ├── DailyViewObserverTest.php │ ├── ExampleTest.php │ ├── ImageUploadModelTest.php │ ├── ImageUploadObserverTest.php │ ├── MediaObserverTest.php │ ├── PresentationModelTest.php │ ├── PresentationObserverTest.php │ ├── UserCanUploadTest.php │ └── UserModelTest.php ├── tsconfig.json ├── vite.config.js └── vitest.setup.ts /.dockerignore: -------------------------------------------------------------------------------- 1 | /.phpunit.cache 2 | /node_modules 3 | /public/build 4 | /public/hot 5 | /public/storage 6 | /storage/*.key 7 | /vendor 8 | .phpunit.result.cache 9 | Homestead.json 10 | Homestead.yaml 11 | npm-debug.log 12 | yarn-error.log 13 | /.fleet 14 | /.idea 15 | /.vscode 16 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | 17 | [docker-compose.yml] 18 | indent_size = 4 19 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | LOG_DEPRECATIONS_CHANNEL=null 9 | LOG_LEVEL=debug 10 | 11 | DB_CONNECTION=pgsql 12 | DB_HOST=pgsql 13 | DB_PORT=5432 14 | DB_DATABASE=simple_slides_app 15 | DB_USERNAME=root 16 | DB_PASSWORD=secret 17 | 18 | BROADCAST_DRIVER=log 19 | CACHE_DRIVER=file 20 | FILESYSTEM_DISK=local 21 | QUEUE_CONNECTION=sync 22 | SESSION_DRIVER=file 23 | SESSION_LIFETIME=120 24 | 25 | MEMCACHED_HOST=127.0.0.1 26 | 27 | REDIS_HOST=redis 28 | REDIS_PASSWORD=null 29 | REDIS_PORT=6379 30 | 31 | MAIL_MAILER=smtp 32 | MAIL_HOST=mailpit 33 | MAIL_PORT=1025 34 | MAIL_USERNAME=null 35 | MAIL_PASSWORD=null 36 | MAIL_ENCRYPTION=null 37 | MAIL_FROM_ADDRESS="hello@example.com" 38 | MAIL_FROM_NAME="${APP_NAME}" 39 | 40 | AWS_ACCESS_KEY_ID= 41 | AWS_SECRET_ACCESS_KEY= 42 | AWS_DEFAULT_REGION=us-east-1 43 | AWS_BUCKET= 44 | AWS_USE_PATH_STYLE_ENDPOINT=false 45 | 46 | PUSHER_APP_ID= 47 | PUSHER_APP_KEY= 48 | PUSHER_APP_SECRET= 49 | PUSHER_HOST= 50 | PUSHER_PORT=443 51 | PUSHER_SCHEME=https 52 | PUSHER_APP_CLUSTER=mt1 53 | 54 | VITE_APP_NAME="${APP_NAME}" 55 | VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 56 | VITE_PUSHER_HOST="${PUSHER_HOST}" 57 | VITE_PUSHER_PORT="${PUSHER_PORT}" 58 | VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" 59 | VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 60 | -------------------------------------------------------------------------------- /.env.prod.example: -------------------------------------------------------------------------------- 1 | APP_NAME="Simple Slides" 2 | APP_ENV=production 3 | APP_KEY= 4 | APP_DEBUG=false 5 | APP_URL=http://localhost 6 | 7 | LOG_LEVEL=critical 8 | 9 | DB_CONNECTION=pgsql 10 | DB_HOST=pgsql 11 | DB_PORT=5432 12 | DB_DATABASE=simple_slides_app 13 | DB_USERNAME=root 14 | DB_PASSWORD=secret 15 | 16 | BROADCAST_DRIVER=redis 17 | CACHE_DRIVER=redis 18 | QUEUE_CONNECTION=sync 19 | SESSION_DRIVER=redis 20 | FILESYSTEM_DISK=do 21 | SESSION_LIFETIME=120 22 | 23 | REDIS_HOST=redis 24 | REDIS_PASSWORD=null 25 | REDIS_PORT=6379 26 | 27 | # Sendgrid 28 | MAIL_MAILER=smtp 29 | MAIL_HOST=smtp.sendgrid.net 30 | MAIL_PORT=587 31 | MAIL_USERNAME=apikey 32 | MAIL_PASSWORD= 33 | MAIL_ENCRYPTION=tls 34 | MAIL_FROM_NAME="Simple Slides" 35 | MAIL_FROM_ADDRESS="no-reply@simpleslides.dev" 36 | 37 | # Digital Ocean Spaces 38 | DO_ACCESS_KEY_ID= 39 | DO_SECRET_ACCESS_KEY= 40 | DO_DEFAULT_REGION=nyc3 41 | DO_BUCKET= 42 | DO_ENDPOINT=https://nyc3.digitaloceanspaces.com/ 43 | 44 | FILAMENT_FILESYSTEM_DISK=do 45 | MEDIA_DISK=do 46 | -------------------------------------------------------------------------------- /.env.testing: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY=base64:mpoLKew8xsj4Qnk6F5+OxKFibU6MgrCCT4LGOdQnH0c= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | LOG_DEPRECATIONS_CHANNEL=null 9 | LOG_LEVEL=debug 10 | 11 | DB_CONNECTION=pgsql 12 | DB_HOST=pgsql 13 | DB_PORT=5432 14 | DB_DATABASE=simple_slides_app 15 | DB_USERNAME=root 16 | DB_PASSWORD=secret 17 | 18 | BROADCAST_DRIVER=log 19 | CACHE_DRIVER=file 20 | FILESYSTEM_DISK=local 21 | QUEUE_CONNECTION=sync 22 | SESSION_DRIVER=file 23 | SESSION_LIFETIME=120 24 | 25 | MEMCACHED_HOST=127.0.0.1 26 | 27 | REDIS_HOST=redis 28 | REDIS_PASSWORD=null 29 | REDIS_PORT=6379 30 | 31 | MAIL_MAILER=smtp 32 | MAIL_HOST=mailpit 33 | MAIL_PORT=1025 34 | MAIL_USERNAME=null 35 | MAIL_PASSWORD=null 36 | MAIL_ENCRYPTION=null 37 | MAIL_FROM_ADDRESS="hello@example.com" 38 | MAIL_FROM_NAME="${APP_NAME}" 39 | 40 | AWS_ACCESS_KEY_ID= 41 | AWS_SECRET_ACCESS_KEY= 42 | AWS_DEFAULT_REGION=us-east-1 43 | AWS_BUCKET= 44 | AWS_USE_PATH_STYLE_ENDPOINT=false 45 | 46 | PUSHER_APP_ID= 47 | PUSHER_APP_KEY= 48 | PUSHER_APP_SECRET= 49 | PUSHER_HOST= 50 | PUSHER_PORT=443 51 | PUSHER_SCHEME=https 52 | PUSHER_APP_CLUSTER=mt1 53 | 54 | VITE_APP_NAME="${APP_NAME}" 55 | VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 56 | VITE_PUSHER_HOST="${PUSHER_HOST}" 57 | VITE_PUSHER_PORT="${PUSHER_PORT}" 58 | VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" 59 | VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 60 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | 3 | *.blade.php diff=html 4 | *.css diff=css 5 | *.html diff=html 6 | *.md diff=markdown 7 | *.php diff=php 8 | 9 | /.github export-ignore 10 | CHANGELOG.md export-ignore 11 | .styleci.yml export-ignore 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.phpunit.cache 2 | /node_modules 3 | /public/build 4 | /public/hot 5 | /public/storage 6 | /storage/*.key 7 | /vendor 8 | .env 9 | .env.backup 10 | .env.prod 11 | .phpunit.result.cache 12 | Homestead.json 13 | Homestead.yaml 14 | auth.json 15 | npm-debug.log 16 | yarn-error.log 17 | /.fleet 18 | /.idea 19 | /.vscode 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Aaron Krauss 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | job(new AggregateDailyViews)->daily(); 17 | } 18 | 19 | /** 20 | * Register the commands for the application. 21 | */ 22 | protected function commands(): void 23 | { 24 | $this->load(__DIR__.'/Commands'); 25 | 26 | require base_path('routes/console.php'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/Enums/PresentationFilter.php: -------------------------------------------------------------------------------- 1 | 'Instructions', 19 | self::ADHOC => 'Adhoc', 20 | }; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Enums/SlideDelimiter.php: -------------------------------------------------------------------------------- 1 | 'Double New Line', 25 | self::THREE_DASHES => '---', 26 | }; 27 | } 28 | 29 | /** 30 | * Returns the user-friendly label 31 | */ 32 | public function helperText(): string 33 | { 34 | return match ($this) { 35 | self::DOUBLE_NEW_LINE => '2 newlines (i.e. hitting Enter twice)', 36 | self::THREE_DASHES => '3 hyphens (---)', 37 | }; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Enums/Traits/EnumToArray.php: -------------------------------------------------------------------------------- 1 | pluck('name') 19 | ->toArray(); 20 | } 21 | 22 | /** 23 | * The array of values for the enum. 24 | * 25 | * @return mixed[] 26 | */ 27 | public static function values(): array 28 | { 29 | return collect(self::cases()) 30 | ->pluck('value') 31 | ->toArray(); 32 | } 33 | 34 | /** 35 | * The array of values for the enum. 36 | * 37 | * @return array 38 | */ 39 | public static function array(): array 40 | { 41 | return collect(self::cases()) 42 | ->reduce(function ($carry, $row): array { 43 | $carry[$row->value] = strval($row->label()); 44 | 45 | return $carry; 46 | }, []); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $dontFlash = [ 16 | 'current_password', 17 | 'password', 18 | 'password_confirmation', 19 | ]; 20 | 21 | /** 22 | * Register the exception handling callbacks for the application. 23 | */ 24 | public function register(): void 25 | { 26 | $this->reportable(function (Throwable $e) { 27 | // 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Filament/Pages/Auth/Register.php: -------------------------------------------------------------------------------- 1 | schema([ 15 | $this->getNameFormComponent(), 16 | $this->getEmailFormComponent(), 17 | TextInput::make('username') 18 | ->unique('users', 'username') 19 | ->rules('required|string|lowercase|alpha_dash:ascii|max:255') 20 | ->required() 21 | ->maxLength(255), 22 | $this->getPasswordFormComponent(), 23 | $this->getPasswordConfirmationFormComponent(), 24 | ]); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Filament/Resources/ImageUploadResource/Pages/CreateImageUpload.php: -------------------------------------------------------------------------------- 1 | label('Copy Image URL') 21 | ->copyable(fn (ImageUpload $record): string => $record->getFirstMediaUrl('image')), 22 | CopyAction::make('copyMarkdownUrl') 23 | ->label('Copy Markdown URL') 24 | ->copyable(fn (ImageUpload $record): string => $record->markdownUrl), 25 | Actions\DeleteAction::make(), 26 | ]), 27 | ]; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/Filament/Resources/ImageUploadResource/Pages/ListImageUploads.php: -------------------------------------------------------------------------------- 1 | user()->isAdministrator()) { 14 | $size = number_format( 15 | num: Media::sum('size') / (1000 * 1000), 16 | decimals: 2, 17 | ); 18 | 19 | return [ 20 | Stat::make('Total Storage Space Used (in MB)', $size), 21 | ]; 22 | } 23 | 24 | $limit = number_format( 25 | num: config('app-upload.limit') / (1000 * 1000), 26 | decimals: 0, 27 | ); 28 | 29 | $size = number_format( 30 | num: auth()->user()->image_uploaded_size / (1000 * 1000), 31 | decimals: 2, 32 | ); 33 | 34 | return [ 35 | Stat::make('Storage Space Used (in MB)', "$size / $limit") 36 | ->description( 37 | 'This includes images in your library, as well as '. 38 | 'thumbnails from your presentations. If this goes over '. 39 | 'the limit, you won\'t be able to upload any more images.' 40 | ), 41 | ]; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/Filament/Resources/PresentationResource/Pages/CreatePresentation.php: -------------------------------------------------------------------------------- 1 | action('create'), 20 | ]; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Filament/Resources/PresentationResource/Pages/ListPresentations.php: -------------------------------------------------------------------------------- 1 | aggregateViews(withinRange: true), 23 | $this->dailyViews(), 24 | $this->aggregateViews(), 25 | ]; 26 | } 27 | 28 | private function dailyViews(): Stat 29 | { 30 | $views = DailyView::forUser() 31 | ->stats(presentationId: $this->filters['presentation_id']) 32 | ->get(); 33 | 34 | $totalviews = $views->count(); 35 | $uniqueviews = $views->unique(function (DailyView $item) { 36 | return $item->presentation_id.$item->session_id; 37 | })->count(); 38 | 39 | $percentUniqueviews = $totalviews == 0 40 | ? 0 41 | : round(($uniqueviews / $totalviews) * 100); 42 | 43 | return Stat::make('Total Views Today', $totalviews) 44 | ->description($percentUniqueviews."% ($uniqueviews) Unique Views"); 45 | } 46 | 47 | private function aggregateViews(bool $withinRange = false): Stat 48 | { 49 | $views = AggregateView::forUser() 50 | ->stats( 51 | presentationId: $this->filters['presentation_id'], 52 | startDate: $withinRange ? $this->filters['start_date'] : null, 53 | endDate: $withinRange ? $this->filters['end_date'] : null, 54 | )->get(); 55 | 56 | $totalviews = $views->sum('total_count'); 57 | $uniqueviews = $views->sum('unique_count'); 58 | 59 | $percentUniqueviews = $totalviews == 0 60 | ? 0 61 | : round(($uniqueviews / $totalviews) * 100); 62 | 63 | $heading = $withinRange ? 'Total Views in Date Range' : 'Total Lifetime Views'; 64 | 65 | return Stat::make($heading, $totalviews) 66 | ->description($percentUniqueviews."% ($uniqueviews) Unique Views"); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/Filament/Widgets/ViewTrendsChart.php: -------------------------------------------------------------------------------- 1 | stats(presentationId: $this->filters['presentation_id']) 31 | )->between( 32 | start: Carbon::parse($this->filters['start_date'])->startOfDay(), 33 | end: Carbon::parse($this->filters['end_date'])->endOfDay(), 34 | ) 35 | ->perDay(); 36 | 37 | $totalData = $trend->sum('total_count'); 38 | $uniqueData = $trend->sum('unique_count'); 39 | 40 | return [ 41 | 'datasets' => [ 42 | [ 43 | 'label' => 'Total Views', 44 | 'data' => $totalData->map(fn (TrendValue $value) => $value->aggregate), 45 | 'borderColor' => '#9BD0F5', 46 | ], 47 | [ 48 | 'label' => 'Unique Views', 49 | 'data' => $uniqueData->map(fn (TrendValue $value) => $value->aggregate), 50 | ], 51 | ], 52 | 'labels' => $totalData->map(fn (TrendValue $value) => $value->date), 53 | ]; 54 | } 55 | 56 | protected function getType(): string 57 | { 58 | return 'line'; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/Http/Controllers/AdhocSlidesController.php: -------------------------------------------------------------------------------- 1 | dispatchDailyView(); 14 | 15 | return Inertia::render('AdhocSlides'); 16 | } 17 | 18 | public function show(string $slides): Response 19 | { 20 | if (! $this->isValidBase64String($slides)) { 21 | abort(404); 22 | } 23 | 24 | $this->dispatchDailyView(slug: $slides); 25 | 26 | return Inertia::render('AdhocSlides', [ 27 | 'encodedSlides' => $slides, 28 | 'meta' => [ 29 | 'title' => 'My Presentation', 30 | ], 31 | ]); 32 | } 33 | 34 | private function isValidBase64String(string $value): bool 35 | { 36 | // Decode and encode the string via base64. 37 | // If the string is the same, then it is valid. 38 | if (base64_encode((string) base64_decode($value, true)) == $value) { 39 | return true; 40 | } 41 | 42 | return false; 43 | } 44 | 45 | private function dispatchDailyView(?string $slug = null): void 46 | { 47 | if (auth()->user()?->isAdministrator() ?? false) { 48 | return; 49 | } 50 | 51 | dispatch( 52 | fn () => DailyView::createForAdhocPresentation(slug: $slug) 53 | )->afterResponse(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | presentations() 16 | ->where('slug', $slug) 17 | ->firstOrFail(); 18 | 19 | if (! $presentation->canBeViewed) { 20 | abort(403); 21 | } 22 | 23 | if ($presentation->shouldTrackView) { 24 | dispatch(function () use ($presentation) { 25 | $presentation->addDailyView(); 26 | })->afterResponse(); 27 | } 28 | 29 | return Inertia::render('Presentation', [ 30 | 'presentation' => new PresentationResource($presentation), 31 | 'meta' => [ 32 | 'title' => $presentation->title, 33 | 'description' => $presentation->description, 34 | 'imageUrl' => $presentation->getFirstMediaUrl('thumbnail'), 35 | ], 36 | ]); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/Http/Controllers/SettingsController.php: -------------------------------------------------------------------------------- 1 | [ 14 | 'title' => 'Settings', 15 | ], 16 | ]); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | expectsJson() ? null : route('login'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/HandleInertiaRequests.php: -------------------------------------------------------------------------------- 1 | 30 | */ 31 | public function share(Request $request): array 32 | { 33 | $index = intval(request()->input('index')); 34 | $progress = request()->input('progress'); 35 | $loop = intval(request()->input('loop')); 36 | 37 | return [ 38 | ...parent::share($request), 39 | 'index' => $index, 40 | 'progress' => $progress, 41 | 'loop' => $loop, 42 | 'auth' => [ 43 | 'user' => $request->user(), 44 | ], 45 | 'ziggy' => fn () => [ 46 | ...(new Ziggy)->toArray(), 47 | 'location' => $request->url(), 48 | ], 49 | ]; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/Http/Middleware/PreventRequestsDuringMaintenance.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 24 | return redirect(RouteServiceProvider::HOME); 25 | } 26 | } 27 | 28 | return $next($request); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | 'current_password', 16 | 'password', 17 | 'password_confirmation', 18 | ]; 19 | } 20 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustHosts.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function hosts(): array 15 | { 16 | return [ 17 | $this->allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | |string|null 14 | */ 15 | protected $proxies = '*'; 16 | 17 | /** 18 | * The headers that should be used to detect proxies. 19 | * 20 | * @var int 21 | */ 22 | protected $headers = 23 | Request::HEADER_X_FORWARDED_FOR | 24 | Request::HEADER_X_FORWARDED_HOST | 25 | Request::HEADER_X_FORWARDED_PORT | 26 | Request::HEADER_X_FORWARDED_PROTO | 27 | Request::HEADER_X_FORWARDED_AWS_ELB; 28 | } 29 | -------------------------------------------------------------------------------- /app/Http/Middleware/ValidateSignature.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 'fbclid', 16 | // 'utm_campaign', 17 | // 'utm_content', 18 | // 'utm_medium', 19 | // 'utm_source', 20 | // 'utm_term', 21 | ]; 22 | } 23 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Requests/Auth/LoginRequest.php: -------------------------------------------------------------------------------- 1 | |string> 26 | */ 27 | public function rules(): array 28 | { 29 | return [ 30 | 'email' => ['required', 'string', 'email'], 31 | 'password' => ['required', 'string'], 32 | ]; 33 | } 34 | 35 | /** 36 | * Attempt to authenticate the request's credentials. 37 | * 38 | * @throws \Illuminate\Validation\ValidationException 39 | */ 40 | public function authenticate(): void 41 | { 42 | $this->ensureIsNotRateLimited(); 43 | 44 | if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) { 45 | RateLimiter::hit($this->throttleKey()); 46 | 47 | throw ValidationException::withMessages([ 48 | 'email' => trans('auth.failed'), 49 | ]); 50 | } 51 | 52 | RateLimiter::clear($this->throttleKey()); 53 | } 54 | 55 | /** 56 | * Ensure the login request is not rate limited. 57 | * 58 | * @throws \Illuminate\Validation\ValidationException 59 | */ 60 | public function ensureIsNotRateLimited(): void 61 | { 62 | if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { 63 | return; 64 | } 65 | 66 | event(new Lockout($this)); 67 | 68 | $seconds = RateLimiter::availableIn($this->throttleKey()); 69 | 70 | throw ValidationException::withMessages([ 71 | 'email' => trans('auth.throttle', [ 72 | 'seconds' => $seconds, 73 | 'minutes' => ceil($seconds / 60), 74 | ]), 75 | ]); 76 | } 77 | 78 | /** 79 | * Get the rate limiting throttle key for the request. 80 | */ 81 | public function throttleKey(): string 82 | { 83 | return Str::transliterate(Str::lower($this->input('email')).'|'.$this->ip()); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/Http/Resources/PresentationResource.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | public function toArray(Request $request): array 16 | { 17 | return $this 18 | ->resource 19 | ->only([ 20 | 'id', 21 | 'content', 22 | 'slide_delimiter', 23 | 'is_published', 24 | ]); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Jobs/AggregateDailyViews.php: -------------------------------------------------------------------------------- 1 | selectRaw('presentation_id, session_id, count(*) as total') 33 | ->groupBy('presentation_id', 'session_id') 34 | ->get() 35 | ->groupBy('presentation_id') 36 | ->map(function ($record) { 37 | return [ 38 | 'presentation_id' => $record[0]->presentation_id, 39 | 'unique_count' => $record->count(), 40 | 'total_count' => $record->sum('total'), 41 | ]; 42 | })->values() 43 | ->toArray(); 44 | 45 | // Process daily views from adhoc presentations 46 | $adhocData = DailyView::whereNull('presentation_id') 47 | ->selectRaw('adhoc_slug, session_id, count(*) as total') 48 | ->groupBy('adhoc_slug', 'session_id') 49 | ->get() 50 | ->groupBy('adhoc_slug') 51 | ->map(function ($record) { 52 | return [ 53 | 'adhoc_slug' => $record[0]->adhoc_slug, 54 | 'unique_count' => $record->count(), 55 | 'total_count' => $record->sum('total'), 56 | ]; 57 | })->values() 58 | ->toArray(); 59 | 60 | // Note: Inserting these separately, since the columns are different. 61 | AggregateView::insert($presentationData); 62 | AggregateView::insert($adhocData); 63 | 64 | DailyView::truncate(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/Jobs/GenerateThumbnail.php: -------------------------------------------------------------------------------- 1 | presentation->slug}-{$this->presentation->user->username}.jpg"); 34 | 35 | $browsershot = Browsershot::url(route('presentations.show', [ 36 | 'user' => $this->presentation->user->username, 37 | 'slug' => $this->presentation->slug, 38 | ])) 39 | ->waitUntilNetworkIdle() 40 | ->windowSize(1200, 630) 41 | ->newHeadless() 42 | ->setOption('args', [ 43 | '--disable-web-security', 44 | '--disable-gpu', 45 | '--disable-dev-shm-usage', 46 | '--disable-setuid-sandbox', 47 | '--no-first-run', 48 | '--no-sandbox', 49 | '--no-zygote', 50 | '--deterministic-fetch', 51 | '--disable-features=IsolateOrigins', 52 | '--disable-site-isolation-trials', 53 | ]) 54 | ->setScreenshotType('jpeg', 90) 55 | ->setOption('addStyleTag', json_encode([ 56 | 'content' => '.slide-view { height: 100vh !important; } ' 57 | .'.browsershot-hide { display: none !important; }', 58 | ])); 59 | 60 | if (! App::environment('local')) { 61 | $browsershot->setChromePath('/usr/bin/chromium-browser'); 62 | } 63 | 64 | $browsershot->save($tempPath); 65 | 66 | $this->presentation->clearMediaCollection('thumbnail'); 67 | $this->presentation->addMedia($tempPath)->toMediaCollection('thumbnail'); 68 | 69 | // Note: If in the future we implement a websocket server, 70 | // then we can implement a completed notification like this. 71 | // 72 | // Notification::make() 73 | // ->title('Thumbnail successfully generated. Refresh your page to view the new thumbnail.') 74 | // ->broadcast($this->user) 75 | // ->success() 76 | // ->send(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/Livewire/UsernameComponent.php: -------------------------------------------------------------------------------- 1 | 26 | */ 27 | public array $only = ['username']; 28 | 29 | public function form(Form $form): Form 30 | { 31 | return $form 32 | ->schema([ 33 | TextInput::make('username') 34 | ->unique(ignoreRecord: true) 35 | ->required() 36 | ->rules(['string', 'lowercase', 'alpha_dash:ascii', 'max:255']) 37 | ->helperText( 38 | 'NOTE: Changing this will change the URL of your ' 39 | .'presentations, so be careful here. ' 40 | .'i.e. /{username}/{presentation}' 41 | ), 42 | ]) 43 | ->statePath('data'); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/Models/DailyView.php: -------------------------------------------------------------------------------- 1 | */ 15 | use HasFactory; 16 | 17 | const UPDATED_AT = null; 18 | 19 | /** 20 | * The attributes that are mass assignable. 21 | * 22 | * @var array 23 | */ 24 | protected $fillable = [ 25 | 'presentation_id', 26 | 'adhoc_slug', 27 | ]; 28 | 29 | /** 30 | * Generate a daily view record for this adhoc presentation. 31 | */ 32 | public static function createForAdhocPresentation(?string $slug = null): self 33 | { 34 | return self::create([ 35 | 'adhoc_slug' => $slug, 36 | ]); 37 | } 38 | 39 | /** 40 | * Scope a query to return stats for the dashboard 41 | * 42 | * @param Builder $query 43 | */ 44 | public function scopeStats(Builder $query, ?string $presentationId = null): void 45 | { 46 | if ($presentationId === PresentationFilter::INSTRUCTIONS->value) { 47 | $query 48 | ->whereNull('presentation_id') 49 | ->whereNull('adhoc_slug'); 50 | 51 | return; 52 | } 53 | 54 | if ($presentationId === PresentationFilter::ADHOC->value) { 55 | $query 56 | ->whereNull('presentation_id') 57 | ->whereNotNull('adhoc_slug') 58 | ->get(); 59 | 60 | return; 61 | } 62 | 63 | if (is_null($presentationId)) { 64 | return; 65 | } 66 | 67 | $query->where('presentation_id', intval($presentationId)); 68 | } 69 | 70 | /** 71 | * Scope a query to only include daily views for the authenticated user. 72 | * 73 | * @param Builder $query 74 | */ 75 | public function scopeForUser(Builder $query): void 76 | { 77 | $query->when(! auth()->user()->isAdministrator(), function ($qr) { 78 | $qr->whereHas('presentation', function ($qrPresn) { 79 | $qrPresn->where('user_id', auth()->id()); 80 | }); 81 | }); 82 | } 83 | 84 | /** 85 | * The Presentation that this record belongs to 86 | * 87 | * @return BelongsTo 88 | */ 89 | public function presentation(): BelongsTo 90 | { 91 | return $this->belongsTo(Presentation::class); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /app/Models/ImageUpload.php: -------------------------------------------------------------------------------- 1 | */ 16 | use HasFactory; 17 | 18 | use InteractsWithMedia; 19 | 20 | /** 21 | * The attributes that are not mass assignable. 22 | * 23 | * @var string[] 24 | */ 25 | protected $guarded = [ 26 | 'id', 27 | ]; 28 | 29 | /** 30 | * Get the computed markdown URL for the image 31 | * 32 | * @return Attribute 33 | */ 34 | protected function markdownUrl(): Attribute 35 | { 36 | return Attribute::make( 37 | get: fn (mixed $value, array $attributes) => "![{$attributes['alt_text']}]({$this->getFirstMediaUrl('image')})", 38 | ); 39 | } 40 | 41 | /** 42 | * The User that this record belongs to 43 | * 44 | * @return BelongsTo 45 | */ 46 | public function user(): BelongsTo 47 | { 48 | return $this->belongsTo(User::class); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/Observers/DailyViewObserver.php: -------------------------------------------------------------------------------- 1 | session_id)) { 15 | return; 16 | } 17 | 18 | $dailyView->session_id = session()->getId(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Observers/ImageUploadObserver.php: -------------------------------------------------------------------------------- 1 | check() && $imageUpload->user_id === null) { 15 | $imageUpload->user_id = intval(auth()->id()); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/Observers/MediaObserver.php: -------------------------------------------------------------------------------- 1 | check()) { 15 | return; 16 | } 17 | 18 | auth()->user()->modifyImageUploadedSize($media->size); 19 | } 20 | 21 | /** 22 | * Handle the Media "deleted" event. 23 | */ 24 | public function deleted(Media $media): void 25 | { 26 | if (! auth()->check()) { 27 | return; 28 | } 29 | 30 | auth()->user()->modifyImageUploadedSize($media->size * -1); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Observers/PresentationObserver.php: -------------------------------------------------------------------------------- 1 | check() && $presentation->user_id === null) { 15 | $presentation->user_id = intval(auth()->id()); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/Policies/PresentationPolicy.php: -------------------------------------------------------------------------------- 1 | isAdministrator()) { 16 | return true; 17 | } 18 | 19 | return null; 20 | } 21 | 22 | /** 23 | * Determine whether the user can view any models. 24 | */ 25 | public function viewAny(User $user): bool 26 | { 27 | return true; 28 | } 29 | 30 | /** 31 | * Determine whether the user can view the model. 32 | */ 33 | public function view(User $user, Presentation $presentation): bool 34 | { 35 | return $presentation->user_id === $user->id; 36 | } 37 | 38 | /** 39 | * Determine whether the user can create models. 40 | */ 41 | public function create(User $user): bool 42 | { 43 | return true; 44 | } 45 | 46 | /** 47 | * Determine whether the user can update the model. 48 | */ 49 | public function update(User $user, Presentation $presentation): bool 50 | { 51 | return $presentation->user_id === $user->id; 52 | } 53 | 54 | /** 55 | * Determine whether the user can delete the model. 56 | */ 57 | public function delete(User $user, Presentation $presentation): bool 58 | { 59 | return $presentation->user_id === $user->id; 60 | } 61 | 62 | /** 63 | * Determine whether the user can restore the model. 64 | */ 65 | public function restore(User $user, Presentation $presentation): bool 66 | { 67 | return $presentation->user_id === $user->id; 68 | } 69 | 70 | /** 71 | * Determine whether the user can permanently delete the model. 72 | */ 73 | public function forceDelete(User $user, Presentation $presentation): bool 74 | { 75 | return $presentation->user_id === $user->id; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/Policies/UserPolicy.php: -------------------------------------------------------------------------------- 1 | isAdministrator()) { 15 | return true; 16 | } 17 | 18 | return null; 19 | } 20 | 21 | /** 22 | * Determine whether the user can view any models. 23 | */ 24 | public function viewAny(User $user): bool 25 | { 26 | return false; 27 | } 28 | 29 | /** 30 | * Determine whether the user can view the model. 31 | */ 32 | public function view(User $user, User $model): bool 33 | { 34 | return $user->id === $model->id; 35 | } 36 | 37 | /** 38 | * Determine whether the user can create models. 39 | */ 40 | public function create(User $user): bool 41 | { 42 | return false; 43 | } 44 | 45 | /** 46 | * Determine whether the user can update the model. 47 | */ 48 | public function update(User $user, User $model): bool 49 | { 50 | return $user->id === $model->id; 51 | } 52 | 53 | /** 54 | * Determine whether the user can delete the model. 55 | */ 56 | public function delete(User $user, User $model): bool 57 | { 58 | return false; 59 | } 60 | 61 | /** 62 | * Determine whether the user can restore the model. 63 | */ 64 | public function restore(User $user, User $model): bool 65 | { 66 | return false; 67 | } 68 | 69 | /** 70 | * Determine whether the user can permanently delete the model. 71 | */ 72 | public function forceDelete(User $user, User $model): bool 73 | { 74 | return false; 75 | } 76 | 77 | /** 78 | * Determine whether the user can upload more files. 79 | */ 80 | public function upload(User $user): bool 81 | { 82 | return $user->image_uploaded_size < config('app-upload.limit'); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | label('Helpful Videos') 32 | ->url( 33 | 'https://www.youtube.com/playlist?list=PLWXp2X5PBDOkzYGV3xd0zviD6xR8OoiFR', 34 | shouldOpenInNewTab: true 35 | )->icon('heroicon-s-play-circle'), 36 | ]); 37 | }); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $policies = [ 16 | // 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | */ 22 | public function boot(): void 23 | { 24 | // 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | > 19 | */ 20 | protected $listen = [ 21 | Registered::class => [ 22 | SendEmailVerificationNotification::class, 23 | ], 24 | ]; 25 | 26 | /** 27 | * Register any events for your application. 28 | */ 29 | public function boot(): void 30 | { 31 | Models\DailyView::observe(Observers\DailyViewObserver::class); 32 | Models\ImageUpload::observe(Observers\ImageUploadObserver::class); 33 | Models\Presentation::observe(Observers\PresentationObserver::class); 34 | Media::observe(Observers\MediaObserver::class); 35 | } 36 | 37 | /** 38 | * Determine if events and listeners should be automatically discovered. 39 | */ 40 | public function shouldDiscoverEvents(): bool 41 | { 42 | return false; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | by($request->user()?->id ?: $request->ip()); 29 | }); 30 | 31 | $this->routes(function () { 32 | Route::middleware('api') 33 | ->prefix('api') 34 | ->group(base_path('routes/api.php')); 35 | 36 | Route::middleware('web') 37 | ->group(base_path('routes/web.php')); 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /config/app-upload.php: -------------------------------------------------------------------------------- 1 | 2 | intval(env('UPLOAD_LIMIT', 50 * 1000 * 1000)), // 50 MB 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Upload Size Validation Message 21 | |-------------------------------------------------------------------------- 22 | | 23 | | The validation message presented when a user tries to upload a file 24 | | and they have exceeded the storage limit. 25 | | 26 | */ 27 | 28 | 'limit_exceeded_message' => 'You have exceeded your available upload storage space. To make more '. 29 | 'room, please delete some images from your library, or remove '. 30 | 'thumbnails from your presentations.', 31 | ]; 32 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 41 | 'port' => env('PUSHER_PORT', 443), 42 | 'scheme' => env('PUSHER_SCHEME', 'https'), 43 | 'encrypted' => true, 44 | 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', 45 | ], 46 | 'client_options' => [ 47 | // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html 48 | ], 49 | ], 50 | 51 | 'ably' => [ 52 | 'driver' => 'ably', 53 | 'key' => env('ABLY_KEY'), 54 | ], 55 | 56 | 'redis' => [ 57 | 'driver' => 'redis', 58 | 'connection' => 'default', 59 | ], 60 | 61 | 'log' => [ 62 | 'driver' => 'log', 63 | ], 64 | 65 | 'null' => [ 66 | 'driver' => 'null', 67 | ], 68 | 69 | ], 70 | 71 | ]; 72 | -------------------------------------------------------------------------------- /config/cors.php: -------------------------------------------------------------------------------- 1 | ['api/*', 'sanctum/csrf-cookie'], 19 | 20 | 'allowed_methods' => ['*'], 21 | 22 | 'allowed_origins' => ['*'], 23 | 24 | 'allowed_origins_patterns' => [], 25 | 26 | 'allowed_headers' => ['*'], 27 | 28 | 'exposed_headers' => [], 29 | 30 | 'max_age' => 0, 31 | 32 | 'supports_credentials' => false, 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /config/filament.php: -------------------------------------------------------------------------------- 1 | [ 18 | 19 | // 'echo' => [ 20 | // 'broadcaster' => 'pusher', 21 | // 'key' => env('VITE_PUSHER_APP_KEY'), 22 | // 'cluster' => env('VITE_PUSHER_APP_CLUSTER'), 23 | // 'wsHost' => env('VITE_PUSHER_HOST'), 24 | // 'wsPort' => env('VITE_PUSHER_PORT'), 25 | // 'wssPort' => env('VITE_PUSHER_PORT'), 26 | // 'authEndpoint' => '/api/v1/broadcasting/auth', 27 | // 'disableStats' => true, 28 | // 'encrypted' => true, 29 | // ], 30 | 31 | ], 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Default Filesystem Disk 36 | |-------------------------------------------------------------------------- 37 | | 38 | | This is the storage disk Filament will use to put media. You may use any 39 | | of the disks defined in the `config/filesystems.php`. 40 | | 41 | */ 42 | 43 | 'default_filesystem_disk' => env('FILAMENT_FILESYSTEM_DISK', 'public'), 44 | 45 | /* 46 | |-------------------------------------------------------------------------- 47 | | Assets Path 48 | |-------------------------------------------------------------------------- 49 | | 50 | | This is the directory where Filament's assets will be published to. It 51 | | is relative to the `public` directory of your Laravel application. 52 | | 53 | | After changing the path, you should run `php artisan filament:assets`. 54 | | 55 | */ 56 | 57 | 'assets_path' => null, 58 | 59 | /* 60 | |-------------------------------------------------------------------------- 61 | | Livewire Loading Delay 62 | |-------------------------------------------------------------------------- 63 | | 64 | | This sets the delay before loading indicators appear. 65 | | 66 | | Setting this to 'none' makes indicators appear immediately, which can be 67 | | desirable for high-latency connections. Setting it to 'default' applies 68 | | Livewire's standard 200ms delay. 69 | | 70 | */ 71 | 72 | 'livewire_loading_delay' => 'default', 73 | 74 | ]; 75 | -------------------------------------------------------------------------------- /config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 65536, 48 | 'threads' => 1, 49 | 'time' => 4, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /config/meta.php: -------------------------------------------------------------------------------- 1 | 'Simple Slides is a responsive and text-first presentation '. 5 | 'tool that keeps your audience engaged.', 6 | 'base_og_image' => 'https://simpleslides.dev/images/simple-slides-og.jpg', 7 | 'twitter_handle' => '@thecodeboss', 8 | ]; 9 | -------------------------------------------------------------------------------- /config/sanctum.php: -------------------------------------------------------------------------------- 1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( 19 | '%s%s', 20 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', 21 | Sanctum::currentApplicationUrlWithPort() 22 | ))), 23 | 24 | /* 25 | |-------------------------------------------------------------------------- 26 | | Sanctum Guards 27 | |-------------------------------------------------------------------------- 28 | | 29 | | This array contains the authentication guards that will be checked when 30 | | Sanctum is trying to authenticate a request. If none of these guards 31 | | are able to authenticate the request, Sanctum will use the bearer 32 | | token that's present on an incoming request for authentication. 33 | | 34 | */ 35 | 36 | 'guard' => ['web'], 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Expiration Minutes 41 | |-------------------------------------------------------------------------- 42 | | 43 | | This value controls the number of minutes until an issued token will be 44 | | considered expired. If this value is null, personal access tokens do 45 | | not expire. This won't tweak the lifetime of first-party sessions. 46 | | 47 | */ 48 | 49 | 'expiration' => null, 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Sanctum Middleware 54 | |-------------------------------------------------------------------------- 55 | | 56 | | When authenticating your first-party SPA with Sanctum you may need to 57 | | customize some of the middleware Sanctum uses while processing the 58 | | request. You may change the middleware listed below as required. 59 | | 60 | */ 61 | 62 | 'middleware' => [ 63 | 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, 64 | 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, 65 | ], 66 | 67 | ]; 68 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | 'scheme' => 'https', 22 | ], 23 | 24 | 'postmark' => [ 25 | 'token' => env('POSTMARK_TOKEN'), 26 | ], 27 | 28 | 'ses' => [ 29 | 'key' => env('AWS_ACCESS_KEY_ID'), 30 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 31 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 32 | ], 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /config/tinker.php: -------------------------------------------------------------------------------- 1 | [ 17 | // App\Console\Commands\ExampleCommand::class, 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Auto Aliased Classes 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Tinker will not automatically alias classes in your vendor namespaces 26 | | but you may explicitly allow a subset of classes to get aliased by 27 | | adding the names of each of those classes to the following list. 28 | | 29 | */ 30 | 31 | 'alias' => [ 32 | 'App\Models', 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Classes That Should Not Be Aliased 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Typically, Tinker automatically aliases classes as you require them in 41 | | Tinker. However, you may wish to never alias certain classes, which 42 | | you may accomplish by listing the classes in the following array. 43 | | 44 | */ 45 | 46 | 'dont_alias' => [ 47 | 'App\Nova', 48 | ], 49 | 50 | ]; 51 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /database/factories/AggregateViewFactory.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class AggregateViewFactory extends Factory 12 | { 13 | /** 14 | * Define the model's default state. 15 | * 16 | * @return array 17 | */ 18 | public function definition(): array 19 | { 20 | return [ 21 | 'adhoc_slug' => fake()->optional()->slug(), 22 | 'presentation_id' => fake()->boolean() ? Presentation::factory() : null, 23 | ]; 24 | } 25 | 26 | /** 27 | * Set data for an instructions record 28 | */ 29 | public function instructions(): static 30 | { 31 | return $this->state(fn (array $attributes) => [ 32 | 'presentation_id' => null, 33 | 'adhoc_slug' => null, 34 | ]); 35 | } 36 | 37 | /** 38 | * Set data for an adhoc record 39 | */ 40 | public function adhoc(): static 41 | { 42 | return $this->state(fn (array $attributes) => [ 43 | 'presentation_id' => null, 44 | 'adhoc_slug' => fake()->slug(), 45 | ]); 46 | } 47 | 48 | /** 49 | * Set data for a presentation record 50 | */ 51 | public function presentation(): static 52 | { 53 | return $this->state(fn (array $attributes) => [ 54 | 'presentation_id' => Presentation::factory(), 55 | ]); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /database/factories/DailyViewFactory.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class DailyViewFactory extends Factory 12 | { 13 | /** 14 | * Define the model's default state. 15 | * 16 | * @return array 17 | */ 18 | public function definition(): array 19 | { 20 | return [ 21 | 'adhoc_slug' => fake()->optional()->slug(), 22 | 'session_id' => fake()->uuid(), 23 | 'presentation_id' => fake()->boolean() ? Presentation::factory() : null, 24 | ]; 25 | } 26 | 27 | /** 28 | * Set data for an instructions record 29 | */ 30 | public function instructions(): static 31 | { 32 | return $this->state(fn (array $attributes) => [ 33 | 'presentation_id' => null, 34 | 'adhoc_slug' => null, 35 | ]); 36 | } 37 | 38 | /** 39 | * Set data for an adhoc record 40 | */ 41 | public function adhoc(): static 42 | { 43 | return $this->state(fn (array $attributes) => [ 44 | 'presentation_id' => null, 45 | 'adhoc_slug' => fake()->slug(), 46 | ]); 47 | } 48 | 49 | /** 50 | * Set data for a presentation record 51 | */ 52 | public function presentation(): static 53 | { 54 | return $this->state(fn (array $attributes) => [ 55 | 'presentation_id' => Presentation::factory(), 56 | ]); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /database/factories/ImageUploadFactory.php: -------------------------------------------------------------------------------- 1 | 12 | */ 13 | class ImageUploadFactory extends Factory 14 | { 15 | /** 16 | * Configure the model factory. 17 | */ 18 | public function configure(): static 19 | { 20 | if (App::environment('testing')) { 21 | return $this; 22 | } 23 | 24 | return $this->afterCreating(function (ImageUpload $record) { 25 | $record 26 | ->addMediaFromUrl('https://loremflickr.com/640/480') 27 | ->toMediaCollection('image'); 28 | }); 29 | } 30 | 31 | /** 32 | * Define the model's default state. 33 | * 34 | * @return array 35 | */ 36 | public function definition(): array 37 | { 38 | return [ 39 | 'title' => fake()->realText(50), 40 | 'alt_text' => fake()->realText(100), 41 | 'user_id' => User::factory(), 42 | ]; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | class UserFactory extends Factory 13 | { 14 | /** 15 | * Define the model's default state. 16 | * 17 | * @return array 18 | */ 19 | public function definition(): array 20 | { 21 | return [ 22 | 'name' => fake()->name(), 23 | 'email' => fake()->unique()->safeEmail(), 24 | 'username' => fake()->unique()->userName(), 25 | 'email_verified_at' => now(), 26 | 'password' => Hash::make('password'), 27 | 'remember_token' => Str::random(10), 28 | 'is_admin' => false, 29 | 'image_uploaded_size' => 0, 30 | ]; 31 | } 32 | 33 | /** 34 | * Indicate that the model's email address should be unverified. 35 | */ 36 | public function unverified(): static 37 | { 38 | return $this->state(fn (array $attributes) => [ 39 | 'email_verified_at' => null, 40 | ]); 41 | } 42 | 43 | /** 44 | * Set data for an admin user. 45 | */ 46 | public function admin(): static 47 | { 48 | return $this->state(fn (array $attributes) => [ 49 | 'is_admin' => true, 50 | ]); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('name')->index(); 17 | $table->string('username')->unique()->index(); 18 | $table->string('email')->unique()->index(); 19 | $table->boolean('is_admin')->default(false)->index(); 20 | $table->integer('image_uploaded_size')->default(0)->index(); 21 | $table->timestamp('email_verified_at')->nullable(); 22 | $table->string('password'); 23 | $table->rememberToken(); 24 | $table->timestamps(); 25 | $table->softDeletes(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | */ 32 | public function down(): void 33 | { 34 | Schema::dropIfExists('users'); 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php: -------------------------------------------------------------------------------- 1 | string('email')->primary(); 16 | $table->string('token'); 17 | $table->timestamp('created_at')->nullable(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | */ 24 | public function down(): void 25 | { 26 | Schema::dropIfExists('password_reset_tokens'); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('uuid')->unique(); 17 | $table->text('connection'); 18 | $table->text('queue'); 19 | $table->longText('payload'); 20 | $table->longText('exception'); 21 | $table->timestamp('failed_at')->useCurrent(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('failed_jobs'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->morphs('tokenable'); 17 | $table->string('name'); 18 | $table->string('token', 64)->unique(); 19 | $table->text('abilities')->nullable(); 20 | $table->timestamp('last_used_at')->nullable(); 21 | $table->timestamp('expires_at')->nullable(); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | */ 29 | public function down(): void 30 | { 31 | Schema::dropIfExists('personal_access_tokens'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /database/migrations/2023_11_16_052229_create_breezy_tables.php: -------------------------------------------------------------------------------- 1 | id(); 15 | $table->string('authenticatable_type'); 16 | $table->unsignedBigInteger('authenticatable_id'); 17 | $table->string('panel_id')->nullable(); 18 | $table->string('guard')->nullable(); 19 | $table->string('ip_address', 45)->nullable(); 20 | $table->text('user_agent')->nullable(); 21 | $table->timestamp('expires_at')->nullable(); 22 | $table->text('two_factor_secret') 23 | ->nullable(); 24 | $table->text('two_factor_recovery_codes') 25 | ->nullable(); 26 | $table->timestamp('two_factor_confirmed_at') 27 | ->nullable(); 28 | $table->timestamps(); 29 | }); 30 | 31 | } 32 | 33 | public function down() 34 | { 35 | Schema::dropIfExists('breezy_sessions'); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /database/migrations/2023_11_16_145250_create_presentations_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('title')->index(); 17 | $table->string('slug')->index(); 18 | $table->text('description')->nullable(); 19 | $table->text('content')->nullable(); 20 | $table->boolean('is_published')->default(false)->index(); 21 | $table->foreignId('user_id')->index()->constrained(); 22 | $table->timestamps(); 23 | $table->unique(['user_id', 'slug']); 24 | $table->softDeletes(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | */ 31 | public function down(): void 32 | { 33 | Schema::dropIfExists('presentations'); 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /database/migrations/2023_11_19_204221_create_media_table.php: -------------------------------------------------------------------------------- 1 | id(); 13 | 14 | $table->morphs('model'); 15 | $table->uuid('uuid')->nullable()->unique(); 16 | $table->string('collection_name'); 17 | $table->string('name'); 18 | $table->string('file_name'); 19 | $table->string('mime_type')->nullable(); 20 | $table->string('disk'); 21 | $table->string('conversions_disk')->nullable(); 22 | $table->unsignedBigInteger('size'); 23 | $table->json('manipulations'); 24 | $table->json('custom_properties'); 25 | $table->json('generated_conversions'); 26 | $table->json('responsive_images'); 27 | $table->unsignedInteger('order_column')->nullable()->index(); 28 | 29 | $table->nullableTimestamps(); 30 | }); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2023_11_23_042735_create_image_uploads_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('title'); 17 | $table->string('alt_text'); 18 | $table->foreignId('user_id')->index()->constrained(); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | */ 26 | public function down(): void 27 | { 28 | Schema::dropIfExists('image_uploads'); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /database/migrations/2024_04_08_190654_create_daily_views_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->foreignId('presentation_id')->nullable()->index()->constrained(); 17 | $table->string('adhoc_slug')->nullable()->index(); 18 | $table->string('session_id')->index(); 19 | $table->timestamp('created_at')->useCurrent(); 20 | 21 | $table->index(['presentation_id', 'session_id']); 22 | $table->index(['adhoc_slug', 'session_id']); 23 | $table->index(['presentation_id', 'adhoc_slug', 'session_id']); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | */ 30 | public function down(): void 31 | { 32 | Schema::dropIfExists('daily_views'); 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /database/migrations/2024_04_08_190703_create_aggregate_views_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->foreignId('presentation_id')->nullable()->index()->constrained(); 17 | $table->string('adhoc_slug')->nullable()->index(); 18 | $table->integer('total_count')->index()->default(0); 19 | $table->integer('unique_count')->index()->default(0); 20 | $table->timestamp('created_at')->index()->useCurrent(); 21 | 22 | $table->index(['presentation_id', 'adhoc_slug']); 23 | $table->index(['presentation_id', 'created_at']); 24 | $table->index(['presentation_id', 'adhoc_slug', 'created_at']); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | */ 31 | public function down(): void 32 | { 33 | Schema::dropIfExists('aggregate_views'); 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /database/migrations/2024_10_26_043110_add_slide_delimiter_to_presentations.php: -------------------------------------------------------------------------------- 1 | string('slide_delimiter')->default('(\n\n|\r\n)'); 16 | }); 17 | } 18 | 19 | /** 20 | * Reverse the migrations. 21 | */ 22 | public function down(): void 23 | { 24 | Schema::table('presentations', function (Blueprint $table) { 25 | $table->dropColumn('slide_delimiter'); 26 | }); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create([ 19 | 'name' => 'Admin User', 20 | 'email' => 'admin@example.com', 21 | 'username' => 'admin-user', 22 | 'is_admin' => true, 23 | ]); 24 | 25 | // Generate a non-admin user, with some content. 26 | User::factory() 27 | ->hasPresentations(3, [ 28 | 'is_published' => true, 29 | ]) 30 | ->hasImageUploads(2) 31 | ->create([ 32 | 'name' => 'Test User', 33 | 'email' => 'test@example.com', 34 | 'username' => 'test-user', 35 | ]); 36 | 37 | // Generate some extra users with content. 38 | User::factory() 39 | ->count(4) 40 | ->has(Presentation::factory()->count(3)) 41 | ->hasImageUploads(1) 42 | ->create(); 43 | 44 | foreach (User::all() as $user) { 45 | $user->regenerateImageUploadedSize(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /docker-compose.prod.yml: -------------------------------------------------------------------------------- 1 | services: 2 | laravel: 3 | build: 4 | context: . 5 | dockerfile: docker/app/Dockerfile 6 | env_file: 7 | - .env.prod 8 | ports: 9 | - 80:80 10 | depends_on: 11 | - pgsql 12 | - redis 13 | pgsql: 14 | image: 'postgres:15' 15 | environment: 16 | PGPASSWORD: '${DB_PASSWORD:-secret}' 17 | POSTGRES_DB: '${DB_DATABASE}' 18 | POSTGRES_USER: '${DB_USERNAME}' 19 | POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}' 20 | volumes: 21 | - 'pgsql:/var/lib/postgresql/data' 22 | healthcheck: 23 | test: 24 | - CMD 25 | - pg_isready 26 | - '-q' 27 | - '-d' 28 | - '${DB_DATABASE}' 29 | - '-U' 30 | - '${DB_USERNAME}' 31 | retries: 3 32 | timeout: 5s 33 | redis: 34 | image: 'redis:alpine' 35 | volumes: 36 | - 'redis:/data' 37 | healthcheck: 38 | test: 39 | - CMD 40 | - redis-cli 41 | - ping 42 | retries: 3 43 | timeout: 5s 44 | volumes: 45 | pgsql: 46 | driver: local 47 | redis: 48 | driver: local 49 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | laravel.test: 3 | build: 4 | context: ./vendor/laravel/sail/runtimes/8.2 5 | dockerfile: Dockerfile 6 | args: 7 | WWWGROUP: '${WWWGROUP}' 8 | image: sail-8.2/app 9 | extra_hosts: 10 | - 'host.docker.internal:host-gateway' 11 | platform: linux/amd64 12 | ports: 13 | - '${APP_PORT:-80}:80' 14 | - '${VITE_PORT:-5173}:${VITE_PORT:-5173}' 15 | environment: 16 | WWWUSER: '${WWWUSER}' 17 | LARAVEL_SAIL: 1 18 | PHP_CLI_SERVER_WORKERS: 10 19 | XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' 20 | XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' 21 | IGNITION_LOCAL_SITES_PATH: '${PWD}' 22 | volumes: 23 | - '.:/var/www/html' 24 | networks: 25 | - sail 26 | depends_on: 27 | - pgsql 28 | - redis 29 | - mailpit 30 | pgsql: 31 | image: 'postgres:15' 32 | ports: 33 | - '${FORWARD_DB_PORT:-5432}:5432' 34 | environment: 35 | PGPASSWORD: '${DB_PASSWORD:-secret}' 36 | POSTGRES_DB: '${DB_DATABASE}' 37 | POSTGRES_USER: '${DB_USERNAME}' 38 | POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}' 39 | volumes: 40 | - 'sail-pgsql:/var/lib/postgresql/data' 41 | - './vendor/laravel/sail/database/pgsql/create-testing-database.sql:/docker-entrypoint-initdb.d/10-create-testing-database.sql' 42 | networks: 43 | - sail 44 | healthcheck: 45 | test: 46 | - CMD 47 | - pg_isready 48 | - '-q' 49 | - '-d' 50 | - '${DB_DATABASE}' 51 | - '-U' 52 | - '${DB_USERNAME}' 53 | retries: 3 54 | timeout: 5s 55 | redis: 56 | image: 'redis:alpine' 57 | ports: 58 | - '${FORWARD_REDIS_PORT:-6379}:6379' 59 | volumes: 60 | - 'sail-redis:/data' 61 | networks: 62 | - sail 63 | healthcheck: 64 | test: 65 | - CMD 66 | - redis-cli 67 | - ping 68 | retries: 3 69 | timeout: 5s 70 | mailpit: 71 | image: 'axllent/mailpit:latest' 72 | ports: 73 | - '${FORWARD_MAILPIT_PORT:-1025}:1025' 74 | - '${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025' 75 | networks: 76 | - sail 77 | networks: 78 | sail: 79 | driver: bridge 80 | volumes: 81 | sail-pgsql: 82 | driver: local 83 | sail-redis: 84 | driver: local 85 | -------------------------------------------------------------------------------- /docker/app/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG PHP_VERSION=8.2 2 | ARG INSTALL_BCMATH=true 3 | ARG INSTALL_CALENDAR=false 4 | ARG INSTALL_EXIF=true 5 | ARG INSTALL_GD=true 6 | ARG INSTALL_IMAGICK=true 7 | ARG INSTALL_MOSQUITTO=false 8 | ARG INSTALL_MYSQL=false 9 | ARG INSTALL_OPCACHE=true 10 | ARG INSTALL_PCNTL=true 11 | ARG INSTALL_PGSQL=true 12 | ARG INSTALL_REDIS=true 13 | ARG INSTALL_SQLSRV=false 14 | ARG INSTALL_XDEBUG=false 15 | ARG INSTALL_ZIP=true 16 | ARG INSTALL_INTL=true 17 | ARG PHP_UPLOAD_MAX_FILESIZE 64m 18 | ARG PHP_POST_MAX_SIZE 64m 19 | ARG PHP_MEMORY_LIMIT 512m 20 | ARG DEPS='nodejs npm chromium' 21 | 22 | # Backend build 23 | FROM ghcr.io/clevyr/php:$PHP_VERSION-base as php-builder 24 | WORKDIR /app 25 | 26 | COPY composer.json composer.lock ./ 27 | RUN composer install \ 28 | --ignore-platform-reqs \ 29 | --no-autoloader \ 30 | --no-interaction \ 31 | --no-progress \ 32 | --no-suggest 33 | 34 | COPY . . 35 | RUN set -x \ 36 | && export TELESCOPE_ENABLED=false \ 37 | && composer dump-autoload \ 38 | --classmap-authoritative \ 39 | --no-interaction \ 40 | && php artisan vendor:publish --tag=public 41 | 42 | 43 | # Frontend build 44 | FROM node:lts-alpine as node-builder 45 | WORKDIR /app 46 | 47 | RUN set -x \ 48 | && apk add --no-cache \ 49 | autoconf \ 50 | automake \ 51 | bash \ 52 | g++ \ 53 | libc6-compat \ 54 | libjpeg-turbo \ 55 | libjpeg-turbo-dev \ 56 | libpng \ 57 | libpng-dev \ 58 | libtool \ 59 | libwebp \ 60 | libwebp-dev \ 61 | make \ 62 | nasm \ 63 | python3 \ 64 | cairo-dev \ 65 | jpeg-dev \ 66 | pango-dev \ 67 | giflib-dev 68 | 69 | ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true 70 | ENV CHROMIUM_PATH /usr/bin/chromium-browser 71 | 72 | COPY artisan package.json package-lock.json ./ 73 | RUN npm ci 74 | 75 | COPY --from=php-builder /app . 76 | ARG NODE_ENV=production 77 | RUN npm run build 78 | 79 | 80 | # Local image 81 | FROM ghcr.io/clevyr/php:$PHP_VERSION as local-image 82 | WORKDIR /app 83 | 84 | RUN npm --global install puppeteer@v23 85 | 86 | # Install libraries for laravel-medialibrary 87 | RUN set -x \ 88 | && apk add --no-cache \ 89 | ffmpeg \ 90 | jpegoptim 91 | 92 | COPY --chown=root docker/app/rootfs / 93 | 94 | RUN crontab /etc/cron.d/scheduler 95 | 96 | CMD ["s6-svscan", "/etc/s6/app"] 97 | 98 | 99 | # Deployed image 100 | FROM local-image 101 | 102 | COPY --from=php-builder --chown=82:82 /app . 103 | COPY --from=node-builder --chown=82:82 /app/public public/ 104 | -------------------------------------------------------------------------------- /docker/app/rootfs/entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ex 3 | 4 | cd /app 5 | 6 | ( 7 | if [ -f .env ]; then 8 | source .env 9 | fi 10 | 11 | if [ "$APP_ENV" != "local" ]; then 12 | php artisan config:cache 13 | else 14 | composer install --ignore-platform-reqs --no-interaction --no-progress 15 | php artisan config:clear 16 | php artisan vendor:publish --tag=public 17 | fi 18 | 19 | if [ -L public/storage ]; then 20 | rm public/storage 21 | fi 22 | ln -s ../storage/app/public public/storage 23 | 24 | php artisan vendor:publish --force --tag=telescope-assets --tag=horizon-assets 25 | 26 | if [ "$DB_FRESH_ON_START" = "true" ]; then 27 | php artisan migrate:fresh 28 | php artisan db:seed 29 | else 30 | php artisan migrate --force 31 | fi 32 | ) 33 | 34 | exec php-fpm 35 | -------------------------------------------------------------------------------- /docker/app/rootfs/etc/cron.d/scheduler: -------------------------------------------------------------------------------- 1 | * * * * * s6-setuidgid "${PUID:-www-data}" php /app/artisan schedule:run -n | grep -v 'No scheduled commands are ready to run.' 2 | -------------------------------------------------------------------------------- /docker/app/rootfs/etc/nginx/conf.d/default.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | listen [::]:80 default ipv6only=on; 4 | 5 | server_name _; 6 | 7 | access_log off; 8 | 9 | root /app/public; 10 | index index.php index.html index.htm; 11 | 12 | client_max_body_size 64m; 13 | 14 | location / { 15 | try_files $uri $uri/ /index.php?$query_string; 16 | } 17 | 18 | location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ { 19 | try_files $uri $uri/ /index.php?$query_string; 20 | expires 7d; 21 | } 22 | 23 | location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ { 24 | try_files $uri $uri/ /index.php?$query_string; 25 | add_header Access-Control-Allow-Origin "*"; 26 | expires 7d; 27 | } 28 | 29 | location ~ [^/]\.php(/|$) { 30 | fastcgi_pass 127.0.0.1:9000; 31 | 32 | # regex to split $uri to $fastcgi_script_name and $fastcgi_path 33 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 34 | 35 | # Check that the PHP script exists before passing it 36 | try_files $fastcgi_script_name =404; 37 | 38 | # Bypass the fact that try_files resets $fastcgi_path_info 39 | # see: http://trac.nginx.org/nginx/ticket/321 40 | set $path_info $fastcgi_path_info; 41 | fastcgi_param PATH_INFO $path_info; 42 | 43 | fastcgi_index index.php; 44 | 45 | fastcgi_param SCRIPT_FILENAME /app/public/index.php; 46 | 47 | include fastcgi.conf; 48 | } 49 | 50 | location ~* \.(htaccess|htpasswd) { 51 | deny all; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /docker/app/rootfs/etc/s6/app/nginx/down-signal: -------------------------------------------------------------------------------- 1 | SIGQUIT 2 | -------------------------------------------------------------------------------- /docker/app/rootfs/etc/s6/app/nginx/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exec nginx -g 'daemon off;' 4 | -------------------------------------------------------------------------------- /docker/app/rootfs/etc/s6/app/php-fpm/down-signal: -------------------------------------------------------------------------------- 1 | SIGQUIT 2 | -------------------------------------------------------------------------------- /docker/app/rootfs/etc/s6/app/php-fpm/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exec /entrypoint 4 | -------------------------------------------------------------------------------- /docker/app/rootfs/etc/s6/worker/cron/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -x 3 | 4 | exec crond -f 5 | -------------------------------------------------------------------------------- /docker/app/rootfs/etc/s6/worker/queue-runner/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -x 3 | 4 | exec php /app/artisan queue:work -n --delay=90 --tries=3 5 | -------------------------------------------------------------------------------- /docker/app/rootfs/health-check: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | HEALTH_CHECK_IP="${1:-127.0.0.1}" 4 | 5 | REDIRECT_STATUS=true \ 6 | SCRIPT_NAME=/ping \ 7 | SCRIPT_FILENAME=/ping \ 8 | REQUEST_METHOD=GET \ 9 | cgi-fcgi -bind -connect "$HEALTH_CHECK_IP:9000" \ 10 | | grep pong 11 | exit $? 12 | -------------------------------------------------------------------------------- /docker/app/rootfs/usr/local/etc/php/conf.d/99-docker-php-ext-xdebug-config.ini: -------------------------------------------------------------------------------- 1 | [xdebug] 2 | xdebug.remote_autostart = 0 3 | xdebug.remote_enable = 1 4 | xdebug.remote_host = "host.docker.internal" 5 | xdebug.remote_port = 9000 6 | xdebug.remote_profiler_enable_trigger = 1 7 | -------------------------------------------------------------------------------- /docker/sail-extra.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | apt-get update 4 | apt-get install -y gconf-service libasound2 libappindicator3-1 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libgbm-dev libatk-bridge2.0- 5 | apt-get install -y ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "type": "module", 4 | "scripts": { 5 | "dev": "vite", 6 | "build": "vue-tsc && vite build" 7 | }, 8 | "dependencies": { 9 | "dompurify": "^3.0.5", 10 | "happy-dom": "^14.0.0", 11 | "marked": "^14.0.0", 12 | "vue-router": "^4.2.4" 13 | }, 14 | "devDependencies": { 15 | "@inertiajs/vue3": "^1.0.0", 16 | "@tailwindcss/forms": "^0.5.3", 17 | "@types/dompurify": "^3.0.2", 18 | "@vitejs/plugin-vue": "^5.0.0", 19 | "@vitest/coverage-v8": "^2.0.0", 20 | "@vue/test-utils": "^2.4.1", 21 | "autoprefixer": "^10.4.14", 22 | "axios": "^1.1.2", 23 | "laravel-vite-plugin": "^1.0.0", 24 | "msw": "^2.0.0", 25 | "postcss": "^8.4.18", 26 | "puppeteer": "^23.0.0", 27 | "tailwindcss": "^3.2.1", 28 | "typescript": "^5.0.2", 29 | "vite": "^5.0.0", 30 | "vue": "^3.2.41", 31 | "vue-tsc": "^2.0.0" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /phpstan.neon: -------------------------------------------------------------------------------- 1 | includes: 2 | - ./vendor/larastan/larastan/extension.neon 3 | 4 | parameters: 5 | paths: 6 | - app/ 7 | 8 | level: 7 9 | ignoreErrors: 10 | - 11 | message: '#^Undefined variable\: \$this$#' 12 | path: ./tests/* 13 | reportUnmatched: false 14 | - 15 | message: '#^Function (something|) not found\.$#' 16 | path: ./tests/* 17 | reportUnmatched: false 18 | - 19 | message: '#^Access to an undefined property#' 20 | path: ./tests/* 21 | reportUnmatched: false 22 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | tests/Unit 10 | 11 | 12 | tests/Feature 13 | 14 | 15 | tests/Filament 16 | 17 | 18 | 19 | 20 | app 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Send Requests To Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alkrauss48/simple-slides/d558446cecddf834897fcc5a00eae0326c57f386/public/favicon.ico -------------------------------------------------------------------------------- /public/favicon/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alkrauss48/simple-slides/d558446cecddf834897fcc5a00eae0326c57f386/public/favicon/android-chrome-192x192.png -------------------------------------------------------------------------------- /public/favicon/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alkrauss48/simple-slides/d558446cecddf834897fcc5a00eae0326c57f386/public/favicon/android-chrome-512x512.png -------------------------------------------------------------------------------- /public/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alkrauss48/simple-slides/d558446cecddf834897fcc5a00eae0326c57f386/public/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /public/favicon/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #da532c 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /public/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alkrauss48/simple-slides/d558446cecddf834897fcc5a00eae0326c57f386/public/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /public/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alkrauss48/simple-slides/d558446cecddf834897fcc5a00eae0326c57f386/public/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /public/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alkrauss48/simple-slides/d558446cecddf834897fcc5a00eae0326c57f386/public/favicon/favicon.ico -------------------------------------------------------------------------------- /public/favicon/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alkrauss48/simple-slides/d558446cecddf834897fcc5a00eae0326c57f386/public/favicon/mstile-150x150.png -------------------------------------------------------------------------------- /public/favicon/safari-pinned-tab.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | Created by potrace 1.14, written by Peter Selinger 2001-2017 9 | 10 | 12 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /public/favicon/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "short_name": "", 4 | "icons": [ 5 | { 6 | "src": "/favicon/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/favicon/android-chrome-512x512.png", 12 | "sizes": "512x512", 13 | "type": "image/png" 14 | } 15 | ], 16 | "theme_color": "#ffffff", 17 | "background_color": "#ffffff", 18 | "display": "standalone" 19 | } 20 | -------------------------------------------------------------------------------- /public/images/clevyr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alkrauss48/simple-slides/d558446cecddf834897fcc5a00eae0326c57f386/public/images/clevyr.png -------------------------------------------------------------------------------- /public/images/pun-dog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alkrauss48/simple-slides/d558446cecddf834897fcc5a00eae0326c57f386/public/images/pun-dog.jpg -------------------------------------------------------------------------------- /public/images/simple-slides-og.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alkrauss48/simple-slides/d558446cecddf834897fcc5a00eae0326c57f386/public/images/simple-slides-og.jpg -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class); 50 | 51 | $response = $kernel->handle( 52 | $request = Request::capture() 53 | )->send(); 54 | 55 | $kernel->terminate($request, $response); 56 | -------------------------------------------------------------------------------- /public/js/filament/forms/components/key-value.js: -------------------------------------------------------------------------------- 1 | function r({state:o}){return{state:o,rows:[],shouldUpdateRows:!0,init:function(){this.updateRows(),this.rows.length<=0?this.rows.push({key:"",value:""}):this.updateState(),this.$watch("state",(t,e)=>{let s=i=>i===null?0:Array.isArray(i)?i.length:typeof i!="object"?0:Object.keys(i).length;s(t)===0&&s(e)===0||this.updateRows()})},addRow:function(){this.rows.push({key:"",value:""}),this.updateState()},deleteRow:function(t){this.rows.splice(t,1),this.rows.length<=0&&this.addRow(),this.updateState()},reorderRows:function(t){let e=Alpine.raw(this.rows);this.rows=[];let s=e.splice(t.oldIndex,1)[0];e.splice(t.newIndex,0,s),this.$nextTick(()=>{this.rows=e,this.updateState()})},updateRows:function(){if(!this.shouldUpdateRows){this.shouldUpdateRows=!0;return}let t=[];for(let[e,s]of Object.entries(this.state??{}))t.push({key:e,value:s});this.rows=t},updateState:function(){let t={};this.rows.forEach(e=>{e.key===""||e.key===null||(t[e.key]=e.value)}),this.shouldUpdateRows=!1,this.state=t}}}export{r as default}; 2 | -------------------------------------------------------------------------------- /public/js/filament/forms/components/tags-input.js: -------------------------------------------------------------------------------- 1 | function i({state:a,splitKeys:n}){return{newTag:"",state:a,createTag:function(){if(this.newTag=this.newTag.trim(),this.newTag!==""){if(this.state.includes(this.newTag)){this.newTag="";return}this.state.push(this.newTag),this.newTag=""}},deleteTag:function(t){this.state=this.state.filter(e=>e!==t)},reorderTags:function(t){let e=this.state.splice(t.oldIndex,1)[0];this.state.splice(t.newIndex,0,e),this.state=[...this.state]},input:{["x-on:blur"]:"createTag()",["x-model"]:"newTag",["x-on:keydown"](t){["Enter",...n].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),this.createTag())},["x-on:paste"](){this.$nextTick(()=>{if(n.length===0){this.createTag();return}let t=n.map(e=>e.replace(/[/\-\\^$*+?.()|[\]{}]/g,"\\$&")).join("|");this.newTag.split(new RegExp(t,"g")).forEach(e=>{this.newTag=e,this.createTag()})})}}}}export{i as default}; 2 | -------------------------------------------------------------------------------- /public/js/filament/forms/components/textarea.js: -------------------------------------------------------------------------------- 1 | function r({initialHeight:t,shouldAutosize:i,state:s}){return{state:s,wrapperEl:null,init:function(){this.wrapperEl=this.$el.parentNode,this.setInitialHeight(),i?this.$watch("state",()=>{this.resize()}):this.setUpResizeObserver()},setInitialHeight:function(){this.$el.scrollHeight<=0||(this.wrapperEl.style.height=t+"rem")},resize:function(){if(this.setInitialHeight(),this.$el.scrollHeight<=0)return;let e=this.$el.scrollHeight+"px";this.wrapperEl.style.height!==e&&(this.wrapperEl.style.height=e)},setUpResizeObserver:function(){new ResizeObserver(()=>{this.wrapperEl.style.height=this.$el.style.height}).observe(this.$el)}}}export{r as default}; 2 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /resources/css/app.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | body { 6 | font-family: "Montserrat", Helvetica, sans-serif; 7 | -webkit-font-smoothing: antialiased; 8 | -moz-osx-font-smoothing: grayscale; 9 | } 10 | 11 | #app { 12 | @apply dark:bg-zinc-900 dark:text-white; 13 | } 14 | 15 | .slide-arrow-button { 16 | @apply fixed bottom-6 w-0 h-0 touch-none border-y-[20px] border-y-transparent; 17 | } 18 | 19 | .button { 20 | @apply 21 | px-4 py-2 22 | bg-black text-white 23 | dark:bg-white dark:text-black 24 | border-black dark:border-white 25 | border-solid border-2 26 | hover:bg-white hover:text-black 27 | focus:bg-white focus:text-black 28 | dark:hover:bg-black dark:hover:text-white 29 | dark:focus:bg-black dark:focus:text-white; 30 | } 31 | -------------------------------------------------------------------------------- /resources/css/typography.css: -------------------------------------------------------------------------------- 1 | .typography * { 2 | margin: 0; 3 | text-align: center; 4 | } 5 | 6 | .typography li { 7 | text-align: left; 8 | } 9 | 10 | .typography .textFitted { 11 | display: flex !important; 12 | flex-direction: column; 13 | align-items: center; 14 | justify-content: center; 15 | width: 100%; 16 | height: 100%; 17 | } 18 | 19 | .typography img { 20 | display: block; 21 | margin: 0 auto; 22 | max-width: 100%; 23 | max-height: 80vh; 24 | width: 100%; 25 | } 26 | 27 | .typography ul{ 28 | padding-left: 1em; 29 | list-style-type: disc; 30 | } 31 | 32 | .typography ol { 33 | padding-left: 1.5em; 34 | list-style-type: decimal; 35 | } 36 | 37 | .typography blockquote { 38 | font-style: italic; 39 | } 40 | 41 | .typography h1, 42 | .typography h2, 43 | .typography h3, 44 | .typography h4, 45 | .typography h5, 46 | .typography h6 { 47 | font-weight: bold; 48 | } 49 | 50 | .typography code { 51 | background-color: rgba(226, 226, 226, .4); 52 | padding: .25rem; 53 | } 54 | 55 | .typography pre { 56 | background-color: rgba(226, 226, 226, .4); 57 | padding: .5rem 1rem; 58 | text-align: left; 59 | } 60 | 61 | .typography pre code { 62 | background-color: transparent; 63 | padding: 0; 64 | text-align: left; 65 | } 66 | 67 | .typography a { 68 | color: #05a0db; 69 | } 70 | 71 | .typography a:hover, .typography a:focus { 72 | text-decoration: underline; 73 | } 74 | 75 | .typography h1 { 76 | font-size: 2em; 77 | } 78 | 79 | .typography h2 { 80 | font-size: 1.5em; 81 | } 82 | 83 | .typography h3 { 84 | font-size: 1.25em; 85 | } 86 | 87 | .typography h4 { 88 | font-size: 1em; 89 | } 90 | 91 | .typography h5 { 92 | font-size: .9em; 93 | } 94 | 95 | .typography h6 { 96 | font-size: .75em; 97 | } 98 | -------------------------------------------------------------------------------- /resources/js/Components/AppHead.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 21 | -------------------------------------------------------------------------------- /resources/js/Components/ApplicationLogo.vue: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /resources/js/Components/DraftBanner.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 15 | -------------------------------------------------------------------------------- /resources/js/Components/PreloadContent.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 20 | -------------------------------------------------------------------------------- /resources/js/Components/ProgressBar.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 32 | -------------------------------------------------------------------------------- /resources/js/Components/ProgressLabel.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 22 | -------------------------------------------------------------------------------- /resources/js/Components/SlideArrows.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 39 | -------------------------------------------------------------------------------- /resources/js/Components/SlideContent.vue: -------------------------------------------------------------------------------- 1 | 28 | 29 | 40 | -------------------------------------------------------------------------------- /resources/js/Components/icons/CogIcon.vue: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /resources/js/Components/icons/GithubIcon.vue: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /resources/js/Components/icons/MoonFillIcon.vue: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /resources/js/Components/icons/MoonStrokeIcon.vue: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /resources/js/Components/icons/YoutubeIcon.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | -------------------------------------------------------------------------------- /resources/js/Layouts/SlideLayout.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 35 | -------------------------------------------------------------------------------- /resources/js/Pages/AdhocSlides.vue: -------------------------------------------------------------------------------- 1 | 37 | 38 | 43 | -------------------------------------------------------------------------------- /resources/js/Pages/Presentation.vue: -------------------------------------------------------------------------------- 1 | 28 | 29 | 35 | -------------------------------------------------------------------------------- /resources/js/app.ts: -------------------------------------------------------------------------------- 1 | import './bootstrap'; 2 | import '../css/app.css'; 3 | import '../css/typography.css'; 4 | 5 | import { createApp, h, DefineComponent } from 'vue'; 6 | import { createInertiaApp } from '@inertiajs/vue3'; 7 | import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; 8 | import { ZiggyVue } from '../../vendor/tightenco/ziggy'; 9 | import { applyVisualMode } from './utils/handleVisualMode.ts'; 10 | 11 | const appName = import.meta.env.VITE_APP_NAME || 'Simple Slides'; 12 | 13 | applyVisualMode(); 14 | 15 | createInertiaApp({ 16 | title: (title) => `${title} - ${appName}`, 17 | resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')), 18 | setup({ el, App, props, plugin }) { 19 | createApp({ render: () => h(App, props) }) 20 | .use(plugin) 21 | .use(ZiggyVue, Ziggy) 22 | .mount(el); 23 | }, 24 | progress: { 25 | color: '#4B5563', 26 | }, 27 | }); 28 | -------------------------------------------------------------------------------- /resources/js/bootstrap.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * We'll load the axios HTTP library which allows us to easily issue requests 3 | * to our Laravel back-end. This library automatically handles sending the 4 | * CSRF token as a header based on the value of the "XSRF" token cookie. 5 | */ 6 | 7 | import axios from 'axios'; 8 | window.axios = axios; 9 | 10 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 11 | 12 | /** 13 | * Echo exposes an expressive API for subscribing to channels and listening 14 | * for events that are broadcast by Laravel. Echo and event broadcasting 15 | * allows your team to easily build robust real-time web applications. 16 | */ 17 | 18 | // import Echo from 'laravel-echo'; 19 | 20 | // import Pusher from 'pusher-js'; 21 | // window.Pusher = Pusher; 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: import.meta.env.VITE_PUSHER_APP_KEY, 26 | // cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1', 27 | // wsHost: import.meta.env.VITE_PUSHER_HOST ? import.meta.env.VITE_PUSHER_HOST : `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`, 28 | // wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80, 29 | // wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443, 30 | // forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https', 31 | // enabledTransports: ['ws', 'wss'], 32 | // }); 33 | -------------------------------------------------------------------------------- /resources/js/constants/general.ts: -------------------------------------------------------------------------------- 1 | export const INSTRUCTIONS_URL = '/instructions.md'; 2 | 3 | export const DRAFT_MESSAGE = 'This presentation is in draft status.'; 4 | -------------------------------------------------------------------------------- /resources/js/constants/keys.ts: -------------------------------------------------------------------------------- 1 | export const ENTER = 'Enter'; 2 | export const SPACE = ' '; 3 | export const DOLLAR_SIGN = '$'; 4 | export const ZERO = '0'; 5 | 6 | export const INCREMENTORS = [ 7 | ENTER, 8 | SPACE, 9 | 'ArrowDown', 10 | 'ArrowRight', 11 | 'PageDown', 12 | 'n', 13 | 'N', 14 | 'j', 15 | 'J', 16 | 'l', 17 | 'L', 18 | ]; 19 | 20 | export const DECREMENTORS = [ 21 | 'Backspace', 22 | 'ArrowUp', 23 | 'ArrowLeft', 24 | 'PageUp', 25 | 'p', 26 | 'P', 27 | 'k', 28 | 'K', 29 | 'h', 30 | 'H', 31 | ]; 32 | 33 | export const LARGE_INCREMENTORS = [ 34 | 'f', 35 | 'F', 36 | ]; 37 | 38 | export const LARGE_DECREMENTORS = [ 39 | 'b', 40 | 'B', 41 | ]; 42 | 43 | export const ALL_APP_KEYS = [ 44 | ...INCREMENTORS, 45 | ...DECREMENTORS, 46 | ...LARGE_INCREMENTORS, 47 | ...LARGE_DECREMENTORS, 48 | DOLLAR_SIGN, 49 | ZERO, 50 | ]; 51 | 52 | export default { 53 | ENTER, 54 | SPACE, 55 | DOLLAR_SIGN, 56 | ZERO, 57 | INCREMENTORS, 58 | DECREMENTORS, 59 | LARGE_INCREMENTORS, 60 | LARGE_DECREMENTORS, 61 | ALL_APP_KEYS 62 | }; 63 | -------------------------------------------------------------------------------- /resources/js/constants/meta.ts: -------------------------------------------------------------------------------- 1 | export const BASE_TITLE = 'Home'; 2 | -------------------------------------------------------------------------------- /resources/js/enums/progressType.ts: -------------------------------------------------------------------------------- 1 | export enum ProgressType { 2 | Bar = "bar", 3 | Label = "label", 4 | } 5 | 6 | export default ProgressType; 7 | -------------------------------------------------------------------------------- /resources/js/enums/visualMode.ts: -------------------------------------------------------------------------------- 1 | export enum VisualMode { 2 | Dark = "dark", 3 | Light = "light", 4 | } 5 | 6 | export const isDarkMode = (mode: VisualMode) : boolean => { 7 | return mode === VisualMode.Dark; 8 | }; 9 | 10 | export const isLightMode = (mode: VisualMode) : boolean => { 11 | return mode === VisualMode.Light; 12 | }; 13 | 14 | export default VisualMode; 15 | -------------------------------------------------------------------------------- /resources/js/interfaces/meta.ts: -------------------------------------------------------------------------------- 1 | interface Meta { 2 | title: string, 3 | description: string, 4 | imageUrl: string, 5 | } 6 | 7 | export default Meta; 8 | -------------------------------------------------------------------------------- /resources/js/interfaces/presentation.ts: -------------------------------------------------------------------------------- 1 | interface Presentation { 2 | id: string, 3 | content: string, 4 | slide_delimiter: string, 5 | is_published: boolean, 6 | } 7 | 8 | export default Presentation; 9 | -------------------------------------------------------------------------------- /resources/js/interfaces/queryParams.ts: -------------------------------------------------------------------------------- 1 | import ProgressType from '../enums/progressType.ts'; 2 | 3 | interface QueryParams { 4 | index?: number, 5 | loop?: number, 6 | progress?: ProgressType, 7 | } 8 | 9 | export default QueryParams; 10 | -------------------------------------------------------------------------------- /resources/js/mocks/browser.ts: -------------------------------------------------------------------------------- 1 | import { setupServer } from 'msw/node' 2 | import handlers from './handlers.ts'; 3 | 4 | export const server = setupServer(...handlers); 5 | -------------------------------------------------------------------------------- /resources/js/mocks/handlers.ts: -------------------------------------------------------------------------------- 1 | import { http, HttpResponse } from 'msw' 2 | 3 | import { INSTRUCTIONS_URL } from '@/constants/general.ts'; 4 | 5 | export const MOCK_ADHOC_URL = 'https://fake.dev/presentation'; 6 | export const MOCK_WINDOWS_ADHOC_URL = 'https://fake.dev/presentation-windows'; 7 | 8 | const data: String[] = [ 9 | 'Welcome to', 10 | '# Simple Slides', 11 | '[https://example.com](https://example.com)', 12 | ]; 13 | 14 | export default [ 15 | http.get(INSTRUCTIONS_URL, (info) => { 16 | return new HttpResponse(data.join("\n\n")); 17 | }), 18 | http.get(MOCK_ADHOC_URL, (info) => { 19 | return new HttpResponse(data.join("\n\n")); 20 | }), 21 | http.get(MOCK_WINDOWS_ADHOC_URL, (info) => { 22 | return new HttpResponse(data.join("\r\n")); 23 | }), 24 | ]; 25 | -------------------------------------------------------------------------------- /resources/js/store/dataStore.ts: -------------------------------------------------------------------------------- 1 | import { reactive } from 'vue' 2 | import DOMPurify from 'dompurify'; 3 | import { marked } from 'marked'; 4 | 5 | const dataStore = reactive({ 6 | data: [], 7 | 8 | async fetchAndProcessData(url: string): Promise { 9 | const response = await fetch(url); 10 | const body = await response.text(); 11 | 12 | // Not passing a delimiter, because this situation would always use 13 | // the default delimiter. 14 | this.processData(body); 15 | }, 16 | 17 | processData(content: string, delimiter: string = '(\n\n|\r\n)'): void { 18 | const parsedBody = content 19 | .split(new RegExp(delimiter)) 20 | .filter((content) => content.trim().length > 0) 21 | .map((content) => { 22 | const parsed = marked.parse(content, { async: false }); 23 | 24 | return DOMPurify.sanitize(parsed); 25 | }).map((content) => content.replace(/\n$/, '')); 26 | 27 | this.data = parsedBody; 28 | }, 29 | 30 | reset() { 31 | this.data = []; 32 | }, 33 | }); 34 | 35 | export default dataStore; 36 | -------------------------------------------------------------------------------- /resources/js/store/slideStore.ts: -------------------------------------------------------------------------------- 1 | import { reactive } from 'vue' 2 | 3 | import ProgressType from '@/enums/progressType.ts'; 4 | import dataStore from './dataStore.ts' 5 | 6 | const slideStore = reactive({ 7 | index: 0, 8 | loop: 0, 9 | progress: ProgressType.Bar, 10 | 11 | getNewIndex(count: number) : number { 12 | if (slideStore.index + count < 0) { 13 | return 0; 14 | } 15 | 16 | if (slideStore.index + count >= dataStore.data.length) { 17 | return dataStore.data.length - 1; 18 | } 19 | 20 | return slideStore.index + count; 21 | }, 22 | 23 | increment(count: number) : void { 24 | const newIndex = this.getNewIndex(count); 25 | 26 | if (slideStore.index === newIndex) { 27 | return; 28 | } 29 | 30 | slideStore.index = newIndex; 31 | }, 32 | 33 | isStart() : boolean { 34 | return this.index === 0; 35 | }, 36 | 37 | isEnd() : boolean { 38 | return this.index === dataStore.data.length - 1; 39 | }, 40 | 41 | canLoop() : boolean { 42 | if (this.loop < 2) { 43 | return false; 44 | } 45 | 46 | return true; 47 | }, 48 | 49 | reset() { 50 | this.index = 0; 51 | this.progress = ProgressType.Bar; 52 | }, 53 | }); 54 | 55 | export default slideStore; 56 | -------------------------------------------------------------------------------- /resources/js/test/components/DraftBanner.test.ts: -------------------------------------------------------------------------------- 1 | import { shallowMount, VueWrapper } from '@vue/test-utils' 2 | 3 | import DraftBanner from '@/Components/DraftBanner.vue' 4 | import { DRAFT_MESSAGE } from '@/constants/general.ts'; 5 | 6 | const mountWrapper = () : VueWrapper => { 7 | return shallowMount(DraftBanner); 8 | }; 9 | 10 | test('shows message', () => { 11 | const wrapper = mountWrapper(); 12 | 13 | expect(wrapper.find('#draft-message').text()).toBe(DRAFT_MESSAGE); 14 | }); 15 | -------------------------------------------------------------------------------- /resources/js/test/components/PreloadContent.test.ts: -------------------------------------------------------------------------------- 1 | import { shallowMount } from '@vue/test-utils' 2 | 3 | import dataStore from '@/store/dataStore.ts' 4 | import PreloadContent from '@/Components/PreloadContent.vue' 5 | 6 | test('shows the data as text', () => { 7 | dataStore.data = ['foo', 'bar', 'baz']; 8 | 9 | const wrapper = shallowMount(PreloadContent); 10 | 11 | expect(wrapper.text()).toContain('foo'); 12 | expect(wrapper.text()).toContain('bar'); 13 | expect(wrapper.text()).toContain('baz'); 14 | }); 15 | -------------------------------------------------------------------------------- /resources/js/test/components/ProgressBar.test.ts: -------------------------------------------------------------------------------- 1 | import { shallowMount, VueWrapper } from '@vue/test-utils' 2 | 3 | import ProgressBar from '@/Components/ProgressBar.vue' 4 | import dataStore from '@/store/dataStore.ts' 5 | import slideStore from '@/store/slideStore.ts' 6 | 7 | const mountWrapper = () : VueWrapper => { 8 | dataStore.data = Array(17).fill(''); 9 | slideStore.index = 4; 10 | 11 | return shallowMount(ProgressBar); 12 | }; 13 | 14 | test('gets percentage', () => { 15 | const wrapper = mountWrapper(); 16 | 17 | expect(wrapper.vm.percentage).toBe(25); 18 | }); 19 | 20 | test('gets 0 percentage for 0 total', () => { 21 | dataStore.data = []; 22 | slideStore.index = 0; 23 | 24 | const wrapper: VueWrapper = shallowMount(ProgressBar); 25 | 26 | expect(wrapper.vm.percentage).toBe(0); 27 | }); 28 | 29 | test('gets 0 percentage for 1 total on last slide', () => { 30 | dataStore.data = ['']; 31 | slideStore.index = 0; 32 | 33 | const wrapper: VueWrapper = shallowMount(ProgressBar); 34 | 35 | expect(wrapper.vm.percentage).toBe(0); 36 | }); 37 | 38 | test('gets 100 percentage for 2 total on last slide', () => { 39 | dataStore.data = ['', '']; 40 | slideStore.index = 1; 41 | 42 | const wrapper: VueWrapper = shallowMount(ProgressBar); 43 | 44 | expect(wrapper.vm.percentage).toBe(100); 45 | }); 46 | 47 | test('gets percentage label', () => { 48 | const wrapper = mountWrapper(); 49 | 50 | expect(wrapper.vm.percentageLabel).toBe('25%'); 51 | }); 52 | 53 | test('gets style', () => { 54 | const wrapper = mountWrapper(); 55 | 56 | expect(wrapper.vm.style).toStrictEqual({ 57 | width: '25%', 58 | }); 59 | }); 60 | -------------------------------------------------------------------------------- /resources/js/test/components/ProgressLabel.test.ts: -------------------------------------------------------------------------------- 1 | import { shallowMount, VueWrapper } from '@vue/test-utils' 2 | 3 | import ProgressLabel from '@/Components/ProgressLabel.vue' 4 | import dataStore from '@/store/dataStore.ts' 5 | import slideStore from '@/store/slideStore.ts' 6 | 7 | test('gets label', () => { 8 | dataStore.data = Array(16).fill(''); 9 | slideStore.index = 4; 10 | 11 | const wrapper: VueWrapper = shallowMount(ProgressLabel); 12 | 13 | expect(wrapper.vm.label).toBe('5 / 16'); 14 | }); 15 | -------------------------------------------------------------------------------- /resources/js/test/components/SlideView.loop.test.ts: -------------------------------------------------------------------------------- 1 | import { mount, VueWrapper } from '@vue/test-utils' 2 | 3 | import SlideView from '@/Components/SlideView.vue' 4 | import Keys from '@/constants/keys.ts'; 5 | import ProgressType from '@/enums/progressType.ts' 6 | import dataStore from '@/store/dataStore.ts' 7 | import slideStore from '@/store/slideStore.ts' 8 | 9 | // Incrementors 10 | 11 | const mountWrapper = () : VueWrapper => { 12 | dataStore.data = ['foo', 'bar', 'baz', 'foo', 'bar', 'baz', 'foo', 'bar']; 13 | slideStore.index = 1; 14 | slideStore.loop = 5; 15 | slideStore.progress = ProgressType.Bar; 16 | 17 | return mount(SlideView); 18 | }; 19 | 20 | test('loopInterval is not null with valid loop set', async () => { 21 | const wrapper = mountWrapper(); 22 | 23 | expect(wrapper.vm.loopInterval).not.toBe(null); 24 | }); 25 | 26 | test('loopInterval is cleared with valid loop set', async () => { 27 | const wrapper = mountWrapper(); 28 | const spy = vi.spyOn(global, 'clearInterval'); 29 | 30 | wrapper.vm.checkAndClearLoopInterval(); 31 | 32 | expect(spy).toHaveBeenCalledTimes(1); 33 | expect(spy.mock.lastCall?.[0]).toBe(Number(wrapper.vm.loopInterval)); 34 | }); 35 | 36 | test('loopInterval is cleared on valid key press', async () => { 37 | const wrapper = mountWrapper(); 38 | const spy = vi.spyOn(global, 'clearInterval'); 39 | 40 | wrapper.vm.bindKeyDown({ key: Keys.ENTER }); 41 | 42 | expect(spy).toHaveBeenCalledTimes(1); 43 | expect(spy.mock.lastCall?.[0]).toBe(Number(wrapper.vm.loopInterval)); 44 | }); 45 | 46 | test('loopInterval is not cleared on invalid key press', async () => { 47 | const wrapper = mountWrapper(); 48 | const spy = vi.spyOn(global, 'clearInterval'); 49 | 50 | wrapper.vm.bindKeyDown({ key: 'x' }); 51 | 52 | expect(spy).toHaveBeenCalledTimes(0); 53 | }); 54 | 55 | test('slide increments with loop timer', async () => { 56 | vi.useFakeTimers(); 57 | 58 | const wrapper = mountWrapper(); 59 | 60 | expect(slideStore.index).toBe(1); 61 | 62 | vi.advanceTimersToNextTimer(); 63 | 64 | expect(slideStore.index).toBe(2); 65 | }); 66 | -------------------------------------------------------------------------------- /resources/js/test/components/SlideView.test.ts: -------------------------------------------------------------------------------- 1 | import { shallowMount, VueWrapper } from '@vue/test-utils' 2 | 3 | import SlideView from '@/Components/SlideView.vue' 4 | import ProgressType from '@/enums/progressType.ts' 5 | import dataStore from '@/store/dataStore.ts' 6 | import slideStore from '@/store/slideStore.ts' 7 | 8 | const mountWrapper = () : VueWrapper => { 9 | dataStore.data = ['foo', 'bar', 'baz']; 10 | slideStore.index = 1; 11 | slideStore.progress = ProgressType.Bar; 12 | 13 | return shallowMount(SlideView); 14 | }; 15 | 16 | test('gets content', () => { 17 | const wrapper = mountWrapper(); 18 | 19 | expect(wrapper.vm.content).toBe('bar'); 20 | }); 21 | 22 | test('returns showProgressLabel as true', () => { 23 | const wrapper = mountWrapper(); 24 | 25 | slideStore.progress = ProgressType.Label; 26 | 27 | expect(wrapper.vm.showProgressLabel).toBeTruthy(); 28 | }); 29 | 30 | test('returns showProgressLabel as false', () => { 31 | const wrapper = mountWrapper(); 32 | 33 | expect(wrapper.vm.showProgressLabel).toBeFalsy(); 34 | }); 35 | 36 | test('incrementCount increments index and calls router replace', () => { 37 | const wrapper = mountWrapper(); 38 | wrapper.vm.incrementContent(1); 39 | 40 | expect(slideStore.index).toBe(2); 41 | }); 42 | 43 | test('incrementCount increments index only to max, and calls router replace', () => { 44 | const wrapper = mountWrapper(); 45 | wrapper.vm.incrementContent(5); 46 | 47 | expect(slideStore.index).toBe(2); 48 | }); 49 | 50 | test('incrementCount decrements index and calls router replace', () => { 51 | const wrapper = mountWrapper(); 52 | wrapper.vm.incrementContent(-1); 53 | 54 | expect(slideStore.index).toBe(0); 55 | }); 56 | 57 | test('incrementCount decrements index only to min, and calls router replace', () => { 58 | const wrapper = mountWrapper(); 59 | wrapper.vm.incrementContent(-5); 60 | 61 | expect(slideStore.index).toBe(0); 62 | }); 63 | 64 | test('buildQueryParams includes index', () => { 65 | const wrapper = mountWrapper(); 66 | const query = wrapper.vm.buildQueryParams(); 67 | 68 | expect(query.index).toBe(1); 69 | expect(query.progress).toBeFalsy(); 70 | }); 71 | 72 | test('buildQueryParams includes progress', () => { 73 | const wrapper = mountWrapper(); 74 | 75 | slideStore.progress = ProgressType.Label; 76 | 77 | const query = wrapper.vm.buildQueryParams(); 78 | 79 | expect(query.progress).toBe(ProgressType.Label); 80 | }); 81 | -------------------------------------------------------------------------------- /resources/js/test/enums/visualMode.test.ts: -------------------------------------------------------------------------------- 1 | import { VisualMode, isDarkMode, isLightMode } from '@/enums/visualMode.ts'; 2 | 3 | test('properly detects dark mode', async () => { 4 | expect(isDarkMode(VisualMode.Dark)).toBeTruthy(); 5 | expect(isDarkMode(VisualMode.Light)).toBeFalsy(); 6 | }); 7 | 8 | test('properly detects light mode', async () => { 9 | expect(isLightMode(VisualMode.Dark)).toBeFalsy(); 10 | expect(isLightMode(VisualMode.Light)).toBeTruthy(); 11 | }); 12 | -------------------------------------------------------------------------------- /resources/js/test/pages/AdhocSlides.test.ts: -------------------------------------------------------------------------------- 1 | import { shallowMount, VueWrapper } from '@vue/test-utils' 2 | 3 | 4 | import ProgressType from '@/enums/progressType.ts'; 5 | import QueryParams from '@/interfaces/queryParams.ts'; 6 | import { MOCK_ADHOC_URL } from '@/mocks/handlers.ts'; 7 | import { server } from '@/mocks/browser.ts'; 8 | import AdhocSlidesPage from '@/Pages/AdhocSlides.vue' 9 | import dataStore from '@/store/dataStore.ts' 10 | import slideStore from '@/store/slideStore.ts' 11 | 12 | afterEach(() => { 13 | dataStore.reset() 14 | slideStore.reset(); 15 | localStorage.clear() 16 | }); 17 | 18 | const mountWrapper = (encodedSlides: string | undefined) : VueWrapper => { 19 | const params: QueryParams = { 20 | index: 5, 21 | loop: 10, 22 | progress: ProgressType.Label, 23 | }; 24 | 25 | return shallowMount(AdhocSlidesPage, { 26 | props: { 27 | ...params, 28 | encodedSlides, 29 | } 30 | }); 31 | }; 32 | 33 | describe('fetching data', () => { 34 | // Start server before all tests 35 | beforeAll(() => server.listen({ onUnhandledRequest: 'error' })) 36 | 37 | // Close server after all tests 38 | afterAll(() => server.close()) 39 | 40 | // Reset handlers after each test `important for test isolation` 41 | afterEach(() => server.resetHandlers()) 42 | 43 | test('mounts the query params in the slide store', async () => { 44 | const wrapper = mountWrapper(btoa(MOCK_ADHOC_URL)); 45 | 46 | expect(slideStore.index).toBe(5); 47 | expect(slideStore.loop).toBe(10); 48 | expect(slideStore.progress).toBe(ProgressType.Label); 49 | }); 50 | 51 | test('sets data in the data store for adhoc slides', async () => { 52 | const wrapper = mountWrapper(btoa(MOCK_ADHOC_URL)); 53 | 54 | expect(dataStore.data.length).toBe(3); 55 | expect(dataStore.data[0]).toBe('

Welcome to

'); 56 | expect(dataStore.data[1]).toBe('

Simple Slides

'); 57 | expect(dataStore.data[2]).toBe('

https://example.com

'); 58 | }); 59 | 60 | test('sets data in the data store for instructions', async () => { 61 | const wrapper = mountWrapper(undefined); 62 | 63 | expect(dataStore.data.length).toBe(3); 64 | expect(dataStore.data[0]).toBe('

Welcome to

'); 65 | expect(dataStore.data[1]).toBe('

Simple Slides

'); 66 | expect(dataStore.data[2]).toBe('

https://example.com

'); 67 | }); 68 | }); 69 | -------------------------------------------------------------------------------- /resources/js/test/pages/Presentation.test.ts: -------------------------------------------------------------------------------- 1 | import { shallowMount, VueWrapper } from '@vue/test-utils' 2 | 3 | import DraftBanner from '@/Components/DraftBanner.vue' 4 | import ProgressType from '@/enums/progressType.ts'; 5 | import Presentation from '@/interfaces/presentation.ts'; 6 | import QueryParams from '@/interfaces/queryParams.ts'; 7 | import PresentationPage from '@/Pages/Presentation.vue' 8 | import dataStore from '@/store/dataStore.ts' 9 | import slideStore from '@/store/slideStore.ts' 10 | 11 | afterEach(() => { 12 | slideStore.reset(); 13 | }); 14 | 15 | const mountWrapper = (isPublished: boolean = true) : VueWrapper => { 16 | const params: QueryParams = { 17 | index: 5, 18 | loop: 10, 19 | progress: ProgressType.Label, 20 | }; 21 | 22 | const presentation: Presentation = { 23 | id: '1', 24 | content: '1\n\n2\n\n3', 25 | slide_delimiter: '(\n\n|\r\n)', 26 | is_published: isPublished, 27 | }; 28 | 29 | return shallowMount(PresentationPage, { 30 | props: { 31 | ...params, 32 | presentation, 33 | } 34 | }); 35 | }; 36 | 37 | test('mounts the query params in the slide store', async () => { 38 | const wrapper = mountWrapper(); 39 | 40 | expect(slideStore.index).toBe(5); 41 | expect(slideStore.loop).toBe(10); 42 | expect(slideStore.progress).toBe(ProgressType.Label); 43 | }); 44 | 45 | test('parses the presentation content in the data store', async () => { 46 | const wrapper = mountWrapper(); 47 | 48 | expect(dataStore.data).toStrictEqual([ 49 | '

1

', 50 | '

2

', 51 | '

3

', 52 | ]); 53 | }); 54 | 55 | test('does not show the draft banner for published presentations', async () => { 56 | const wrapper = mountWrapper(); 57 | 58 | expect(wrapper.vm.isDraft).toBeFalsy(); 59 | }); 60 | 61 | test('shows the draft banner for draft presentations', async () => { 62 | const wrapper = mountWrapper(false); 63 | 64 | expect(wrapper.vm.isDraft).toBeTruthy(); 65 | }); 66 | -------------------------------------------------------------------------------- /resources/js/test/pages/Privacy.test.ts: -------------------------------------------------------------------------------- 1 | import { shallowMount, VueWrapper } from '@vue/test-utils' 2 | 3 | import PrivacyPage from '@/Pages/Privacy.vue' 4 | 5 | const mountWrapper = () : VueWrapper => { 6 | return shallowMount(PrivacyPage); 7 | }; 8 | 9 | test('loads the privacy policy page', async () => { 10 | const wrapper = mountWrapper(); 11 | 12 | expect(wrapper.find('h1').text()).toBe('Privacy Policy'); 13 | }); 14 | -------------------------------------------------------------------------------- /resources/js/test/pages/Settings.test.ts: -------------------------------------------------------------------------------- 1 | // @ts-nocheck 2 | 3 | import { shallowMount, VueWrapper } from '@vue/test-utils' 4 | 5 | import SettingsPage from '@/Pages/Settings.vue' 6 | import { VisualMode } from '@/enums/visualMode.ts'; 7 | import { getVisualMode } from '@/utils/handleVisualMode.ts' 8 | 9 | afterEach(() => { 10 | localStorage.clear() 11 | }); 12 | 13 | const mountWrapper = () : VueWrapper => { 14 | return shallowMount(SettingsPage); 15 | }; 16 | 17 | test('sets the slidesUrl value', async () => { 18 | const wrapper = mountWrapper(); 19 | 20 | const textarea = wrapper.find('#slidesUrl'); 21 | 22 | await textarea.setValue('https://foo.com'); 23 | 24 | expect(textarea.element.value).toBe('https://foo.com'); 25 | }); 26 | 27 | // TODO: Handle mocking inertia visit function. 28 | // test('successfully submits the form', async () => { 29 | // const wrapper = mountWrapper(); 30 | // 31 | // await wrapper.find('#slidesUrl').setValue('https://foo.com'); 32 | // 33 | // await wrapper.find('form').trigger('submit'); 34 | // }); 35 | 36 | test('fails to submit the form if invalid', async () => { 37 | const wrapper = mountWrapper(); 38 | 39 | await wrapper.find('form').trigger('submit'); 40 | }); 41 | 42 | test('setting darkMode to true sets dark mode', async () => { 43 | const wrapper = mountWrapper(); 44 | 45 | await wrapper.find('#darkMode').trigger('click') 46 | 47 | expect(getVisualMode()).toBe(VisualMode.Dark); 48 | }); 49 | 50 | test('setting darkMode back to false sets light mode', async () => { 51 | const wrapper = mountWrapper(); 52 | 53 | await wrapper.find('#darkMode').trigger('click') 54 | 55 | expect(getVisualMode()).toBe(VisualMode.Dark); 56 | 57 | await wrapper.find('#lightMode').trigger('click') 58 | 59 | expect(getVisualMode()).toBe(VisualMode.Light); 60 | }); 61 | -------------------------------------------------------------------------------- /resources/js/test/store/dataStore.test.ts: -------------------------------------------------------------------------------- 1 | import { server } from '@/mocks/browser.ts'; 2 | import { MOCK_ADHOC_URL, MOCK_WINDOWS_ADHOC_URL } from '@/mocks/handlers.ts'; 3 | import dataStore from '@/store/dataStore.ts'; 4 | 5 | beforeEach(() => { 6 | dataStore.reset() 7 | }) 8 | 9 | test('gets the right initial values', async () => { 10 | expect(dataStore.data).toStrictEqual([]); 11 | }); 12 | 13 | test('can reset to initial values', async () => { 14 | dataStore.data = ['1', '2', '3']; 15 | 16 | expect(dataStore.data).toStrictEqual(['1', '2', '3']); 17 | 18 | dataStore.reset(); 19 | 20 | expect(dataStore.data).toStrictEqual([]); 21 | }); 22 | 23 | test('can process provided data with default delimiter', async () => { 24 | const text = '1\n\n2\n\n3'; 25 | 26 | dataStore.processData(text); 27 | 28 | expect(dataStore.data).toStrictEqual([ 29 | '

1

', 30 | '

2

', 31 | '

3

', 32 | ]); 33 | }); 34 | 35 | test('can process provided data with the triple hyphen delimiter', async () => { 36 | const text = '1---2---3'; 37 | 38 | dataStore.processData(text, '---'); 39 | 40 | expect(dataStore.data).toStrictEqual([ 41 | '

1

', 42 | '

2

', 43 | '

3

', 44 | ]); 45 | }); 46 | 47 | describe('fetching data', () => { 48 | // Start server before all tests 49 | beforeAll(() => server.listen({ onUnhandledRequest: 'error' })) 50 | 51 | // Close server after all tests 52 | afterAll(() => server.close()) 53 | 54 | // Reset handlers after each test `important for test isolation` 55 | afterEach(() => server.resetHandlers()) 56 | 57 | test('gets the instructions', async () => { 58 | expect(dataStore.data).toStrictEqual([]); 59 | 60 | await dataStore.fetchAndProcessData(MOCK_ADHOC_URL); 61 | 62 | expect(dataStore.data.length).toBe(3); 63 | expect(dataStore.data[0]).toBe('

Welcome to

'); 64 | expect(dataStore.data[1]).toBe('

Simple Slides

'); 65 | expect(dataStore.data[2]).toBe('

https://example.com

'); 66 | }); 67 | 68 | test('gets the instructions with \r\n data', async () => { 69 | expect(dataStore.data).toStrictEqual([]); 70 | 71 | await dataStore.fetchAndProcessData(MOCK_WINDOWS_ADHOC_URL); 72 | 73 | expect(dataStore.data.length).toBe(3); 74 | expect(dataStore.data[0]).toBe('

Welcome to

'); 75 | expect(dataStore.data[1]).toBe('

Simple Slides

'); 76 | expect(dataStore.data[2]).toBe('

https://example.com

'); 77 | }); 78 | }); 79 | -------------------------------------------------------------------------------- /resources/js/test/store/slideStore.test.ts: -------------------------------------------------------------------------------- 1 | import ProgressType from '@/enums/progressType.ts' 2 | import dataStore from '@/store/dataStore.ts' 3 | import slideStore from '@/store/slideStore.ts' 4 | 5 | afterEach(() => { 6 | dataStore.reset(); 7 | slideStore.reset(); 8 | }); 9 | 10 | test('gets the right initial values', async () => { 11 | expect(slideStore.index).toBe(0); 12 | expect(slideStore.progress).toBe(ProgressType.Bar); 13 | }); 14 | 15 | test('can reset to initial values', async () => { 16 | slideStore.index = 5; 17 | slideStore.progress = ProgressType.Label; 18 | 19 | expect(slideStore.index).toBe(5); 20 | expect(slideStore.progress).toBe(ProgressType.Label); 21 | 22 | slideStore.reset(); 23 | 24 | expect(slideStore.index).toBe(0); 25 | expect(slideStore.progress).toBe(ProgressType.Bar); 26 | }); 27 | 28 | test('will not change slide store if no new index', async () => { 29 | slideStore.index = 0; 30 | 31 | slideStore.increment(-1); 32 | 33 | expect(slideStore.index).toBe(0); 34 | }); 35 | 36 | test('returns true for isEnd if slide index is at the end', async () => { 37 | dataStore.data = ['a', 'b', 'c']; 38 | slideStore.index = 2; 39 | 40 | expect(slideStore.isEnd()).toBe(true); 41 | }); 42 | 43 | test('returns false for isEnd if slide index is not at the end', async () => { 44 | dataStore.data = ['a', 'b', 'c']; 45 | slideStore.index = 1; 46 | 47 | expect(slideStore.isEnd()).toBe(false); 48 | }); 49 | 50 | test('returns true for isStart if slide index is at the start', async () => { 51 | dataStore.data = ['a', 'b', 'c']; 52 | slideStore.index = 0; 53 | 54 | expect(slideStore.isStart()).toBe(true); 55 | }); 56 | 57 | test('returns false for isStart if slide index is not at the start', async () => { 58 | dataStore.data = ['a', 'b', 'c']; 59 | slideStore.index = 1; 60 | 61 | expect(slideStore.isStart()).toBe(false); 62 | }); 63 | 64 | test('returns true for canLoop if loop value is valid', async () => { 65 | slideStore.loop = 5; 66 | 67 | expect(slideStore.canLoop()).toBe(true); 68 | }); 69 | 70 | test('returns false for canLoop if loop value is invalid', async () => { 71 | slideStore.loop = 1; 72 | 73 | expect(slideStore.canLoop()).toBe(false); 74 | }); 75 | -------------------------------------------------------------------------------- /resources/js/test/utils/handleQueryParams.test.ts: -------------------------------------------------------------------------------- 1 | import ProgressType from '@/enums/progressType.ts'; 2 | import QueryParams from '@/interfaces/queryParams.ts'; 3 | import slideStore from '@/store/slideStore.ts' 4 | import { processQueryParams } from '@/utils/handleQueryParams.ts' 5 | 6 | afterEach(() => { 7 | slideStore.reset(); 8 | }); 9 | 10 | test('sets default query param values in the slide store', async () => { 11 | const params: QueryParams = { }; 12 | 13 | processQueryParams(params); 14 | 15 | expect(slideStore.index).toBe(0); 16 | expect(slideStore.loop).toBe(0); 17 | expect(slideStore.progress).toBe(ProgressType.Bar); 18 | }); 19 | 20 | test('sets correct query param values in the slide store', async () => { 21 | const params: QueryParams = { 22 | index: 5, 23 | loop: 10, 24 | progress: ProgressType.Label, 25 | }; 26 | 27 | processQueryParams(params); 28 | 29 | expect(slideStore.index).toBe(5); 30 | expect(slideStore.loop).toBe(10); 31 | expect(slideStore.progress).toBe(ProgressType.Label); 32 | }); 33 | -------------------------------------------------------------------------------- /resources/js/test/utils/handleVisualMode.test.ts: -------------------------------------------------------------------------------- 1 | import { VisualMode } from '@/enums/visualMode.ts'; 2 | import { applyVisualMode, getVisualMode, setVisualMode } from '@/utils/handleVisualMode.ts' 3 | 4 | afterEach(() => { 5 | localStorage.clear() 6 | }) 7 | 8 | test('gets the right base visual mode', async () => { 9 | expect(getVisualMode()).toBe(VisualMode.Light); 10 | }); 11 | 12 | test('gets the right visual mode from localStorage', async () => { 13 | localStorage.setItem('visualMode', VisualMode.Dark.toString()) 14 | 15 | expect(getVisualMode()).toBe(VisualMode.Dark); 16 | }); 17 | 18 | test('sets the visual mode to light', async () => { 19 | setVisualMode(VisualMode.Light); 20 | 21 | expect(getVisualMode()).toBe(VisualMode.Light); 22 | }); 23 | 24 | test('sets the visual mode to dark', async () => { 25 | setVisualMode(VisualMode.Dark); 26 | 27 | expect(getVisualMode()).toBe(VisualMode.Dark); 28 | }); 29 | 30 | test('applying the visual mode without an option uses the default', async () => { 31 | applyVisualMode(); 32 | 33 | expect(document.body.classList.toString()).not.toContain('dark'); 34 | }); 35 | 36 | test('applying the visual mode to dark changes the body', async () => { 37 | applyVisualMode(VisualMode.Dark); 38 | 39 | expect(document.body.classList.toString()).toContain('dark'); 40 | }); 41 | 42 | test('applying the visual mode to light changes the body', async () => { 43 | applyVisualMode(VisualMode.Light); 44 | 45 | expect(document.body.classList.toString()).not.toContain('dark'); 46 | }); 47 | 48 | test('setting the visual mode to dark also applies the visual mode', async () => { 49 | setVisualMode(VisualMode.Dark); 50 | 51 | expect(document.body.classList.toString()).toContain('dark'); 52 | }); 53 | 54 | test('setting the visual mode to light also applies the visual mode', async () => { 55 | setVisualMode(VisualMode.Light); 56 | 57 | expect(document.body.classList.toString()).not.toContain('dark'); 58 | }); 59 | -------------------------------------------------------------------------------- /resources/js/types/global.d.ts: -------------------------------------------------------------------------------- 1 | import { PageProps as InertiaPageProps } from '@inertiajs/core'; 2 | import { AxiosInstance } from 'axios'; 3 | import ziggyRoute, { Config as ZiggyConfig } from 'ziggy-js'; 4 | import { PageProps as AppPageProps } from './'; 5 | 6 | declare global { 7 | interface Window { 8 | axios: AxiosInstance; 9 | } 10 | 11 | var route: typeof ziggyRoute; 12 | var Ziggy: ZiggyConfig; 13 | } 14 | 15 | declare module 'vue' { 16 | interface ComponentCustomProperties { 17 | route: typeof ziggyRoute; 18 | } 19 | } 20 | 21 | declare module '@inertiajs/core' { 22 | interface PageProps extends InertiaPageProps, AppPageProps {} 23 | } 24 | -------------------------------------------------------------------------------- /resources/js/types/index.d.ts: -------------------------------------------------------------------------------- 1 | export interface User { 2 | id: number; 3 | name: string; 4 | email: string; 5 | email_verified_at: string; 6 | } 7 | 8 | export type PageProps = Record> = T & { 9 | auth: { 10 | user: User; 11 | }; 12 | }; 13 | -------------------------------------------------------------------------------- /resources/js/types/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /resources/js/utils/handleContent.ts: -------------------------------------------------------------------------------- 1 | // @ts-ignore 2 | import textfit from '../lib/textFit.js'; 3 | 4 | /* c8 ignore next 13 */ 5 | export const runTextFit = (element: HTMLDivElement) : void => { 6 | textfit(element, { 7 | maxFontSize: 1000, 8 | }); 9 | }; 10 | 11 | export const openAllLinksInNewTab = () : void => { 12 | document 13 | .querySelectorAll(".slide-content a") 14 | .forEach((element) => { 15 | element.setAttribute("target", "_blank"); 16 | }); 17 | }; 18 | -------------------------------------------------------------------------------- /resources/js/utils/handleQueryParams.ts: -------------------------------------------------------------------------------- 1 | import ProgressType from '@/enums/progressType.ts'; 2 | import QueryParams from '@/interfaces/queryParams.ts'; 3 | import slideStore from '@/store/slideStore.ts' 4 | 5 | export const processQueryParams = (params: QueryParams): void => { 6 | slideStore.index = params.index ?? 0; 7 | slideStore.loop = params.loop ?? 0; 8 | slideStore.progress = params.progress ?? ProgressType.Bar; 9 | }; 10 | -------------------------------------------------------------------------------- /resources/js/utils/handleVisualMode.ts: -------------------------------------------------------------------------------- 1 | import { VisualMode, isDarkMode } from '../enums/visualMode.ts'; 2 | 3 | export const getVisualMode = () : VisualMode => { 4 | return (localStorage.getItem('visualMode') as VisualMode) ?? VisualMode.Light 5 | }; 6 | 7 | export const setVisualMode = (value: VisualMode) => { 8 | localStorage.setItem('visualMode', value.toString()); 9 | 10 | applyVisualMode(value); 11 | }; 12 | 13 | export const applyVisualMode = (value: VisualMode = getVisualMode()) : void => { 14 | if (isDarkMode(value)) { 15 | document.body.classList.add('dark'); 16 | return; 17 | } 18 | 19 | document.body.classList.remove('dark'); 20 | }; 21 | -------------------------------------------------------------------------------- /resources/views/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{ config('app.name', 'Simple Slides') }} 8 | 9 | 11 | 13 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | @routes 43 | @vite(['resources/js/app.ts', "resources/js/Pages/{$page['component']}.vue"]) 44 | @inertiaHead 45 | 46 | 47 | @inertia 48 | 49 | 50 | -------------------------------------------------------------------------------- /resources/views/filament/dashboard/footer.blade.php: -------------------------------------------------------------------------------- 1 | 2 |

3 | Note: Views are only tracked on published presentations. 4 | Additionally, if you are logged in and view one of your own 5 | presentations, a view will not be tracked. 6 |

7 |
8 | -------------------------------------------------------------------------------- /resources/views/livewire/username-component.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | {{ $this->form }} 6 | 7 |
8 | 9 | Update 10 | 11 |
12 |
13 |
14 |
15 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 18 | return $request->user(); 19 | }); 20 | -------------------------------------------------------------------------------- /routes/auth.php: -------------------------------------------------------------------------------- 1 | group(function () { 15 | Route::get('register', [RegisteredUserController::class, 'create']) 16 | ->name('register'); 17 | 18 | Route::post('register', [RegisteredUserController::class, 'store']); 19 | 20 | Route::get('login', [AuthenticatedSessionController::class, 'create']) 21 | ->name('login'); 22 | 23 | Route::post('login', [AuthenticatedSessionController::class, 'store']); 24 | 25 | Route::get('forgot-password', [PasswordResetLinkController::class, 'create']) 26 | ->name('password.request'); 27 | 28 | Route::post('forgot-password', [PasswordResetLinkController::class, 'store']) 29 | ->name('password.email'); 30 | 31 | Route::get('reset-password/{token}', [NewPasswordController::class, 'create']) 32 | ->name('password.reset'); 33 | 34 | Route::post('reset-password', [NewPasswordController::class, 'store']) 35 | ->name('password.store'); 36 | }); 37 | 38 | Route::middleware('auth')->group(function () { 39 | Route::get('verify-email', EmailVerificationPromptController::class) 40 | ->name('verification.notice'); 41 | 42 | Route::get('verify-email/{id}/{hash}', VerifyEmailController::class) 43 | ->middleware(['signed', 'throttle:6,1']) 44 | ->name('verification.verify'); 45 | 46 | Route::post('email/verification-notification', [EmailVerificationNotificationController::class, 'store']) 47 | ->middleware('throttle:6,1') 48 | ->name('verification.send'); 49 | 50 | Route::get('confirm-password', [ConfirmablePasswordController::class, 'show']) 51 | ->name('password.confirm'); 52 | 53 | Route::post('confirm-password', [ConfirmablePasswordController::class, 'store']); 54 | 55 | Route::put('password', [PasswordController::class, 'update'])->name('password.update'); 56 | 57 | Route::post('logout', [AuthenticatedSessionController::class, 'destroy']) 58 | ->name('logout'); 59 | }); 60 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->purpose('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | name('home'); 23 | Route::get('/settings', [SettingsController::class, 'index'])->name('settings'); 24 | 25 | Route::get('/privacy', function (): Response { 26 | return Inertia::render('Privacy'); 27 | }); 28 | 29 | Route::get('/{user:username}/{slug}', [PresentationController::class, 'show']) 30 | ->name('presentations.show'); 31 | 32 | Route::get('/{slides}', [AdhocSlidesController::class, 'show']) 33 | ->name('adhoc-slides.show'); 34 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | compiled.php 2 | config.php 3 | down 4 | events.scanned.php 5 | maintenance.php 6 | routes.php 7 | routes.scanned.php 8 | schedule-* 9 | services.json 10 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/temp/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | import defaultTheme from 'tailwindcss/defaultTheme'; 2 | import forms from '@tailwindcss/forms'; 3 | 4 | /** @type {import('tailwindcss').Config} */ 5 | export default { 6 | darkMode: 'class', 7 | content: [ 8 | './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php', 9 | './storage/framework/views/*.php', 10 | './resources/views/**/*.blade.php', 11 | './resources/js/**/*.vue', 12 | ], 13 | 14 | theme: { 15 | extend: { 16 | fontFamily: { 17 | sans: ['Figtree', ...defaultTheme.fontFamily.sans], 18 | }, 19 | }, 20 | }, 21 | 22 | plugins: [forms], 23 | }; 24 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 18 | 19 | return $app; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/Feature/Auth/AuthenticationTest.php: -------------------------------------------------------------------------------- 1 | get(route('filament.admin.auth.login')); 11 | 12 | $response->assertStatus(200); 13 | }); 14 | 15 | test('users can authenticate using the login screen', function () { 16 | $user = User::factory()->create(); 17 | 18 | livewire(Login::class) 19 | ->set('data.email', $user->email) 20 | ->set('data.password', 'password') 21 | ->call('authenticate') 22 | ->assertHasNoErrors() 23 | ->assertRedirect(RouteServiceProvider::HOME); 24 | 25 | $this->assertAuthenticated(); 26 | }); 27 | 28 | test('users can not authenticate with invalid password', function () { 29 | $user = User::factory()->create(); 30 | 31 | livewire(Login::class) 32 | ->set('data.email', $user->email) 33 | ->set('data.password', 'wrong-password') 34 | ->call('authenticate') 35 | ->assertHasErrors(); 36 | 37 | $this->assertGuest(); 38 | }); 39 | 40 | test('users can logout', function () { 41 | $user = User::factory()->create(); 42 | 43 | $response = $this->actingAs($user)->post(route('filament.admin.auth.logout')); 44 | 45 | $this->assertGuest(); 46 | $response->assertRedirect(route('filament.admin.auth.login')); 47 | }); 48 | -------------------------------------------------------------------------------- /tests/Feature/Auth/EmailVerificationTest.php: -------------------------------------------------------------------------------- 1 | create([ 11 | 'email_verified_at' => null, 12 | ]); 13 | 14 | $response = $this 15 | ->actingAs($user) 16 | ->get(route('filament.admin.auth.email-verification.prompt')); 17 | 18 | $response->assertStatus(200); 19 | }); 20 | 21 | test('email can be verified', function () { 22 | $user = User::factory()->create([ 23 | 'email_verified_at' => null, 24 | ]); 25 | 26 | Event::fake(); 27 | 28 | $verificationUrl = URL::temporarySignedRoute( 29 | 'filament.admin.auth.email-verification.verify', 30 | now()->addMinutes(60), 31 | ['id' => $user->id, 'hash' => sha1($user->email)] 32 | ); 33 | 34 | $response = $this->actingAs($user)->get($verificationUrl); 35 | 36 | Event::assertDispatched(Verified::class); 37 | expect($user->fresh()->hasVerifiedEmail())->toBeTrue(); 38 | $response->assertRedirect(RouteServiceProvider::HOME); 39 | }); 40 | 41 | test('email is not verified with invalid hash', function () { 42 | $user = User::factory()->create([ 43 | 'email_verified_at' => null, 44 | ]); 45 | 46 | $verificationUrl = URL::temporarySignedRoute( 47 | 'filament.admin.auth.email-verification.verify', 48 | now()->addMinutes(60), 49 | ['id' => $user->id, 'hash' => sha1('wrong-email')] 50 | ); 51 | 52 | $this->actingAs($user)->get($verificationUrl); 53 | 54 | expect($user->fresh()->hasVerifiedEmail())->toBeFalse(); 55 | }); 56 | -------------------------------------------------------------------------------- /tests/Feature/Auth/PasswordResetTest.php: -------------------------------------------------------------------------------- 1 | get(route('filament.admin.auth.password-reset.request')); 12 | 13 | $response->assertSuccessful(); 14 | }); 15 | 16 | test('password reset request can be initiated', function () { 17 | Notification::fake(); 18 | 19 | $user = User::factory()->create(); 20 | 21 | livewire(RequestPasswordReset::class) 22 | ->set('data.email', $user->email) 23 | ->call('request'); 24 | 25 | Notification::assertSentTo($user, ResetPasswordNotification::class); 26 | }); 27 | 28 | test('reset password form displays with valid token', function () { 29 | Notification::fake(); 30 | 31 | $user = User::factory()->create(); 32 | 33 | livewire(RequestPasswordReset::class) 34 | ->set('data.email', $user->email) 35 | ->call('request'); 36 | 37 | Notification::assertSentTo($user, ResetPasswordNotification::class, function ($notification) { 38 | $response = $this->get($notification->url); 39 | 40 | $response->assertSuccessful(); 41 | 42 | return true; 43 | }); 44 | }); 45 | -------------------------------------------------------------------------------- /tests/Feature/Auth/RegistrationTest.php: -------------------------------------------------------------------------------- 1 | get('/register'); 11 | 12 | $response->assertStatus(200); 13 | }); 14 | 15 | test('new users can register', function () { 16 | livewire(Register::class) 17 | ->set('data.name', 'New User') 18 | ->set('data.email', 'newuser@example.com') 19 | ->set('data.username', 'new-user') 20 | ->set('data.password', 'password123') 21 | ->set('data.passwordConfirmation', 'password123') 22 | ->call('register') 23 | ->assertHasNoErrors() 24 | ->assertRedirect(RouteServiceProvider::HOME); 25 | 26 | expect(User::where('email', 'newuser@example.com')->exists())->toBeTrue(); 27 | 28 | $this->assertAuthenticated(); 29 | }); 30 | 31 | test('users must register with a username', function () { 32 | livewire(Register::class) 33 | ->set('data.name', 'New User') 34 | ->set('data.email', 'newuser@example.com') 35 | ->set('data.password', 'password123') 36 | ->set('data.passwordConfirmation', 'password123') 37 | ->call('register') 38 | ->assertHasErrors(['data.username']); 39 | 40 | $this->assertGuest(); 41 | }); 42 | -------------------------------------------------------------------------------- /tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 5 | 6 | $response->assertStatus(200); 7 | }); 8 | -------------------------------------------------------------------------------- /tests/Filament/UsernameComponentTest.php: -------------------------------------------------------------------------------- 1 | user = User::factory()->create(); 10 | 11 | $this->actingAs($this->user); 12 | }); 13 | 14 | it('can render component', function () { 15 | livewire(UsernameComponent::class) 16 | ->assertStatus(200); 17 | }); 18 | 19 | it('loads initial data', function () { 20 | livewire(UsernameComponent::class) 21 | ->assertViewHas('data.username', $this->user->username); 22 | }); 23 | 24 | it('updates the username', function () { 25 | livewire(UsernameComponent::class) 26 | ->set('data.username', 'new-username') 27 | ->call('submit'); 28 | 29 | expect($this->user->refresh()) 30 | ->username->toBe('new-username'); 31 | }); 32 | -------------------------------------------------------------------------------- /tests/Pest.php: -------------------------------------------------------------------------------- 1 | in('Feature'); 18 | uses(TestCase::class, RefreshDatabase::class)->in('Unit'); 19 | uses(TestCase::class, RefreshDatabase::class)->in('Filament'); 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Expectations 24 | |-------------------------------------------------------------------------- 25 | | 26 | | When you're writing tests, you often need to check that values meet certain conditions. The 27 | | "expect()" function gives you access to a set of "expectations" methods that you can use 28 | | to assert different things. Of course, you may extend the Expectation API at any time. 29 | | 30 | */ 31 | 32 | expect()->extend('toBeOne', function () { 33 | return $this->toBe(1); 34 | }); 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Functions 39 | |-------------------------------------------------------------------------- 40 | | 41 | | While Pest is very powerful out-of-the-box, you may have some testing code specific to your 42 | | project that you don't want to repeat in every file. Here you can also expose helpers as 43 | | global functions to help you to reduce the number of lines of code in your test files. 44 | | 45 | */ 46 | 47 | function something() 48 | { 49 | // .. 50 | } 51 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | adhoc_slug->toBe('abc123'); 13 | }); 14 | 15 | test('Daily views can get created with no adhoc slugs', function () { 16 | $view = DailyView::createForAdhocPresentation(); 17 | 18 | expect($view) 19 | ->adhoc_slug->toBeNull(); 20 | }); 21 | 22 | describe('forUser', function () { 23 | beforeEach(function () { 24 | $this->admin = User::factory()->admin()->create(); 25 | $this->user = User::factory()->hasPresentations(1)->create(); 26 | 27 | DailyView::factory()->count(10)->create(); 28 | 29 | DailyView::factory()->count(2)->create([ 30 | 'presentation_id' => $this->user->presentations()->first()->id, 31 | ]); 32 | }); 33 | 34 | test('Admins can see all daily views', function () { 35 | $this->actingAs($this->admin); 36 | 37 | expect(DailyView::forUser()->count())->toBe(12); 38 | }); 39 | 40 | test('Users can see only their daily views', function () { 41 | $this->actingAs($this->user); 42 | 43 | expect(DailyView::forUser()->count())->toBe(2); 44 | }); 45 | }); 46 | 47 | describe('stats', function () { 48 | beforeEach(function () { 49 | $this->presentation = Presentation::factory()->create(); 50 | 51 | // Total of 12 DailyView records 52 | 53 | DailyView::factory()->count(6)->presentation()->create(); 54 | 55 | DailyView::factory()->count(3)->instructions()->create(); 56 | DailyView::factory()->count(1)->adhoc()->create(); 57 | 58 | DailyView::factory()->count(2)->create([ 59 | 'presentation_id' => $this->presentation, 60 | ]); 61 | }); 62 | 63 | test('will show all records with no presentationId set', function () { 64 | expect(DailyView::stats()->count())->toBe(12); 65 | }); 66 | 67 | test('will show instructions records', function () { 68 | expect(DailyView::stats(presentationId: PresentationFilter::INSTRUCTIONS->value) 69 | ->count())->toBe(3); 70 | }); 71 | 72 | test('will show adhoc records', function () { 73 | expect(DailyView::stats(presentationId: PresentationFilter::ADHOC->value) 74 | ->count())->toBe(1); 75 | }); 76 | 77 | test('will show specific presentation records', function () { 78 | expect(DailyView::stats(presentationId: $this->presentation->id) 79 | ->count())->toBe(2); 80 | }); 81 | }); 82 | -------------------------------------------------------------------------------- /tests/Unit/DailyViewObserverTest.php: -------------------------------------------------------------------------------- 1 | create([ 7 | 'session_id' => null, 8 | ]); 9 | 10 | expect($view) 11 | ->session_id->not->toBeNull(); 12 | }); 13 | 14 | test('Daily views do not add the session_id if one is already provided', function () { 15 | $view = DailyView::factory()->create([ 16 | 'session_id' => 'abc123', 17 | ]); 18 | 19 | expect($view) 20 | ->session_id->toBe('abc123'); 21 | }); 22 | -------------------------------------------------------------------------------- /tests/Unit/ExampleTest.php: -------------------------------------------------------------------------------- 1 | toBeTrue(); 5 | }); 6 | -------------------------------------------------------------------------------- /tests/Unit/ImageUploadModelTest.php: -------------------------------------------------------------------------------- 1 | imageUpload = ImageUpload::factory() 9 | ->create([ 10 | 'alt_text' => 'Foo', 11 | ]); 12 | 13 | $this->imageUpload 14 | ->addMedia(UploadedFile::fake()->image('avatar.jpg')) 15 | ->toMediaCollection('image'); 16 | }); 17 | 18 | test('markdownUrl attribute returns properly', function () { 19 | $imagePath = $this->imageUpload->getFirstMediaUrl('image'); 20 | 21 | expect($imagePath)->not->toBeNull(); 22 | 23 | $expected = "![Foo]($imagePath)"; 24 | 25 | expect($this->imageUpload) 26 | ->markdownUrl->toBe($expected); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /tests/Unit/ImageUploadObserverTest.php: -------------------------------------------------------------------------------- 1 | create(); 8 | 9 | $this->actingAs($user); 10 | 11 | $imageUpload = ImageUpload::factory()->create([ 12 | 'user_id' => null, 13 | ]); 14 | 15 | expect($imageUpload) 16 | ->user_id->toBe($user->id); 17 | }); 18 | 19 | test('ImageUploads keep their original user if it exists on create', function () { 20 | $user = User::factory()->create(); 21 | 22 | $this->actingAs($user); 23 | 24 | $imageUpload = ImageUpload::factory()->create(); 25 | 26 | expect($imageUpload) 27 | ->user_id->not->toBe($user->id); 28 | }); 29 | 30 | test('ImageUploads will fail if missing a user_id, with no authenticated user', function () { 31 | expect(fn () => ImageUpload::factory()->create(['user_id' => null])) 32 | ->toThrow(Exception::class); 33 | }); 34 | -------------------------------------------------------------------------------- /tests/Unit/MediaObserverTest.php: -------------------------------------------------------------------------------- 1 | hasPresentations(1) 10 | ->create(); 11 | 12 | $this->actingAs($user); 13 | 14 | expect($user)->image_uploaded_size->toBe(0); 15 | 16 | $user 17 | ->presentations 18 | ->first() 19 | ->addMedia(UploadedFile::fake()->image('avatar.jpg')) 20 | ->toMediaCollection('thumbnail'); 21 | 22 | expect($user)->image_uploaded_size->not->toBe(0); 23 | expect($user)->image_uploaded_size->toBe(Media::first()->size); 24 | }); 25 | 26 | test('user image uploaded size increases on media deletion', function () { 27 | $user = User::factory() 28 | ->hasPresentations(1) 29 | ->create(); 30 | 31 | $this->actingAs($user); 32 | 33 | $user 34 | ->presentations 35 | ->first() 36 | ->addMedia(UploadedFile::fake()->image('avatar.jpg')) 37 | ->toMediaCollection('thumbnail'); 38 | 39 | expect($user)->image_uploaded_size->not->toBe(0); 40 | 41 | Media::first()->delete(); 42 | 43 | expect($user)->image_uploaded_size->toBe(0); 44 | }); 45 | -------------------------------------------------------------------------------- /tests/Unit/PresentationModelTest.php: -------------------------------------------------------------------------------- 1 | create(['slug' => null]); 9 | 10 | expect($presentation) 11 | ->slug->toBe(Str::slug($presentation->title)); 12 | }); 13 | 14 | test('Presentation does not change slug on update', function () { 15 | $presentation = Presentation::factory()->create(); 16 | 17 | $originalSlug = $presentation->slug; 18 | 19 | $presentation->title = 'foo'; 20 | $presentation->save(); 21 | 22 | expect($presentation->refresh()) 23 | ->slug->toBe($originalSlug); 24 | }); 25 | 26 | test('Presentation can create daily view', function () { 27 | $presentation = Presentation::factory()->create(['slug' => null]); 28 | 29 | $view = $presentation->addDailyView(); 30 | 31 | expect($view) 32 | ->presentation_id->toBe($presentation->id); 33 | }); 34 | 35 | describe('forUser', function () { 36 | beforeEach(function () { 37 | $this->admin = User::factory()->admin()->create(); 38 | $this->user = User::factory()->hasPresentations(2)->create(); 39 | 40 | Presentation::factory()->count(10)->create(); 41 | }); 42 | 43 | test('Admins can see all presentations', function () { 44 | $this->actingAs($this->admin); 45 | 46 | expect(Presentation::forUser()->count())->toBe(12); 47 | }); 48 | 49 | test('Users can see only their presentations', function () { 50 | $this->actingAs($this->user); 51 | 52 | expect(Presentation::forUser()->count())->toBe(2); 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /tests/Unit/PresentationObserverTest.php: -------------------------------------------------------------------------------- 1 | create(); 8 | 9 | $this->actingAs($user); 10 | 11 | $presentation = Presentation::factory()->create([ 12 | 'user_id' => null, 13 | ]); 14 | 15 | expect($presentation) 16 | ->user_id->toBe($user->id); 17 | }); 18 | 19 | test('Presentations keep their original user if it exists on create', function () { 20 | $user = User::factory()->create(); 21 | 22 | $this->actingAs($user); 23 | 24 | $presentation = Presentation::factory()->create(); 25 | 26 | expect($presentation) 27 | ->user_id->not->toBe($user->id); 28 | }); 29 | 30 | test('Presentations will fail if missing a user_id, with no authenticated user', function () { 31 | expect(fn () => Presentation::factory()->create(['user_id' => null])) 32 | ->toThrow(Exception::class); 33 | }); 34 | -------------------------------------------------------------------------------- /tests/Unit/UserCanUploadTest.php: -------------------------------------------------------------------------------- 1 | create(); 7 | 8 | expect($user->can('upload', User::class))->toBeTrue(); 9 | }); 10 | 11 | test('user can not upload if they are at their max storage space', function () { 12 | $user = User::factory()->create([ 13 | 'image_uploaded_size' => config('app-upload.limit'), 14 | ]); 15 | 16 | expect($user->can('upload', User::class))->toBeFalse(); 17 | }); 18 | 19 | test('user can not upload if they are above their max storage space', function () { 20 | $user = User::factory()->create([ 21 | 'image_uploaded_size' => (config('app-upload.limit') + 10), 22 | ]); 23 | 24 | expect($user->can('upload', User::class))->toBeFalse(); 25 | }); 26 | 27 | test('admin users can upload even if they are above their max storage space', function () { 28 | $user = User::factory()->create([ 29 | 'is_admin' => true, 30 | 'image_uploaded_size' => (config('app-upload.limit') + 10), 31 | ]); 32 | 33 | expect($user->can('upload', User::class))->toBeTrue(); 34 | }); 35 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "types": ["vitest/globals"], 4 | 5 | "allowJs": true, 6 | "module": "ESNext", 7 | "moduleResolution": "bundler", 8 | "jsx": "preserve", 9 | "strict": true, 10 | "isolatedModules": true, 11 | "target": "ESNext", 12 | "esModuleInterop": true, 13 | "forceConsistentCasingInFileNames": true, 14 | "noEmit": true, 15 | "skipLibCheck": true, 16 | "allowImportingTsExtensions": true, 17 | "paths": { 18 | "@/*": ["./resources/js/*"] 19 | } 20 | }, 21 | "include": ["resources/js/**/*.ts", "resources/js/**/*.d.ts", "resources/js/**/*.vue"] 22 | } 23 | -------------------------------------------------------------------------------- /vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import laravel from 'laravel-vite-plugin'; 3 | import vue from '@vitejs/plugin-vue'; 4 | 5 | export default defineConfig({ 6 | plugins: [ 7 | laravel({ 8 | input: 'resources/js/app.ts', 9 | refresh: true, 10 | }), 11 | vue({ 12 | template: { 13 | transformAssetUrls: { 14 | base: null, 15 | includeAbsolute: false, 16 | }, 17 | }, 18 | }), 19 | ], 20 | test: { 21 | globals: true, 22 | environment: 'happy-dom', 23 | setupFiles: './vitest.setup.ts', 24 | }, 25 | }); 26 | -------------------------------------------------------------------------------- /vitest.setup.ts: -------------------------------------------------------------------------------- 1 | Object.defineProperty(document, 'fonts', { 2 | value: { 3 | // Create an iterable object to avoid TypeError 4 | [Symbol.iterator]: function* () { 5 | yield { family: 'Roboto', weight: '400' }; // Example font object 6 | yield { family: 'Arial', weight: '700' }; 7 | }, 8 | load: vi.fn(), 9 | }, 10 | writable: true, 11 | }); 12 | --------------------------------------------------------------------------------