Skip to content

Commit a20ae1d

Browse files
Added Theme support to main branch
Added Theme support to main branch
2 parents 6c04067 + 26275c1 commit a20ae1d

22 files changed

+1982
-225
lines changed

.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ALLOW_USER_HTML=false
2323
#App Settings=Changes settings regarding your LittleLink Custom installation. You probably only want to change the App Name setting.
2424
#=App_Name changes the displayed name for the App in the title, for example.
2525
APP_NAME="LittleLink Custom"
26-
APP_KEY=base64:YUFWn5swwXryVBujHaOdiPqNvLEsC7RZs8df3rb/DJs=
26+
APP_KEY=
2727
#=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.
2828
APP_URL=
2929

app/Http/Controllers/UserController.php

+46-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77

88
use Auth;
99
use DB;
10+
use ZipArchive;
1011

1112
use App\Models\User;
1213
use App\Models\Button;
1314
use App\Models\Link;
1415

16+
1517
//Function tests if string starts with certain string (used to test for illegal strings)
1618
function stringStartsWith($haystack,$needle,$case=true) {
1719
if ($case){
@@ -56,8 +58,8 @@ public function littlelink(request $request)
5658
return abort(404);
5759
}
5860

59-
$userinfo = User::select('name', 'littlelink_name', 'littlelink_description')->where('id', $id)->first();
60-
$information = User::select('name', 'littlelink_name', 'littlelink_description')->where('id', $id)->get();
61+
$userinfo = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->where('id', $id)->first();
62+
$information = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->where('id', $id)->get();
6163

6264
$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();
6365

@@ -74,8 +76,8 @@ public function littlelinkhome(request $request)
7476
return abort(404);
7577
}
7678

77-
$userinfo = User::select('name', 'littlelink_name', 'littlelink_description')->where('id', $id)->first();
78-
$information = User::select('name', 'littlelink_name', 'littlelink_description')->where('id', $id)->get();
79+
$userinfo = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->where('id', $id)->first();
80+
$information = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->where('id', $id)->get();
7981

8082
$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();
8183

@@ -301,8 +303,47 @@ public function editPage(request $request)
301303
return Redirect('/studio/page');
302304
}
303305

306+
//Show custom theme
307+
public function showTheme(request $request)
308+
{
309+
$userId = Auth::user()->id;
310+
311+
$data['pages'] = User::where('id', $userId)->select('littlelink_name', 'theme')->get();
312+
313+
return view('/studio/theme', $data);
314+
}
315+
316+
//Save custom theme
317+
public function editTheme(request $request)
318+
{
319+
$request->validate([
320+
'zip' => 'sometimes|mimes:zip',
321+
]);
322+
323+
$userId = Auth::user()->id;
324+
325+
$zipfile = $request->file('zip');
326+
327+
$theme = $request->theme;
328+
329+
User::where('id', $userId)->update(['theme' => $theme]);
330+
331+
if(!empty($zipfile)){
332+
333+
$zipfile->move(base_path('/themes'), "temp.zip");
334+
335+
$zip = new ZipArchive;
336+
$zip->open(base_path() . '/themes/temp.zip');
337+
$zip->extractTo(base_path() . '/themes');
338+
$zip->close();
339+
unlink(base_path() . '/themes/temp.zip');
340+
}
341+
342+
return Redirect('/studio/theme');
343+
}
344+
304345
//Show user (name, email, password)
305-
public function showProfile()
346+
public function showProfile(request $request)
306347
{
307348
$userId = Auth::user()->id;
308349

database/migrations/2014_10_12_000000_create_users_table.php

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function up()
2525
$table->enum('block', ['yes', 'no'])->default('no');
2626
$table->rememberToken();
2727
$table->timestamps();
28+
$table->string('theme')->nullable();
2829
});
2930
}
3031

littlelink/css/share.button.css

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
.share-icon {
2+
padding: 0px 8px 3.5px 0px;
3+
vertical-align: middle;
4+
width: 20px;
5+
height: 20px;
6+
}
7+
18
.sharediv {
29
position:relative;
310
top: 30px;
@@ -94,4 +101,4 @@ sharebutton:hover,
94101
margin-left: auto;
95102
margin-right: auto;
96103
}
97-
}
104+
}

0 commit comments

Comments
 (0)