From c382ef6b7e6eb41b210a62931675b0e594c97b62 Mon Sep 17 00:00:00 2001 From: benemery Date: Tue, 8 Apr 2014 00:00:44 +0100 Subject: [PATCH] Don't use URLify if a user has manually set a slug Not a big deal, and can easily be handled by using the available js_hook, but this has annoyed the hell out of me and others may find it useful. --- wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js b/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js index e34bbaf609..63f80a26a0 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js +++ b/wagtail/wagtailadmin/static/wagtailadmin/js/page-editor.js @@ -239,8 +239,8 @@ function InlinePanel(opts) { return self; } -function cleanForSlug(val){ - if(URLify != undefined) { // Check to be sure that URLify function exists +function cleanForSlug(val, useURLify){ + if(URLify != undefined && useURLify !== false) { // Check to be sure that URLify function exists, and that we want to use it. return URLify(val, val.length); } else { // If not just do the "replace" return val.replace(/\s/g,"-").replace(/[^A-Za-z0-9\-]/g,"").toLowerCase(); @@ -262,7 +262,8 @@ function initSlugAutoPopulate(){ function initSlugCleaning(){ $('#id_slug').blur(function(){ - $(this).val(cleanForSlug($(this).val())); + // if a user has just set the slug themselves, don't remove stop words etc, just illegal characters + $(this).val(cleanForSlug($(this).val(), false)); }); }