示例#1
0
文件: model.py 项目: zqqf16/Peanut
    def parse_path_and_url(self):
        template = configs.path.pagination
        relative_path = template.format(
            number=self.page,
            num=self.page,
            n=self.page
        )

        if self.page == 1:
            relative_path = ''

        file_path = None
        url = None
        if re.search(r'index.html?$', self.base_url):
            # If base_url ends with index.html or index.htm,
            # insert page path before the index.*
            parent, index = os.path.split(self.base_url)
            url = file_path = os.path.join(parent, relative_path, index)
        else:
            if not self.base_url.endswith('/'):
                self.base_url = self.base_url + '/'
            else:
                if relative_path != '' and not relative_path.endswith('/'):
                    relative_path = relative_path + '/'
            url = os.path.join(self.base_url, relative_path)
            file_path = os.path.join(url, 'index.html')

        if not url.startswith('/'):
            url = '/' + url
        if file_path.startswith('/'):
            file_path = file_path[1:]

        self.file_path = url_safe(file_path)
        self.url = url_safe(url)
示例#2
0
    def parse_path_and_url(self):
        template = configs.path.pagination
        relative_path = template.format(number=self.page,
                                        num=self.page,
                                        n=self.page)

        if self.page == 1:
            relative_path = ''

        file_path = None
        url = None
        if re.search(r'index.html?$', self.base_url):
            # If base_url ends with index.html or index.htm,
            # insert page path before the index.*
            parent, index = os.path.split(self.base_url)
            url = file_path = os.path.join(parent, relative_path, index)
        else:
            if not self.base_url.endswith('/'):
                self.base_url = self.base_url + '/'
            else:
                if relative_path != '' and not relative_path.endswith('/'):
                    relative_path = relative_path + '/'
            url = os.path.join(self.base_url, relative_path)
            file_path = os.path.join(url, 'index.html')

        if not url.startswith('/'):
            url = '/' + url
        if file_path.startswith('/'):
            file_path = file_path[1:]

        self.file_path = url_safe(file_path)
        self.url = url_safe(url)
示例#3
0
文件: model.py 项目: witcxc/Peanut
    def __init__(self, title, slug, content=None, meta=None):
        self.title = title
        self.slug = url_safe(slug)
        self.content = content

        meta = meta or {}
        self.date = meta.pop('date', None) or datetime.now()
        self.publish = meta.pop('publish', True)
        self.layout = meta.pop('layout', Post.layout)
        self.top = meta.pop('top', False)
        self.tag_titles = meta.pop('tags', [])

        self.meta = meta
示例#4
0
文件: model.py 项目: witcxc/Peanut
    def __init__(self, title, slug, content=None, meta=None):
        self.title = title
        self.slug = url_safe(slug)
        self.content = content

        meta = meta or {}
        self.date = meta.pop('date', None) or datetime.now()
        self.publish = meta.pop('publish', True)
        self.layout = meta.pop('layout', Post.layout)
        self.top = meta.pop('top', False)
        self.tag_titles = meta.pop('tags', [])

        self.meta = meta
示例#5
0
    def __init__(self, title, slug, raw=None, content=None, meta=None):
        self.title = title
        self.slug = url_safe(slug)
        self.content = content
        self.raw = raw

        meta = meta or {}
        self.date = meta.pop('date', None) or datetime.now()
        self.publish = meta.pop('publish', True)
        self.layout = meta.pop('layout', Post.layout)
        self.top = meta.pop('top', False)
        self.tag_titles = meta.pop('tags', [])

        image = meta.pop('image', None)
        if isinstance(image, dict):
            self.image = image.get('feature', None)
        else:
            self.image = image

        self.meta = meta
示例#6
0
文件: model.py 项目: zqqf16/Peanut
 def __init__(self, title):
     self.title = title
     self.slug = url_safe(title)
示例#7
0
文件: model.py 项目: zqqf16/Peanut
 def file_path(self):
     template = configs.path.get(self.__class__.layout, '').lstrip('/')
     return url_safe(template.format(**self.__dict__))
示例#8
0
 def __init__(self, title):
     self.title = title
     self.slug = url_safe(title)
示例#9
0
 def file_path(self):
     template = configs.path.get(self.__class__.layout, '').lstrip('/')
     return url_safe(template.format(**self.__dict__))
示例#10
0
文件: model.py 项目: linmuhe/peanut
 def file_path(self):
     template = configs.path.get(self.__class__.layout, '').lstrip('/')
     # print(template);
     # print(self.__dict__);
     return url_safe(template.format(**self.__dict__).replace("//", '/'))