Commits

Anonymous committed 90b8554

html5 compliance.

Comments (0)

Files changed (19)

couchit/_design/page/by_slug/map.js

 function (doc) {
     if (doc.itemType == 'page') {
-        emit([doc.site, doc.toLowerCase().title.replace(/ /g, "_")], doc);
+        emit([doc.site, doc.title.toLowerCase().replace(/ /g, "_")], doc);
     }
 }

couchit/_design/site/alias/map.js

 function(doc) {
   if (doc.itemType && doc.itemType == 'site')
-    for (var i=0; i< doc.alias.length; i++)
-       emit(doc.alias[i], doc);
+       emit(doc.alias, doc);
 }
 
 from couchdb.client import ResourceNotFound
 from couchit.models import Site, Page
-from couchit.utils import utf8
+from couchit.utils import utf8, make_hash
 from couchit.utils.diff import diff_blocks
 
 
 __all__ = ['get_site', 'get_page', 'get_pageof',
-'all_pages', 'get_diff', 'LEXERS_CHOICE', 'get_changes']
+'all_pages', 'get_diff', 'LEXERS_CHOICE', 'get_changes', 
+'validate_password', 'validate_token']
 
 def _get_lexers():
     lexers = get_all_lexers()
         return lrows[0]
     return None
     
+def validate_password(db, siteid, password):
+    rows = Site.view(db, '_view/site/password', key=[siteid, make_hash(password)])
+    lrows = list(iter(rows))
+    if lrows:
+        return True
+    return False
+
+def validate_token(db, siteid, token):
+    rows = Site.view(db, '_view/site/token', key=[token, siteid])
+    lrows = list(iter(rows))
+    if lrows:
+        return True
+    return False
 
 def get_page(db, siteid, name):
     rows = Page.view(db, '_view/page/by_slug', key=[siteid, name.lower()])

couchit/application.py

     
     def dispatch(self, environ, start_response):
         local.request = request = BCRequest(self, environ)
-
-        local.url_adapter = adapter = urls_map.bind_to_environ(environ)
-
         cur_path = [p for p in request.path.split('/') if p]
         
         # test if we are under a subdomain or domain alias
             site_url = ''
         else:
             site_url = "/" + site.cname
-
         local.site_url = site_url
         
         if not subdomain:
                     environ['wsgi.url_scheme'],
                     environ['REQUEST_METHOD'],
                     path_info)
-                    
-
+        else:
+            local.url_adapter = adapter = urls_map.bind_to_environ(environ)
+            
         # process urls
         try:
             endpoint, args = adapter.match()
             response = e
 
         if request.session.should_save:
-            permanent = request.session.get('permanent', True)
+            permanent = request.session.get('permanent', False)
             max_age=None
             expires=None
             if permanent:

couchit/context_processors.py

 
 @register_contextprocessor
 def site_url(request):
-    return { 'site_url': local.site_url }
+    return {
+        'site_url': local.site_url,
+        'current_url': request.url
+    }
 
 @register_contextprocessor
 def authenticated(request):

couchit/models.py

 from couchit.utils import make_hash
 from couchit.utils.diff import unified_diff, diff_blocks
 
-__all__ = ['Page', 'Site']
+__all__ = ['Page', 'Site', 'PasswordToken']
 
 
 class ArrayField(Field):
     from random import choice
     return ''.join([choice(charset) for i in range(8)])
 
+class PasswordToken(Document):
+    site = TextField()
+    itemType = TextField(default='token')
 
 class Site(Document):
     alias = TextField()
                 _changes = []
                 for row in changes:
                     for change in row:
-                        print change
                         _changes.append(change)
                 self.changes = _changes
-                print self.changes
                 db[self.id] = self._data
         return self
 
             return []
         rows = self.view(db, '_view/page/revisions', key=self.id)
         result = list(iter(rows))
-        print result
         if result: # order revisions
             result.sort(lambda a,b: cmp(a.updated, b.updated))
             result.reverse()

