def _set_edit_url(self, repo_url, edit_uri): if not edit_uri: self.edit_url = repo_url else: # Normalize URL from Windows path '\\' -> '/' input_path_url = self.input_path.replace('\\', '/') self.edit_url = utils.urljoin(repo_url, edit_uri + input_path_url)
def get_page_context(page, content, toc, meta, config): """ Generate the page context by extending the global context and adding page specific variables. """ if page.is_homepage or page.title is None: page_title = None else: page_title = page.title if page.is_homepage: page_description = config['site_description'] else: page_description = None if config['site_url']: base = config['site_url'] if not base.endswith('/'): base += '/' canonical_url = utils.urljoin(base, page.abs_url.lstrip('/')) else: canonical_url = None return { 'page_title': page_title, 'page_description': page_description, 'content': content, 'toc': toc, 'meta': meta, 'canonical_url': canonical_url, 'current_page': page, 'previous_page': page.previous_page, 'next_page': page.next_page }
def _set_canonical_url(self, base): if base: if not base.endswith('/'): base += '/' self.canonical_url = urljoin(base, self.url) self.abs_url = urlparse(self.canonical_url).path else: self.canonical_url = None self.abs_url = None
def set_edit_url(self, repo_url, edit_uri): if not repo_url.endswith('/'): repo_url += '/' if not edit_uri: self.edit_url = repo_url else: if not edit_uri.endswith('/'): edit_uri += '/' self.edit_url = utils.urljoin(repo_url + edit_uri, self.input_path)
def set_edit_url(self, repo_url, edit_uri): if not repo_url.endswith('/'): repo_url += '/' if not edit_uri: self.edit_url = repo_url else: if not edit_uri.endswith('/'): edit_uri += '/' self.edit_url = utils.urljoin( repo_url + edit_uri, self.input_path)
def set_edit_url(self, repo_url, edit_uri): if not repo_url.endswith('/'): # Skip when using query or fragment in edit_uri if not edit_uri.startswith('?') and not edit_uri.startswith('#'): repo_url += '/' if not edit_uri: self.edit_url = repo_url else: # Normalize URL from Windows path '\\' -> '/' input_path_url = self.input_path.replace('\\', '/') if not edit_uri.endswith('/'): edit_uri += '/' self.edit_url = utils.urljoin(repo_url, edit_uri + input_path_url)
def get_page_context(page, content, toc, meta, config): """ Generate the page context by extending the global context and adding page specific variables. """ if page.is_homepage or page.title is None: page_title = None else: page_title = page.title if page.is_homepage: page_description = config['site_description'] else: page_description = None if config['site_url']: base = config['site_url'] if not base.endswith('/'): base += '/' canonical_url = utils.urljoin( base, page.abs_url.lstrip('/')) else: canonical_url = None return { 'page_title': page_title, 'page_description': page_description, 'content': content, 'toc': toc, 'toc_html': ''.join(toc.toc_html), 'meta': meta, 'canonical_url': canonical_url, 'current_page': page, 'previous_page': page.previous_page, 'next_page': page.next_page }
def _set_edit_url(self, repo_url, edit_uri): if repo_url and edit_uri: src_path = self.file.src_path.replace('\\', '/') self.edit_url = urljoin(repo_url, edit_uri + src_path) else: self.edit_url = None
def set_canonical_url(self, base): if not base.endswith('/'): base += '/' self.canonical_url = utils.urljoin(base, self.abs_url.lstrip('/'))
def _set_edit_url(self, repo_url, edit_uri): # Normalize URL from Windows path '\\' -> '/' input_path_url = self.input_path.replace('\\', '/') self.edit_url = utils.urljoin(repo_url, edit_uri + input_path_url)