Added option to set profile as homepage

The homepage can now be changed to a user's profile page with the option "HOME_URL" in the config (found on the Admin Panel under Admin>Config).

This commit is a bit janky, I wanted to change the homepage with a setting saved in the database, but I couldn't finish this in time, so this has to do for now.

An if statement in the web routes PHP checks if the new setting is present in the config and changes the homepage to the listed LittleLink Custom name. If the homage  is changed, the page previously set as the homepage where users can register and or login can now be found at .../home.
This commit is contained in:
Julian Prieber 2022-03-24 14:44:33 +01:00
parent 4b9d39ce66
commit 89d54492fd
5 changed files with 40 additions and 2 deletions

5
.env
View File

@ -8,6 +8,11 @@ NOTIFY_UPDATES=true
DISPLAY_FOOTER=true DISPLAY_FOOTER=true
DISPLAY_CREDIT=true DISPLAY_CREDIT=true
#Home URL=Changes if a user profile should be displayed as the homepage
#=Leave empty to use the default homepage. To set your profile as the homepage, enter a LittleLink name. You can find this on the user panel under the page setting, the name is what comes after the '@'.
#=(e.g. 'admin' without the '@')
HOME_URL=
#App Settings=Changes settings regarding your LittleLink Custom installation. You probably only want to change the App Name setting. #App Settings=Changes settings regarding your LittleLink Custom installation. You probably only want to change the App Name setting.
#=App_Name changes the displayed name for the App in the title, for example. #=App_Name changes the displayed name for the App in the title, for example.
APP_NAME="LittleLink Custom" APP_NAME="LittleLink Custom"

View File

@ -48,6 +48,24 @@ class UserController extends Controller
return view('littlelink', ['userinfo' => $userinfo, 'information' => $information, 'links' => $links, 'littlelink_name' => $littlelink_name]); return view('littlelink', ['userinfo' => $userinfo, 'information' => $information, 'links' => $links, 'littlelink_name' => $littlelink_name]);
} }
//Show littlelink page as home page if set in config
public function littlelinkhome(request $request)
{
$littlelink_name = env('HOME_URL');
$id = User::select('id')->where('littlelink_name', $littlelink_name)->value('id');
if (empty($id)) {
return abort(404);
}
$userinfo = User::select('name', 'littlelink_name', 'littlelink_description')->where('id', $id)->first();
$information = User::select('name', 'littlelink_name', 'littlelink_description')->where('id', $id)->get();
$links = DB::table('links')->join('buttons', 'buttons.id', '=', 'links.button_id')->select('links.link', 'links.id', 'links.button_id', 'links.title', 'buttons.name')->where('user_id', $id)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->get();
return view('littlelink', ['userinfo' => $userinfo, 'information' => $information, 'links' => $links, 'littlelink_name' => $littlelink_name]);
}
//Show buttons for add link //Show buttons for add link
public function showButtons() public function showButtons()
{ {

View File

@ -19,7 +19,10 @@ return [
'currentEnv' => 'Current .env', 'currentEnv' => 'Current .env',
], ],
'currentEnv' => [ 'currentEnv' => [
'title' => 'Current .env file Content', 'title' => '
To be able to save values you see here PHP needs to be able to write to your current directory.
Strings with a # in front of them are comments and wont affect anything.
',
'tableTitles' => [ 'tableTitles' => [
'key' => 'Key', 'key' => 'Key',
'value' => 'Value', 'value' => 'Value',

View File

@ -17,6 +17,14 @@ use App\Http\Controllers\UserController;
| |
*/ */
//Changes the homepage to a LittleLink Custom profile if set in the config
if(env('HOME_URL') != '') {
Route::get('/', [UserController::class, 'littlelinkhome'])->name('littlelink');
Route::get('/home', [App\Http\Controllers\HomeController::class, 'home'])->name('home');
} else {
Route::get('/', [App\Http\Controllers\HomeController::class, 'home'])->name('home');
}
//Redirect if no page URL is set //Redirect if no page URL is set
Route::get('/@', function () { Route::get('/@', function () {
return redirect('/studio/no_page_name'); return redirect('/studio/no_page_name');
@ -27,7 +35,6 @@ Route::get('/going/{id?}/{link?}', [UserController::class, 'clickNumber'])->wher
Route::get('/+{littlelink}', [UserController::class, 'littlelink'])->name('littlelink'); Route::get('/+{littlelink}', [UserController::class, 'littlelink'])->name('littlelink');
Route::get('/@{littlelink}', [UserController::class, 'littlelink'])->name('littlelink'); Route::get('/@{littlelink}', [UserController::class, 'littlelink'])->name('littlelink');
Route::get('/pages/{name}', [AdminController::class, 'pages'])->name('pages'); Route::get('/pages/{name}', [AdminController::class, 'pages'])->name('pages');
Route::get('/', [App\Http\Controllers\HomeController::class, 'home'])->name('home');
//User route //User route
Route::group([ Route::group([

View File

@ -8,6 +8,11 @@ NOTIFY_UPDATES=true
DISPLAY_FOOTER=true DISPLAY_FOOTER=true
DISPLAY_CREDIT=true DISPLAY_CREDIT=true
#Home URL=Changes if a user profile should be displayed as the homepage
#=Leave empty to use the default homepage. To set your profile as the homepage, enter a LittleLink name. You can find this on the user panel under the page setting, the name is what comes after the '@'.
#=(e.g. 'admin' without the '@')
HOME_URL=
#App Settings=Changes settings regarding your LittleLink Custom installation. You probably only want to change the App Name setting. #App Settings=Changes settings regarding your LittleLink Custom installation. You probably only want to change the App Name setting.
#=App_Name changes the displayed name for the App in the title, for example. #=App_Name changes the displayed name for the App in the title, for example.
APP_NAME="LittleLink Custom" APP_NAME="LittleLink Custom"