Пример #1
0
    def make_context(self, *args):
        super(BlobView, self).make_context(*args)

        if guess_is_binary(self.context['blob_or_tree']):
            self.context.update({
                'is_markup': False,
                'is_binary': True,
                'is_image': False,
            })
            if guess_is_image(self.context['filename']):
                self.context.update({
                    'is_image': True,
                })
        else:
            render_markup = 'markup' not in request.args
            rendered_code = pygmentize(
                force_unicode(self.context['blob_or_tree'].data),
                self.context['filename'],
                render_markup
            )
            self.context.update({
                'too_large': sum(map(len, self.context['blob_or_tree'].chunked)) > 100*1024,
                'is_markup': markup.can_render(self.context['filename']),
                'render_markup': render_markup,
                'rendered_code': rendered_code,
                'is_binary': False,
            })
Пример #2
0
 def make_template_context(self, *args):
     super(BlameView, self).make_template_context(*args)
     if self.context['can_render']:
         rendered_code = pygmentize(
             force_unicode(self.context['blob_or_tree'].data),
             self.context['filename'],
             render_markup=False,
         )
         line_commits = self.context['repo'].blame(self.context['commit'], self.context['path'])
         replace_dupes(line_commits, None)
         self.context.update({
             'rendered_code': rendered_code,
             'line_commits': line_commits,
         })
Пример #3
0
 def make_template_context(self, *args):
     super(FileView, self).make_template_context(*args)
     if self.context['can_render']:
         render_markup = 'markup' not in request.args
         rendered_code = pygmentize(
             force_unicode(self.context['blob_or_tree'].data),
             self.context['filename'],
             render_markup
         )
         self.context.update({
             'is_markup': markup.can_render(self.context['filename']),
             'render_markup': render_markup,
             'rendered_code': rendered_code,
         })
Пример #4
0
    def make_template_context(self, *args):
        super(BlobView, self).make_template_context(*args)

        if not isinstance(self.context['blob_or_tree'], Blob):
            raise NotFound("Not a blob")

        binary = guess_is_binary(self.context['blob_or_tree'])
        too_large = sum(map(len,
                            self.context['blob_or_tree'].chunked)) > 100 * 1024

        if binary:
            self.context.update({
                'is_markup': False,
                'is_binary': True,
                'is_image': False,
            })
            if guess_is_image(self.context['filename']):
                self.context.update({
                    'is_image': True,
                })
        elif too_large:
            self.context.update({
                'too_large': True,
                'is_markup': False,
                'is_binary': False,
            })
        else:
            render_markup = 'markup' not in request.args
            rendered_code = pygmentize(
                force_unicode(self.context['blob_or_tree'].data),
                self.context['filename'], render_markup)
            self.context.update({
                'too_large':
                False,
                'is_markup':
                markup.can_render(self.context['filename']),
                'render_markup':
                render_markup,
                'rendered_code':
                rendered_code,
                'is_binary':
                False,
            })
Пример #5
0
 def make_context(self, *args):
     super(BlobView, self).make_context(*args)
     render_markup = 'markup' not in request.args
     rendered_code = pygmentize(force_unicode(self.context['blob'].data),
                                self.context['filename'], render_markup)
     self.context.update({
         'too_large':
         sum(map(len, self.context['blob'].chunked)) > 100 * 1024,
         'is_markup':
         markup.can_render(self.context['filename']),
         'render_markup':
         render_markup,
         'rendered_code':
         rendered_code,
         'is_binary':
         guess_is_binary(self.context['blob']),
         'is_image':
         guess_is_image(self.context['filename']),
     })
Пример #6
0
    def make_context(self, *args):
        super(BlobView, self).make_context(*args)

        if self.context['blob'] == None or not hasattr(self.context['blob'], 'chunked'):
            raise RedirectException(url_for('history', repo=self.context['repo'].name, commit_id='master', path=self.context['path']))

        render_markup = 'markup' not in request.args
        rendered_code = pygmentize(
            force_unicode(self.context['blob'].data),
            self.context['filename'],
            render_markup
        )
        self.context.update({
            'too_large': sum(map(len, self.context['blob'].chunked)) > 100*1024,
            'is_markup': markup.can_render(self.context['filename']),
            'render_markup': render_markup,
            'rendered_code': rendered_code,
            'is_binary': guess_is_binary(self.context['blob']),
            'is_image': guess_is_image(self.context['filename']),
        })
