From 724c1511afb3d57693af20a701ae93a4eca8429a Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 6 May 2013 20:13:59 +0000 Subject: [PATCH] moved slugify to utils --- src/topics.js | 35 ++--------------------------------- src/utils.js | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 35 deletions(-) diff --git a/src/topics.js b/src/topics.js index f58d8632dd..70a0dffe6a 100644 --- a/src/topics.js +++ b/src/topics.js @@ -4,17 +4,6 @@ var RDB = require('./redis.js'), user = require('./user.js'); (function(Topics) { - //data structure - - //*global:next_topic_id - // *tid:1:title - // *tid:1:uid - // *tid:1:posts (array of pid) - // *tid:1:timestamp - // *uid:1:tozpics - // *topic:slug:how-to-eat-chicken:tid - - Topics.get_by_category = function(callback, category, start, end) { @@ -136,7 +125,7 @@ var RDB = require('./redis.js'), RDB.lpush('topics:' + category + ':tid', tid); } - var slug = tid + '/' + slugify(title); + var slug = tid + '/' + utils.slugify(title); // Topic Info RDB.set('tid:' + tid + ':title', title); @@ -167,24 +156,4 @@ var RDB = require('./redis.js'), }; -}(exports)); - - -//http://dense13.com/blog/2009/05/03/converting-string-to-slug-javascript/ -function slugify(str) { - str = str.replace(/^\s+|\s+$/g, ''); // trim - str = str.toLowerCase(); - - // remove accents, swap ñ for n, etc - var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;"; - var to = "aaaaeeeeiiiioooouuuunc------"; - for (var i=0, l=from.length ; i