Commit 7d45a29e by benjaoming

Merge pull request #260 from Jayflux/fixing_hyphen

URLify is being overriden by this line which is removing the hyphen
parents 469d050c 682a217f
......@@ -264,6 +264,8 @@ class CreateForm(forms.Form, SpamProtectionMixin):
else:
raise forms.ValidationError(_(u'A slug named "%s" already exists.') % already_urlpath.slug)
slug = slug.lower()
slug = slug.replace('-', '_')
return slug
def clean(self):
......
......@@ -18,7 +18,7 @@
// if downcode doesn't hit, the char will be stripped here
s = s.replace(/[^-\w\s]/g, ''); // remove unneeded chars
s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces
s = s.replace(/[-\s]+/g, '-'); // convert spaces to hyphens
s = s.replace(/[-\s]+/g, '_'); // convert spaces to hyphens
s = s.toLowerCase(); // convert to lowercase
return s.substring(0, num_chars);// trim to first num_chars chars
}
......@@ -30,10 +30,7 @@
var e = $("#id_slug")[0];
if(!e._changed) {
slug = URLify(this.value, 50);
wikislug = slug.replace(/\-/g, " ");
wikislug = wikislug.replace(/\w\S*/gi, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1);});
wikislug = wikislug.replace(/\s*/g, "");
e.value = wikislug;
e.value = slug;
}
});
});
......
......@@ -60,7 +60,7 @@ class Create(FormView, ArticleMixin):
initial['slug'] = self.request.GET.get('slug', None)
kwargs['initial'] = initial
form = form_class(self.request, self.urlpath, **kwargs)
form.fields['slug'].widget = forms.TextInputPrepend(prepend='/'+self.urlpath.path)
form.fields['slug'].widget = forms.TextInputPrepend(prepend='/'+self.urlpath.path, attrs={'pattern': '[^-A-Z]+', 'title': 'Please only use lowercase alphanumeric characters and underscores'})
return form
def form_valid(self, form):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment