Skip to content

Commit 4babe1f

Browse files
committed
Made update notification optional / Added Event notification
Added optional event notification that can be enabled in the config (is disabled by default). You can read more about this feature on the Blog here: https://blog.littlelink-custom.com/event-notifications/
1 parent 87515a9 commit 4babe1f

File tree

4 files changed

+55
-15
lines changed

4 files changed

+55
-15
lines changed

.env

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
#=Register_auth either auth or verified. If auth is selected, no verification is required. Default is verified.
33
Register_auth=verified
44

5+
#Internal notifications=Notify if update is available or and event is happening such as a poll about the future of this project.
6+
Notify_events=false
7+
Notify_updates=true
8+
59
#App Settings=Changes settings regarding your LittleLink Custom installation. You probably only want to change the App Name setting.
610
#=App_Name changes the displayed name for the App in the title, for example.
711
App_Name="LittleLink Custom"
812
APP_KEY=
913
App_URL=
1014

11-
1215
#Debug Settings=Changes if your page should display a full error description instead of a generic error 500
1316
#=App_debug either true or false. You might want to change this to false after you're done installing, but it's very useful for troubleshooting.
1417
App_debug=true
@@ -17,11 +20,9 @@ App_env=local
1720
Log_channel=stack
1821
Log_level=debug
1922

20-
2123
#Database Settings=Should be left alone. If you wish to use mysql you'd have to seed the database again.
2224
DB_connection=sqlite
2325

24-
2526
#Mail Settings=LittleLink Custom comes with a free to use built-in SMTP server for sending mail. You can leave this setting as is, if you wish to use this service please read our terms and conditions at llc-mail.tru.io. If you do not wish to use the built-in SMTP server, change the setting below
2627
#=Mail_mailer either smtp or built-in. Make sure to change this setting if you want to add a custom SMTP server.
2728
Mail_mailer=built-in
@@ -33,14 +34,12 @@ Mail_encryption=
3334
Mail_from_address=
3435
Mail_from_name="${app_name}"
3536

36-
3737
#Cache Settings=Completely optional
3838
Memcached_host=127.0.0.1
3939
Redis_host=127.0.0.1
4040
Redis_password=null
4141
Redis_port=6379
4242

43-
4443
#Miscellaneous Settings=Should be left alone if you don't know what you're doing.
4544
Broadcast_driver=log
4645
Cache_driver=file

