Skip to content

Commit 37e213f

Browse files
committed
Screen rotation support - "settings - ui customisation"
1 parent 917408e commit 37e213f

File tree

8 files changed

+37
-4
lines changed

8 files changed

+37
-4
lines changed

.dockerignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
**/values.dev.yaml
2424
README.md
2525
/public/custom/pictures/**
26+
**/custom.css
2627

2728
!keep
28-
!custom.css

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
- 'Sleep timer' disables the display during set hours.
3838
- Trivia Quiz (multiple selectable topics)
3939
- Support LED Matrix displays running Awtrix software
40+
- Display custom web pages as slides (if web page compatible) - **EXPERIMENTAL!**
41+
- Rotate display -90° (for running on display devices, like Firesticks, which do not support portait rotation)
42+
- Post API (at '/api/sleep') to toggle sleep mode. (Pass in header 'psw: your Posterr password')
4043
---
4144
## Prerequisites
4245
### Mandatory

classes/core/globalPage.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class globalPage {
1717
bgColour,
1818
hasArt,
1919
quizTime,
20-
hideSettingsLinks
20+
hideSettingsLinks,
21+
rotate
2122
) {
2223
this.slideDuration = slideDuration;
2324
this.fadeTransition = fadeTransition;
@@ -28,6 +29,7 @@ class globalPage {
2829
this.cards = [];
2930
this.quizTime = quizTime;
3031
this.hideSettingsLinks = hideSettingsLinks;
32+
this.rotate = rotate;
3133
return;
3234
}
3335

classes/core/settings.js

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class Settings {
8282
this.awtrixIP = DEFAULT_SETTINGS.awtrixIP;
8383
this.enableLinks = DEFAULT_SETTINGS.enableLinks;
8484
this.links = DEFAULT_SETTINGS.links;
85+
this.rotate = DEFAULT_SETTINGS.rotate;
8586
return;
8687
}
8788

@@ -145,6 +146,7 @@ class Settings {
145146
if(readSettings.enableLinks==undefined) readSettings.enableLinks = 'false';
146147
if(readSettings.recentlyAddedDays==undefined) readSettings.recentlyAddedDays = 0;
147148
if(readSettings.enableAwtrix==undefined) readSettings.enableAwtrix = 'false';
149+
if(readSettings.rotate==undefined) readSettings.rotate = 'false';
148150
} catch (ex) {
149151
// do nothing if error as it reads ok anyhow
150152
let d = new Date();
@@ -373,6 +375,8 @@ class Settings {
373375
else this.enableAwtrix = cs.enableAwtrix;
374376
if (jsonObject.awtrixIP) this.awtrixIP = jsonObject.awtrixIP;
375377
else this.awtrixIP = cs.awtrixIP;
378+
if (jsonObject.rotate) this.rotate = jsonObject.rotate;
379+
else this.rotate = cs.rotate;
376380

377381
// convert JSON object to string (pretty format)
378382
const data = JSON.stringify(this, null, 4);

index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ async function loadNowScreening() {
794794
globalPage.hasArt = loadedSettings.hasArt;
795795
globalPage.quizTime = loadedSettings.triviaTimer !== undefined ? loadedSettings.triviaTimer : 15;
796796
globalPage.hideSettingsLinks = loadedSettings.hideSettingsLinks !== undefined ? loadedSettings.hideSettingsLinks : 'false';
797+
globalPage.rotate = loadedSettings.rotate !== undefined ? loadedSettings.rotate : "false";
797798

798799
// restart the clock
799800
nowScreeningClock = setInterval(loadNowScreening, pollInterval);
@@ -1486,7 +1487,7 @@ else {
14861487
// set routes
14871488
app.get(BASEURL + "/", (req, res) => {
14881489
// try {
1489-
res.render("index", { globals: globalPage, hasConfig: setng.GetChanged(), baseUrl: BASEURL, custBrand: globalPage.custBrand, hasArt: globalPage.hasArt, quizTime: globalPage.quizTime }); // index refers to index.ejs
1490+
res.render("index", { globals: globalPage, hasConfig: setng.GetChanged(), baseUrl: BASEURL, custBrand: globalPage.custBrand, hasArt: globalPage.hasArt, quizTime: globalPage.quizTime, rotate: globalPage.rotate }); // index refers to index.ejs
14901491
// }
14911492
// catch (ex) {
14921493
// console.log('res.render:' + __dirname);
@@ -1892,6 +1893,7 @@ app.post(
18921893
awtrixIP: req.body.awtrixIP,
18931894
enableLinks: req.body.enableLinks,
18941895
links: req.body.links,
1896+
rotate: req.body.rotate,
18951897
saved: false
18961898
};
18971899

myviews/header.ejs

+12
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@
2020
<link rel="stylesheet" href="<%=baseUrl%>/css/font-awesome.min.css">
2121
<link rel="stylesheet" href="<%=baseUrl%>/css/styles.css">
2222
<!-- Apply UI customisations -->
23+
<%if(globals.rotate == "true"){%>
24+
<style>html {
25+
transform: rotate(-90deg) !important;
26+
transform-origin: left top !important;
27+
width: 100vh !important;
28+
height: 100vw !important;
29+
overflow-x: hidden !important;
30+
position: absolute !important;
31+
top: 100% !important;
32+
left: 0 !important;
33+
} </style>
34+
<%}%>
2335
<%if(globals.custBrand !== ""){%>
2436
<style>.banners { font-family: '<%=globals.custBrand%>'; }</style>
2537
<%}%>

myviews/settings.ejs

+10
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,16 @@
285285
<div id="collapseUI" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingUI">
286286
<div class="panel-body">
287287

288+
<h6>Screen Orientation</h6>
289+
<div class="form-group">
290+
<div class="custom-control custom-control-nolabel custom-switch ml-auto">
291+
<input type="checkbox" class="custom-control-input" name="rotate" id="rotate" aria-describedby="rotateHelp"
292+
value="true" <% if(typeof formData !== 'undefined' && errors){%><%=formData.rotate ? 'checked' : '' %><%}else{%><%=(settings.rotate == 'true') ? 'checked' : '' %><%}%>>
293+
<label class="custom-control-label" for="rotate">Rotate screen</label>
294+
<small id="themeHelp" class="form-text text-muted">Rotate screen orientation -90 degrees (ideal for Amazon Firestick devices)</small>
295+
</div>
296+
</div>
297+
288298
<h6>Colours</h6>
289299
<div class="form-group">
290300
&nbsp;&nbsp;<input type="color" value="#FAFAD2" id="colourWellTitle">

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "posterr",
3-
"version": "1.19.0",
3+
"version": "1.20.0",
44
"description": "A digital display for your media",
55
"main": "index.js",
66
"bin": "index.js",

0 commit comments

Comments
 (0)