couchit/template.py

                 pos = 1
                 for line in change['changed']['lines']:
                     rst = rst + "<tr class=\"%s\"><th class=\"linenos\"></th><th class=\"linenos\">%s</th>\
-                    <th class=\"diffp\">+</th><td class=\"c wrap %s\">%s</td></tr" % (
+                    <th class=\"diffp\">+</th><td class=\"c wrap %s\">%s</td></tr>" % (
                         class_,
                         change['base']['offset'],
                         class_end,
     'site_claim': views.site_claim,
     'proxy': views.proxy,
     'login': views.site_login,
-    'logout': views.site_logout
+    'logout': views.site_logout,
+    'forgot_password': views.site_forgot_password,
+    'change_password': views.site_change_password
 }
 
 
 
 urls_map = Map([
-    Rule('/proxy', endpoint='proxy', ),
-    Rule('/site/design', endpoint='site_design', ),
-    Rule('/site/claim', endpoint='site_claim', ),
-    Rule('/site/settings', endpoint='site_settings', ),
-    Rule('/site/changes', endpoint='site_changes', ),
-    Rule('/site/changes.<feedtype>', endpoint='site_changes', ),
-    Rule('/login', endpoint='login', ),
-    Rule('/logout', endpoint='logout', ),
-    Rule('/<pagename>/revisions.<feedtype>', endpoint='revisions_feed', ),
-    Rule('/<pagename>/revision/<nb_revision>', endpoint='revision_page', ),
-    Rule('/<pagename>/history', endpoint='history_page', ),
-    Rule('/<pagename>/edit', endpoint='edit_page', ),
-    Rule('/<pagename>/diff', endpoint='diff_page', ),
-    Rule('/', defaults={'pagename': 'home' }, endpoint='show_page', ),
-    Rule('/<pagename>', endpoint='show_page', )
+    Rule('/proxy', endpoint='proxy'),
+    Rule('/site/design', endpoint='site_design'),
+    Rule('/site/claim', endpoint='site_claim'),
+    Rule('/site/forgot-password', endpoint='forgot_password'),
+    Rule('/site/change-password', endpoint='change_password'),
+    Rule('/site/settings', endpoint='site_settings'),
+    Rule('/site/changes', endpoint='site_changes'),
+    Rule('/site/changes.<feedtype>', endpoint='site_changes'),
+    Rule('/login', endpoint='login'),
+    Rule('/logout', endpoint='logout'),
+    Rule('/<pagename>/revisions.<feedtype>', endpoint='revisions_feed'),
+    Rule('/<pagename>/revision/<nb_revision>', endpoint='revision_page'),
+    Rule('/<pagename>/history', endpoint='history_page'),
+    Rule('/<pagename>/edit', endpoint='edit_page'),
+    Rule('/<pagename>/diff', endpoint='diff_page'),
+    Rule('/', defaults={'pagename': 'home' }, endpoint='show_page'),
+    Rule('/<pagename>', endpoint='show_page')
 ])
 

couchit/utils/mail.py

 #
 # Copyright (c) 2008 Django Software Foundation and individual contributors.
 #
-# adapted for couchit waiting an easier system
+# adapted for couchit waiting an easier/better system
 """
 Tools for sending email.
 """
 from werkzeug.routing import NotFound
 from werkzeug.utils import url_unquote
 from couchit import settings
-from couchit.models import Site, Page
+from couchit.models import Site, Page, PasswordToken
 from couchit.api import *
 from couchit.http import BCResponse
 from couchit.template import render_response, url_for, render_template, send_json
 
 re_page = re.compile(r'^[- \w]+$', re.U)
 
+def not_logged(f):
+    def decorated(request, **kwargs):
+        authenticated = request.session.get('%s_authenticated' % request.site.cname, False)
+        if authenticated:
+            redirect_url = local.site_url and local.site_url or "/"
+            return redirect(redirect_url)
+        return f(request, **kwargs)
+    return decorated
+        
 def not_found(request):
     return render_response("not_found.html")
 
 def show_page(request=None, pagename=None):
     if pagename is None:
         pagename ='home'
+        
     page = get_page(local.db, request.site.id, pagename)
     if not page or page.id is None or not re_page.match(pagename):
         if pagename.lower() in FORBIDDEN_PAGES:
     
 
 def site_settings(request):
-    return render_response('site/settings.html', site=request.site)
+    # get all pages
+    pages = all_pages(local.db, request.site.id)
+    return render_response('site/settings.html', pages=pages)
 
-    
+@not_logged    
 def site_login(request):
-    pass
+    back=request.values.get('back', '')
+    error = None
+    notify = request.session.get('notify', '')
+    if notify:
+        del request.session['notify']
+    if request.method == "POST":
+        if validate_password(local.db, request.site.id, request.form['password']):
+            request.session['%s_authenticated' % request.site.cname] = True
+            if request.form['remember']:
+                request.session['permanent'] = True
+            back = request.form['back']
+            redirect_url = back and back or '/'
+            return redirect(redirect_url)
+        else:
+            error = u'Password is invalid.'
+    return render_response('site/login.html', back=back, error=error, notify=notify)
     
 
 def site_logout(request):
     else:
         redirect_url = '/'
     return redirect(redirect_url)
-    
+
+@not_logged
+def site_change_password(request):
+    error = None
+    token = request.values.get('t', None)
+    invalid_token = False
+    if request.method == 'GET':
+        if token is None or not validate_token(local.db, request.site.id, token):
+            error = u"Invalid token. Please verify url in your mail."
+            invalid_token = True
+    if request.method == 'POST':
+        token = request.form.get('token', '')
+        password = request.form.get('password')
+        if not validate_token(local.db, request.site.id, token):
+            error = u"Invalid token. Please verify url in your mail."
+            invalid_token = True
+        else:
+            if password:
+                site = get_site(local.db, request.site.cname)
+                site.password = make_hash(request.form['password'])
+                site.store(local.db)
+            
+                # delete token
+                del local.db[token]
+            
+                request.session['%s_authenticated' % request.site.cname] = True
+                request.site = site
+                if local.site_url:
+                    redirect_url = local.site_url
+                else:
+                    redirect_url = '/'
+            
+                return redirect(redirect_url)
+            else:
+                error=u'Password is empty.'
+    return render_response('site/change_password.html', token=token, 
+                error=error, invalid_token=invalid_token)
+
+@not_logged    
+def site_forgot_password(request):
+    back=request.values.get('back', '')
+    if request.method == 'POST':
+        back = request.form['back']
+        
+        # create token
+        otoken = PasswordToken(site=request.site.id)
+        otoken.store(local.db)
+        
+        if request.site.alias:
+            site_url = "http://%s.%s" % (request.site.alias, settings.SERVER_NAME)
+        else:
+            site_url = "http://%s/%s" % (settings.SERVER_NAME, request.site.cname)
+        
+        # send email
+        mail_subject = u"Password to your couchit site"
+        mail_content = render_template('site/forgot_password.txt', url=site_url, token=otoken.id)
+        send_mail(mail_subject, mail_content, "CouchIt <feedback@couch.it>", 
+            [request.site.email], fail_silently=True)
+            
+        request.session['notify'] = u"We've sent out the secret link. Go check your email!"
+        redirect_url = url_for('login', back=back)
+        return redirect(redirect_url)
+        
+    return render_response('site/forgot_password.html', back=back)
 
 def site_design(request):
     DEFAULT_COLORS = dict(
             "Content-Type": os.environ["CONTENT_TYPE"],
             "Accept": os.environ["ACCEPT"]
         }
-        print headers
         body = input_stream.read()
         r = urllib2.Request(url, body, headers)
         y = urllib2.urlopen(r)
             "Content-Type": request.environ["CONTENT_TYPE"],
             "Accept": request.environ["HTTP_ACCEPT"]
         }
