Commits

Anonymous committed 9ca9cdc

protect some cname.

Comments (0)

Files changed (4)

couchit/application.py

 from couchit import views
 from couchit.template import template_env, url_for
 
+
 class CouchitApp(object):
     def __init__(self):
         local.application = self
             response = redirect('http://%s' % settings.SERVER_NAME)
             return response(environ, start_response)
 
-        if subdomain and subdomain != 'www': # get alias
+        if subdomain and subdomain != 'www' and subdomain not in views.FORBIDDEN_CNAME: # get alias
             request.alias = subdomain
             site = get_site(local.db, subdomain, by_alias=True)
         elif cur_path: # get shortname
 
 FORBIDDEN_PAGES = ['site', 'delete', 'edit', 'create', 'history', 'changes']
 
+FORBIDDEN_CNAME = ['mail', 'www', 'blog', 'news', 'media', 'upload', 'files']
+
 re_page = re.compile(r'^[- \w]+$', re.U)
 re_address = re.compile(r'^[-_\w]+$')
 
                 'ok': False,
                 'error': u"alias is empty or length < 3"
             })
-        elif get_site(local.db, alias, True) and request.site.alias != alias:
+        elif get_site(local.db, alias, True) and request.site.alias != alias or alias in FORBIDDEN_CNAME:
             return send_json({
                 'ok': False,
                 'error':  u"A site with this name has already been registered in couch.it"

static/css/src/layout.css

     
 }
 
-
+span.rename {
+    font-size: 12px;
+    line-height: 18px;
+    vertical-align: middle;
+}
 
 #phistory, 
 #pdiff,

templates/page/show.html

     <article id="post">
         {% if page.title or page.subtitle %}
         <header>
-            <h2>{{ page.title }}</h2>
+            <h2>{{ page.title }} <span class="rename">(<a href="">rename</a>)</span></h2>
             <ul class="page_infos">
                 <li><time title="GMT" datetime="{{ page.updated|rfc3339 }}">{{ page.updated|formatdatetime }}</time></li>
                 {% if page.title != "Home" and can_edit %}