Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to see almost all routes #290

Merged
merged 13 commits into from
Jul 30, 2023
3 changes: 3 additions & 0 deletions app/Http/Livewire/Resource/RatingCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public function mount(int|Resource $resource)
{
$this->resource = $resource;
$this->user = auth()->user();
if ($this->user == $this->resource->user) {
$this->closeModal();
}
}

public function save()
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Livewire/Resource/ResourceLike.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function mount(Resource $resource)

public function like()
{
if (! $this->user) {
return redirect()->route('login');
}
$this->user->toggleLike($this->resource);
$this->count = $this->resource->likers()->count();
$this->liked = $this->resource->isLikedBy($this->user);
Expand Down
3 changes: 2 additions & 1 deletion resources/views/errors/503.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@lang('Maintenance')
</h1>
<p class="text-gray-400">503 &mdash; Service Unavailable</p>
<p class="text-gray-400">Check our status page for more info: <a href="https://status.pokemon3d.net" class="text-bold text-green-400">status.pokemon3d.net</a></p>
<a href="{{ route('home') }}" class="inline-flex items-center justify-center px-8 py-4 mt-8 font-extrabold transition duration-150 bg-green-500 border border-green-400 rounded-lg shadow-xl w-76 text-green-50 group-hover:text-green-100 hover:bg-green-600 hover:-translate-y-1">
<svg xmlns="http://www.w3.org/2000/svg" class="inline-block w-5 h-5 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" />
Expand All @@ -20,4 +21,4 @@
</div>
</div>
</main>
</x-guest-layout>
</x-guest-layout>
74 changes: 39 additions & 35 deletions resources/views/livewire/resource/resource-show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
{{ $resource->name }} <span class="text-gray-400 dark:text-gray-500">{{ $resource->updates->first() ? $resource->updates->first()->title : __('Unreleased') }}</span>
</div>
<div class="flex justify-end gap-1">
@if(auth()->user()->id != $resource->user_id || config('app.debug') == true)
@livewire('resource.resource-like', ['resource' => $resource])
<button onclick="Livewire.emit('openModal', 'resource.rating-create', {{ json_encode(['resource' => $resource->id]) }})" class="px-2 py-1 transition-colors duration-150 rounded-md text-sky-100 bg-sky-600 focus:shadow-outline hover:bg-sky-700">
<svg xmlns="http://www.w3.org/2000/svg" class="inline-block w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z" />
</svg>
@lang('Leave a rating')
</button>
@endif
@auth
@if(auth()->user()->id != $resource->user_id || config('app.debug') == true)
@livewire('resource.resource-like', ['resource' => $resource])
<button onclick="Livewire.emit('openModal', 'resource.rating-create', {{ json_encode(['resource' => $resource->id]) }})" class="px-2 py-1 transition-colors duration-150 rounded-md text-sky-100 bg-sky-600 focus:shadow-outline hover:bg-sky-700">
<svg xmlns="http://www.w3.org/2000/svg" class="inline-block w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z" />
</svg>
@lang('Leave a rating')
</button>
@endif
@endauth
@if($resource->updates->first())
<button wire:click="download" class="px-2 py-1 text-green-100 transition-colors duration-150 bg-green-600 rounded-md focus:shadow-outline hover:bg-green-700">
<svg xmlns="http://www.w3.org/2000/svg" class="inline-block w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
Expand All @@ -29,35 +31,37 @@
@lang('Download')
</button>
@endif
@if(auth()->user()->id == $resource->user_id)
<div x-data="{ dropdownOpen: false }" class="" x-cloak>
<button @click="dropdownOpen = !dropdownOpen" class="px-2 py-1 text-gray-100 transition-colors duration-150 bg-gray-600 rounded-md focus:shadow-outline hover:bg-gray-700">
<svg xmlns="http://www.w3.org/2000/svg" class="inline-block w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z" />
</svg>
</button>
<div x-show="dropdownOpen" @click.away="dropdownOpen = false" class="absolute z-10 w-48 py-2 mt-2 bg-white border border-gray-200 rounded-md shadow-md dark:bg-gray-900 dark:border-gray-800">
<button onclick="Livewire.emit('openModal', 'resource.update-create', {{ json_encode(['resource_uuid' => $resource->uuid]) }})" class="block w-full px-4 py-2 text-sm text-left text-gray-700 dark:text-gray-300 hover:bg-green-700 hover:text-white">
@auth
@if(auth()->user()->id == $resource->user_id)
<div x-data="{ dropdownOpen: false }" class="" x-cloak>
<button @click="dropdownOpen = !dropdownOpen" class="px-2 py-1 text-gray-100 transition-colors duration-150 bg-gray-600 rounded-md focus:shadow-outline hover:bg-gray-700">
<svg xmlns="http://www.w3.org/2000/svg" class="inline-block w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 13h6m-3-3v6m5 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z" />
</svg>
@lang('Post an update')
</button>
<button onclick="Livewire.emit('openModal', 'resource.resource-form', {{ json_encode(['resource' => $resource->id]) }})" class="block w-full px-4 py-2 text-sm text-left text-gray-700 dark:text-gray-300 hover:bg-green-700 hover:text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="inline-block w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
</svg>
@lang('Edit')
</button>
<button onclick="Livewire.emit('openModal', 'resource.resource-delete', {{ json_encode(['resource' => $resource->id]) }})" class="block w-full px-4 py-2 text-sm text-left text-gray-700 dark:text-gray-300 hover:bg-green-700 hover:text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="inline-block w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
@lang('Delete')
</button>
<div x-show="dropdownOpen" @click.away="dropdownOpen = false" class="absolute z-10 w-48 py-2 mt-2 bg-white border border-gray-200 rounded-md shadow-md dark:bg-gray-900 dark:border-gray-800">
<button onclick="Livewire.emit('openModal', 'resource.update-create', {{ json_encode(['resource_uuid' => $resource->uuid]) }})" class="block w-full px-4 py-2 text-sm text-left text-gray-700 dark:text-gray-300 hover:bg-green-700 hover:text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="inline-block w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 13h6m-3-3v6m5 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
</svg>
@lang('Post an update')
</button>
<button onclick="Livewire.emit('openModal', 'resource.resource-form', {{ json_encode(['resource' => $resource->id]) }})" class="block w-full px-4 py-2 text-sm text-left text-gray-700 dark:text-gray-300 hover:bg-green-700 hover:text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="inline-block w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
</svg>
@lang('Edit')
</button>
<button onclick="Livewire.emit('openModal', 'resource.resource-delete', {{ json_encode(['resource' => $resource->id]) }})" class="block w-full px-4 py-2 text-sm text-left text-gray-700 dark:text-gray-300 hover:bg-green-700 hover:text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="inline-block w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
@lang('Delete')
</button>
</div>
</div>
</div>
@endif
@endif
@endauth
</div>
</div>
<div class="w-full p-4 bg-white rounded-lg shadow-lg dark:bg-gray-900 dark:shadow-gray-700">
Expand All @@ -72,7 +76,7 @@
<div class="p-4 bg-gray-100 rounded dark:bg-gray-800">
<div class="flex flex-row justify-between">
<span>@lang('Author'):</span>
<span><a href="{{ route('member.show', $resource->user) }}" class="text-green-400 hover:text-green-500 hover:underline">{{ $resource->user->username }}</a></span>
<span><a href="{{ route('member.show', $resource->user->username) }}" class="text-green-400 hover:text-green-500 hover:underline">{{ $resource->user->username }}</a></span>
</div>
<div class="flex flex-row justify-between">
<span>@lang('Rating'):</span>
Expand Down
8 changes: 4 additions & 4 deletions resources/views/livewire/review/review-list.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 grid-flow-cols">

<div class="col-span-1 p-4 overflow-hidden text-gray-700 border border-gray-200 rounded-lg shadow-lg sm:col-span-2 md:col-span-3 lg:col-span-4 bg-gray-50 dark:bg-gray-900 dark:border-gray-700 dark:text-gray-100">
<div class="my-1 text-lg font-bold">@lang('Overall Game Reviews')</div>
<div class="flex items-center"><x-review-stars :stars="$averageRating" :size="8" /><span class="ml-2">{{ round($averageRating, 2) }} ({{ $numberOfReviews }})</span></div>
Expand All @@ -11,7 +11,7 @@
<a href="{{ route('member.show', $review->author) }}">
<img alt="{{ $review->author->username }}" src="{{ $review->author->profile_photo_url ?? asset('img/TreeLogoSmall.png') }}" class="inline-flex object-cover w-8 h-8 mx-auto mr-2 rounded-full"/>
</a>
<a href="{{ route('member.show', $review->author) }}" class="mr-2 text-green-400 hover:text-green-500 hover:underline">{{ $review->author->username }}</a>
<a href="{{ route('member.show', $review->author->username) }}" class="mr-2 text-green-400 hover:text-green-500 hover:underline">{{ $review->author->username }}</a>
</div>
<div>
<x-review-stars :stars="$review->rating" :size="6" />
Expand All @@ -22,5 +22,5 @@
</div>
</div>
@endforeach
</div>

</div>
Loading
Loading