resources/views/layouts/sidebar.blade.php

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function update_color_scheme() {
3535
<?php // loads dark mode CSS if dark mode detected
3636
$color_scheme = isset($_COOKIE["color_scheme"]) ? $_COOKIE["color_scheme"] : false; ?>
3737
@if ($color_scheme == 'dark')
38-
<!-- switch the two <link> Tags below to default to dark mode if cookie detection fails -->
38+
<!-- switch the two <link> Tags below to default to dark mode if cookie detection fails -->
3939
<link rel="stylesheet" href="{{ asset('/studio/css/bootstrap.min-dark.css') }}">
4040
<link rel="stylesheet" href="{{ asset('/studio/css/style-dashboard-dark.css') }}">
4141
@else
@@ -138,7 +138,7 @@ function update_color_scheme() {
138138
<div class="row">
139139
140140
<! –– #### begin update detection #### ––>
141-
141+
@if(env('Notify_updates') === true)
142142
<?php // Checks if URL exists
143143
try {
144144
function URL_exists(string $url): bool
@@ -169,16 +169,53 @@ function URL_exists(string $url): bool
169169
<a style="color:#007bff" class="nav-link" href="https://littlelink-custom.com/how-to-update.html" target="_blank" title="Click here to learn more about how to update">An update is available</a>
170170
@endif
171171
@endif
172+
@endif
172173
<! –– #### end update detection #### ––>
173174
174175
<a class="nav-link" href="{{ url('') }}/@<?= Auth::user()->littlelink_name ?>" target="_blank">Watch Page</a>
175176
</div>
176177
</li>
177178
</ul>
178-
</div>
179+
</div
179180
</div>
180181
</nav>
181-
182+
<! –– #### begin event detection #### ––>
183+
<?php
184+
try {
185+
function URL_event_exists(string $url): bool
186+
{
187+
return str_contains(get_headers($url)[0], "200 OK");
188+
}
189+
if (URL_event_exists("https://julianprieber.github.io/littlelink-custom-events/event.json")){
190+
$EventServerExists = "true";
191+
}
192+
} catch (exception $e) {
193+
$EventServerExists = "false";
194+
}
195+
?>
196+
@if(env('Notify_events') === true and $EventServerExists == 'true')
197+
<?php
198+
$GetEventJson = file_get_contents("https://julianprieber.github.io/littlelink-custom-events/event.json");
199+
$EventJson = json_decode($GetEventJson, true);
200+
?>
201+
@if(auth()->user()->role == 'admin' and strtotime(date("d-m-Y")) < strtotime($EventJson['enddate']))
202+
<nav class="navbar navbar-expand-lg navbar-light bg-light">
203+
<div class="container-fluid">
204+
<a class="nav-link" href="{{ $EventJson['link'] }}" target="{{ $EventJson['target'] }}"><mark onMouseOver="{{ $EventJson['hoveron'] }}" onMouseOut="{{ $EventJson['hoveroff'] }}" style="{{ $EventJson['style'] }}" title="{{ $EventJson['hover'] }}">{{ $EventJson['title'] }}</mark></a>
205+
</div>
206+
</nav>
207+
@endif
208+
@endif
209+
@if(env('Notify_events') === false and auth()->user()->role == 'admin')
210+
<a href="{{ url('env-editor') }}" id="notify" style="color:#F75D59; font-weight:600; font-size:120%; background-color:#F5FFFA;"></a>
211+
<script>
212+
if(localStorage.getItem("firstTime")==null){
213+
document.getElementById("notify").innerHTML = "➡️ Click here to get notified about important events or security vulnerabilities";
214+
localStorage.setItem("firstTime","done");
215+
}
216+
</script>
217+
@endif
218+
<! –– #### end event detection #### ––>
182219
@yield('content')
183220
184221
</div>
@@ -189,4 +226,4 @@ function URL_exists(string $url): bool
189226
<script src="{{ asset('/studio/js/bootstrap.min.js') }}"></script>
190227
<script src="{{ asset('/studio/js/main-dashboard.js') }}"></script>
191228
</body>
192-
</html>
229+
</html>

resources/views/vendor/env-editor/index.blade.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
</li>
2828
</ul>
2929

30+
@if(env('Notify_events') === false)
31+
<br><br>
32+
<a style="color:#ffbb39; font-weight:300; font-size:120%;">You currently have Event Notifications disabled. To get notified about polls, possible security vulnerabilities or important news, change the setting <code>Notify_events</code> below to <code>true</code>. If you enable this and an event is happening, a small text will pop up on your Admin Panel which will only be visible for admins.</a>
33+
@endif
34+
3035
<div class="tab-content" id="nav-tabContent">
3136
<div class="tab-pane fade show active p-3" id="current-env" role="tabpanel" aria-labelledby="nav-home-tab">
3237
<env-main-tab></env-main-tab>

storage/backups/default_settings

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
#=Register_auth either auth or verified. If auth is selected, no verification is required. Default is verified.
33
Register_auth=verified
44

5+
#Internal notifications=Notify if update is available or and event is happening such as a poll about the future of this project.
6+
Notify_events=false
7+
Notify_updates=true
8+
59
#App Settings=Changes settings regarding your LittleLink Custom installation. You probably only want to change the App Name setting.
610
#=App_Name changes the displayed name for the App in the title, for example.
711
App_Name="LittleLink Custom"
812
APP_KEY=base64:YOU+MUST+CHANGE+THIS+YUFukELiN6Bk9gQ19+9zwk=
913
App_URL=
1014

11-
1215
#Debug Settings=Changes if your page should display a full error description instead of a generic error 500
1316
#=App_debug either true or false. You might want to change this to false after you're done installing, but it's very useful for troubleshooting.
1417
App_debug=true
@@ -17,11 +20,9 @@ App_env=local
1720
Log_channel=stack
1821
Log_level=debug
1922

20-
2123
#Database Settings=Should be left alone. If you wish to use mysql you'd have to seed the database again.
2224
DB_connection=sqlite
2325

24-
2526
#Mail Settings=LittleLink Custom comes with a free to use built-in SMTP server for sending mail. You can leave this setting as is, if you wish to use this service please read our terms and conditions at llc-mail.tru.io. If you do not wish to use the built-in SMTP server, change the setting below
2627
#=Mail_mailer either smtp or built-in. Make sure to change this setting if you want to add a custom SMTP server.
2728
Mail_mailer=built-in
@@ -33,14 +34,12 @@ Mail_encryption=
3334
Mail_from_address=
3435
Mail_from_name="${app_name}"
3536

36-
3737
#Cache Settings=Completely optional
3838
Memcached_host=127.0.0.1
3939
Redis_host=127.0.0.1
4040
Redis_password=null
4141
Redis_port=6379
4242

43-
4443
#Miscellaneous Settings=Should be left alone if you don't know what you're doing.
4544
Broadcast_driver=log
4645
Cache_driver=file

0 commit comments

Comments
 (0)