示例#1
0
文件: views.py 项目: ewdurbin/klaus
    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
文件: views.py 项目: ldrumm/klaus
    def make_template_context(self, *args):
        super(BaseFileView, self).make_template_context(*args)
        self.context.update({
            'can_render': True,
            'is_binary': False,
            'too_large': False,
            'is_markup': False,
        })

        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({
                'can_render':
                False,
                'is_binary':
                True,
                'is_image':
                guess_is_image(self.context['filename']),
            })
        elif too_large:
            self.context.update({
                'can_render': False,
                'too_large': True,
            })
示例#3
0
文件: views.py 项目: srinivas32/klaus
    def make_template_context(self, *args):
        super(BaseFileView, self).make_template_context(*args)
        self.context.update(
            {
                "can_render": True,
                "is_binary": False,
                "too_large": False,
                "is_markup": False,
            }
        )

        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(
                {
                    "can_render": False,
                    "is_binary": True,
                    "is_image": guess_is_image(self.context["filename"]),
                }
            )
        elif too_large:
            self.context.update(
                {
                    "can_render": False,
                    "too_large": True,
                }
            )
示例#4
0
文件: views.py 项目: johnko/klaus
    def make_template_context(self, *args):
        super(BaseFileView, self).make_template_context(*args)
        self.context.update({"can_render": True, "is_binary": False, "too_large": False, "is_markup": False})

        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(
                {"can_render": False, "is_binary": True, "is_image": guess_is_image(self.context["filename"])}
            )
        elif too_large:
            self.context.update({"can_render": False, "too_large": True})
示例#5
0
文件: views.py 项目: lazymike/klaus
    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,
            })
示例#6
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']),
     })
示例#7
0
文件: views.py 项目: PatMart/klaus
    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']),
        })
示例#8
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
示例#9
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,
            })
示例#10
0
文件: views.py 项目: jonashaag/klaus
    def make_template_context(self, *args):
        super(BaseFileView, self).make_template_context(*args)
        self.context.update({
            'can_render': True,
            'is_binary': False,
            'too_large': False,
            'is_markup': False,
        })

        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({
                'can_render': False,
                'is_binary': True,
                'is_image': guess_is_image(self.context['filename']),
            })
        elif too_large:
            self.context.update({
                'can_render': False,
                'too_large': True,
            })
示例#11
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
示例#12
0
文件: views.py 项目: posativ/klaus
    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"]))
            })