From 665c3b30d41cf1309dbd8d138b8244e6d613f27e Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 18 Mar 2015 21:30:45 +0000 Subject: update deployment path on demeter --- deploy.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy.sh b/deploy.sh index 6b7962d..4420a8f 100755 --- a/deploy.sh +++ b/deploy.sh @@ -6,8 +6,8 @@ # 1. choose where to deploy -live="$HOME/html/sariul" -devel="$HOME/html/sariul-devel" +live="$HOME/html/sariul/cgi-bin" +devel="$HOME/html/sariul-devel/cgi-bin" if [ "$1" = "live" ]; then dest="$live" -- cgit v1.2.3 From 3685396f3b915302c194a441d626c67554615ec5 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 18 Mar 2015 21:30:51 +0000 Subject: deployment script creates dummy password file to avoid error --- deploy.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deploy.sh b/deploy.sh index 4420a8f..c967121 100755 --- a/deploy.sh +++ b/deploy.sh @@ -45,6 +45,10 @@ cp -RL ../schoolclock/sounds $dest cd $HOME # mkhomepg -p mkdir -p $dest/data +if ! [ -e "$dest/password" ]; then + echo "dummy_password" > $dest/password + echo "Please update password in $dest/password!" +fi chmod 777 $dest/data chmod 755 $dest/sariulclocks.cgi -- cgit v1.2.3 From bb9d542481dba42795d16fe7572b687611b81600 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 18 Mar 2015 21:31:04 +0000 Subject: TODO --- src/sariulclocks.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sariulclocks.hs b/src/sariulclocks.hs index 74ae00c..137e1bd 100644 --- a/src/sariulclocks.hs +++ b/src/sariulclocks.hs @@ -164,6 +164,9 @@ cgiMain = do -- TODO: use POST,REDIRECT,GET https://stackoverflow.com/questions/570015/how-do-i-reload-a-page-without-a-postdata-warning-in-javascript/570069#570069 + + -- TODO: restore time wasting clock if password was wrong + let scores' = if points' /= 0 && userPassword == (unpack . strip . pack) password then updateScore scores (fromJust cookieClass) points' timeWasted' -- cgit v1.2.3 From af365f6c6eb27f8e3680afca52aa70550e992f6f Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 18 Mar 2015 21:31:13 +0000 Subject: reset time wasting clock at start of lesson, not end Otherwise if the user inputs a wrong password the time wasted will get wiped out before it's submitted. This is a hack: should probably use a cookie to keep the time safe in between server connections. --- assets/js/main.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/assets/js/main.js b/assets/js/main.js index 1586c5c..5ab3902 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -89,6 +89,9 @@ function startLesson() // set the cookie and reload to start the session createCookie("class_cookie", cookieString, 1); + // reset clock because it's currently dangerous to do so when + // ending a lesson + timeWastingClock.reset(); // reload, preventing Firefox from resubmitting POST data window.location.assign(document.URL.split("#")[0]); } @@ -124,7 +127,9 @@ function endLesson() // submit timeWastingClock.stop(); - timeWastingClock.reset(); + // dangerous to reset clock here in case user inputs wrong + // password: instead reset when *starting* a class + // timeWastingClock.reset(); $form.submit(); } -- cgit v1.2.3 From 740abe29157f9afbfc1b83cf29945960dfe4fd6b Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 18 Mar 2015 23:53:35 +0000 Subject: fix: cookie paths --- assets/js/main.js | 3 ++- src/Types/Session.hs | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index 5ab3902..f4d5af2 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -46,7 +46,8 @@ function createCookie(name,value,days) { var expires = "; expires="+date.toGMTString(); } else var expires = ""; - document.cookie = name+"="+value+expires+"; path=/"; + // TODO: make this not absolute + document.cookie = name+"="+value+expires+"; path=/sariul/cgi-bin"; } function readCookie(name) { diff --git a/src/Types/Session.hs b/src/Types/Session.hs index 5d037a4..210cd28 100644 --- a/src/Types/Session.hs +++ b/src/Types/Session.hs @@ -26,7 +26,7 @@ makeClassCookie now session = Nothing -> "Nothing" , cookieExpires = Just $ endOfSchoolDay now , cookieDomain = Nothing - , cookiePath = Nothing + , cookiePath = Just "/sariul/cgi-bin" , cookieSecure = False} makeClockCookie :: ClockTime -> Session -> Cookie @@ -38,7 +38,7 @@ makeClockCookie now session = CountUpClock -> "1" , cookieExpires = Just $ endOfSchoolDay now , cookieDomain = Nothing - , cookiePath = Nothing + , cookiePath = Just "/sariul/cgi-bin" , cookieSecure = False} makeSsCookie :: ClockTime -> Session -> Cookie @@ -50,7 +50,8 @@ makeSsCookie now session = Just c -> show $ numberOfSs c , cookieExpires = Just $ endOfSchoolDay now , cookieDomain = Nothing - , cookiePath = Nothing +-- make the cookie path not absolute + , cookiePath = Just "/sariul/cgi-bin" , cookieSecure = False} endOfSchoolDay :: ClockTime -> CalendarTime -- cgit v1.2.3