Пример #7
0
    def get_context_data(self, **ctx):
        context = super(BlobView, self).get_context_data(**ctx)

        if not isinstance(context['blob_or_tree'], Blob):
            raise RepoException("Not a blob")

        binary = guess_is_binary(context['blob_or_tree'])
        too_large = sum(map(len, context['blob_or_tree'].chunked)) > 100 * 1024

        if binary:
            context.update({
                'is_markup': False,
                'is_binary': True,
                'is_image': False,
            })
            if guess_is_image(context['filename']):
                context.update({
                    'is_image': True,
                })
        elif too_large:
            context.update({
                'too_large': True,
                'is_markup': False,
                'is_binary': False,
            })
        else:
            render_markup = 'markup' not in self.request.GET
            rendered_code = pygmentize(
                force_unicode(context['blob_or_tree'].data),
                context['filename'],
                render_markup
            )
            context.update({
                'too_large': False,
                'is_markup': markup.can_render(context['filename']),
                'render_markup': render_markup,
                'rendered_code': rendered_code,
                'is_binary': False,
            })

        return context
Пример #8
0
    def make_template_context(self, *args):
        super(BlobView, self).make_template_context(*args)

        if not isinstance(self.context['blob_or_tree'], Blob):
            raise NotFound("Not a blob")

        binary = guess_is_binary(self.context['blob_or_tree'])
        too_large = sum(map(len, self.context['blob_or_tree'].chunked)) > 100*1024

        if binary:
            self.context.update({
                'is_markup': False,
                'is_binary': True,
                'is_image': False,
            })
            if guess_is_image(self.context['filename']):
                self.context.update({
                    'is_image': True,
                })
        elif too_large:
            self.context.update({
                'too_large': True,
                'is_markup': False,
                'is_binary': False,
            })
        else:
            render_markup = 'markup' not in request.args
            rendered_code = pygmentize(
                force_unicode(self.context['blob_or_tree'].data),
                self.context['filename'],
                render_markup
            )
            self.context.update({
                'too_large': False,
                'is_markup': markup.can_render(self.context['filename']),
                'render_markup': render_markup,
                'rendered_code': rendered_code,
                'is_binary': False,
            })
Пример #9
0
    def get_context_data(self, **ctx):
        context = super(BlobView, self).get_context_data(**ctx)

        if not isinstance(context['blob_or_tree'], Blob):
            raise RepoException("Not a blob")

        binary = guess_is_binary(context['blob_or_tree'])
        too_large = sum(map(len, context['blob_or_tree'].chunked)) > 100 * 1024

        if binary:
            context.update({
                'is_markup': False,
                'is_binary': True,
                'is_image': False,
            })
            if guess_is_image(context['filename']):
                context.update({
                    'is_image': True,
                })
        elif too_large:
            context.update({
                'too_large': True,
                'is_markup': False,
                'is_binary': False,
            })
        else:
            render_markup = 'markup' not in self.request.GET
            rendered_code = pygmentize(
                force_unicode(context['blob_or_tree'].data),
                context['filename'], render_markup)
            context.update({
                'too_large': False,
                'is_markup': markup.can_render(context['filename']),
                'render_markup': render_markup,
                'rendered_code': rendered_code,
                'is_binary': False,
            })

        return context
Пример #10
0
    def make_template_context(self, *args):
        super(BlameView, self).make_template_context(*args)

        if not isinstance(self.context['blob_or_tree'], Blob):
            raise NotFound("Not a blob")

        binary = guess_is_binary(self.context['blob_or_tree'])
        too_large = sum(map(len, self.context['blob_or_tree'].chunked)) > 100*1024

        if binary:
            self.context.update({
                'is_markup': False,
                'is_binary': True,
                'is_image': False,
            })
            if guess_is_image(self.context['filename']):
                self.context.update({
                    'is_image': True,
                })
        elif too_large:
            self.context.update({
                'too_large': True,
                'is_markup': False,
                'is_binary': False,
            })
        else:
            self.context.update({
                'too_large': False,
                'is_markup': markup.can_render(self.context['filename']),
                'is_binary': False,
                'rendered_code': pygmentize(
                    force_unicode(self.context['blob_or_tree'].data),
                    self.context['filename'],
                    render_markup=False , linenos=False),
                'authors': list(self.context["repo"].blame(self.context["commit"], self.context["path"]))
            })