From 22acc51284a56dd2aee2a35ca1fcd4bdc6854a09 Mon Sep 17 00:00:00 2001
From: maphy-psd <psd.phi@gmail.com>
Date: Sat, 19 Aug 2017 12:38:45 +0200
Subject: [PATCH 1/6] add PAPERLESS_FORCE_SCRIPT_NAME

---
 paperless.conf.example | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/paperless.conf.example b/paperless.conf.example
index a17aac327..3f9e2e98d 100644
--- a/paperless.conf.example
+++ b/paperless.conf.example
@@ -80,6 +80,11 @@ PAPERLESS_PASSPHRASE="secret"
 # as is "example.com,www.example.com", but NOT " example.com" or "example.com,"
 #PAPERLESS_ALLOWED_HOSTS="example.com,www.example.com"
 
+# To host paperless under a subpath url like example.com/paperless you set
+# this value to /paperless. No trailing slash!
+#
+# https://docs.djangoproject.com/en/1.11/ref/settings/#force-script-name
+#PAPERLESS_FORCE_SCRIPT_NAME=""
 
 ###############################################################################
 ####                          Software Tweaks                              ####

From 6f5c1ac4e1510a91eb9267dc097e16c5bbb3440d Mon Sep 17 00:00:00 2001
From: maphy-psd <psd.phi@gmail.com>
Date: Sat, 19 Aug 2017 12:39:25 +0200
Subject: [PATCH 2/6] add FORCE_SCRIPT_NAME setting

---
 src/paperless/settings.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/paperless/settings.py b/src/paperless/settings.py
index 2e525ae41..fdbbc2a7d 100644
--- a/src/paperless/settings.py
+++ b/src/paperless/settings.py
@@ -47,7 +47,11 @@
 if _allowed_hosts:
     ALLOWED_HOSTS = _allowed_hosts.split(",")
 
-
+FORCE_SCRIPT_NAME = None
+_force_script_name = os.getenv("PAPERLESS_FORCE_SCRIPT_NAME")
+if _force_script_name:
+    FORCE_SCRIPT_NAME = _force_script_name
+    
 # Application definition
 
 INSTALLED_APPS = [

From e4854f214442aaaad6ea2d9f4a6092d832a533e1 Mon Sep 17 00:00:00 2001
From: maphy-psd <psd.phi@gmail.com>
Date: Sat, 19 Aug 2017 18:37:17 +0200
Subject: [PATCH 3/6] def thumbnail uses FORCE_SCRIPT_NAME

with this edit the tumbnails are show up..
---
 src/documents/admin.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/documents/admin.py b/src/documents/admin.py
index 7cba10c74..90d952fda 100644
--- a/src/documents/admin.py
+++ b/src/documents/admin.py
@@ -70,9 +70,13 @@ def created_(self, obj):
     created_.short_description = "Created"
 
     def thumbnail(self, obj):
+        if settings.FORCE_SCRIPT_NAME:
+            _src="{}/fetch/thumb/{}".format(settings.FORCE_SCRIPT_NAME,obj.id)
+        else:
+            _src="/fetch/thumb/{}".format(obj.id)
         png_img = self._html_tag(
             "img",
-            src="/fetch/thumb/{}".format(obj.id),
+            src=_src,
             width=180,
             alt="Thumbnail of {}".format(obj.file_name),
             title=obj.file_name

From 73af9552ecd4406268568b191342d5027fd3b65f Mon Sep 17 00:00:00 2001
From: maphy-psd <psd.phi@gmail.com>
Date: Sun, 20 Aug 2017 14:13:23 +0200
Subject: [PATCH 4/6] getenv has "None" as default

@MasterofJOKers in PR#255
---
 src/paperless/settings.py | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/paperless/settings.py b/src/paperless/settings.py
index fdbbc2a7d..95d16bb66 100644
--- a/src/paperless/settings.py
+++ b/src/paperless/settings.py
@@ -47,10 +47,7 @@
 if _allowed_hosts:
     ALLOWED_HOSTS = _allowed_hosts.split(",")
 
-FORCE_SCRIPT_NAME = None
-_force_script_name = os.getenv("PAPERLESS_FORCE_SCRIPT_NAME")
-if _force_script_name:
-    FORCE_SCRIPT_NAME = _force_script_name
+FORCE_SCRIPT_NAME = os.getenv("PAPERLESS_FORCE_SCRIPT_NAME")
     
 # Application definition
 

From 7a627e4ad8dae576b52c398b056a7d47f34fd5c9 Mon Sep 17 00:00:00 2001
From: maphy-psd <psd.phi@gmail.com>
Date: Sun, 20 Aug 2017 14:29:51 +0200
Subject: [PATCH 5/6] white spacing and remove var's prefix

---
 src/documents/admin.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/documents/admin.py b/src/documents/admin.py
index 90d952fda..718901f47 100644
--- a/src/documents/admin.py
+++ b/src/documents/admin.py
@@ -71,12 +71,12 @@ def created_(self, obj):
 
     def thumbnail(self, obj):
         if settings.FORCE_SCRIPT_NAME:
-            _src="{}/fetch/thumb/{}".format(settings.FORCE_SCRIPT_NAME,obj.id)
+            src_link = "{}/fetch/thumb/{}".format(settings.FORCE_SCRIPT_NAME, obj.id)
         else:
-            _src="/fetch/thumb/{}".format(obj.id)
+            src_link = "/fetch/thumb/{}".format(obj.id)
         png_img = self._html_tag(
             "img",
-            src=_src,
+            src=src_link,
             width=180,
             alt="Thumbnail of {}".format(obj.file_name),
             title=obj.file_name

From 82f05e27c326a9c0ad5bcf21746e23cb5336ad14 Mon Sep 17 00:00:00 2001
From: maphy-psd <psd.phi@gmail.com>
Date: Sun, 20 Aug 2017 16:18:39 +0200
Subject: [PATCH 6/6] fix travis ci E510

E501 line too long (85 > 79 characters)
---
 src/documents/admin.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/documents/admin.py b/src/documents/admin.py
index 718901f47..16f544fb6 100644
--- a/src/documents/admin.py
+++ b/src/documents/admin.py
@@ -71,7 +71,8 @@ def created_(self, obj):
 
     def thumbnail(self, obj):
         if settings.FORCE_SCRIPT_NAME:
-            src_link = "{}/fetch/thumb/{}".format(settings.FORCE_SCRIPT_NAME, obj.id)
+            src_link = "{}/fetch/thumb/{}".format(
+                settings.FORCE_SCRIPT_NAME, obj.id)
         else:
             src_link = "/fetch/thumb/{}".format(obj.id)
         png_img = self._html_tag(