paul@69 | 1 | #!/usr/bin/env python |
paul@69 | 2 | |
paul@146 | 3 | """ |
paul@146 | 4 | A Web interface to a user's calendar. |
paul@146 | 5 | |
paul@146 | 6 | Copyright (C) 2014, 2015 Paul Boddie <paul@boddie.org.uk> |
paul@146 | 7 | |
paul@146 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@146 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@146 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@146 | 11 | version. |
paul@146 | 12 | |
paul@146 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@146 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@146 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@146 | 16 | details. |
paul@146 | 17 | |
paul@146 | 18 | You should have received a copy of the GNU General Public License along with |
paul@146 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@146 | 20 | """ |
paul@146 | 21 | |
paul@146 | 22 | # Edit this path to refer to the location of the imiptools libraries, if |
paul@146 | 23 | # necessary. |
paul@146 | 24 | |
paul@146 | 25 | LIBRARY_PATH = "/var/lib/imip-agent" |
paul@146 | 26 | |
paul@440 | 27 | import sys |
paul@146 | 28 | sys.path.append(LIBRARY_PATH) |
paul@69 | 29 | |
paul@446 | 30 | from imipweb.calendar import CalendarPage |
paul@446 | 31 | from imipweb.event import EventPage |
paul@756 | 32 | from imipweb.resource import ResourceClient |
paul@69 | 33 | |
paul@756 | 34 | class Manager(ResourceClient): |
paul@69 | 35 | |
paul@69 | 36 | "A simple manager application." |
paul@69 | 37 | |
paul@69 | 38 | def select_action(self): |
paul@69 | 39 | |
paul@69 | 40 | "Select the desired action and show the result." |
paul@69 | 41 | |
paul@121 | 42 | path_info = self.env.get_path_info().strip("/") |
paul@121 | 43 | |
paul@69 | 44 | if not path_info: |
paul@446 | 45 | CalendarPage(self).show() |
paul@446 | 46 | elif EventPage(self).show(path_info): |
paul@70 | 47 | pass |
paul@70 | 48 | else: |
paul@70 | 49 | self.no_page() |
paul@69 | 50 | |
paul@82 | 51 | def __call__(self): |
paul@69 | 52 | |
paul@69 | 53 | "Interpret a request and show an appropriate response." |
paul@69 | 54 | |
paul@69 | 55 | if not self.user: |
paul@69 | 56 | self.no_user() |
paul@69 | 57 | else: |
paul@69 | 58 | self.select_action() |
paul@69 | 59 | |
paul@70 | 60 | # Write the headers and actual content. |
paul@70 | 61 | |
paul@69 | 62 | print >>self.out, "Content-Type: text/html; charset=%s" % self.encoding |
paul@69 | 63 | print >>self.out |
paul@69 | 64 | self.out.write(unicode(self.page).encode(self.encoding)) |
paul@69 | 65 | |
paul@69 | 66 | if __name__ == "__main__": |
paul@128 | 67 | Manager()() |
paul@69 | 68 | |
paul@69 | 69 | # vim: tabstop=4 expandtab shiftwidth=4 |