Compare commits

...

28 commits

Author SHA1 Message Date
3c014f3c4d Merge pull request 'notblink' (#16) from notblink into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #16
2020-09-11 17:27:21 +02:00
7f970820d8 Fix quotes
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2020-09-11 17:14:08 +02:00
76228565aa [CI] Fix vnu path in html validator
All checks were successful
continuous-integration/drone/push Build is passing
2020-09-11 17:02:06 +02:00
3ccad58405 Try to remove blink JS
Some checks failed
continuous-integration/drone/push Build is failing
2020-09-11 16:54:43 +02:00
a51a2f8b7a Merge pull request 'favicon2' (#15) from favicon2 into master
All checks were successful
continuous-integration/drone/push Build is passing
2020-04-09 01:03:51 +02:00
1841998933 pylint
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2020-04-09 00:49:36 +02:00
9694eb66b4 Add both favicons and routing
Some checks failed
continuous-integration/drone/push Build is failing
Fix bad sed in Dockerfiles COPY
2020-04-09 00:44:08 +02:00
cb2552a7c3 Change icon according to time 2020-04-09 00:35:10 +02:00
96e3b7ae6d Add statics to the image
All checks were successful
continuous-integration/drone/push Build is passing
2020-04-09 00:33:52 +02:00
fe99c62d75 Remove tests from master
All checks were successful
continuous-integration/drone/push Build is passing
2020-04-09 00:17:35 +02:00
e86991fe75 Merge pull request 'default-hour' (#14) from default-hour into master
Some checks failed
continuous-integration/drone/push Build is failing
2020-04-09 00:06:57 +02:00
9c3d4252d1 Fix bug
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2020-04-08 21:47:20 +02:00
ff0bca9421 Try to improve tests
Some checks failed
continuous-integration/drone/push Build is failing
2020-04-08 21:09:51 +02:00
6ae863148f Fix behaviour when specifying only hour
Some checks failed
continuous-integration/drone/push Build is failing
2020-04-08 20:32:53 +02:00
ad22413145 [CI] Also fix tests
Some checks failed
continuous-integration/drone/push Build is failing
2020-04-08 03:59:16 +02:00
4e5cc46b28 Change default beer hour 2020-04-08 03:58:33 +02:00
092c5c82e8 Merge pull request '[UI] Add favicon' (#13) from favicon into master
Some checks failed
continuous-integration/drone/push Build is failing
2020-04-08 03:57:38 +02:00
86848b504f [UI] Add favicon
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2020-04-08 03:49:37 +02:00
735b092de1 Merge pull request 'Fix 404 on trailing slash' (#12) from trailing_slash into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #12
2020-03-06 09:35:53 +01:00
5133edbc52 Fix 404 on trailing slash
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2020-03-05 14:54:39 +01:00
1c713d46d9 Merge pull request '[CI] Don't rebuild docker image when merging' (#11) from fix-merge into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #11
2020-03-03 13:20:40 +01:00
990d3ac8bf [CI] Don't rebuild docker image when merging
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
Should fix #9
2020-03-03 09:34:13 +01:00
fed0b11a24 Merge pull request 'unit-test2' (#10) from unit-test2 into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #10
2020-03-03 01:30:26 +01:00
0e2121294e Merge branch 'unit-test2' of gitea.wired.lan:kleph/beer into unit-test2
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2020-03-03 01:21:32 +01:00
d167fe1b52 [tests] Test parameters passed in URL
Fixes #7
2020-03-03 01:20:03 +01:00
fdc5423a8d [CI] Add sample staging tests 2020-03-03 01:20:03 +01:00
9d05055acb Merge pull request 'test-staging' (#8) from test-staging into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #8
2020-03-03 01:02:27 +01:00
a5fbeea615 [CI] Add sample staging tests
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
2020-03-03 00:28:56 +01:00
7 changed files with 68 additions and 23 deletions

View file

@ -16,7 +16,7 @@ steps:
- name: w3c validator - name: w3c validator
image: validator/validator:latest image: validator/validator:latest
commands: commands:
- vnu static/*.html - /vnu-runtime-image/bin/vnu static/*.html
- name: markdown lint - name: markdown lint
image: pipelinecomponents/markdownlint:latest image: pipelinecomponents/markdownlint:latest
@ -53,6 +53,10 @@ steps:
from_secret: dockerhub_username from_secret: dockerhub_username
password: password:
from_secret: dockerhub_password from_secret: dockerhub_password
when:
event:
exclude:
- pull_request
depends_on: depends_on:
- unit tests - unit tests
@ -102,6 +106,10 @@ steps:
BRANCH: ${DRONE_COMMIT_BRANCH} BRANCH: ${DRONE_COMMIT_BRANCH}
commands: commands:
- bash staging_tests.sh - bash staging_tests.sh
when:
branch:
exclude:
- master
- name: deploy live - name: deploy live
image: sinlead/drone-kubectl image: sinlead/drone-kubectl

View file

@ -3,6 +3,7 @@ FROM python:slim
RUN pip install flask RUN pip install flask
COPY /beer/beer.py /beer.py COPY /beer/beer.py /beer.py
COPY /beer/templates /templates COPY /beer/templates /templates
COPY /beer/static /static
EXPOSE 5000 EXPOSE 5000
CMD ["python", "/beer.py"] CMD ["python", "/beer.py"]

View file

@ -4,24 +4,42 @@
from flask import Flask from flask import Flask
from flask import render_template from flask import render_template
from flask import send_from_directory
# pylint: disable=invalid-name # pylint: disable=invalid-name
app = Flask(__name__) app = Flask(__name__)
app.url_map.strict_slashes = False
@app.route('/') @app.route('/')
@app.route('/<int(min=0, max=23):hours>') @app.route('/<int(min=0, max=23):hours>')
@app.route('/<int(min=0, max=23):hours>/<int(min=0, max=59):minutes>') @app.route('/<int(min=0, max=23):hours>/<int(min=0, max=59):minutes>')
def index(hours=None, minutes=None): def index(hours=None, minutes=None):
""" main and only app """ """ main and only app """
if not hours:
if hours:
if not minutes:
minutes = 0
else:
hours = 17 hours = 17
if not minutes: minutes = 30
minutes = 0
data = render_template('beer.html', hours=hours, minutes=minutes) data = render_template('beer.html', hours=hours, minutes=minutes)
return data return data
@app.route('/favicon.ico')
def default_favicon():
""" serve default favicon """
return send_from_directory('static', 'clock-icon.png')
@app.route('/favicon/<mode>')
def favicon(mode):
""" serve the favicon according to the timer """
if mode == 'beer':
filename = 'beer-icon.png'
else:
filename = 'clock-icon.png'
return send_from_directory('static', filename)
def main(): def main():
""" main func """ """ main func """

BIN
beer/static/beer-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
beer/static/clock-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -32,20 +32,23 @@
<p id="demo"></p> <p id="demo"></p>
<script> <script>
(function() {
var blinks = document.getElementsByTagName('blink');
var visibility = 'hidden';
window.setInterval(function() {
for (var i = blinks.length - 1; i >= 0; i--) {
blinks[i].style.visibility = visibility;
}
visibility = (visibility === 'visible') ? 'hidden' : 'visible';
}, 250);
})();
</script>
<script>
// Update the count down every 1 second
const changeFavicon = link => {
let $favicon = document.querySelector('link[rel="icon"]')
// If a <link rel="icon"> element already exists,
// change its href to the given link.
if ($favicon !== null) {
$favicon.href = link
// Otherwise, create a new element and append it to <head>.
} else {
$favicon = document.createElement("link")
$favicon.rel = "icon"
$favicon.href = link
document.head.appendChild($favicon)
}
}
// Update the count down every 1 second
var x = setInterval(function() { var x = setInterval(function() {
// Get today's date and time // Get today's date and time
@ -69,7 +72,8 @@ var x = setInterval(function() {
// If the count down is finished, write some text // If the count down is finished, write some text
if (distance < 0) { if (distance < 0) {
clearInterval(x); clearInterval(x);
document.getElementById("demo").innerHTML = "<blink>BEER TIME !</blink>"; document.getElementById("demo").innerHTML = '<span class="blink">BEER TIME !</span>';
changeFavicon('/favicon/beer')
} }
}, 1000); }, 1000);
</script> </script>

View file

@ -3,20 +3,34 @@ if [ ${BRANCH} == 'master' ]; then
else else
TEST_URL='http://staging.beer.k3s.kleph.eu' TEST_URL='http://staging.beer.k3s.kleph.eu'
fi fi
echo "testing URL: ${TEST_URL}"
while :
do
status_code=$(curl -o /dev/null -s -w '%{http_code}' ${TEST_URL})
echo "status code: ${status_code}"
[[ ${status_code} -eq 200 ]] && break
[[ ${i} -gt 5 ]] && exit 1
echo "service not ready or in error"
sleep 5
i=$(( i+1 ))
done
CURL_OPTS='-s' CURL_OPTS='-s'
# default # default
curl ${CURL_OPTS} ${TEST_URL} | grep -q 'setHours( 17, 0);' curl ${CURL_OPTS} ${TEST_URL} | grep -q 'setHours( 17, 30);'
[ $? -ne 0 ] && exit 1 [ $? -ne 0 ] && echo "Failed with default" && exit 1
# set 1 parameter # set 1 parameter
hours=18 hours=18
curl ${CURL_OPTS} ${TEST_URL}/${hours} | grep -q "setHours( ${hours}, 0);" curl ${CURL_OPTS} ${TEST_URL}/${hours} | grep -q "setHours( ${hours}, 0);"
[ $? -ne 0 ] && exit 1 [ $? -ne 0 ] && echo "Failed with 1 parameter set" && exit 1
# set 2 parameters # set 2 parameters
minutes=30 minutes=30
curl ${CURL_OPTS} ${TEST_URL}/${hours}/${minutes} | grep -q "setHours( ${hours}, ${minutes});" curl ${CURL_OPTS} ${TEST_URL}/${hours}/${minutes} | grep -q "setHours( ${hours}, ${minutes});"
[ $? -ne 0 ] && exit 1 [ $? -ne 0 ] && echo "Failed with 2 parameters set" && exit 1
echo "OK"
exit 0 exit 0