Merge pull request 'Last before first production' (#14) from dev into master
Reviewed-on: #14
This commit is contained in:
56
app/Http/Controllers/ShortLinkController.php
Normal file
56
app/Http/Controllers/ShortLinkController.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Entry;
|
||||||
|
use App\Models\News;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class ShortLinkController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
private const array LETTER_TO_TYPE = [
|
||||||
|
't' => 'translations',
|
||||||
|
'r' => 'romhacks',
|
||||||
|
'h' => 'homebrew',
|
||||||
|
'u' => 'utilities',
|
||||||
|
'd' => 'documents',
|
||||||
|
'l' => 'lua-scripts',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function legacy( int $wpId )
|
||||||
|
{
|
||||||
|
$log = DB::table('migrations_logs')
|
||||||
|
->where('source_system')
|
||||||
|
->whereIn('source_table', ['wp_posts', 'wp_posts__news'] )
|
||||||
|
->where('source_id', $wpId)
|
||||||
|
->first(['target_table', 'target_id']);
|
||||||
|
|
||||||
|
abort_unless((bool)$log, 404);
|
||||||
|
|
||||||
|
if( $log->target_table == 'entries' ){
|
||||||
|
$entry = Entry::findOrFail($log->target_id);
|
||||||
|
return redirect()->route('entries.show', ['section' => $entry->type, 'entry' => $entry], 301 );
|
||||||
|
} else if( $log->target_table == 'news' ){
|
||||||
|
$news = News::findOrFail($log->target_id);
|
||||||
|
return redirect()->route('news.show', ['news' => $news], 301);
|
||||||
|
}
|
||||||
|
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function redirect( string $letter, int $id )
|
||||||
|
{
|
||||||
|
if( $letter === 'n' ){
|
||||||
|
$news = News::findOrFail($id);
|
||||||
|
return redirect()->route('news.show', ['news' => $news], 301 );
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = self::LETTER_TO_TYPE[$letter] ?? abort(404);
|
||||||
|
$entry = Entry::where('id', $id)->where('type', $type)->firstOrFail();
|
||||||
|
|
||||||
|
return redirect()->route('entries.show', ['section' => $entry->type, 'entry' => $entry], 301 );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -52,7 +52,7 @@ return [
|
|||||||
[
|
[
|
||||||
'name' => 'Discord',
|
'name' => 'Discord',
|
||||||
'icon' => 'messages-square',
|
'icon' => 'messages-square',
|
||||||
'route' => 'home'
|
'custom_route' => 'https://discord.gg/5CKzeWmZZU'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'Members',
|
'name' => 'Members',
|
||||||
@@ -80,15 +80,21 @@ return [
|
|||||||
'pages' => [
|
'pages' => [
|
||||||
'name' => 'Pages',
|
'name' => 'Pages',
|
||||||
'items' => [
|
'items' => [
|
||||||
|
[
|
||||||
|
'name' => 'Support us',
|
||||||
|
'icon' => 'coffee',
|
||||||
|
'custom_route' => 'https://ko-fi.com/romhackplaza',
|
||||||
|
'color' => 'var(--rhpz-orange)'
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'name' => 'Learn Romhacking',
|
'name' => 'Learn Romhacking',
|
||||||
'icon' => 'graduation-cap',
|
'icon' => 'graduation-cap',
|
||||||
'route' => 'home'
|
'xf_route' => 'help/learn-romhacking'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'About',
|
'name' => 'About',
|
||||||
'icon' => 'info',
|
'icon' => 'info',
|
||||||
'route' => 'home'
|
'xf_route' => 'help/about'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'Contact Us',
|
'name' => 'Contact Us',
|
||||||
@@ -96,9 +102,9 @@ return [
|
|||||||
'xf_route' => 'misc/contact'
|
'xf_route' => 'misc/contact'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'Legal pages',
|
'name' => 'Help & Legal pages',
|
||||||
'icon' => 'scale',
|
'icon' => 'scale',
|
||||||
'route' => 'home'
|
'xf_route' => 'help'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|||||||
14
extra.less
14
extra.less
@@ -71,6 +71,9 @@ ul {
|
|||||||
/* Menu settings */
|
/* Menu settings */
|
||||||
--menu-size: 260px;
|
--menu-size: 260px;
|
||||||
--menu-user-avatar-bg: #555;
|
--menu-user-avatar-bg: #555;
|
||||||
|
|
||||||
|
/* Gap */
|
||||||
|
--gap: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.\$light-mode {
|
.\$light-mode {
|
||||||
@@ -132,6 +135,7 @@ ul {
|
|||||||
background-color: var(--bg2);
|
background-color: var(--bg2);
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
display: flex;
|
display: flex;
|
||||||
|
min-width: 0;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
transition: transform 0.2s, border-color 0.2s;
|
transition: transform 0.2s, border-color 0.2s;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -144,6 +148,7 @@ ul {
|
|||||||
.\$entry-cover-wrapper {
|
.\$entry-cover-wrapper {
|
||||||
position: relative;
|
position: relative;
|
||||||
aspect-ratio: 4/3;
|
aspect-ratio: 4/3;
|
||||||
|
min-width: 0;
|
||||||
background-color: var(--bg);
|
background-color: var(--bg);
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid var(--border);
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -183,6 +188,7 @@ ul {
|
|||||||
font-size: 1.1rem;
|
font-size: 1.1rem;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
line-height: 1.3;
|
line-height: 1.3;
|
||||||
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
.\$entry-card-author {
|
.\$entry-card-author {
|
||||||
@@ -5277,6 +5283,14 @@ ul {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.\$menu-user-info {
|
.\$menu-user-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -115,6 +115,14 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.menu-user-info {
|
.menu-user-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<div class="comment-block">
|
<div class="comment-block">
|
||||||
<x-xen-foro-avatar :user="$review->user_id" />
|
<div class="comment-avatar">
|
||||||
|
<x-xen-foro-avatar :user="$review->user_id" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="comment-content">
|
<div class="comment-content">
|
||||||
<div class="comment-meta">
|
<div class="comment-meta">
|
||||||
|
|||||||
@@ -42,7 +42,9 @@
|
|||||||
@continue
|
@continue
|
||||||
@else
|
@else
|
||||||
<div class="comment-block">
|
<div class="comment-block">
|
||||||
|
<div class="comment-avatar">
|
||||||
<x-xen-foro-avatar :user="$comment['user_id']" />
|
<x-xen-foro-avatar :user="$comment['user_id']" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="comment-content">
|
<div class="comment-content">
|
||||||
<div class="comment-meta">
|
<div class="comment-meta">
|
||||||
|
|||||||
@@ -16,8 +16,11 @@
|
|||||||
|
|
||||||
@foreach( $menu['items'] as $item )
|
@foreach( $menu['items'] as $item )
|
||||||
@if( !isset( $item['requires_auth'] ) || $item['requires_auth'] === true && $VISITOR->loggedIn() )
|
@if( !isset( $item['requires_auth'] ) || $item['requires_auth'] === true && $VISITOR->loggedIn() )
|
||||||
<a href="{{ isset($item['xf_route']) ? xfRoute($item['xf_route']) : route($item['route']) }}"
|
<a href="{{ isset($item['xf_route']) ? xfRoute($item['xf_route']) : $item['custom_route'] ?? route($item['route']) }}"
|
||||||
@class(['menu-item', 'active' => request()->routeIs( $item['route'] ?? '' )]) >
|
@class(['menu-item', 'active' => request()->routeIs( $item['route'] ?? '' )])
|
||||||
|
style="{{ isset( $item['color'] ) ? 'color:' . $item['color'] . ';' : '' }}"
|
||||||
|
{{ isset( $item['custom_route'] ) ? 'target="_blank"' : '' }}
|
||||||
|
>
|
||||||
<i data-lucide="{{ $item['icon'] }}"></i><span>{{ $item['name'] }}</span>
|
<i data-lucide="{{ $item['icon'] }}"></i><span>{{ $item['name'] }}</span>
|
||||||
</a>
|
</a>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<i data-lucide="x-circle" size="12"></i>
|
<i data-lucide="x-circle" size="12"></i>
|
||||||
Rejected
|
Rejected
|
||||||
@php
|
@php
|
||||||
$daysLeft = intval(7 - now()->diffInDays($entry->rejected_at));
|
$daysLeft = 7 + intval(now()->diffInDays($entry->rejected_at));
|
||||||
@endphp
|
@endphp
|
||||||
@if($daysLeft > 0)
|
@if($daysLeft > 0)
|
||||||
- deleted in {{ $daysLeft }} days
|
- deleted in {{ $daysLeft }} days
|
||||||
|
|||||||
@@ -9,3 +9,4 @@ Artisan::command('inspire', function () {
|
|||||||
|
|
||||||
Schedule::command('entries:purge-rejected')->daily();
|
Schedule::command('entries:purge-rejected')->daily();
|
||||||
Schedule::command('entries:purge-featured')->daily();
|
Schedule::command('entries:purge-featured')->daily();
|
||||||
|
Schedule::command('sitemap:generate')->daily();
|
||||||
|
|||||||
@@ -132,3 +132,9 @@ Route::name('redirect.')->controller(\App\Http\Controllers\RedirectController::c
|
|||||||
Route::get('/entry/report_redirect', 'entryReportRedirect' )->name('entry_report');
|
Route::get('/entry/report_redirect', 'entryReportRedirect' )->name('entry_report');
|
||||||
Route::get('/news/report_redirect', 'newsReportRedirect' )->name('news_report');
|
Route::get('/news/report_redirect', 'newsReportRedirect' )->name('news_report');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ShortLinkController
|
||||||
|
Route::domain('rhpz.org')->name('shorturl.')->controller(\App\Http\Controllers\ShortLinkController::class)->group(function () {
|
||||||
|
Route::get('/{id}', 'legacy' )->where('id', '[0-9]+')->name('legacy');
|
||||||
|
Route::get('/{letter}/{id}', 'redirect' )->where(['letter' => '[a-z]', 'id' => '[0-9]+'])->name('redirect');
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user