示例#1
0
 def _parse_filename(self, f):
     date, slug = re.match(r'(?:(\d{4}(?:-\d{2}-\d{2}){1,2})-)?(.+)', f.name).groups()
     
     return (
         slugify(slug),
         self._get_date(f.mtime, date)
     )
示例#2
0
 def _get_content_url(self, url, slug, date, frontmatter):
     subs = {
         '<year>': '%Y',
         '<month>': '%m',
         '<day>': '%d',
         '<i_month>': unicode(date.month),
         '<i_day>': unicode(date.day),
         '<slug>': slug
     }
     
     url = url.replace('%', '%%')
     
     for match, replace in subs.iteritems():
         url = url.replace(match, replace)
     
     for attribute, value in frontmatter.iteritems():
         if isinstance(value, basestring):
             url = url.replace('<{0}>'.format(attribute), slugify(value))
     
     url = date.strftime(url).decode('utf-8')
     
     return format_url(url, url.endswith('/'))
示例#3
0
    def _get_content_url(self, url, slug, date, frontmatter):
        subs = {
            '<year>': '%Y',
            '<month>': '%m',
            '<day>': '%d',
            '<i_month>': unicode(date.month),
            '<i_day>': unicode(date.day),
            '<slug>': slug
        }

        url = url.replace('%', '%%')

        for match, replace in subs.iteritems():
            url = url.replace(match, replace)

        for attribute, value in frontmatter.iteritems():
            if isinstance(value, basestring):
                url = url.replace('<{0}>'.format(attribute), slugify(value))

        url = date.strftime(url).decode('utf-8')

        return format_url(url, url.endswith('/'))
示例#4
0
    def _get_page_url(self, url, text):
        slug = slugify(text)

        return format_url(absurl(url, slug), url.endswith('/'))
示例#5
0
    def _parse_filename(self, f):
        date, slug = re.match(r'(?:(\d{4}(?:-\d{2}-\d{2}){1,2})-)?(.+)',
                              f.name).groups()

        return (slugify(slug), self._get_date(f.mtime, date))
示例#6
0
文件: containers.py 项目: NaPs/mynt
 def _get_page_url(self, url, text):
     slug = slugify(text)
     
     return format_url(absurl(url, slug), url.endswith('/'))