Added link icons to littlelink page

This commit is contained in:
Julian Prieber 2022-12-05 20:02:23 +01:00
parent fd6b0e1dac
commit 34133543f1
3 changed files with 147 additions and 5 deletions

View File

@ -698,4 +698,70 @@ class UserController extends Controller
return redirect('/'); return redirect('/');
} }
//Edit/save page icons
public function editIcons(request $request)
{
function searchIcon($icon)
{
$iconId = DB::table('links')
->where('user_id', Auth::id())
->where('title', $icon)
->where('button_id', 94)
->value('id');
if (is_null($iconId)){
return false;
} else {
return $iconId;
}
}
function addIcon($icon, $link){
$links = new Link;
$links->user_id = Auth::id();
$links->button_id = '94';
$links->link = $link;
$links->title = $icon;
$links->save();
}
function updateIcon($icon, $link){
Link::where('id', searchIcon($icon))->update([
'button_id' => 94,
'link' => $link,
'title' => $icon
]);
}
function saveIcon($icon, $link){
if(isset($link)){
if(searchIcon($icon) != NULL){
updateIcon($icon, $link);
}else{
addIcon($icon, $link);}
}
}
saveIcon('mastodon', $request->mastodon);
saveIcon('instagram', $request->instagram);
saveIcon('twitter', $request->twitter);
saveIcon('github', $request->github);
saveIcon('linkedin', $request->linkedin);
return Redirect('studio/links#icons');
}
} }

View File

