diff --git a/.dockerignore b/.dockerignore index e69de29..46d3aea 100644 --- a/.dockerignore +++ b/.dockerignore @@ -0,0 +1,2 @@ +src/resources/data.json +src/public/img/profilepic.png \ No newline at end of file diff --git a/README.md b/README.md index e54abec..472fe46 100644 --- a/README.md +++ b/README.md @@ -30,18 +30,17 @@ services: image: nikurasukun/socialtree:latest volumes: - PATH/TO/CONFIG.json:/var/www/html/src/resources/data.json - - PATH/TO/PROFILE/PICTURE.png:/var/www/html/src/public/img/profilepic.png ports: - "40890:80" ``` -Mount your profile pic to `/var/www/html/src/resources/data.json` and the json with the config to -`/var/www/html/src/public/img/profilepic.png` +Mount a json with the config to `/var/www/html/src/resources/data.json` It has to look like this ```json { "username": "Nikurasu", "theme": "orange", + "profilepicture": "https://link.to.profilepicture.com/image.png", "links": [{ "platform": "Twitter", "link": "https://twitter.com/nik_png", @@ -61,6 +60,9 @@ With `username` you specify the displayed name. The `theme` option specifies the themes are available: - `orange` +With `profilepicture` you specify the displayed profile picture. Upload it at the image hoster or cloud provider of your +choice (imgur, imbb, Google Drive, nextcloud, etc.) and paste the direct link to the image here. + In the `links` array you can specify as many links as you want. The `platform` option is used for the coloring of the link. At the moment I support these platforms: - YouTube diff --git a/docker/images/base/Dockerfile b/docker/images/base/Dockerfile index 857a799..34be82e 100644 --- a/docker/images/base/Dockerfile +++ b/docker/images/base/Dockerfile @@ -26,4 +26,4 @@ RUN sed -ri -e "s/^DB_DATABASE=.*$/DB_DATABASE=\/var\/www\/html\/src\/resources\ RUN sed -ri -e "s/^JSON_FILE_PATH=.*$/JSON_FILE_PATH=\/var\/www\/html\/src\/resources\/data.json/" /var/www/html/src/.env EXPOSE 80 -CMD php src/artisan preloadDB:all && sapachectl -D FOREGROUND +CMD php src/artisan preloadDB:all && apachectl -D FOREGROUND diff --git a/src/_ide_helper_models.php b/src/_ide_helper_models.php index 19efc33..af4eb55 100644 --- a/src/_ide_helper_models.php +++ b/src/_ide_helper_models.php @@ -76,6 +76,7 @@ namespace App\Models{ * @property int $id * @property string $username * @property string $theme + * @property string $profilepicture * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at * @method static \Illuminate\Database\Eloquent\Builder|Userdata newModelQuery() diff --git a/src/app/Console/Commands/PreloadDBAll.php b/src/app/Console/Commands/PreloadDBAll.php index 244f540..0eeaa5c 100644 --- a/src/app/Console/Commands/PreloadDBAll.php +++ b/src/app/Console/Commands/PreloadDBAll.php @@ -49,9 +49,10 @@ class PreloadDBAll extends Command if ( array_key_exists('username', $config) && array_key_exists('links', $config) && + array_key_exists('profilepicture', $config) && array_key_exists('theme', $config) ) { - $preloadDBController->setInitialUserData($config['username'], $config['theme']); + $preloadDBController->setInitialUserData($config['username'], $config['theme'], $config['profilepicture']); $arrayHasAllKeys = true; foreach ($config['links'] as $link) { diff --git a/src/app/Http/Controllers/PreloadDBController.php b/src/app/Http/Controllers/PreloadDBController.php index 84feafe..7eff8d0 100644 --- a/src/app/Http/Controllers/PreloadDBController.php +++ b/src/app/Http/Controllers/PreloadDBController.php @@ -18,7 +18,7 @@ class PreloadDBController extends Controller $this->linksService = new LinksService(); } - public function setInitialUserData(string $username, string $theme) + public function setInitialUserData(string $username, string $theme, string $profilepicture) { $userdatas = $this->userdatasService->getAllUserdatas(); $userdataslenght = count($userdatas); @@ -29,7 +29,7 @@ class PreloadDBController extends Controller $this->userdatasService->deleteUserdataByID($userdatas[$userdata]['id']); } } - $this->userdatasService->setNewUserdata($username, $theme); + $this->userdatasService->setNewUserdata($username, $theme, $profilepicture); } public function setInitialLinks(array $newlinks) diff --git a/src/app/Http/Controllers/SocialTreePageController.php b/src/app/Http/Controllers/SocialTreePageController.php index fbb5186..17f6d29 100644 --- a/src/app/Http/Controllers/SocialTreePageController.php +++ b/src/app/Http/Controllers/SocialTreePageController.php @@ -23,11 +23,13 @@ class SocialTreePageController extends Controller $userdata = $this->userdatasService->getFirstUserdata(); $username = $userdata['username']; $theme = $userdata['theme']; + $profilepicture = $userdata['profilepicture']; return view('app',[ 'title' => $username . 's LinkTree', 'username' => $username, 'links' => $links, 'theme' => $theme, + 'profilepicture' => $profilepicture, 'content' => 'linkpage' ]); } diff --git a/src/app/Models/Userdata.php b/src/app/Models/Userdata.php index f49aca2..47c1255 100644 --- a/src/app/Models/Userdata.php +++ b/src/app/Models/Userdata.php @@ -11,6 +11,7 @@ use Illuminate\Database\Eloquent\Model; * @property int $id * @property string $username * @property string $theme + * @property string $profilepicture * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at * @method static \Illuminate\Database\Eloquent\Builder|Userdata newModelQuery() @@ -29,6 +30,7 @@ class Userdata extends Model protected $table = 'userdatas'; protected $attributes = [ 'username'=> 'null', - 'theme'=> 'orange' + 'theme'=> 'orange', + 'profilepicture' => 'https://upload.wikimedia.org/wikipedia/commons/a/ac/Default_pfp.jpg', ]; } diff --git a/src/app/Services/Userdatas/UserdataDataMutator.php b/src/app/Services/Userdatas/UserdataDataMutator.php index 3a0017f..5993139 100644 --- a/src/app/Services/Userdatas/UserdataDataMutator.php +++ b/src/app/Services/Userdatas/UserdataDataMutator.php @@ -6,11 +6,12 @@ use App\Models\Userdata; class UserdataDataMutator { - public function setNewUserdata(string $username, string $theme): bool + public function setNewUserdata(string $username, string $theme, string $profilepicture): bool { $userdata = new Userdata(); $userdata->username = $username; $userdata->theme = $theme; + $userdata->profilepicture = $profilepicture; return $userdata->save(); } diff --git a/src/app/Services/Userdatas/UserdatasService.php b/src/app/Services/Userdatas/UserdatasService.php index 635fe96..cb14468 100644 --- a/src/app/Services/Userdatas/UserdatasService.php +++ b/src/app/Services/Userdatas/UserdatasService.php @@ -23,9 +23,9 @@ class UserdatasService return count($this->userdatasDataProvider->getAllUserdatas()); } - public function setNewUserdata(string $username, string $theme) + public function setNewUserdata(string $username, string $theme, string $profilepicture) { - return $this->userdatasDataMutator->setNewUserdata($username, $theme); + return $this->userdatasDataMutator->setNewUserdata($username, $theme, $profilepicture); } public function deleteUserdataByID(int $id) diff --git a/src/database/migrations/2021_12_01_110933_create_userdatas_table.php b/src/database/migrations/2021_12_01_110933_create_userdatas_table.php index 730d343..3722f45 100644 --- a/src/database/migrations/2021_12_01_110933_create_userdatas_table.php +++ b/src/database/migrations/2021_12_01_110933_create_userdatas_table.php @@ -17,6 +17,7 @@ class CreateUserdatasTable extends Migration $table->id(); $table->string('username'); $table->string('theme'); + $table->string('profilepicture'); $table->timestamps(); }); } diff --git a/src/public/img/profilepic.png b/src/public/img/profilepic.png deleted file mode 100644 index 71282fb..0000000 Binary files a/src/public/img/profilepic.png and /dev/null differ diff --git a/src/resources/views/linkpage.blade.php b/src/resources/views/linkpage.blade.php index 885ec6a..0684f19 100644 --- a/src/resources/views/linkpage.blade.php +++ b/src/resources/views/linkpage.blade.php @@ -1,5 +1,5 @@
- +

@{{$username}}