# Path: tiddlywebplugins/tiddlyspace/cookie_form.py
# FORM_FINISH = """
# <input type="hidden" id="csrf_token" name="csrf_token" />
# <input type="submit" value="submit" />
# </form>
# <script type="text/javascript"
#         src="/bags/tiddlyspace/tiddlers/TiddlySpaceCSRF"></script>
# <script type="text/javascript">
#     var csrfToken = window.getCSRFToken(),
#         el = null;
# 
#     if (csrfToken) {
#         el = document.getElementById('csrf_token');
#         el.value = csrfToken;
#     }
# </script>
# """


import urlparse
from tiddlyweb.web.util import server_host_url, make_cookie
from tiddlywebplugins.openid2 import Challenger as OpenID
from tiddlywebplugins.tiddlyspace.cookie_form import FORM_FINISH
        if not secondary_cookie_only:
            cookie_header_string = make_cookie('tiddlyweb_user', usersign,
                    mac_key=secret, path=self._cookie_path(environ),
                    expires=cookie_age)
            headers.append(('Set-Cookie', cookie_header_string))

        start_response('303 See Other', headers)
        return [uri]

    def _render_form(self, environ, start_response, openid='',
            message='', form=''):
        """
        Send out a CSRF protected form for doing openid login.
        This isn't generally used in TiddlySpace, client side
        interfaces POST their own data.
        """
        redirect = environ['tiddlyweb.query'].get(
            'tiddlyweb_redirect', ['/'])[0]
        start_response('200 OK', [(
            'Content-Type', 'text/html')])
        environ['tiddlyweb.title'] = 'OpenID Login'
        return ["""
<div id='content'>
    <div class='message'>%s</div>
    <pre>
    <form action="" method="POST">
    OpenID: <input name="openid" size="60" value="%s"/>
    <input type="hidden" name="tiddlyweb_redirect" value="%s" />
    %s
    </pre>

# Path: tiddlywebplugins/tiddlyspace/cookie_form.py
# FORM_FINISH = """
# <input type="hidden" id="csrf_token" name="csrf_token" />
# <input type="submit" value="submit" />
# </form>
# <script type="text/javascript"
#         src="/bags/tiddlyspace/tiddlers/TiddlySpaceCSRF"></script>
# <script type="text/javascript">
#     var csrfToken = window.getCSRFToken(),
#         el = null;
# 
#     if (csrfToken) {
#         el = document.getElementById('csrf_token');
#         el.value = csrfToken;
#     }
# </script>
# """


# Path: tiddlywebplugins/tiddlyspace/openid.py
import urlparse
from tiddlyweb.web.util import server_host_url, make_cookie
from tiddlywebplugins.openid2 import Challenger as OpenID
from tiddlywebplugins.tiddlyspace.cookie_form import FORM_FINISH

        if not secondary_cookie_only:
            cookie_header_string = make_cookie('tiddlyweb_user', usersign,
                    mac_key=secret, path=self._cookie_path(environ),
                    expires=cookie_age)
            headers.append(('Set-Cookie', cookie_header_string))

        start_response('303 See Other', headers)
        return [uri]

    def _render_form(self, environ, start_response, openid='',
            message='', form=''):
        """
        Send out a CSRF protected form for doing openid login.
        This isn't generally used in TiddlySpace, client side
        interfaces POST their own data.
        """
        redirect = environ['tiddlyweb.query'].get(
            'tiddlyweb_redirect', ['/'])[0]
        start_response('200 OK', [(
            'Content-Type', 'text/html')])
        environ['tiddlyweb.title'] = 'OpenID Login'
        return ["""
<div id='content'>
    <div class='message'>%s</div>
    <pre>
    <form action="" method="POST">
    OpenID: <input name="openid" size="60" value="%s"/>
    <input type="hidden" name="tiddlyweb_redirect" value="%s" />
    %s
    </pre>

</div>""" % (message, openid, redirect, FORM_FINISH)]