Skip to content

Commit

Permalink
many updates ooh ow oof i hope it doesnt break :3
Browse files Browse the repository at this point in the history
  • Loading branch information
0x1DEA committed Nov 23, 2023
1 parent 3f85f6b commit d7fe443
Show file tree
Hide file tree
Showing 21 changed files with 418 additions and 156 deletions.
2 changes: 1 addition & 1 deletion app/Actions/Statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Exception;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;

class Statistics
Expand All @@ -19,6 +18,7 @@ public static function all(): array
'reviews' => self::count(\App\Models\Content\Review::class),
'videos' => self::count(\App\Models\Content\Video::class),
'playlists' => self::count(\App\Models\Content\Playlist::class),
'macros' => self::count(\App\Models\Game\LevelReplay::class),
//'nongs' => self::count(\App\Models\Content\Song::class),
];
}
Expand Down
25 changes: 16 additions & 9 deletions app/Http/Controllers/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Models\Article;
use Illuminate\Contracts\Support\Responsable;
use Illuminate\Http\Request;

class ArticleController extends Controller
Expand All @@ -12,31 +13,37 @@ class ArticleController extends Controller
*/
public function index()
{
return page('Articles/Show');
return page('News', [
'articles' => Article::query()->latest()->paginate()
]);
}

/**
* Show the form for creating a new resource.
*/
public function create()
public function create(): Responsable
{
//
return page('Articles/Create')
->meta('Create Article', 'Submit your hot takes');
}

/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//

}

/**
* Display the specified resource.
*/
public function show(Article $article)
public function show(Article $article): Responsable
{
//
return page('Articles/Show', [
'article' => $article->load(['post']),
'articles' => Article::query()
->whereNot('id', '=', $article->id)
->limit(3)
->get()
])->meta($article->title, $article->blurb ?? 'Read articles and news on Hyperbolus');
}

/**
Expand Down
11 changes: 8 additions & 3 deletions app/Http/Controllers/Content/ThreadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Models\Content\Thread;
use App\Models\System\Subscription;
use App\Models\System\User;
use Illuminate\Contracts\Support\Responsable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Http\RedirectResponse;
Expand All @@ -18,11 +19,15 @@

class ThreadController extends Controller
{
public function create(): Response
public function create(): Responsable
{
return Inertia::render('Threads/Create', [
return page('Threads/Create', [
'forum_id' => \request('fid') ?? null,
]);
])
->meta('Create Thread', 'Start a discussion')
->breadcrumbs([
crumb('Forums', route('forums.index'))
]);
}

/**
Expand Down
54 changes: 52 additions & 2 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,60 @@

namespace App\Http\Controllers;

use App\Models\Article;
use App\Models\Content\Post;
use App\Models\Content\Review;
use App\Models\Content\Video;
use App\Models\System\Setting;
use App\Models\System\User;
use Illuminate\Contracts\Support\Responsable;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
use Inertia\Inertia;
use Inertia\Response;

class HomeController extends Controller
{
public function home(): Response
public function home()
{
return Inertia::render('Home');
$fpa = Setting::query()->where('key', '=', 'frontpage_article')->first();

if ($fpa) {
$q = Article::query()->find($fpa);
} else {
$q = Article::query()->latest()->first();
}

return page('Home', [
'frontpage_article' => $q,
'recent_articles' => Article::query()
->latest()
->whereNot('id', '=', $q->id ?? 0)
->limit(2)
->get(),
'recent_posts' => Post::query()
->latest()
->with(['author', 'thread', 'thread.author'])
->limit(5)
->get(),
'recent_reviews' => Review::query()
->latest()
->with(['author', 'level'])
->limit(5)
->get(),
'recent_videos' => Video::query()
->latest()
->limit(6)
->get(),
'newest_user' => User::query()->latest()->first()
])->meta('Home', 'Hyperbolus, your home for Geometry Dash');
}

public function news(): Responsable
{
return page('News', [
'frontpage_article' => [],
])->meta('News', 'The latest news in the Geometry Dash community');
}

public function client(): Response
Expand All @@ -24,6 +68,12 @@ public function forge(): Response
return Inertia::render('Forge');
}

public function about(): Responsable
{
return page('About')
->meta('About Hyperbolus', 'Read all about our coooool fucking backstory');
}

public function levels(): Response
{
$featured = Cache::get('levels.featured');
Expand Down
39 changes: 39 additions & 0 deletions app/Models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,52 @@

namespace App\Models;

use App\Models\Content\Post;
use App\Models\Content\Tag;
use App\Models\System\User;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphToMany;

/**
* @mixin IdeHelperArticle
*/
class Article extends Model
{
use HasFactory;
use Sluggable;

protected $with = [
'author'
];

public function sluggable(): array
{
return [
'slug' => [
'source' => 'title',
],
];
}

public function getRouteKeyName(): string
{
return 'slug';
}

public function post(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Post::class);
}

public function author(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(User::class);
}

