Skip to content

Commit

Permalink
Implement version and copyright renders
Browse files Browse the repository at this point in the history
  • Loading branch information
rafael-santiago committed Jul 7, 2024
1 parent 2d8e283 commit 880d2c2
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 3 deletions.
18 changes: 18 additions & 0 deletions src/internal/renders/copyright_render.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Copyright (c) 2024, Rafael Santiago
// All rights reserved.
//
// This source code is licensed under the GPLv2 license found in the
// COPYING.GPLv2 file in the root directory of Eutherpe's source tree.
//
package renders

import (
"internal/vars"
"strings"
)

func CopyrightRender(templatedInput string, _ *vars.EutherpeVars) string {
return strings.Replace(templatedInput, vars.EutherpeTemplateNeedleCopyrightDisclaimer,
vars.EutherpeCopyrightDisclaimer, -1)
}
21 changes: 21 additions & 0 deletions src/internal/renders/copyright_render_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Copyright (c) 2024, Rafael Santiago
// All rights reserved.
//
// This source code is licensed under the GPLv2 license found in the
// COPYING.GPLv2 file in the root directory of Eutherpe's source tree.
//
package renders

import (
"internal/vars"
"testing"
)

func TestCopyrightRender(t *testing.T) {
output := CopyrightRender(vars.EutherpeTemplateNeedleCopyrightDisclaimer,
nil)
if output != vars.EutherpeCopyrightDisclaimer {
t.Errorf("CopyrightDisclaimer() is not rendering accordingly.\n")
}
}
2 changes: 1 addition & 1 deletion src/internal/renders/renders.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func RenderData(templatedInput string, eutherpeVars *vars.EutherpeVars) string {
ShuffleModeRender, PlayModeRender, PlayerStatusRender, VolumeLevelRender,
CommonTagsRender, LastSelectionRender, AuthenticationModeSwitchRender,
UpNextCountRender, FoundStorageDevicesCountRender, FoundBluetoothDevicesCountRender,
HTTPSModeSwitchRender, ESSIDRender, HostNameRender,
HTTPSModeSwitchRender, ESSIDRender, HostNameRender, VersionRender, CopyrightRender,
}
var output string = templatedInput
eutherpeVars.Lock()
Expand Down
13 changes: 12 additions & 1 deletion src/internal/renders/test-data/expected-eutherpe.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,11 @@ <h3>&#128264; You are connected to device: /dev/deepblue42</h3>
</center>
</div>
<div id="Settings" class="configcontent" style="display:none;">
<h3>&#x1F528; Settings</h3></td><td>
<h3>&#x1F528; Settings</h3>
<div align="right">
<input class="eutherpeBUTTON" type="button" value="&#x1F97E Reboot" onclick="reboot();"/>
<input class="eutherpeBUTTON" type="button" value="&#x1F50C Power-off" onclick="powerOff();"/>
<input class="eutherpeBUTTON" type="button" value="&#x1F989 About..." onclick="showAboutDiv();"/>
</div>
<hr>
<div style="text-align: center; padding: 10%;">
Expand Down Expand Up @@ -209,6 +210,16 @@ <h3>&#x1F528; Settings</h3></td><td>
<input class="eutherpeBUTTON" type="button" value="Save" onclick="saveWiFiCredentials();"/>
<input class="eutherpeBUTTON" type="button" value="Back" onclick="closeWiFiCredentials();"/>
</div>
<div id="About" class="configcontent" style="text-align: left; padding: 1%; display: none;">
<h3>&#x1F4CC; About &#x1F3BC &#x1F3B5 &#x1F50A &#x1F3A7 &#x1F483 &#x1F57A &#x1F3B7 &#x1F3B9 &#x1F3A4 &#x1F3BA &#x1F3BB &#x1F941 &#x1F3B8 &#x1F3B6 &#x1F918</h3>
<hr>
You are using Eutherpe-v1<br><br>
Eutherpe is Copyright (c) 2024 by Rafael Santiago<br><br>You can redistribute it and/or modify under the terms of the GNU General Public License version 2.<br><br>Bug reports, feedback etc: <a href="mailto:[email protected]"?subject="[Eutherpe] <here goes the subject>"><u>mail me</u></a> or open an <a href="https://github.com/rafael-santiago/eutherpe/issues"><u>issue</u></a> at Eutherpe's project repository. Thanks in advance! &#x1F609
<hr>
<center>
<input class="eutherpeBUTTON" type="button" value="Back" onclick="closeAbout();"/>
</center>
</div>
<input type="hidden" id="lastSelection" name="lastSelection" value=""/>
<input type="hidden" id="lastError" name="lastError" value=""/>
<input type="hidden" id="lastQueryAnswer" name="lastQueryAnswer" value="false"/>
Expand Down
18 changes: 18 additions & 0 deletions src/internal/renders/version_render.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Copyright (c) 2024, Rafael Santiago
// All rights reserved.
//
// This source code is licensed under the GPLv2 license found in the
// COPYING.GPVv2 file in the root directory of Eutherpe's source tree.
//
package renders

import (
"internal/vars"
"strings"
)

