def slugify(value):
    """
    Convert to ASCII. Convert spaces to hyphens. Remove characters that aren't
    alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip
    leading and trailing whitespace.
    """
    return _slugify(value)
Exemplo n.º 2
0
def slugify(value):
    """
    Converts to lowercase, removes non-word characters (alphanumerics and
    underscores) and converts spaces to hyphens. Also strips leading and
    trailing whitespace.
    """
    return _slugify(value)
Exemplo n.º 3
0
def slugify(value):
    """
    Converts to ASCII. Converts spaces to hyphens. Removes characters that
    aren't alphanumerics, underscores, or hyphens. Converts to lowercase.
    Also strips leading and trailing whitespace.
    """
    return _slugify(value)
Exemplo n.º 4
0
def slugify(value):
    """
    Converts to lowercase, removes non-word characters (alphanumerics and
    underscores) and converts spaces to hyphens. Also strips leading and
    trailing whitespace.
    """
    return _slugify(value)
Exemplo n.º 5
0
def slugify(text: str) -> str:
    # https://docs.djangoproject.com/en/3.2/ref/utils/#django.utils.text.slugify
    """
        >>> slugify(' Joel is a slug ')
        'joel-is-a-slug'
    """
    return _slugify(text)
Exemplo n.º 6
0
def slugify(value):
    slug = _slugify(value, allow_unicode=True)
    slug = slug.replace('ş', 's')
    slug = slug.replace('ç', 'c')
    slug = slug.replace('ö', 'o')
    slug = slug.replace('ı', 'i')
    slug = slug.replace('ü', 'u')
    slug = slug.replace('ğ', 'g')
    return slug
Exemplo n.º 7
0
def slugify(base, instance=None, slug_field='slug'):
    if not isinstance(base, str):
        base = str(base)
    slug = base = _slugify(base.replace('_', ' '))
    length = len(base)
    if length > 235:
        base = base[:235]
    if instance:
        def get_query():
            query = instance.objects.filter(**{slug_field: slug})
            if instance.pk:
                query = query.exclude(pk=instance.pk)
            return query.exists()
        i = 1
        while get_query():
            slug = "%s-%s" % (base, i)
            i += 1
    return slug
def ub_slugify_anchor(value):
    """
    Converts to ASCII. Converts spaces to hyphens. Removes characters that
    aren't alphanumerics, underscores, or hyphens. Converts to lowercase.
    Converts numbers to words. Also strips leading and trailing whitespace.
    """
    replacements = {
        '0': 'zero',
        '1': 'one',
        '2': 'two',
        '3': 'three',
        '4': 'four',
        '5': 'five',
        '6': 'six',
        '7': 'seven',
        '8': 'eight',
        '9': 'nine'
    }

    return re.sub(r'(\d)', lambda m: replacements.get(m.group(1), m.group(1)), _slugify(value))
def ub_slugify_anchor(value):
    """
    Converts to ASCII. Converts spaces to hyphens. Removes characters that
    aren't alphanumerics, underscores, or hyphens. Converts to lowercase.
    Converts numbers to words. Also strips leading and trailing whitespace.
    """
    replacements = {
        '0': 'zero',
        '1': 'one',
        '2': 'two',
        '3': 'three',
        '4': 'four',
        '5': 'five',
        '6': 'six',
        '7': 'seven',
        '8': 'eight',
        '9': 'nine'
    }

    return re.sub(r'(\d)', lambda m: replacements.get(m.group(1), m.group(1)),
                  _slugify(value))
Exemplo n.º 10
0
def slugify(value, truncate_chars):
    '''Truncator и slugify - стандартные утилиты Django. Функция ограничивает текст до заданного количества символов.'''
    return Truncator(_slugify(unidecode.unidecode(value))).chars(
        truncate_chars, truncate='')
Exemplo n.º 11
0
def slugify(value):
    return _slugify(unidecode.unidecode(value))
Exemplo n.º 12
0
def slugify(text):
    """ Custom slugify that gracefully handles æ, ø and å. """
    text = text.lower().replace('æ', 'ae').replace('ø', 'o').replace('å', 'a')
    return _slugify(text)
Exemplo n.º 13
0
"""Default variable filters."""
Exemplo n.º 14
0
def slugify(value):
    new_value = u('')
    for c in u(value).lower():
        new_value += RU_EN.get(c, c)
    return _slugify(new_value)