Skip to content

Commit

Permalink
Merge pull request #691 from arXiv/develop
Browse files Browse the repository at this point in the history
deploy various changes
  • Loading branch information
kyokukou authored Aug 8, 2024
2 parents 825096c + cbc7e8d commit 01048c8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
4 changes: 4 additions & 0 deletions browse/controllers/files/dissemination.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ def pdf_resp_fn(file: FileObj,
resp = default_resp_fn(file, arxiv_id, docmeta, version)
filename = f"{arxiv_id.filename}v{version.version}.pdf"
resp.headers["Content-Disposition"] = f"inline; filename=\"{filename}\""
if arxiv_id.has_version:
resp.headers["Link"] = f"<https://arxiv.org/pdf/{arxiv_id.idv}>; rel='canonical'"
else:
resp.headers["Link"] = f"<https://arxiv.org/pdf/{arxiv_id.id}>; rel='canonical'"
if arxiv_id.has_version:
resp.headers=add_surrogate_key(resp.headers,["pdf",f"pdf-{arxiv_id.idv}"])
else:
Expand Down
11 changes: 3 additions & 8 deletions browse/routes/dissemination.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,10 @@ def pdf(arxiv_id: str, archive=None): # type: ignore
Does a 404 if the key for the ID does not exist on the bucket.
"""
return get_pdf_resp(arxiv_id, archive)

@blueprint.route("/pdf_test/<string:archive>/<string:arxiv_id>.pdf", methods=['GET', 'HEAD'])
@blueprint.route("/pdf_test/<string:arxiv_id>.pdf", methods=['GET', 'HEAD'])
def pdf_test(arxiv_id: str, archive=None): # type: ignore
"""Path to test pdf via fastly.

Can be removed when no longer needed."""
return get_dissemination_resp(fileformat.pdf, arxiv_id, archive)
if request.query_string: # redirect to strip off any useless query strings
return redirect(url_for('.pdf', arxiv_id=arxiv_id, archive=archive, _external=True), 301)
return get_pdf_resp(arxiv_id, archive)


@blueprint.route("/format/<string:archive>/<string:arxiv_id>", methods=['GET', 'HEAD'])
Expand Down
4 changes: 2 additions & 2 deletions browse/static/css/ar5iv.0.7.9.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
--main-width-margin:54rem;
--headings-font-family:"noto-sans",sans-serif;
--text-font-family:"noto-serif",serif;
--math-font-family:"stix-two-math","Cambria Math",math;
--math-caligraphic-font-family:"stix-two-math","Cambria Math",math;
--math-font-family:"STIX Two Math","STIX Two Math Fallback","Cambria Math",math;
--math-caligraphic-font-family:"STIX Two Math","STIX Two Math Fallback","Cambria Math",math;
--code-font-family:"noto-mono",monospace;
--background-color:white;
--text-color:#292929;
Expand Down
2 changes: 1 addition & 1 deletion browse/templates/user_banner.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h2>Help spread the word</h2>
<img role="presentation" class="bps-banner-image" src="{{ url_for('static', filename='images/icons/smileybones-infinity-large.png') }}" alt="arXiv Accessibility Forum 2024">
<div class="copy-donation bps-banner">
<h2>Grab your spot!</h2>
<p>Want to see access to research regardless of disability? Sign up for the <a href="https://cornell.ca1.qualtrics.com/jfe/form/SV_eEZ1d27LF2fVM7Y" target="_blank">arXiv Accessibility Forum</a> in September and <a href="https://accessibility2024.arxiv.org/" target="_blank">Learn more</a>.</p>
<p>Want to support truly open science and create access to research, regardless of disability? Sign up for the <a href="https://cornell.ca1.qualtrics.com/jfe/form/SV_eEZ1d27LF2fVM7Y" target="_blank">arXiv Accessibility Forum</a> in September and <a href="https://accessibility2024.arxiv.org/" target="_blank">Learn more</a>.</p>
</div>
<div class="amount-donation bps-banner">
<div class="donate-cta"><a class="banner_link banner-btn-grad" target="_blank" href="https://cornell.ca1.qualtrics.com/jfe/form/SV_eEZ1d27LF2fVM7Y"><b>Sign Up</b></a></div>
Expand Down
16 changes: 15 additions & 1 deletion tests/dissemination/test_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,23 @@ def test_pdf_headers(client_with_test_fs):
assert "pdf-cs/0011004v" not in head
assert "paper-id-cs/0011004" in head

assert rv.headers["Link"] == "<https://arxiv.org/pdf/cs/0011004>; rel='canonical'"

rv=client_with_test_fs.head("/pdf/cs/0011004v1")
head=rv.headers["Surrogate-Key"]
assert " pdf " in " "+head+" "
assert "pdf-cs/0011004-current" not in head
assert "pdf-cs/0011004v1" in head
assert "paper-id-cs/0011004" in head
assert "paper-id-cs/0011004" in head

assert rv.headers["Link"] == "<https://arxiv.org/pdf/cs/0011004v1>; rel='canonical'", "should not have version"


def test_pdf_redirect(client_with_test_fs):
rv=client_with_test_fs.head("/pdf/cs/0011004v1?crazy_query_string=notgood")
assert rv.status_code == 301
assert rv.headers["Location"] == "http://localhost/pdf/cs/0011004v1"

rv = client_with_test_fs.head("/pdf/2201.0001?crazy_query_string=notgood")
assert rv.status_code == 301
assert rv.headers["Location"] == "http://localhost/pdf/2201.0001"

0 comments on commit 01048c8

Please sign in to comment.