From ad99404d2588e182a115d89b0b457d957e8ca7b6 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Thu, 14 Apr 2016 12:44:35 +0200 Subject: Properly handle bigger files --- app/models/blob.rb | 8 ++++++++ app/models/snippet.rb | 4 ++++ 2 files changed, 12 insertions(+) (limited to 'app/models') diff --git a/app/models/blob.rb b/app/models/blob.rb index 72e6c5fa3fd..0fea6b7f576 100644 --- a/app/models/blob.rb +++ b/app/models/blob.rb @@ -19,6 +19,14 @@ class Blob < SimpleDelegator new(blob) end + def no_highlighting? + size && size > 1.megabyte + end + + def only_display_raw? + size && size > 5.megabytes + end + def svg? text? && language && language.name == 'SVG' end diff --git a/app/models/snippet.rb b/app/models/snippet.rb index b96e3937281..0fd08061925 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -112,6 +112,10 @@ class Snippet < ActiveRecord::Base visibility_level end + def no_highlighting? + content.lines.count > 1000 + end + class << self # Searches for snippets with a matching title or file name. # -- cgit v1.2.1