-        print request.environ
         r = urllib2.Request(url, headers=headers)
         y = urllib2.urlopen(r)
         

static/css/src/layout.css

 
 #phistory, 
 #pdiff,
-#pdesign {
+#pdesign,
+#psettings {
     display: block;
     padding: 10px;
     border: 4px solid;
 
 div.help_error { display: block; font-weight: bold; font-size: 83%; width: 100%; position: relative; }
 
+p.notify, p.errors {
+    padding: .8em; margin-bottom: 1em; border: 2px solid #ddd;
+}
+
 /* claim */
 
 .claim, .logout { 

static/css/src/slate.css

 #phistory,
 #pdiff,
 #pdesign,
-#claim_wrapper {
+#claim_wrapper,
+#psettings {
     background-color: #fff;
     border-color: #d4d4d4;
     color: #000;
     border: #ff0000;
 }
 
+p.notice {
+     background: #FFF6BF; color: #514721; border-color: #FFD324;
+}

static/css/src/typography.css

     text-align: center;
 }
 
-.claim {
+.claim, .logout, .login {
     font-weight: bold;
     text-decoration: none;
 }

templates/base.html

 <!DOCTYPE html>
 
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<html lang="en">
 
 <head>
     <meta charset="utf-8" />
     <title>couchit - {% block title %}{% endblock %}</title>
     {% if DEBUG %}
     <link rel="stylesheet" href="/static/css/src/debug.css" type="text/css" />
-    <link rel="stylesheet" type="text/css" href="/static/css/src/textarea.css">
+    <link rel="stylesheet" type="text/css" href="/static/css/src/textarea.css" />
     <script src="/static/js/lib/prototype.js" type="text/javascript"></script>
     <script src="/static/js/lib/effects.js" type="text/javascript"></script>
     <script src="/static/js/lib/dragdrop.js" type="text/javascript"></script>
     <script src="/static/js/lib/slider.js" type="text/javascript"></script>
     <script src="/static/js/src/application.js" type="text/javascript"></script>
     {% else %}
-    <link rel="stylesheet" href="/static/css/screen.css" type="text/css" media="screen, projection">
-    <link rel="stylesheet" href="/static/css/theme.css" type="text/css" media="screen, projection">
-    <link rel="stylesheet" href="/static/css/print.css" type="text/css" media="print"> 
+    <link rel="stylesheet" href="/static/css/screen.css" type="text/css" media="screen, projection" />
+    <link rel="stylesheet" href="/static/css/theme.css" type="text/css" media="screen, projection" />
+    <link rel="stylesheet" href="/static/css/print.css" type="text/css" media="print" /> 
     <!--[if IE]>
-      <link rel="stylesheet" href="/static/css/ie.css" type="text/css" media="screen, projection">
+      <link rel="stylesheet" href="/static/css/ie.css" type="text/css" media="screen, projection" />
     <![endif]-->
     <script src="/static/js/couchit.js" type="text/javascript"></script>
     {% endif %}
 body{background-color:#{{ site.theme.background_color }};color:#{{ site.theme.text_color }};}
 a{color:#{{ site.theme.link_color }};}
 #page article, #pedit #pedit_wrapper{background-color:#{{ site.theme.page_fill_color }};border-right-color:#{{ site.theme.border_color }};border-left-color:#{{ site.theme.border_color }};border-bottom-color:#{{ site.theme.border_color }};color:#{{ site.theme.page_text_color }};}
-#phistory,#pdiff,#pdesign,#pedit,#claim_wrapper{background-color:#{{ site.theme.page_fill_color }};border-color:#{{ site.theme.border_color }};color:#{{ site.theme.page_text_color }};}
-#phistory,#pdiff,#pdesign,#page,#claim_wrapper{color:#{{ site.theme.page_text_color }};}
-#phistory a, #pdiff a, #pdesign a, #page a{color:#{{ site.theme.page_link_color }};}
+#phistory,#pdiff,#pdesign,#pedit,#claim_wrapper,#psettings{background-color:#{{ site.theme.page_fill_color }};border-color:#{{ site.theme.border_color }};color:#{{ site.theme.page_text_color }};}
+#phistory,#pdiff,#pdesign,#page,#claim_wrapper,#psettings{color:#{{ site.theme.page_text_color }};}
+#phistory a, #pdiff a, #pdesign a, #page a, #psettings a{color:#{{ site.theme.page_link_color }};}
 ul.subsection_tabs{background-color:#{{ site.theme.border_color }};}
 ul.subsection_tabs li.tab a, ul.subsection_tabs li.tab a:visited{color:#{{ site.theme.menu_inactive_color }};}
 .box{background-color:#{{ site.theme.page_fill_color }};}
         {% if authenticated %}
             <a href="{{ url_for('logout') }}" class="logout">logout</a>
         {% else %}
-        <a href="{{ url_for('login') }}" class="logout">login</a>
+        <a href="{{ url_for('login') }}?back={{ current_url }}" class="logout">login</a>
         {% endif %}
      
         {% else %}
     {% endif %}
     
     <div id="container">
+        <header>
+            <h1></h1>
+            <h2></h2>
+        </header>
         
         <div id="page_wrapper">
             {% block fullpage %}
         </div>
         
         <footer class="footer_wrapper">
-            {% block footer %}{% endblock %}
+           
             <p>Powered by <a href="http://couch.it">CouchIt</a></p>
         </footer>
         
+         {% block footer %}{% endblock %}
+        
     </div>
 </body>
 </html>

templates/page/history.html

 {% extends "base.html" %}
 {% block title %}Revision history of {{ page.title }}{% endblock %}
 {% block head %}
-    <link rel="alternate" type="application/atom+xml" href="{{ url_for('revisions_feed', cname=site.cname, pagename=page.title|replace(" ", "_"), feedtype='atom') }}" title="Atom Revisions Feed" />
+    <link rel="alternate" type="application/atom+xml" href="{{ url_for('revisions_feed', pagename=page.title|replace(" ", "_"), feedtype='atom') }}" title="Atom Revisions Feed" />
 {% endblock %}
 {% block page %}
 <section id="phistory">
-    <h2>Revision history of <a href="{{ url_for('show_page', cname=site.cname, pagename=page.title|replace(" ", "_")) }}">{{ page.title }}</a></h2>
+    <h2>Revision history of <a href="{{ url_for('show_page', pagename=page.title|replace(' ', '_')) }}">{{ page.title }}</a></h2>
 
-    <form id="fhistory" name="fhistory" method="get" action="{{ url_for('diff_page', cname=site.cname, pagename=page.title|replace(" ", "_")) }}">
-        <p><input type="submit" class="fhistory" name"fhistory" value="Compare selected version" /></p>
+    <form id="fhistory" name="fhistory" method="get" action="{{ url_for('diff_page', pagename=page.title|replace(' ', '_')) }}">
+        <p><input type="submit" class="shistory" name="shistory" value="Compare selected version" /></p>
         <table class="historyTable">
             <tr>
-                <td><input type="checkbox" class="c" name="r" value="{{ page.nb_revision }}"></td>
-                <td class="nbrev"><a href="{{ url_for('revision_page', cname=site.cname, pagename=page.title|replace(" ", "_"), nb_revision=page.nb_revision ) }}">{{ page.nb_revision }}</a></td>
+                <td><input type="checkbox" class="c" name="r" value="{{ page.nb_revision }}" /></td>
+                <td class="nbrev"><a href="{{ url_for('revision_page', pagename=page.title|replace(" ", "_"), nb_revision=page.nb_revision) }}">{{ page.nb_revision }}</a></td>
                 <td><time title="GMT" datetime="{{ page.updated|rfc3339 }}">{{ page.updated|formatdatetime }}</time></td>
                 <td class="changes">
                     {% if page.changes %}
                     <ol>
                         {% for change in page.changes %}
                         {% if change['type'] != 'unmod' %}
-                        <li>{{ change['type']|pretty_type }} "<span class="lineChange">{{ change['changed']['lines']|join('\n')|trim|striptags|truncate(40) }}"</li> 
+                        <li>{{ change['type']|pretty_type }} <span class="lineChange">&quot;{{ change['changed']['lines']|join('\n')|trim|striptags|truncate(40) }}&quot;</span></li> 
                         {% endif %}  
                         {% endfor %}
                     </ol>
             </tr>
             {% for rev in revisions %}
             <tr>
-                <td><input type="checkbox"  class="c" name="r" value="{{ rev.nb_revision }}"></td>
-                <td class="nbrev"><a href="{{ url_for('revision_page', cname=site.cname, pagename=rev.title|replace(" ", "_"), nb_revision=rev.nb_revision ) }}">{{ rev.nb_revision }}</a></td>
+                <td><input type="checkbox"  class="c" name="r" value="{{ rev.nb_revision }}" /></td>
+                <td class="nbrev"><a href="{{ url_for('revision_page', pagename=rev.title|replace(" ", "_"), nb_revision=rev.nb_revision ) }}">{{ rev.nb_revision }}</a></td>
                 <td><time title="GMT" datetime="{{ rev.updated|rfc3339 }}">{{ rev.updated|formatdatetime }}</time></td>
                 <td class="changes">
                     {% if rev.changes %}
                     <ol>
                         {% for change in rev.changes %}
                             {% if change['type'] != 'unmod' %}
-                        <li>{{ change['type']|pretty_type }} "<span class="lineChange">{{ change['changed']['lines']|join('\n')|trim|striptags|truncate(40) }}"</li> 
+                        <li>{{ change['type']|pretty_type }} <span class="lineChange">&quot;{{ change['changed']['lines']|join('\n')|trim|striptags|truncate(40) }}&quot;</span></li> 
                             {% endif %}  
                         {% endfor %}
                     </ol>
 
             {% endfor %}    
         </table>
-        <p><input type="submit" class="fhistory" name"fhistory" value="Compare selected version" /></p>
+        <p><input type="submit" class="shistory" name="shistory" value="Compare selected version" /></p>
     </form>
 </section>
 {% endblock %}
 
 {% block footer %}
-<script type="text/javascript" charset="utf-8">
+<script type="text/javascript">
     Site.name = "{{ site.cname }}";
     Site.url = "{{ site_url }}"
     new Create();

templates/page/show.html

 <script src="/static/js/lib/textarea.js" type="text/javascript"></script>
 <script src="/static/js/lib/window.js" type="text/javascript"></script>
 <script src="/static/js/lib/showdown.js" type="text/javascript"></script>
-<script src="/static/js/src/page.js" type="text/javascript" charset="utf-8"></script>
+<script src="/static/js/src/page.js" type="text/javascript"></script>
 {% else %}
 <script src="/static/js/couchit-page.js" type="text/javascript"></script>
 {% endif %}
 
 
 {% block footer %}
-    <script type="text/javascript" charset="utf-8">
-        Site.name = "{{ site.cname }}";
-        Site.url = "{{ site_url }}";
-        {% if not page.id %}
-        Page.created = true;
-        {% endif %}
-        new Create();
-        new PageUI();
-    </script>
+<script type="text/javascript">
+Site.name = "{{ site.cname }}";
+Site.url = "{{ site_url }}";
+{% if not page.id %}
+Page.created = true;
+{% endif %}
+new Create();
+new PageUI();
+</script>
 {% endblock %}

templates/site/changes.html

                     <ol>
                         {% for change in page.changes %}
                             {% if change['type'] != 'unmod' %}
-                        <li>{{ change['type']|pretty_type }} "<span class="lineChange">{{ change['changed']['lines']|join('\n')|trim|striptags|truncate(40) }}"</li> 
+                        <li>{{ change['type']|pretty_type }} <span class="lineChange">&quot;{{ change['changed']['lines']|join('\n')|trim|striptags|truncate(40) }}&quot;</span></li> 
                             {% endif %}  
                         {% endfor %}
                     </ol>
                     <span class="created">Created page.</span>
                         {% endif %}
                     {% endif %}
-
-
                 </td>
             </tr>
         {% endfor %}
 {% endblock %}
 
 {% block footer %}
-<script type="text/javascript" charset="utf-8">
+<script type="text/javascript">
     Site.name = "{{ site.cname }}";
-    Site.url = "/" + "{{ site.cname }}"
+    Site.url = "/" + "{{ site.cname }}";
     new Create();
 </script>
 {% endblock %}

templates/site/design.html

 {% endblock %}
 
 {% block footer %}
-    <script type="text/javascript" charset="utf-8">
+    <script type="text/javascript">
         Site.name = "{{ site.cname }}";
         Site.url = "{{ site_url }}";
         new Create();

templates/site/settings.html

 
 
 {% block page %}
-<form name="fsettings" id="fsettings" action="{{ url_for('site_settings', cname=site.cname) }}" method="post">
-    <h2>Settings</h2>
-    <table class="">
-        <tr>
-            <th>Title</th>
-            <td><input type="text" name="title" id="title" value="{{ site.title }}" /></td>
-        </tr>
-        <tr>
-            <th>Subtitle</th>
-            <td><input type="text" name="subtitle" id="subtitle" value="{{ subtitle }}" /></td>
-        </tr>
-        {% if site.password %}
+<section id="psettings">
+    <form name="fsettings" id="fsettings" action="{{ url_for('site_settings') }}" method="post">
+        <h2>Settings</h2>
+        <table class="">
+            <tr>
+                <th>Title</th>
+                <td><input type="text" name="site_title" id="site_title" value="{{ site.title }}" /></td>
+            </tr>
+            <tr>
+                <th>Subtitle</th>
+                <td><input type="text" name="site_subtitle" id="site_subtitle" value="{{ subtitle }}" /></td>
+            </tr>
+            {% if site.claimed %}
+                <tr>
+                    <th>Password</th>
+                    <td><a href="{{ site_url }}/site/change-password">Change password</a></td>
+                    
+                </tr>
+                <tr>
+                    <th>Email address:</th>
+                    <td><input type="email" name="email" id="email" value="" /></td>
+                </tr>
+            {% endif %}
             
-        {% endif %}
-        <tr>
-            <th>Site password:</th>
-            <td><input type="password" name="password" id="password" value="{{ password }}" /></td>
-        </tr>
-        <tr>
-            <th>Email address:</th>
-            <td><input type="email" name="email" id="email" value="" /></td>
-        </tr>
-        <tr>
-            <th>Kind of site:</th>
-            <td>
-                <table class="privacy">
-                    <tr>
-                        <td class="first-row"><input type="radio" name="privacy" value="private"{% if site.privacy == "private" %} checked="checked"{% endif %} /></td>
-                        <td class="first-row">Private</td>
-                        <td class="wrap first-row">Require password to view and edit site.</td>
-                    </tr>
-                    <tr>
-                        <td><input type="radio" name="privacy" value="public"{% if site.privacy == "public" %} checked="checked"{% endif %} /></td>
-                        <td>Public</td>
-                        <td class="wrap">Require password to edit site.</td>
-                    </tr>
-                    <tr>
-                        <td><input type="radio" name="privacy" value="open"{% if site.privacy == "open" %} checked="checked"{% endif %} /></td>
-                        <td>Open</td>
-                        <td class="wrap">Everyone can view and edit.</td>
-                    </tr>
-                </table>
-            </td>
-        </tr>
-    </table>
-    <p><input type="submit" id="ssettings" name="ssettings" value="Claim site"> or <a href="" />Cancel</a></p>
-</form>
+            <tr>
+                <th>Kind of site:</th>
+                <td>
+                    <table class="privacy">
+                        <tr>
+                            <td class="first-row"><input type="radio" name="privacy" value="private"{% if site.privacy == "private" %} checked="checked"{% endif %} /></td>
+                            <td class="first-row">Private</td>
+                            <td class="wrap first-row">Require password to view and edit site.</td>
+                        </tr>
+                        <tr>
+                            <td><input type="radio" name="privacy" value="public"{% if site.privacy == "public" %} checked="checked"{% endif %} /></td>
+                            <td>Public</td>
+                            <td class="wrap">Require password to edit site.</td>
+                        </tr>
+                        <tr>
+                            <td><input type="radio" name="privacy" value="open"{% if site.privacy == "open" %} checked="checked"{% endif %} /></td>
+                            <td>Open</td>
+                            <td class="wrap">Everyone can view and edit.</td>
+                        </tr>
+                    </table>
+                </td>
+            </tr>
+        </table>
+        <p><input type="submit" id="ssettings" name="ssettings" value="Claim site" /> or <a href="{% if site_url %}{{ site_url }}{% else %}/{% endif %}">Cancel</a></p>
+    </form>
+</section>
                        
 {% endblock %}
 
 {% block sidebar %}
-    
+{% include "sidebar.html" %}
+{% endblock %}
+
+{% block footer %}
+<script type="text/javascript">
+    Site.name = "{{ site.cname }}";
+    Site.url = "{{ site_url }}";
+    new Create();
+</script>
 {% endblock %}