From 5f2ee6e2944733ec120a09917d0751fcdb37e170 Mon Sep 17 00:00:00 2001 From: Maciej Pasternacki Date: Wed, 22 Oct 2008 00:19:04 +0200 Subject: [PATCH] - move slugify to trane-common --- src/common.lisp | 13 ++++++++++++- src/taxonomy.lisp | 14 +------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/common.lisp b/src/common.lisp index dee9ee2..86da969 100644 --- a/src/common.lisp +++ b/src/common.lisp @@ -7,7 +7,7 @@ ;; Package for internal use in libraries and projects (defpackage #:trane-common (:use #:common-lisp) ; referenced with package name: #:py-configparser - (:export #:id #:slug #:slug-dao + (:export #:id #:slug #:slug-dao #:slugify #:*config* #:*init-functions* #:on-init #:*setup-functions* #:on-setup #:*db* #:make-keyword #:named-lambda #:random-string)) @@ -44,6 +44,17 @@ Usually it will be a reader method automatically defined for ID column of a DAO. "Select DAO of CLASS having \"slug\" column set to SLUG." (first (postmodern:select-dao class (:= 'slug slug)))) +;;; FIXME:flatten characters, unicode and so on +(defun slugify (str) + (iterate (for cs in-string str) + (for c = (char-downcase cs)) + (for safe-p = (find c "abcdefghijklmnopqrstuvwxyz")) + (for previous-safe-p previous safe-p initially t) + (when safe-p + (unless previous-safe-p + (collect #\- result-type string)) + (collect c result-type string)))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Initialization and setup protocol diff --git a/src/taxonomy.lisp b/src/taxonomy.lisp index 99622e7..f35f568 100644 --- a/src/taxonomy.lisp +++ b/src/taxonomy.lisp @@ -16,8 +16,7 @@ #:description #:parent-id #:term-taxonomy #:term-site #:id #:find-terms #:new-term #:apply-term #:term-value #:item-terms - #:unbind-term :term-item-ids #:term-items - #:slugify)) + #:unbind-term :term-item-ids #:term-items)) (in-package #:trane-taxonomy) @@ -129,17 +128,6 @@ NAME is symbol or string, which will be transformed to a keyword anyway." (when id (get-dao (site-dao-class (taxonomy term)) id)))) -;;; FIXME:flatten characters, unicode and so on -(defun slugify (str) - (iterate (for cs in-string str) - (for c = (char-downcase cs)) - (for safe-p = (find c "abcdefghijklmnopqrstuvwxyz")) - (for previous-safe-p previous safe-p initially t) - (when safe-p - (unless previous-safe-p - (collect #\- result-type string)) - (collect c result-type string)))) - (defun ensure-term (taxonomy site &key text slug create-p) "Find or create term in taxonomy TAXONOMY for site SITE. -- 2.11.4.GIT