public function tags(): MorphToMany
{
return $this->morphToMany(Tag::class, 'taggable')->withPivot(['verified', 'score'])->orderByPivot('verified', 'DESC')->orderByPivot('score', 'DESC')->withTimestamps();
}
}
2 changes: 1 addition & 1 deletion config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'strict' => false,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ public function up(): void
{
Schema::create('articles', function (Blueprint $table) {
$table->id();
$table->foreignId('author_id');
$table->string('title');
$table->string('slug');
$table->foreignId('post_id');
$table->string('blurb')->nullable();
$table->string('tagline')->nullable();
$table->string('banner_url')->nullable();
$table->timestamps();
});
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"pako": "^2.1.0",
"pinia": "^2.1.6",
"pretty-bytes": "^6.1.1",
"reading-time": "^1.5.0",
"resumablejs": "^1.1.0",
"tippy.js": "^6.3.7"
}
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added resources/images/Article22UpdateBanner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions resources/js/Components/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import route from "ziggy-js";
<div class="x items-center justify-between lg:max-w-5xl xl:max-w-6xl 2xl:max-w-7xl w-full text-ui-600">
<span class="text-sm">Hyperbolus is not affiliated with RobTopGames AB or Geometry Dash</span>
<div class="space-x-4">
<Link :href="route('about')">About</Link>
<Link :href="route('legal.terms')">Terms of Service</Link>
<Link :href="route('legal.privacy')">Privacy</Link>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Components/Post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const sendLike = () => {
</svg>
<span>{{ post.reactions.length }}</span>
</div>
<Link class="text-sm" v-for="(reaction, index) in post.reactions" :href="route('users.show', reaction.reacter.id)" :title="new Date(reaction.created_at).toLocaleString([], {day: '2-digit', month: '2-digit', year:'2-digit', hour: '2-digit', minute: '2-digit'})"><Username :user="reaction.reacter"/>{{ index < post.reactions.length - 1 ? ',' : '' }}</Link>
<Username class="!text-sm" v-for="(reaction, index) in post.reactions" :user="reaction.reacter"/>
</div>
</div>
</template>
44 changes: 28 additions & 16 deletions resources/js/Components/SiteNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SearchBar from "@/Components/SearchBar.vue";
import SiteLogo from "@/Components/SiteLogo.vue";
import {useSettingsStore} from "@/stores/settings.ts";
import ControlBar from "@/Components/ControlBar.vue";
import Icon from "@/Components/Icon.vue";
const mobileNavOpen = ref(false);
const navigation = useSettingsStore().settings['navigation'] ? useSettingsStore().settings['navigation']['value'] : [];
Expand All @@ -21,28 +22,39 @@ const navigation = useSettingsStore().settings['navigation'] ? useSettingsStore(

</div>
<div class="x px-2 gap-4 justify-between lg:max-w-5xl xl:max-w-6xl 2xl:max-w-7xl w-full">
<div class="x items-center space-x-4">
<div class="x items-center space-x-2">
<SiteLogo class="py-4"/>
<div class="hidden md:flex group/nav h-full items-center text-sm">
<div class="hidden md:flex z-10 transition-opacity left-0 opacity-0 group-hover/nav:opacity-100 absolute w-full h-48 pointer-events-none top-full bg-gradient-to-b from-ui-900 via-ui-900/75 to-ui-900/0 -border-b-2 -border-ui-600">

</div>
<div class="hidden md:flex h-full items-center text-sm">
<span v-if="navigation.length === 0" class="text-red-500">No key 'navigation' defined in site settings</span>
<template v-for="(node, key) in navigation">
<Tooltip v-if="node.hasOwnProperty('children')" container-class="top-full" class="h-full mr-4 x items-center" :caret="false" :decoration="false">
<div class="x items-center">
<Link :href="route(node.route)" class="hover:text-ui-500 transition-colors">{{ node.name }}</Link>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-5 h-5">
<path fill-rule="evenodd" d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z" clip-rule="evenodd" />
</svg>
</div>
<Dropdown v-if="node.hasOwnProperty('children')" align="left" container-classes="shadow-xl w-[32rem] top-[80%]" class="h-full x items-center">
<template #trigger>
<div class="x items-center hover:bg-ui-950 px-3 py-2 rounded">
<Icon class="w-4 w-4" :name="node.icon" size="20" type="solid"/>
<div class="ml-2 transition-colors">{{ node.name }}</div>
</div>
</template>
<template #content>
<div class="y -divide-y -divide-ui-700 min-w-[8rem] -ml-2 -mt-4">
<Link v-for="(child, key) in node.children" :key="key" class="group/nav-link px-2 py-1 hover:hover:bg-ui-800/75 rounded" :href="route(child.route)"><span class="bg-transparent group-hover/nav-link:bg-green-400 rounded-full px-[0.15rem] mr-2"></span> {{ child.name }}</Link>
<div class="y">
<div class="p-2" :class="node.type === 'list' ? 'y space-y-2' : 'grid grid-cols-2 gap-2'">
<Link :href="route(child.route)" v-for="(child, key) in node.children" :key="key" class="block relative group/nav-link">
<div class="x space-x-3 h-full items-center py-2 px-4">
<Icon class="w-6 w-6 group-hover/nav-link:[filter:drop-shadow(0_0_3px_rgb(103_232_249))]" :name="child.icon" size="20" type="solid"/>
<div class="y">
<h3 class="font-bold text-emerald-400">{{ child.name }}</h3>
<h4 class="text-xs">{{ child.description ?? ':3' }}</h4>
</div>
</div>
<div class="absolute inset-0 group-hover/nav-link:[filter:drop-shadow(0_0_3px_rgb(103_232_249))] border border-transparent rounded hover:border-cyan-200"></div>
</Link>
</div>
</div>
</template>
</Tooltip>
<Link v-else :href="route(node.route)" class="hover:text-ui-500 transition-colors mr-4">{{ node.name }}</Link>
</Dropdown>
<Link v-else :href="route(node.route)" class="x block hover:bg-ui-950 px-3 py-2 rounded transition-colors">
<Icon class="w-4 w-4" :name="node.icon" size="20" type="solid"/>
<span class="ml-1">{{ node.name }}</span>
</Link>
</template>
</div>
</div>
Expand Down
Loading

0 comments on commit d7fe443

Please sign in to comment.