@ -258,15 +258,27 @@ function get_operating_system() {
<h1 class="fadein">{{ $info->name }}</h1> <h1 class="fadein">{{ $info->name }}</h1>
<!-- Short Bio --> <!-- Short Bio -->
<center><p style="width:50%;min-width:300px;" class="fadein">@if(env('ALLOW_USER_HTML') === true){!! $info->littlelink_description !!}@else{{ $info->littlelink_description }}@endif</p></center> <p style="width:50%;min-width:300px;" class="fadein">@if(env('ALLOW_USER_HTML') === true){!! $info->littlelink_description !!}@else{{ $info->littlelink_description }}@endif</p>
<!-- Icons -->
<style>.social-icon{font-size:32px;padding:10px;padding-bottom:30px;color:#fff;}</style>
@php $icons = DB::table('links')->where('user_id', 1)->where('button_id', 94)->get(); @endphp
<div class="row fadein">
@foreach($icons as $icon)
<a href="{{$icon->link}}"><i class="social-icon fa-brands fa-{{$icon->title}}"></i></a>
@endforeach
</div>
@endforeach @endforeach
<!-- Buttons --> <!-- Buttons -->
<?php function strp($urlStrp){return str_replace(array('http://', 'https://'), '', $urlStrp);} ?> <?php function strp($urlStrp){return str_replace(array('http://', 'https://'), '', $urlStrp);} ?>
<?php $initial=1; // <-- Effectively sets the initial loading time of the buttons. This value should be left at 1. ?> <?php $initial=1; // <-- Effectively sets the initial loading time of the buttons. This value should be left at 1. ?>
@foreach($links as $link) @foreach($links as $link)
@php $linkName = str_replace('default ','',$link->name) @endphp @php $linkName = str_replace('default ','',$link->name) @endphp
@if($link->button_id === 0) @if($link->name === "icon")
@elseif($link->button_id === 0)
<div style="--delay: {{ $initial++ }}s" class="button-entrance"><a class="button button-title button button-hover icon-hover" rel="noopener noreferrer nofollow" href="{{ route('clickNumber') . '/' . $link->id }}" @if(theme('open_links_in_same_tab') != "true")target="_blank"@endif >{{ $link->title }}</a></div> <div style="--delay: {{ $initial++ }}s" class="button-entrance"><a class="button button-title button button-hover icon-hover" rel="noopener noreferrer nofollow" href="{{ route('clickNumber') . '/' . $link->id }}" @if(theme('open_links_in_same_tab') != "true")target="_blank"@endif >{{ $link->title }}</a></div>
@elseif($link->name === "phone") @elseif($link->name === "phone")
<div style="--delay: {{ $initial++ }}s" class="button-entrance"><a class="button button-default button button-hover icon-hover" rel="noopener noreferrer nofollow" href="{{ $link->link }}"><img alt="button-icon" class="icon hvr-icon" src="@if(theme('use_custom_icons') == "true"){{ url('themes/' . $GLOBALS['themeName'] . '/extra/custom-icons')}}/phone{{theme('custom_icon_extension')}} @else{{ asset('\/littlelink/icons\/')}}phone.svg @endif"></i>{{ $link->title }}</a></div> <div style="--delay: {{ $initial++ }}s" class="button-entrance"><a class="button button-default button button-hover icon-hover" rel="noopener noreferrer nofollow" href="{{ $link->link }}"><img alt="button-icon" class="icon hvr-icon" src="@if(theme('use_custom_icons') == "true"){{ url('themes/' . $GLOBALS['themeName'] . '/extra/custom-icons')}}/phone{{theme('custom_icon_extension')}} @else{{ asset('\/littlelink/icons\/')}}phone.svg @endif"></i>{{ $link->title }}</a></div>

View File

@ -15,6 +15,8 @@
@endif @endif
@push('sidebar-stylesheets') @push('sidebar-stylesheets')
<script src="{{ asset('studio/external-dependencies/fontawesome.js') }}" crossorigin="anonymous"></script>
<link rel="stylesheet" href="{{ asset('studio/external-dependencies/fontawesome.css') }}" />
<style> <style>
@media only screen and (max-width: 1500px) { @media only screen and (max-width: 1500px) {
.pre-side{display:none!important;} .pre-side{display:none!important;}
@ -28,6 +30,7 @@
.pre-bottom{display:none!important;} .pre-bottom{display:none!important;}
} }
</style> </style>
<style>.delete{position:relative; color:transparent; background-color:tomato; border-radius:5px; left:5px; padding:5px 12px; cursor: pointer;}.delete:hover{color:transparent;background-color:#f13d1d;}html,body{max-width:100%;overflow-x:hidden;}</style>
@endpush @endpush
@include('components.favicon') @include('components.favicon')
@ -55,6 +58,8 @@
<div id="links-table-body" data-page="{{request('page', 1)}}" data-per-page="{{$pagePage ? $pagePage : 0}}"> <div id="links-table-body" data-page="{{request('page', 1)}}" data-per-page="{{$pagePage ? $pagePage : 0}}">
@foreach($links as $link) @foreach($links as $link)
@php $button = Button::find($link->button_id); if(isset($button->name)){$buttonName = $button->name;}else{$buttonName = 0;} @endphp
@if($button->name !== 'icon')
<div class='row h-100 pb-0 mb-2 border rounded hvr-glow ' data-id="{{$link->id}}"> <div class='row h-100 pb-0 mb-2 border rounded hvr-glow ' data-id="{{$link->id}}">
@ -63,13 +68,11 @@
</div> </div>
<div class='col border-left h-100'> <div class='col border-left h-100'>
<div class='row h-100'> <div class='row h-100'>
<div class='col-12 p-2' style="max-width:300px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="{{ $link->title }}"> <div class='col-12 p-2' style="max-width:300px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="{{ $link->title }}">
<span class='h6'> <span class='h6'>
<?php $button = Button::find($link->button_id); if(isset($button->name)){$buttonName = $button->name;}else{$buttonName = 0;} ?>
@if($button->name == "custom_website") @if($button->name == "custom_website")
<span style="border: 1px solid #d0d4d7 !important;border-radius:5px;background-color:#6c757d;width:25px!important;height:25px!important;"><img style="margin-bottom:3px;margin-left:4px;margin-right:4px;max-width:15px;max-height:15px;" alt="button-icon" class="icon hvr-icon" src="@if(file_exists(base_path("studio/favicon/icons/").localIcon($link->id))){{url('studio/favicon/icons/'.localIcon($link->id))}}@else{{getFavIcon($link->id)}}@endif"></span> <span style="border: 1px solid #d0d4d7 !important;border-radius:5px;background-color:#6c757d;width:25px!important;height:25px!important;"><img style="margin-bottom:3px;margin-left:4px;margin-right:4px;max-width:15px;max-height:15px;" alt="button-icon" class="icon hvr-icon" src="@if(file_exists(base_path("studio/favicon/icons/").localIcon($link->id))){{url('studio/favicon/icons/'.localIcon($link->id))}}@else{{getFavIcon($link->id)}}@endif"></span>
@elseif($button->name == "space") @elseif($button->name == "space")
@ -134,6 +137,7 @@
</div> </div>
</div> </div>
</div> </div>
@endif
@endforeach @endforeach
</div> </div>
@ -160,13 +164,73 @@
</div> </div>
<br> <br>
<section style="width:100%!important;" class='pre-bottom shadow text-gray-400 pre-side'> <section style="margin-left:-15px;margin-right:-15px;" style="width:100%!important;" class='pre-bottom shadow text-gray-400 pre-side'>
<h3 class="card-header"><i class="bi bi-window-fullscreen" style="font-style:normal!important;"> Preview:</i></h3> <h3 class="card-header"><i class="bi bi-window-fullscreen" style="font-style:normal!important;"> Preview:</i></h3>
<div class='card-body p-0 p-md-3'> <div class='card-body p-0 p-md-3'>
<center><iframe allowtransparency="true" id="frPreview2" style=" border-radius:0.25rem !important; background: #FFFFFF; min-height:600px; height:100%; width:100% !important;" class='w-100' src="{{ url('') }}/@<?= Auth::user()->littlelink_name ?>">Your browser isn't compatible</iframe></center> <center><iframe allowtransparency="true" id="frPreview2" style=" border-radius:0.25rem !important; background: #FFFFFF; min-height:600px; height:100%; width:100% !important;" class='w-100' src="{{ url('') }}/@<?= Auth::user()->littlelink_name ?>">Your browser isn't compatible</iframe></center>
</div> </div>
</section><br>
<section style="margin-left:-15px;margin-right:-15px;" class='shadow text-gray-400'>
<a name="icons"></a>
<h3 class="mb-4 card-header"><i class="fa-solid fa-icons"></i> Page Icons</i></h3>
<div class="card-body p-0 p-md-3">
<form action="{{ route('editIcons') }}" enctype="multipart/form-data" method="post">
@csrf
<div class="form-group col-lg-8">
@php
function iconLink($icon){
$iconLink = DB::table('links')
->where('user_id', Auth::id())
->where('title', $icon)
->where('button_id', 94)
->value('link');
if (is_null($iconLink)){
return false;
} else {
return $iconLink;}}
function searchIcon($icon)
{$iconId = DB::table('links')
->where('user_id', Auth::id())
->where('title', $icon)
->where('button_id', 94)
->value('id');
if(is_null($iconId)){return false;}else{return $iconId;}}
function icon($name, $label){ echo '
<label>'.$label.'</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text"><i class="fa-brands fa-'.$name.'"></i></div>
</div>
<input type="url" class="form-control" name="'.$name.'" value="'.iconLink($name).'" >';
if(searchIcon($name) != NULL){echo '<a href="'. route("deleteLink", searchIcon($name) ) .'" class="delete"><i style="color:#fff" class="bi bi-trash-fill"></i></a>';}
echo '</div><br>';}
@endphp
<style>input{border-top-right-radius: 0.25rem!important; border-bottom-right-radius: 0.25rem!important;}</style>
{!!icon('mastodon', 'Mastodon')!!}
{!!icon('instagram', 'Instagram')!!}
{!!icon('twitter', 'Twitter')!!}
{!!icon('github', 'GitHub')!!}
{!!icon('linkedin', 'LinkedIn')!!}
<button type="submit" class="mt-3 ml-3 btn btn-info">Save links</button>
</form>
</div>
</section> </section>
<script src="{{ asset('studio/external-dependencies/jquery-1.12.4.min.js') }}"></script> <script src="{{ asset('studio/external-dependencies/jquery-1.12.4.min.js') }}"></script>
<script type="text/javascript">$("iframe").load(function() { $("iframe").contents().find("a").each(function(index) { $(this).on("click", function(event) { event.preventDefault(); event.stopPropagation(); }); }); });</script> <script type="text/javascript">$("iframe").load(function() { $("iframe").contents().find("a").each(function(index) { $(this).on("click", function(event) { event.preventDefault(); event.stopPropagation(); }); }); });</script>