Example #1
0
def slugify(value):
    try:  # use unicode-slugify library if installed
        from slugify import slugify as _slugify
        return _slugify(value, only_ascii=True)
    except ImportError:
        from django.utils.text import slugify as _slugify
        return _slugify(value, allow_unicode=False)
Example #2
0
def slugify(raw: str) -> str:

    assert len(raw) > 0

    for aa, bb in UMLAUT_DICT.items():
        raw = raw.replace(aa, bb)

    return _slugify(raw, lowercase=False)
Example #3
0
def slug(s, **kwargs):
    """
    Slugify a string.
    """
    s = s.strip()
    if not isinstance(s, unicode):
        s = unicode(s, errors='ignore')
    return _slugify(s, **kwargs)
def post(title='', format='markdown'):
	"""
	Create a new stub post
	"""
	date = datetime.datetime.now().strftime('%Y-%m-%d')
	slug = _slugify(title)
	filename = _f("_posts/{0}-{1}.{2}".format(date, slug, format))
	if not os.path.exists(filename):
		with open(filename, 'wb') as f:
			content = POST_TEMPLATE.format(title=title, date=date)
			f.write(content)
	else:
		raise _DoingItWrong('That post already exists!')
Example #5
0
def slugify(text):
    """
    A wrapper around python-slugify which preserves file extensions
    and forward slashes.
    """

    parts = text.split("/")
    parts[-1], ext = magic_split_ext(parts[-1])

    out = "/".join(_slugify(part) for part in parts)

    if ext:
        return out + '.' + ext
    return out
Example #6
0
def slugify(text):
    return _slugify(text)
Example #7
0
File: db.py Project: gldnspud/fosmc
def slugify(value):
    if isinstance(value, unicode):
        return _slugify(value)
    else:
        return _slugify(value.decode("utf8"))
Example #8
0
def slugify(string):
    from slugify import slugify as _slugify
    return _slugify(string)
Example #9
0
def slugify(text: str) -> str:
    return _slugify(text, stopwords=STOPWORDS)
Example #10
0
def slugify(text):
    slug = _slugify(text)
    for stopword in STOPWORDS:
        slug = slug.replace('-%s-' % stopword, '-')
    return slug
Example #11
0
def slugify(s):
    """Slugify a string."""
    return _slugify(s)
Example #12
0
def slugify(text):
    return _slugify(text, separator=SLUGIFY_SEP, replacements=SLUGIFY_REPLACE)
Example #13
0
def slugify(value):
    return _slugify(value, to_lower=True)
Example #14
0
def slugify(text: str, delimiter: str = '_') -> str:
    return _slugify(text, separator=delimiter)
Example #15
0
def slug(s: str) -> str:
    return _slugify(s)
Example #16
0
def slugify(words):
    return _slugify(words).lower()
Example #17
0
def slugify(name, separator='-'):
    """Returns a slugified name (we allow _ to be used)"""
    return _slugify(name,
                    regex_pattern=re.compile('[^-_a-z0-9]+'),
                    separator=separator)