def download_link(self, formatter, ns, target, label): if ns == 'download': if 'FILES_DOWNLOADS_VIEW' not in formatter.req.perm: return html.a(label, href='#', title=_('Missing %(permission)s permission', permission='FILES_DOWNLOADS_VIEW'), class_='missing') files_core = FilesCoreComponent(self.env) wiki = ProjectDownloadsWiki(self.env) node_factory, download_config = files_core.files_node_factory_and_config( formatter.req) id_, filename = self._get_id_filename(target) if id_ and filename: primary_path = get_download_path(id_, filename) node = MappedFileNode.from_download_path( primary_path, node_factory, True) if node.exists() and node.is_download(): return wiki.file_link(formatter, 'filesdownload', node.download().download_path, label) node = MappedFileNode.from_download_path( filename, node_factory, True) if node.exists() and node.is_download(): return wiki.file_link(formatter, 'filesdownload', node.download().download_path, label) return wiki.file_link(formatter, 'filesdownload', target, label)
def expand_macro(self, formatter, name, content): """ Stub implementation forwarding the requests to the ProjectDownloadsWiki. """ wiki = ProjectDownloadsWiki(self.env) if name == 'DownloadsCount': return wiki.expand_macro(formatter, 'FilesDownloadsCount', content) elif name in ('ListDownloads', 'FeaturedDownloads', 'ListFeaturedDownloads', 'CustomListDownloads', 'CustomFeaturedDownloads', 'CustomListFeaturedDownloads'): only_featured = str('Featured' in name) return wiki.expand_macro(formatter, 'FilesDownloads', '', {'only_featured':only_featured, 'title': ''})
def expand_macro(self, formatter, name, content): """ Stub implementation forwarding the requests to the ProjectDownloadsWiki. """ wiki = ProjectDownloadsWiki(self.env) if name == 'DownloadsCount': return wiki.expand_macro(formatter, 'FilesDownloadsCount', content) elif name in ('ListDownloads', 'FeaturedDownloads', 'ListFeaturedDownloads', 'CustomListDownloads', 'CustomFeaturedDownloads', 'CustomListFeaturedDownloads'): only_featured = str('Featured' in name) return wiki.expand_macro(formatter, 'FilesDownloads', '', { 'only_featured': only_featured, 'title': '' })
def download_link(self, formatter, ns, target, label): if ns == 'download': if 'FILES_DOWNLOADS_VIEW' not in formatter.req.perm: return html.a(label, href='#', title = _('Missing %(permission)s permission', permission='FILES_DOWNLOADS_VIEW'), class_ = 'missing') files_core = FilesCoreComponent(self.env) wiki = ProjectDownloadsWiki(self.env) node_factory, download_config = files_core.files_node_factory_and_config(formatter.req) id_, filename = self._get_id_filename(target) if id_ and filename: primary_path = get_download_path(id_, filename) node = MappedFileNode.from_download_path(primary_path, node_factory, True) if node.exists() and node.is_download(): return wiki.file_link(formatter, 'filesdownload', node.download().download_path, label) node = MappedFileNode.from_download_path(filename, node_factory, True) if node.exists() and node.is_download(): return wiki.file_link(formatter, 'filesdownload', node.download().download_path, label) return wiki.file_link(formatter, 'filesdownload', target, label)