Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add FORCE_SCRIPT_NAME to host paperless on a subpath url #255

Merged
merged 6 commits into from Sep 6, 2017

Conversation

Projects
None yet
3 participants
@maphy-psd
Copy link
Contributor

commented Aug 19, 2017

I host paperless on raspberrypi/paperless. This should do the trick.

maphy-psd added some commits Aug 19, 2017

def thumbnail uses FORCE_SCRIPT_NAME
with this edit the tumbnails are show up..
@@ -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)

This comment has been minimized.

Copy link
@MasterofJOKers

MasterofJOKers Aug 19, 2017

Contributor

There a space missing after the ,.

This comment has been minimized.

Copy link
@maphy-psd

maphy-psd Aug 20, 2017

Author Contributor

Thanks..i will fix it.

FORCE_SCRIPT_NAME = None
_force_script_name = os.getenv("PAPERLESS_FORCE_SCRIPT_NAME")
if _force_script_name:
FORCE_SCRIPT_NAME = _force_script_name

This comment has been minimized.

Copy link
@MasterofJOKers

MasterofJOKers Aug 19, 2017

Contributor

Looking at https://docs.python.org/3/library/os.html#os.getenv, you could just write FORCE_SCRIPT_NAME = os.getenv("PAPERLESS_FORCE_SCRIPT_NAME") as this would return None per default. There's no need to set it to None explicitly.

This comment has been minimized.

Copy link
@maphy-psd

maphy-psd Aug 20, 2017

Author Contributor

Oh thanks..i still have to learn a lot

png_img = self._html_tag(
"img",
src="/fetch/thumb/{}".format(obj.id),
src=_src,

This comment has been minimized.

Copy link
@danielquinn

danielquinn Aug 20, 2017

Collaborator

Please don't prefix local variables with an underscore like this. It makes sense for instance variables or class methods (as the underscore denotes privacy), but in a local variable it means nothing.

Note that this is different from the prefixing used in settings.py, since that file is just a collection of variables in the global scope, so prefixing with an underscore makes sense there as a means of keeping variables private to the file.

This comment has been minimized.

Copy link
@maphy-psd

maphy-psd Aug 20, 2017

Author Contributor

Sry..you're right. Is src_link ok?

maphy-psd added some commits Aug 20, 2017

fix travis ci E510
E501 line too long (85 > 79 characters)
@danielquinn

This comment has been minimized.

Copy link
Collaborator

commented Sep 6, 2017

Thanks for contributing this. I've been (and still am) on my honeymoon, hence the delay in merging it.

The changes look good, and I appreciate your work to conform to pep8 etc. I'll merge it now, and then add some documentation later this week before doing a version bump.

@danielquinn danielquinn merged commit 2c55aad into the-paperless-project:master Sep 6, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.