Add demo files and seeder
134
README.md
|
|
@ -1,134 +0,0 @@
|
||||||
# kcal – the personal food nutrition journal
|
|
||||||
[](https://github.com/kcal-app/kcal/actions/workflows/ci.yml)
|
|
||||||
[](https://coveralls.io/github/kcal-app/kcal?branch=main)
|
|
||||||
|
|
||||||
## Deployment
|
|
||||||
|
|
||||||
### Heroku
|
|
||||||
|
|
||||||
[](https://heroku.com/deploy)
|
|
||||||
|
|
||||||
The default username and password for a Heroku deployment is `kcal`/`kcal`.
|
|
||||||
|
|
||||||
#### Using Heroku CLI
|
|
||||||
|
|
||||||
For a manual deploy using Heroku CLI, execute the following after initial deployment:
|
|
||||||
|
|
||||||
heroku run php artisan migrate
|
|
||||||
heroku run php artisan user:add
|
|
||||||
heroku config:set APP_KEY=$(php artisan --no-ansi key:generate --show)
|
|
||||||
|
|
||||||
#### Search drivers
|
|
||||||
|
|
||||||
See the [Search](#search-mag) section for information about supported drivers. Additional
|
|
||||||
environment variable configuration is necessary when using any search driver other
|
|
||||||
than the default ("null").
|
|
||||||
|
|
||||||
#### Redis Add-on
|
|
||||||
|
|
||||||
The [Heroku Redis](https://elements.heroku.com/addons/heroku-redis) add-on can be
|
|
||||||
added to the app and will work without any configuration changes. It is left out
|
|
||||||
of the default build only because it takes a very long time to provision.
|
|
||||||
|
|
||||||
## Search :mag:
|
|
||||||
|
|
||||||
The "ingredient" (food or recipe) search for journal entries and recipe ingredients
|
|
||||||
supports three different backends using the `SCOUT_DRIVER` environment variable.
|
|
||||||
In all cases, always ensure that the `SCOUT_DRIVER` environment variable is only
|
|
||||||
set once in kcal's `.env` file.
|
|
||||||
|
|
||||||
Currently, the food and recipe *list* searches do not take advantage of these
|
|
||||||
search drivers. Support for those searches will be added if the Laravel JSON:API
|
|
||||||
adds support for Scout (see: laravel-json-api/laravel#32).
|
|
||||||
|
|
||||||
### Algolia (`algolia`)
|
|
||||||
|
|
||||||
1. [Create and/or log in](https://www.algolia.com/users/sign_in) to an Algolia account.
|
|
||||||
|
|
||||||
1. Create an application for kcal.
|
|
||||||
|
|
||||||
1. Navigate to the application's "API Keys" section.
|
|
||||||
|
|
||||||
1. Using the **Application ID** and **Admin API Key** values, update kcal's `.env` file:
|
|
||||||
|
|
||||||
SCOUT_DRIVER=algolia
|
|
||||||
ALGOLIA_APP_ID=<APPLICATION_ID>
|
|
||||||
ALGOLIA_SECRET=<ADMIN_API_KEY>
|
|
||||||
|
|
||||||
### ElasticSearch (`elastic`)
|
|
||||||
|
|
||||||
1. Determine the host and port for your ElasticSearch service.
|
|
||||||
|
|
||||||
1. Update kcal's `.env` file.
|
|
||||||
|
|
||||||
SCOUT_DRIVER=elastic
|
|
||||||
ELASTIC_HOST=<HOST:PORT>
|
|
||||||
ELASTIC_PORT=<PORT>
|
|
||||||
|
|
||||||
Note: The `ELASTIC_PORT` variable is a convenience option specifically for
|
|
||||||
Docker Compose configurations and is not strictly required.
|
|
||||||
|
|
||||||
1. Run Elastic's migrations.
|
|
||||||
|
|
||||||
php artisan elastic:migrate
|
|
||||||
|
|
||||||
### Fallback (`null`)
|
|
||||||
|
|
||||||
The fallback driver is a simple `WHERE ... LIKE` clause search on a couple of key
|
|
||||||
fields. Results will not be ordered by relevance, and some fields will not be
|
|
||||||
searched (e.g. the tags fields). Using one of the other options is highly recommended.
|
|
||||||
|
|
||||||
Set `SCOUT_DRIVER=null` in kcal's `.env` file to use the fallback driver.
|
|
||||||
|
|
||||||
## Development
|
|
||||||
|
|
||||||
### Laravel Sail
|
|
||||||
|
|
||||||
#### Prerequisites
|
|
||||||
|
|
||||||
- [Composer](https://getcomposer.org/download/)
|
|
||||||
- [Docker](https://docs.docker.com/get-docker/)
|
|
||||||
- [Docker compose](https://docs.docker.com/compose/install/)
|
|
||||||
|
|
||||||
1. Clone the repository.
|
|
||||||
|
|
||||||
git clone https://github.com/kcal-app/kcal.git
|
|
||||||
|
|
||||||
1. Move in to the cloned folder.
|
|
||||||
|
|
||||||
cd kcal
|
|
||||||
|
|
||||||
1. Install development dependencies.
|
|
||||||
|
|
||||||
composer install
|
|
||||||
|
|
||||||
1. Create a local `.env` file.
|
|
||||||
|
|
||||||
cp .env.local.example .env
|
|
||||||
|
|
||||||
Note: the default `APP_URL` setting is `http://127.0.0.1`. If you have
|
|
||||||
[dnsmasq](https://thekelleys.org.uk/dnsmasq/doc.html) or something similar
|
|
||||||
configured for the `test` domain you can change this to `http://kcal.test`.
|
|
||||||
|
|
||||||
1. Generate an app key.
|
|
||||||
|
|
||||||
touch .env
|
|
||||||
php artisan key:generate
|
|
||||||
|
|
||||||
1. Run it! :sailboat:
|
|
||||||
|
|
||||||
vendor/bin/sail up -d
|
|
||||||
|
|
||||||
1. (On first run) Run migrations.
|
|
||||||
|
|
||||||
vendor/bin/sail artisan migrate
|
|
||||||
vendor/bin/sail artisan elastic:migrate
|
|
||||||
|
|
||||||
1. (On first run) Create the initial user.
|
|
||||||
|
|
||||||
vendor/bin/sail artisan db:seed --class UserSeeder
|
|
||||||
|
|
||||||
The default username and password is `admin@kcal.test`.
|
|
||||||
|
|
||||||
Once the application finishes starting, navigate to [http://127.0.0.1:8080](http://127.0.0.1:8080)
|
|
||||||
(or [http://kcal.test:8080](http://kcal.test:8080) if configured).
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
This is the demo branch for http://demo.kcal.cooking
|
||||||
|
|
||||||
|
You probably want https://github.com/kcal-app/kcal
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
"cloudcreativity/laravel-json-api": "^3.2",
|
"cloudcreativity/laravel-json-api": "^3.2",
|
||||||
"cviebrock/eloquent-sluggable": "^8.0",
|
"cviebrock/eloquent-sluggable": "^8.0",
|
||||||
"doctrine/dbal": "^3.0",
|
"doctrine/dbal": "^3.0",
|
||||||
|
"fakerphp/faker": "^1.14",
|
||||||
"fideloper/proxy": "^4.4",
|
"fideloper/proxy": "^4.4",
|
||||||
"fruitcake/laravel-cors": "^2.0",
|
"fruitcake/laravel-cors": "^2.0",
|
||||||
"guzzlehttp/guzzle": "^7.0.1",
|
"guzzlehttp/guzzle": "^7.0.1",
|
||||||
|
|
@ -32,7 +33,6 @@
|
||||||
"brianium/paratest": "^6.2",
|
"brianium/paratest": "^6.2",
|
||||||
"cloudcreativity/json-api-testing": "^3.2",
|
"cloudcreativity/json-api-testing": "^3.2",
|
||||||
"facade/ignition": "^2.5",
|
"facade/ignition": "^2.5",
|
||||||
"fakerphp/faker": "^1.9.1",
|
|
||||||
"laravel/breeze": "^1.0",
|
"laravel/breeze": "^1.0",
|
||||||
"laravel/sail": "^0.0.5",
|
"laravel/sail": "^0.0.5",
|
||||||
"mockery/mockery": "^1.4.2",
|
"mockery/mockery": "^1.4.2",
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "b404494454b0ff89c0db3d7eb87e3a44",
|
"content-hash": "4e6584f6ced86392415351d8c793c1ea",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "algolia/algoliasearch-client-php",
|
"name": "algolia/algoliasearch-client-php",
|
||||||
|
|
@ -1761,6 +1761,71 @@
|
||||||
},
|
},
|
||||||
"time": "2020-02-14T23:51:21+00:00"
|
"time": "2020-02-14T23:51:21+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "fakerphp/faker",
|
||||||
|
"version": "v1.14.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/FakerPHP/Faker.git",
|
||||||
|
"reference": "ed22aee8d17c7b396f74a58b1e7fefa4f90d5ef1"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/FakerPHP/Faker/zipball/ed22aee8d17c7b396f74a58b1e7fefa4f90d5ef1",
|
||||||
|
"reference": "ed22aee8d17c7b396f74a58b1e7fefa4f90d5ef1",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.1 || ^8.0",
|
||||||
|
"psr/container": "^1.0",
|
||||||
|
"symfony/deprecation-contracts": "^2.2"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"fzaninotto/faker": "*"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"bamarni/composer-bin-plugin": "^1.4.1",
|
||||||
|
"ext-intl": "*",
|
||||||
|
"symfony/phpunit-bridge": "^4.4 || ^5.2"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-curl": "Required by Faker\\Provider\\Image to download images.",
|
||||||
|
"ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.",
|
||||||
|
"ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.",
|
||||||
|
"ext-mbstring": "Required for multibyte Unicode string functionality."
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-main": "v1.15-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Faker\\": "src/Faker/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "François Zaninotto"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Faker is a PHP library that generates fake data for you.",
|
||||||
|
"keywords": [
|
||||||
|
"data",
|
||||||
|
"faker",
|
||||||
|
"fixtures"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/FakerPHP/Faker/issues",
|
||||||
|
"source": "https://github.com/FakerPHP/Faker/tree/v.1.14.1"
|
||||||
|
},
|
||||||
|
"time": "2021-03-30T06:27:33+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "fideloper/proxy",
|
"name": "fideloper/proxy",
|
||||||
"version": "4.4.1",
|
"version": "4.4.1",
|
||||||
|
|
@ -8425,71 +8490,6 @@
|
||||||
},
|
},
|
||||||
"time": "2020-10-16T08:27:54+00:00"
|
"time": "2020-10-16T08:27:54+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "fakerphp/faker",
|
|
||||||
"version": "v1.14.1",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/FakerPHP/Faker.git",
|
|
||||||
"reference": "ed22aee8d17c7b396f74a58b1e7fefa4f90d5ef1"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/FakerPHP/Faker/zipball/ed22aee8d17c7b396f74a58b1e7fefa4f90d5ef1",
|
|
||||||
"reference": "ed22aee8d17c7b396f74a58b1e7fefa4f90d5ef1",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.1 || ^8.0",
|
|
||||||
"psr/container": "^1.0",
|
|
||||||
"symfony/deprecation-contracts": "^2.2"
|
|
||||||
},
|
|
||||||
"conflict": {
|
|
||||||
"fzaninotto/faker": "*"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"bamarni/composer-bin-plugin": "^1.4.1",
|
|
||||||
"ext-intl": "*",
|
|
||||||
"symfony/phpunit-bridge": "^4.4 || ^5.2"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-curl": "Required by Faker\\Provider\\Image to download images.",
|
|
||||||
"ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.",
|
|
||||||
"ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.",
|
|
||||||
"ext-mbstring": "Required for multibyte Unicode string functionality."
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-main": "v1.15-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Faker\\": "src/Faker/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "François Zaninotto"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Faker is a PHP library that generates fake data for you.",
|
|
||||||
"keywords": [
|
|
||||||
"data",
|
|
||||||
"faker",
|
|
||||||
"fixtures"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/FakerPHP/Faker/issues",
|
|
||||||
"source": "https://github.com/FakerPHP/Faker/tree/v.1.14.1"
|
|
||||||
},
|
|
||||||
"time": "2021-03-30T06:27:33+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "filp/whoops",
|
"name": "filp/whoops",
|
||||||
"version": "2.12.0",
|
"version": "2.12.0",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Recipe;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Ramsey\Uuid\Uuid;
|
||||||
|
|
||||||
|
class DemoSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Seed the demo application database.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$this->call(DatabaseSeeder::class);
|
||||||
|
|
||||||
|
// Manually associate demo media files.
|
||||||
|
$values = [];
|
||||||
|
$conversations = new \stdClass();
|
||||||
|
$conversations->header = true;
|
||||||
|
$conversations->preview = true;
|
||||||
|
$conversations = json_encode($conversations);
|
||||||
|
$empty = json_encode([]);
|
||||||
|
for ($i = 1; $i <= 25; $i++) {
|
||||||
|
$values[] = [
|
||||||
|
'id' => $i,
|
||||||
|
'model_type' => Recipe::class,
|
||||||
|
'model_id' => $i,
|
||||||
|
'uuid' => Uuid::uuid4(),
|
||||||
|
'collection_name' => 'default',
|
||||||
|
'name' => $i,
|
||||||
|
'file_name' => "{$i}.jpg",
|
||||||
|
'mime_type' => 'image/jpeg',
|
||||||
|
'disk' => 'media',
|
||||||
|
'conversions_disk' => 'media',
|
||||||
|
'size' => Storage::disk('media')->getSize("{$i}/{$i}.jpg"),
|
||||||
|
'manipulations' => $empty,
|
||||||
|
'custom_properties' => $empty,
|
||||||
|
'generated_conversions' => $conversations,
|
||||||
|
'responsive_images' => $empty,
|
||||||
|
'order_column' => $i,
|
||||||
|
'created_at' => Carbon::now(),
|
||||||
|
'updated_at' => Carbon::now(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
DB::table('media')->insert($values);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
*
|
|
||||||
!.gitignore
|
|
||||||
|
After Width: | Height: | Size: 310 KiB |
|
After Width: | Height: | Size: 597 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 176 KiB |
|
After Width: | Height: | Size: 388 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 160 KiB |
|
After Width: | Height: | Size: 379 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 257 KiB |
|
After Width: | Height: | Size: 280 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 275 KiB |
|
After Width: | Height: | Size: 348 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 266 KiB |
|
After Width: | Height: | Size: 493 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 438 KiB |
|
After Width: | Height: | Size: 549 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 349 KiB |
|
After Width: | Height: | Size: 642 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 370 KiB |
|
After Width: | Height: | Size: 681 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 235 KiB |
|
After Width: | Height: | Size: 498 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 692 KiB |
|
After Width: | Height: | Size: 674 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 360 KiB |
|
After Width: | Height: | Size: 652 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 328 KiB |
|
After Width: | Height: | Size: 435 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 107 KiB |
|
After Width: | Height: | Size: 236 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 177 KiB |
|
After Width: | Height: | Size: 293 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 239 KiB |
|
After Width: | Height: | Size: 499 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 192 KiB |
|
After Width: | Height: | Size: 442 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 295 KiB |
|
After Width: | Height: | Size: 462 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 202 KiB |
|
After Width: | Height: | Size: 384 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 272 KiB |
|
After Width: | Height: | Size: 353 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 330 KiB |
|
After Width: | Height: | Size: 477 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 157 KiB |
|
After Width: | Height: | Size: 363 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 488 KiB |
|
After Width: | Height: | Size: 610 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 415 KiB |
|
After Width: | Height: | Size: 552 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 577 KiB |
|
After Width: | Height: | Size: 699 KiB |
|
After Width: | Height: | Size: 42 KiB |