Skip to content

Commit e98d942

Browse files
committed
Added Theme Credit page
A short page that displays the contents of a Theme's readme.md. Currently, a link to this page is only visible in the HTML meta tags if viewed as page source. This page can always be accessed on your.domain.com/theme/@littlelink_name. (For example your.domain.com/theme/@admin)
1 parent 1fd7680 commit e98d942

File tree

4 files changed

+82
-1
lines changed

4 files changed

+82
-1
lines changed

app/Http/Controllers/UserController.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,4 +376,23 @@ public function editProfile(request $request)
376376
}
377377
return back();
378378
}
379+
380+
//Show user theme credit page
381+
public function theme(request $request)
382+
{
383+
$littlelink_name = $request->littlelink;
384+
$id = User::select('id')->where('littlelink_name', $littlelink_name)->value('id');
385+
386+
if (empty($id)) {
387+
return abort(404);
388+
}
389+
390+
$userinfo = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->where('id', $id)->first();
391+
$information = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->where('id', $id)->get();
392+
393+
$links = DB::table('links')->join('buttons', 'buttons.id', '=', 'links.button_id')->select('links.link', 'links.id', 'links.button_id', 'links.title', 'links.custom_css', 'links.custom_icon', 'buttons.name')->where('user_id', $id)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->get();
394+
395+
return view('components/theme', ['userinfo' => $userinfo, 'information' => $information, 'links' => $links, 'littlelink_name' => $littlelink_name]);
396+
}
397+
379398
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@extends('layouts.updater')
2+
@foreach($information as $info)
3+
4+
@Push('updater-head')
5+
<title>{{ $userinfo->name }} 🌇 {{ ucfirst(trans($info->theme)) }} </title>
6+
<meta name="robots" content="noindex">
7+
<style>
8+
.container-theme {
9+
position: absolute;
10+
left: 50%;
11+
top: 50%;
12+
-webkit-transform: translate(-50%, -50%);
13+
transform: translate(-50%, -50%);
14+
}
15+
16+
.container-theme pre {
17+
display: inline-block;
18+
text-align: left;
19+
}
20+
</style>
21+
@endpush
22+
23+
@Push('updater-body')
24+
25+
26+
@if(file_exists(base_path("themes/$info->theme/readme.md")))
27+
28+
29+
<div class="container-theme">
30+
<h1>Theme: {{ ucfirst(trans($info->theme)) }}</h1>
31+
<?php
32+
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
33+
34+
$text = file_get_contents('themes/' . $info->theme . '/readme.md');
35+
36+
if(preg_match($reg_exUrl, $text, $url)) {
37+
38+
$txtspc = '<pre>' . preg_replace($reg_exUrl, "<a href=" . $url[0] . ">$url[0]</a> ", $text) . '</pre>';
39+
echo preg_replace('/[ \t]+/', ' ', preg_replace('/\s\S*$^\s\S*/m', "\n", $txtspc));
40+
41+
} else {
42+
43+
echo '<pre>' . preg_replace('/[ \t]+/', ' ', preg_replace('/\s\S*$^\s\S*/m', "\n", $txtspc)) . '</pre>';
44+
45+
}
46+
?>
47+
</div>
48+
49+
@else
50+
<div class="container"><p>File not found</p></div>
51+
@endif
52+
53+
54+
@endforeach
55+
@endpush

resources/views/littlelink.blade.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,16 @@
5353

5454
@foreach($information as $info)
5555
@if($info->theme != '' and $info->theme != 'default')
56+
57+
<!-- LittleLink Custom Theme: "{{$info->theme}}" -->
58+
59+
<!-- Theme details: -->
60+
<meta name="designer" href="{{ url('') . "/theme/@" . $littlelink_name}}" content="{{ url('') . "/theme/@" . $littlelink_name}}">
61+
5662
<link rel="stylesheet" href="themes/{{$info->theme}}/share.button.css">
5763
<link rel="stylesheet" href="themes/{{$info->theme}}/brands.css">
5864
<link rel="stylesheet" href="themes/{{$info->theme}}/skeleton-auto.css">
59-
@if(file_exists(base_path("themes/{{$info->theme}}/skeleton-auto.css" )))
65+
@if(file_exists(asset('themes/' . $info->theme . '/animations.css')))
6066
<link rel="stylesheet" href="<?php echo asset('themes/' . $info->theme . '/animations.css') ?>">
6167
@else
6268
<link rel="stylesheet" href="{{ asset('littlelink/css/animations.css') }}">

routes/web.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
Route::get('/+{littlelink}', [UserController::class, 'littlelink'])->name('littlelink');
4141
Route::get('/@{littlelink}', [UserController::class, 'littlelink'])->name('littlelink');
4242
Route::get('/pages/{name}', [AdminController::class, 'pages'])->name('pages');
43+
Route::get('/theme/@{littlelink}', [UserController::class, 'theme'])->name('theme');
4344

4445
//User route
4546
Route::group([

0 commit comments

Comments
 (0)