def is_valid(value): if ltools.slugify(value) != value: print("This is not a valid slug ({}).".format(ltools.SLUG_CHARS_DISPLAY)) return False path = os.path.join("articles", value + ".markdown") if os.path.exists(os.path.normpath(path)): print("Article with this filename already exists.") return False return True
def interactive_slug(self): def is_valid(value): if value != ltools.slugify(value): print('This is not a valid slug.') return False return True default = self.slug or ltools.slugify(self.name) self.slug = ltools.input_default('Slug', default, required=True, is_valid=is_valid)
def is_valid(value): if ltools.slugify(value) != value: print('This is not a valid slug ({}).'.format( ltools.SLUG_CHARS_DISPLAY)) return False path = os.path.join('articles', value + '.markdown') if os.path.exists(os.path.normpath(path)): print('Article with this filename already exists.') return False return True
def interactive_filename(self): def is_valid(value): if ltools.slugify(value) != value: print("This is not a valid slug ({}).".format(ltools.SLUG_CHARS_DISPLAY)) return False path = os.path.join("articles", value + ".markdown") if os.path.exists(os.path.normpath(path)): print("Article with this filename already exists.") return False return True default = ltools.slugify(self.title) self.filename = ltools.input_default("Filename", default, required=True, is_valid=is_valid) # Several paths have to be reset. self.filename = os.path.join("articles", self.filename) self.path = os.path.normpath(self.filename + ".markdown") self.cm.filename = self._config_filename()
def render_authors(self): authors = dict() for article in self._get_articles(): for author in article.authors: try: authors[author] |= set([article]) except KeyError: authors[author] = set([article]) for id, articles in authors.items(): author = self.modules['authors'][id] dirs = ['authors', ltools.slugify(author.nickname)] kwargs = { 'page_title': '{} ({})'.format(author.full_name(), author.nickname), 'cur_author': author.id, 'pages_root': os.path.join(*(['/'] + dirs)), } self.render_index(dirs, list(articles), **kwargs) self.render_pages(dirs, list(articles), **kwargs)
def interactive_filename(self): def is_valid(value): if ltools.slugify(value) != value: print('This is not a valid slug ({}).'.format( ltools.SLUG_CHARS_DISPLAY)) return False path = os.path.join('articles', value + '.markdown') if os.path.exists(os.path.normpath(path)): print('Article with this filename already exists.') return False return True default = ltools.slugify(self.title) self.filename = ltools.input_default('Filename', default, required=True, is_valid=is_valid) # Several paths have to be reset. self.filename = os.path.join('articles', self.filename) self.path = os.path.normpath(self.filename + '.markdown') self.cm.filename = self._config_filename()
def do_slugify(value): return ltools.slugify(value)
def is_valid(value): if value != ltools.slugify(value): print('This is not a valid slug.') return False return True