csc-industry

news-update
Jeremy Roman 11 years ago
parent ab539d4c74
commit 2baff0f469
  1. 2
      Makefile
  2. 4
      industry/.htaccess
  3. 3
      industry/Makefile
  4. 42
      industry/archives.cgi
  5. 3
      services/directory.xml

@ -2,7 +2,7 @@ SHELL = umask 002; exec /bin/sh
FILES = events.ics events.atom news.atom index.html stats.html \
favicon.ico default.css csclub.der csclub.pem robots.txt
SUBDIRS = about events office news services media buttons logos flash library
SUBDIRS = about events office news services media buttons logos flash library industry
include common.mk

@ -0,0 +1,4 @@
AddHandler cgi-script .cgi
Options +Indexes +ExecCGI
RewriteEngine On
RewriteRule ^$ /mailman/listinfo/csc-industry [R]

@ -0,0 +1,3 @@
FILES = .htaccess archives.cgi
RELDIR = industry/
include ../common.mk

@ -0,0 +1,42 @@
#!/usr/bin/env python
import os
from md5 import md5
os.umask(0027)
ARCHIVE_LIST = 'csc-industry'
ARCHIVE_MBOX = '/var/lib/mailman/archives/private/%s.mbox/%s.mbox' % (ARCHIVE_LIST, ARCHIVE_LIST)
ARCHIVE_PCK = '/tmp/%s-%s.pck' % (ARCHIVE_LIST, md5(os.path.abspath(__file__)).hexdigest())
try:
mbox_mtime = os.stat(ARCHIVE_MBOX).st_mtime
except:
print 'Content-Type: text/plain\r\n\r\nUnable to stat archive.'
exit()
try:
stat = os.stat(ARCHIVE_PCK)
pickle_mtime = stat.st_mtime
if stat.st_uid != os.getuid():
pickle_mtime = 0
except:
pickle_mtime = 0
import pickle, json
if pickle_mtime < mbox_mtime:
import mailbox
mbox = mailbox.UnixMailbox(open(ARCHIVE_MBOX, 'r'))
messages = []
for msg in mbox:
messages.append({
'subject': msg['subject'],
'date': msg['date'],
'from': msg['from']
})
pck = open(ARCHIVE_PCK, 'w')
pickle.dump(messages, pck)
else:
pck = open(ARCHIVE_PCK, 'r')
messages = pickle.load(pck)
print 'Content-Type: application/json\r\n\r\n' + json.dumps(messages[-3:])

@ -5,5 +5,6 @@
<directory title="Services">
<diritem title="Usage Agreement" href="machine_usage" />
<diritem title="Usage Agreement Summary" href="machine_usage_summary" />
<diritem title="Webmail" href="https://mail.csclub.uwaterloo.ca/" />
<!--diritem title="Webmail" href="https://mail.csclub.uwaterloo.ca/" /-->
<diritem title="csc-industry" href="/industry" />
</directory>

Loading…
Cancel
Save