Exemplo n.º 1
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)
Exemplo n.º 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)
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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
Exemplo n.º 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
Exemplo n.º 6
0
 def __init__(self, title):
     self.title = title
     self.slug = url_safe(title)
Exemplo n.º 7
0
 def file_path(self):
     template = configs.path.get(self.__class__.layout, '').lstrip('/')
     return url_safe(template.format(**self.__dict__))
Exemplo n.º 8
0
 def __init__(self, title):
     self.title = title
     self.slug = url_safe(title)
Exemplo n.º 9
0
 def file_path(self):
     template = configs.path.get(self.__class__.layout, '').lstrip('/')
     return url_safe(template.format(**self.__dict__))
Exemplo n.º 10
0
 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("//", '/'))