diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 47616921..a6f0054b 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1841,6 +1841,7 @@ Python: color: "#3581ba" extensions: - .py + - .cgi - .gyp - .lmi - .pyde @@ -2150,6 +2151,7 @@ Shell: - .sh - .bash - .bats + - .cgi - .tmux - .zsh interpreters: diff --git a/samples/Python/action.cgi b/samples/Python/action.cgi new file mode 100644 index 00000000..80630783 --- /dev/null +++ b/samples/Python/action.cgi @@ -0,0 +1,82 @@ +#!/usr/bin/python + +from model import Feed +import session +import datetime +import sys + +argv = session.argv() + +feed = Feed.get(guid=argv[1]) +action = argv[2] + +if action == 'done': + when = feed.notify_interval * feed.notify_unit +elif action == 'snooze': + if len(argv) > 3: + when = int(argv[3]) + else: + when = 3600 +else: + print '''Status: 400 Bad request +Content-type: text/html + +Unknown action %s''' % action + sys.exit(1) + +feed.notify_next = datetime.datetime.utcnow() + datetime.timedelta(seconds=when) +feed.save() + +response = '''Content-type: text/html + +Alarm reset + + + + +
+

Alarm reset

+
+

Alarm "{name}" has been reset. You won't be notified for another {duration}.

+ +

Actions:

+ +
+
+ +

Reminder Me

+ +''' + +when_left = when +duration_list = [] +for (label,period) in [('month',86400*365/12), + ('week',86400*7), + ('day',86400), + ('hour',3600), + ('minute',60), + ('second',1)]: + if when == period: + duration_list = [label] + break + + val = when_left/period + if val: + duration_list.append("%d %s%s" % ( + val, + label, + val > 1 and 's' or '')) + when_left -= val*period + +basedir=session.request_script_dir() + +print response.format(guid=feed.guid, + name=feed.name, + edit_url="%s/edit.cgi" % basedir, + base_url=basedir, + duration=', '.join(duration_list)) + diff --git a/samples/Shell/settime.cgi b/samples/Shell/settime.cgi new file mode 100644 index 00000000..bdff9ec9 --- /dev/null +++ b/samples/Shell/settime.cgi @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Content-type: text/html" +day=`echo "$QUERY_STRING" | sed -n 's/^.*day=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` +month=`echo "$QUERY_STRING" | sed -n 's/^.*month=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` +year=`echo "$QUERY_STRING" | sed -n 's/^.*year=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` +hour=`echo "$QUERY_STRING" | sed -n 's/^.*hour=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` +minute=`echo "$QUERY_STRING" | sed -n 's/^.*minute=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` +second=`echo "$QUERY_STRING" | sed -n 's/^.*second=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` +echo "" +echo "" + +echo "
 $(killall ems) 
" + + + +echo "
 $(date $month$day$hour$minute$year.$second) 
" + +echo "
 $(/sbin/hwclock -w>/dev/null & /sbin/reboot) 
" + +echo "
 $(/sbin/reboot) 
" + + + + + + +echo "" \ No newline at end of file