예제 #1
0
<a href="../">Plugin list</a>

<h1>%(plugin)s</h1>

<p>%(description)s</p>

<table>
    <tr>
        <th>Command</th>
        <th>Help</th>
    </tr>
%(table)s
</table>"""),
        }

httpserver.set_default_templates(DEFAULT_TEMPLATES)

class WebDocServerCallback(httpserver.SupyHTTPServerCallback):
    def __init__(self, plugin, irc):
        super(WebDocServerCallback, self).__init__()
        self._irc = irc
        self._plugin = plugin
    name = 'WebDoc'
    def doGet(self, handler, path):
        splitted_path = path.split('/')
        if len(splitted_path) == 2:
            names = filter(lambda x: conf.supybot.plugins.get(x).public(),
                    map(lambda cb:cb.name(), self._irc.callbacks))
            plugins = ''.join(map(lambda x:'<li><a href="%s/">%s</a></li>'%(x,x),
                sorted(names)))
            response = 200
예제 #2
0
    </form>
</body>""",
        'factoids/channel.html': PAGE_SKELETON % """\
<body class="puretable">
    <h1>Factoids of %(channel)s</h1>
    <table>
        <tr class="header">
            <th class="key">""" + _('key') + """</th>
            <th class="id">""" + _('id') + """</th>
            <th class="fact">""" + _('fact') + """</th>
        </tr>
        %(rows)s
    </table>
</body>"""
}
httpserver.set_default_templates(DEFAULT_TEMPLATES)

class FactoidsCallback(httpserver.SupyHTTPServerCallback):
    name = 'Factoids web interface'

    def doGetOrHead(self, handler, path, write_content):
        parts = path.split('/')[1:]
        if path == '/':
            self.send_response(200)
            self.send_header('Content-type', 'text/html; charset=utf-8')
            self.end_headers()
            self.write(httpserver.get_template('factoids/index.html'))
        elif len(parts) == 2:
            channel = utils.web.urlunquote(parts[0])
            if not ircutils.isChannel(channel):
                self.send_response(404)