Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #255 from maphy-psd/master
Browse files Browse the repository at this point in the history
add FORCE_SCRIPT_NAME to host paperless on a subpath url
  • Loading branch information
danielquinn authored Sep 6, 2017
2 parents 1e039dc + 82f05e2 commit 2c55aad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions paperless.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -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 ####
Expand Down
7 changes: 6 additions & 1 deletion src/documents/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ def created_(self, obj):
created_.short_description = "Created"

def thumbnail(self, obj):
if settings.FORCE_SCRIPT_NAME:
src_link = "{}/fetch/thumb/{}".format(
settings.FORCE_SCRIPT_NAME, obj.id)
else:
src_link = "/fetch/thumb/{}".format(obj.id)
png_img = self._html_tag(
"img",
src="/fetch/thumb/{}".format(obj.id),
src=src_link,
width=180,
alt="Thumbnail of {}".format(obj.file_name),
title=obj.file_name
Expand Down
3 changes: 2 additions & 1 deletion src/paperless/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
if _allowed_hosts:
ALLOWED_HOSTS = _allowed_hosts.split(",")


FORCE_SCRIPT_NAME = os.getenv("PAPERLESS_FORCE_SCRIPT_NAME")

# Application definition

INSTALLED_APPS = [
Expand Down

0 comments on commit 2c55aad

Please sign in to comment.