def render_code(self, render_markup): should_use_ctags = current_app.should_use_ctags(self.context['repo'], self.context['commit']) if should_use_ctags: if ctags is None: raise ImportError("Ctags enabled but python-ctags not installed") ctags_base_url = url_for( self.view_name, repo=self.context['repo'].name, rev=self.context['rev'], path='' ) ctags_tagsfile = CTAGS_CACHE.get_tagsfile( self.context['repo'].path, self.context['commit'].id ) ctags_args = { 'ctags': ctags.CTags(ctags_tagsfile.encode(sys.getfilesystemencoding())), 'ctags_baseurl': ctags_base_url, } else: ctags_args = {} return highlight_or_render( force_unicode(self.context['blob_or_tree'].data), self.context['filename'], render_markup, **ctags_args )
def render_code(self, render_markup): should_use_ctags = current_app.should_use_ctags( self.context['repo'], self.context['commit']) if should_use_ctags: if ctags is None: raise ImportError( "Ctags enabled but python-ctags not installed") ctags_base_url = url_for(self.view_name, repo=self.context['repo'].name, rev=self.context['rev'], path='') ctags_tagsfile = CTAGS_CACHE.get_tagsfile( self.context['repo'].path, self.context['commit'].id) ctags_args = { 'ctags': ctags.CTags(ctags_tagsfile.encode( sys.getfilesystemencoding())), 'ctags_baseurl': ctags_base_url, } else: ctags_args = {} return highlight_or_render( force_unicode(self.context['blob_or_tree'].data), self.context['filename'], render_markup, **ctags_args)
def make_template_context(self, *args): super(IndexView, self).make_template_context(*args) self.context['base_href'] = url_for('blob', repo=self.context['repo'].name, rev=self.context['rev'], path='') self.context['page'] = 0 history_length = 10 history = self.context['repo'].history( self.context['commit'], self.context['path'], history_length + 1, skip=0, ) if len(history) == history_length + 1: # At least one more commit for next page left more_commits = True # We don't want show the additional commit on this page history.pop() else: more_commits = False self.context.update({ 'history': history, 'more_commits': more_commits, }) try: (readme_filename, readme_data) = self._get_readme() except KeyError: self.context.update({ 'is_markup': None, 'rendered_code': None, }) else: readme_base_url = url_for( 'raw', repo=self.context['repo'].name, rev=self.context['rev'], path=os.path.dirname(self.context['path']), ) readme_filename = force_unicode(readme_filename) readme_data = force_unicode(readme_data) self.context.update({ 'is_markup': markup.can_render(readme_filename), 'rendered_code': highlight_or_render(readme_data, readme_base_url, readme_filename) })
def make_template_context(self, *args): super(IndexView, self).make_template_context(*args) self.context["base_href"] = url_for( "blob", repo=self.context["repo"].namespaced_name, rev=self.context["rev"], path="", ) self.context["page"] = 0 history_length = 10 history = self.context["repo"].history( self.context["commit"], self.context["path"], history_length + 1, skip=0, ) if len(history) == history_length + 1: # At least one more commit for next page left more_commits = True # We don't want show the additional commit on this page history.pop() else: more_commits = False self.context.update( { "history": history, "more_commits": more_commits, } ) try: (readme_filename, readme_data) = self._get_readme() except KeyError: self.context.update( { "is_markup": None, "rendered_code": None, } ) else: readme_filename = force_unicode(readme_filename) readme_data = force_unicode(readme_data) self.context.update( { "is_markup": markup.can_render(readme_filename), "rendered_code": highlight_or_render(readme_data, readme_filename), } )
def make_template_context(self, *args): super(IndexView, self).make_template_context(*args) self.context['base_href'] = url_for( 'blob', repo=self.context['repo'].name, rev=self.context['rev'], path='' ) self.context['page'] = 0 history_length = 10 history = self.context['repo'].history( self.context['commit'], self.context['path'], history_length + 1, skip=0, ) if len(history) == history_length + 1: # At least one more commit for next page left more_commits = True # We don't want show the additional commit on this page history.pop() else: more_commits = False self.context.update({ 'history': history, 'more_commits': more_commits, }) try: (readme_filename, readme_data) = self._get_readme() except KeyError: self.context.update({ 'is_markup': None, 'rendered_code': None, }) else: self.context.update({ 'is_markup': markup.can_render(readme_filename), 'rendered_code': highlight_or_render( force_unicode(readme_data), force_unicode(readme_filename), ), })