Skip to content

Commit

Permalink
Added Theme support to main branch
Browse files Browse the repository at this point in the history
Added Theme support to main branch
  • Loading branch information
JulianPrieber authored May 20, 2022
2 parents 6c04067 + 26275c1 commit a20ae1d
Show file tree
Hide file tree
Showing 22 changed files with 1,982 additions and 225 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ALLOW_USER_HTML=false
#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="LittleLink Custom"
APP_KEY=base64:YUFWn5swwXryVBujHaOdiPqNvLEsC7RZs8df3rb/DJs=
APP_KEY=
#=The APP_URL should be left empty under most circumstances. This setting is not required for LittleLink Custom, and you should only change this if required for your setup.
APP_URL=

Expand Down
51 changes: 46 additions & 5 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

use Auth;
use DB;
use ZipArchive;

use App\Models\User;
use App\Models\Button;
use App\Models\Link;


//Function tests if string starts with certain string (used to test for illegal strings)
function stringStartsWith($haystack,$needle,$case=true) {
if ($case){
Expand Down Expand Up @@ -56,8 +58,8 @@ public function littlelink(request $request)
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();
$userinfo = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->where('id', $id)->first();
$information = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->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', 'links.custom_css', 'links.custom_icon', 'buttons.name')->where('user_id', $id)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->get();

Expand All @@ -74,8 +76,8 @@ public function littlelinkhome(request $request)
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();
$userinfo = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->where('id', $id)->first();
$information = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->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', 'links.custom_css', 'links.custom_icon', 'buttons.name')->where('user_id', $id)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->get();

Expand Down Expand Up @@ -301,8 +303,47 @@ public function editPage(request $request)
return Redirect('/studio/page');
}

//Show custom theme
public function showTheme(request $request)
{
$userId = Auth::user()->id;

$data['pages'] = User::where('id', $userId)->select('littlelink_name', 'theme')->get();

return view('/studio/theme', $data);
}

//Save custom theme
public function editTheme(request $request)
{
$request->validate([
'zip' => 'sometimes|mimes:zip',
]);

$userId = Auth::user()->id;

$zipfile = $request->file('zip');

$theme = $request->theme;

User::where('id', $userId)->update(['theme' => $theme]);

if(!empty($zipfile)){

$zipfile->move(base_path('/themes'), "temp.zip");

$zip = new ZipArchive;
$zip->open(base_path() . '/themes/temp.zip');
$zip->extractTo(base_path() . '/themes');
$zip->close();
unlink(base_path() . '/themes/temp.zip');
}

return Redirect('/studio/theme');
}

//Show user (name, email, password)
public function showProfile()
public function showProfile(request $request)
{
$userId = Auth::user()->id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function up()
$table->enum('block', ['yes', 'no'])->default('no');
$table->rememberToken();
$table->timestamps();
$table->string('theme')->nullable();
});
}

Expand Down
9 changes: 8 additions & 1 deletion littlelink/css/share.button.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.share-icon {
padding: 0px 8px 3.5px 0px;
vertical-align: middle;
width: 20px;
height: 20px;
}

.sharediv {
position:relative;
top: 30px;
Expand Down Expand Up @@ -94,4 +101,4 @@ sharebutton:hover,
margin-left: auto;
margin-right: auto;
}
}
}
Loading

0 comments on commit a20ae1d

Please sign in to comment.