func VersionRender(templatedInput string, _ *vars.EutherpeVars) string {
return strings.Replace(templatedInput, vars.EutherpeTemplateNeedleVersion,
vars.EutherpeVersion, -1)
}
20 changes: 20 additions & 0 deletions src/internal/renders/version_render_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// Copyright (c) 2024, Rafael Santiago
// All rights reserved.
//
// This source code is licensed under the GPLv2 license found in the
// COPYING.GPLv2 file in the root directory of Eutherpe's source tree.
//
package renders

import (
"internal/vars"
"testing"
)

func TestVersionRender(t *testing.T) {
output := VersionRender(vars.EutherpeTemplateNeedleVersion, nil)
if output != vars.EutherpeVersion {
t.Errorf("VersionRender() is not rendering accordingly.\n")
}
}
5 changes: 5 additions & 0 deletions src/internal/vars/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ func (e *EutherpeVars) TuneUp() {
e.HTTPd.Port = "8080"
}

const EutherpeVersion = "v1"
const EutherpeCopyrightDisclaimer = "Eutherpe is Copyright (c) 2024 by Rafael Santiago<br><br>You can redistribute it and/or modify under the terms of the GNU General Public License version 2.<br><br>Bug reports, feedback etc: <a href=\"mailto:[email protected]\"?subject=\"[Eutherpe] <here goes the subject>\"><u>mail me</u></a> or open an <a href=\"https://github.com/rafael-santiago/eutherpe/issues\"><u>issue</u></a> at Eutherpe's project repository. Thanks in advance! &#x1F609"

const EutherpeActionId = "action"

// INFO(Rafael): Actions from "Music" sheet.
Expand Down Expand Up @@ -589,6 +592,8 @@ const EutherpeTemplateNeedleFoundStorageDevicesCount = "{{.FOUND-STORAGE-DEVICES
const EutherpeTemplateNeedleFoundBluetoothDevicesCount = "{{.FOUND-BLUETOOTH-DEVICES-COUNT}}"
const EutherpeTemplateNeedleESSID = "{{.ESSID}}"
const EutherpeTemplateNeedleHostName = "{{.HOSTNAME}}"
const EutherpeTemplateNeedleVersion = "{{.EUTHERPE-VERSION}}"
const EutherpeTemplateNeedleCopyrightDisclaimer = "{{.EUTHERPE-COPYRIGHT-DISCLAIMER}}"

const EutherpeWebUIConfigSheetMusic = "Music"
const EutherpeWebUIConfigSheetCollection = "Collection"
Expand Down
13 changes: 12 additions & 1 deletion src/web/html/eutherpe.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,11 @@ <h3>&#128264; You are connected to device: {{.SELECTED-BLUETOOTH-DEVICE}}</h3>
</center>
</div>
<div id="Settings" class="configcontent" style="display:none;">
<h3>&#x1F528; Settings</h3></td><td>
<h3>&#x1F528; Settings</h3>
<div align="right">
<input class="eutherpeBUTTON" type="button" value="&#x1F97E Reboot" onclick="reboot();"/>
<input class="eutherpeBUTTON" type="button" value="&#x1F50C Power-off" onclick="powerOff();"/>
<input class="eutherpeBUTTON" type="button" value="&#x1F989 About..." onclick="showAboutDiv();"/>
</div>
<hr>
<div style="text-align: center; padding: 10%;">
Expand Down Expand Up @@ -209,6 +210,16 @@ <h3>&#x1F528; Settings</h3></td><td>
<input class="eutherpeBUTTON" type="button" value="Save" onclick="saveWiFiCredentials();"/>
<input class="eutherpeBUTTON" type="button" value="Back" onclick="closeWiFiCredentials();"/>
</div>
<div id="About" class="configcontent" style="text-align: left; padding: 1%; display: none;">
<h3>&#x1F4CC; About &#x1F3BC &#x1F3B5 &#x1F50A &#x1F3A7 &#x1F483 &#x1F57A &#x1F3B7 &#x1F3B9 &#x1F3A4 &#x1F3BA &#x1F3BB &#x1F941 &#x1F3B8 &#x1F3B6 &#x1F918</h3>
<hr>
You are using Eutherpe-{{.EUTHERPE-VERSION}}<br><br>
{{.EUTHERPE-COPYRIGHT-DISCLAIMER}}
<hr>
<center>
<input class="eutherpeBUTTON" type="button" value="Back" onclick="closeAbout();"/>
</center>
</div>
<input type="hidden" id="lastSelection" name="lastSelection" value="{{.LAST-SELECTION}}"/>
<input type="hidden" id="lastError" name="lastError" value="{{.LAST-ERROR}}"/>
<input type="hidden" id="lastQueryAnswer" name="lastQueryAnswer" value="false"/>
Expand Down
8 changes: 8 additions & 0 deletions src/web/js/eutherpe.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ function showPlayByTags() {
openConfig("PlayByTags");
}

function closeAbout() {
openConfig("Settings");
}

function showAboutDiv() {
openConfig("About");
}

function showAddTags() {
songSelection = document.getElementsByClassName("CollectionSong");
selectedOnes = getSelectedSongs(songSelection);
Expand Down

0 comments on commit 880d2c2

Please sign in to comment.