コード例 #1
0
ファイル: articles.py プロジェクト: Naam/lpbm
 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
コード例 #2
0
ファイル: categories.py プロジェクト: Naam/lpbm
 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)
コード例 #3
0
ファイル: articles.py プロジェクト: Naam/lpbm
 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
コード例 #4
0
ファイル: articles.py プロジェクト: Naam/lpbm
    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()
コード例 #5
0
ファイル: render.py プロジェクト: Naam/lpbm
 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)
コード例 #6
0
 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)
コード例 #7
0
ファイル: articles.py プロジェクト: Naam/lpbm
    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()
コード例 #8
0
def do_slugify(value):
    return ltools.slugify(value)
コード例 #9
0
ファイル: render.py プロジェクト: Naam/lpbm
def do_slugify(value):
    return ltools.slugify(value)
コード例 #10
0
ファイル: categories.py プロジェクト: Naam/lpbm
 def is_valid(value):
     if value != ltools.slugify(value):
         print('This is not a valid slug.')
         return False
     return True