mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 01:30:22 +00:00
Add .cgi as an extension for Python and Bash
This commit is contained in:
@@ -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:
|
||||
|
||||
82
samples/Python/action.cgi
Normal file
82
samples/Python/action.cgi
Normal file
@@ -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
|
||||
|
||||
<html><head><title>Alarm reset</title>
|
||||
<link rel="stylesheet" href="{base_url}/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<h1>Alarm reset</h1>
|
||||
<div>
|
||||
<p id="reset">Alarm "<span class="name">{name}</span>" has been reset. You won't be notified for another <span class="duration">{duration}</span>.</p>
|
||||
|
||||
<p>Actions:</p>
|
||||
<ul>
|
||||
<li><a href="{edit_url}?feed={guid}">Edit this reminder</a></li>
|
||||
<li><a href="{edit_url}">Create another reminder</a></li>
|
||||
<li><a href="{base_url}">Visit the Reminder Me site</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="back"><a href=".">Reminder Me</a></p>
|
||||
|
||||
</body></html>'''
|
||||
|
||||
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))
|
||||
|
||||
27
samples/Shell/settime.cgi
Normal file
27
samples/Shell/settime.cgi
Normal file
@@ -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 "<html><body>"
|
||||
|
||||
echo "<pre> $(killall ems) </pre>"
|
||||
|
||||
|
||||
|
||||
echo "<pre> $(date $month$day$hour$minute$year.$second) </pre>"
|
||||
|
||||
echo "<pre> $(/sbin/hwclock -w>/dev/null & /sbin/reboot) </pre>"
|
||||
|
||||
echo "<pre> $(/sbin/reboot) </pre>"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo "</body></html>"
|
||||
Reference in New Issue
Block a user