Commits

Matthew Marshall committed aef38c4

Forced the repo name to be lowercase... Added javascript stuff to give a preview of the url.

Comments (0)

Files changed (4)

htdocs/static/style.css

 
 a.showmore {margin-left: 1em; font-size:.8em;}
 
+#url-user.notgiven, #url-repo.notgiven {color:#666;}
+
 fieldset {border:0px;}
     def clean_reponame(self):
         reponame = self.cleaned_data.get('reponame', None)
         if reponame:
+            reponame = reponame.lower()
             if not re.search(r'^\w+$', reponame):
                 msg = (u'Repository names can only contain letters, ' +
                         u'numbers and underscores')

templates/base.html

 <h1><a href="http://freehg.org">FreeHG.org</a></h1>
 
 {% if user.is_authenticated %}
-    You are logged in as <a href="/u/{{user.username}}">{{user.username}}</a>. (<a href="/logout/">Logout</a>)
+    You are logged in as <span id=#username><a href="/u/{{user.username}}">{{user.username}}</a></span>. (<a href="/logout/">Logout</a>)
 {% else %}
     Not logged in.
 {% endif %}

templates/frontpage.html

 {% block content %}
 
 <div id="frontform" style="margin:0 auto;width:780px;">
+
+Repository url will be: <pre>http://freehg.org/u/{% if user.username %}{{user.username}}{%else%}<span id="url-user" class="notgiven">&lt;username&gt;</span>{%endif%}/<span id="url-repo" class="notgiven">&lt;reponame&gt;</span></pre>
+
 <form action='.' method='POST'>
 <fieldset>
 {% for field in repo_form %}
 <script>
 $(document).ready(function (){
     $('fieldset').each(function(){
-        if ($(this).children('div.form-row').filter(':not(.required)')
-                .filter(':not(.errors)').hide().length) {
+        if ($(this).children('div.form-row:not(.required, .errors)')
+                .hide().length) {
             $(this).append(
                 $('<a href="#" class="showmore">Show more options</a>').click(function(){
                 $(this).hide();
             }));
         }
     });
+
+    var update_repo = function(){
+        if (this.value)
+            $('#url-repo').text(this.value.toLowerCase()).removeClass('notgiven');
+        else
+            $('#url-repo').text("<reponame>").addClass('notgiven');
+    }
+    $('#id_reponame').change(update_repo).keyup(update_repo).trigger('change');
+
+    var update_username = function(){
+        if (this.value)
+            $('#url-user').text(this.value).removeClass('notgiven');
+        else
+            $('#url-user').text("<username>").addClass('notgiven');
+    }
+    $('#id_username, #id_new-username')
+            .change(update_username)
+            .keyup(update_username).trigger('change');
 });
 </script>