Skip to content

Commit

Permalink
Merge 0c2a44d into 54cb131
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Esteves committed Sep 11, 2018
2 parents 54cb131 + 0c2a44d commit 2ecb7d7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ Always reference the ticket number at the end of the issue description.
[310]: //github.com/sanoma/django-arctic/issues/310


## 1.3.3.1

### Changed
- Changed slugify function, allow dashes (matches Django slugify)
- Added a few more characters with accents


## 1.3.3

### Changed
Expand Down
13 changes: 9 additions & 4 deletions arctic/static/arctic/dist/assets/js/app.js

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions arctic/static/arctic/src/assets/js/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@ window.arctic.utils = {
},

slugify: function ( text ) {
text = text.replace(/^\s+|\s+$/g, ''); // trim
text = text.toLowerCase();

// remove accents, swap ñ for n, etc
let from = 'àáäâèéëêìíïîòóöôùúüûñç';
let to = 'aaaaeeeeiiiioooouuuunc';
let from = "åàáäâãèéëêìíïîòóöôùúüûñç";
let to = "aaaaaaeeeeiiiioooouuuunc";
for (let i=0, l=from.length ; i<l ; i++) {
text = text.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
return text
.replace( /[^\w ]+/g, '' )
.replace( / +/g, '-' );
text = text.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
.replace(/\s+/g, '-') // collapse whitespace and replace by -
.replace(/-+/g, '-'); // collapse dashes

return text;
}
};

0 comments on commit 2ecb7d7

Please sign in to comment.