Skip to content

Commit

Permalink
Merge branch 'develop' into ARXIVCE-2998-mirrors-on-stats
Browse files Browse the repository at this point in the history
  • Loading branch information
jweiskoff authored Jan 10, 2025
2 parents 1faa976 + 84ac6b6 commit a5285fa
Show file tree
Hide file tree
Showing 20 changed files with 262 additions and 252 deletions.
46 changes: 16 additions & 30 deletions browse/controllers/cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,26 @@


# Taken from legacy /users/e-prints/httpd/bin/Databases/mirrors
mirrors = [
'de.arxiv.org',
'es.arxiv.org',
'in.arxiv.org',
'cn.arxiv.org',
'lanl.arxiv.org',
'vanguard.math.ucdavis.edu:81',
]
# mirrors = [
# 'de.arxiv.org',
# 'es.arxiv.org',
# 'in.arxiv.org',
# 'cn.arxiv.org',
# 'lanl.arxiv.org',
# 'vanguard.math.ucdavis.edu:81',
# ]

mirror_config = {
'id': 'mirror',
'name': 'xxx-mirror',
'label': 'Select download site:',
'options': [['default', 'always local site (default)', 1]]
}
# mirror_config = {
# 'id': 'mirror',
# 'name': 'xxx-mirror',
# 'label': 'Select download site:',
# 'options': [['default', 'always local site (default)', 1]]
# }

for mirror in mirrors:
mirror_config['options'].append([mirror, mirror, 0]) # type: ignore
# for mirror in mirrors:
# mirror_config['options'].append([mirror, mirror, 0]) # type: ignore

cookies_config = [
{'id': 'ps',
'name': 'xxx-ps-defaults',
'label': 'Select preferred download format:',
'options': [
['default', 'PostScript (600 dpi), PDF (default)', 1],
['dpi=300%26font=bitmapped', 'PostScript (300 dpi)', 0],
['fname=cm%26font=TypeI', 'PostScript (Type I cm)', 0],
['pdf', 'PDF', 0],
['dvi', 'DVI', 0],
['src', 'Source', 0]
],
},
mirror_config,
{'id': 'mj',
'name': 'arxiv_mathjax',
'label': 'Select MathJax configuration: ',
Expand All @@ -49,7 +36,6 @@
}
]


def get_cookies_page(is_debug: bool) -> Any:
"""
Render the cookies page.
Expand Down
11 changes: 5 additions & 6 deletions browse/controllers/files/dissemination.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ 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'"
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 Expand Up @@ -203,7 +200,7 @@ def _html_response(file_list: Union[List[FileObj],FileObj],
# Not a data error since a non-html-source paper might legitimately not have a latexml HTML
resp= unavailable(arxiv_id)

if arxiv_id.has_version:
if arxiv_id.has_version:
resp.headers=add_surrogate_key(resp.headers,["html",f"html-{arxiv_id.idv}"])
else:
resp.headers=add_surrogate_key(resp.headers,["html",f"html-{arxiv_id.id}-current"])
Expand All @@ -213,7 +210,9 @@ def _html_response(file_list: Union[List[FileObj],FileObj],
def _html_source_single_response(file: FileObj, arxiv_id: Identifier) -> Response:
"""Produces a `Response`for a single file for a paper with HTML source."""
if _is_html_name(file): # do post_processing
return default_resp_fn( FileTransform(file, post_process_html), arxiv_id)
resp = default_resp_fn( FileTransform(file, post_process_html), arxiv_id)
resp.headers["Link"] = f"<https://arxiv.org/html/{arxiv_id.id}>; rel='canonical'"
return resp
else:
return default_resp_fn( file, arxiv_id)

Expand Down
2 changes: 1 addition & 1 deletion browse/formatting/cite.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _fmt_author_list(pauths: List[List[str]]) -> str:
authors = [
(f"{au[1]} " if (len(au) > 1 and au[1]) else "")
+ f"{au[0]}"
+ (f" {au[2]} au2" if (len(au) > 2 and au[2]) else "")
+ (f" {au[2]}" if (len(au) > 2 and au[2]) else "")
for au in pauths
]
return " and ".join(authors)
Expand Down
22 changes: 12 additions & 10 deletions browse/routes/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,16 @@ def catchup(subject:str, date:str) -> Response:
@blueprint.route("institutional_banner", methods=["GET"])
def institutional_banner() -> Any:
try:
result = get_institution(request.remote_addr)
forwarded_ips = request.headers.getlist("X-Forwarded-For")
if len(forwarded_ips)>0:
ip = str(forwarded_ips[0]).split(',')[0]
ip = ip.strip()
elif request.remote_addr is None:
return ("{}", status.OK)
else:
ip = str(request.remote_addr)

result = get_institution(ip)
if result:
return (result, status.OK)
else:
Expand Down Expand Up @@ -409,17 +418,10 @@ def year(archive: str, year: int): # type: ignore
return render_template("year.html", **response), code, headers


@blueprint.route("cookies", defaults={"set": ""})
@blueprint.route("cookies/<set>", methods=["POST", "GET"])
def cookies(set): # type: ignore
@blueprint.route("cookies")
def cookies(): # type: ignore
"""Cookies landing page and setter."""
is_debug = request.args.get("debug", None) is not None
if request.method == "POST":
debug = {"debug": "1"} if is_debug else {}
resp = redirect(url_for("browse.cookies", **debug)) # type: ignore
for ctoset in cookies_to_set(request):
resp.set_cookie(**ctoset) # type: ignore
return resp
response, code, headers = get_cookies_page(is_debug)
return render_template("cookies.html", **response), code, headers

Expand Down
3 changes: 1 addition & 2 deletions browse/static/bibex/bibex.js

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions browse/static/css/arXiv.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************
* arXiv.org Cascading Style Sheet
* $Date: 2024/08/22 $
* $Date: 2024/12/06 $
*****************************************/
/****************************************
* General rules
Expand Down Expand Up @@ -1634,7 +1634,12 @@ div#long-author-list {

#abs .arxividv {}

#abs .jref {}
#abs .jref {
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
word-break: break-word;
}

#abs .error {
border: 2px solid #B31B1B;
Expand Down
64 changes: 45 additions & 19 deletions browse/static/css/slider.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* latest update: 8/15/2024 v1.14*/
/* latest update: 12/11/2024*/

body {
margin: 0;
Expand Down Expand Up @@ -139,7 +139,7 @@ body {
padding-left: 0;
text-align: center;
}
@media (min-width: 900px) {
@media (min-width: 769px) {
.slider-wrapper .copy-donation {
float: left;
width: 65%;
Expand All @@ -159,7 +159,8 @@ body {
float: left;
}
.slider-wrapper .donate-cta {
float: left;
float: right;
margin-right: 15%;
}
}
@media (min-width: 983px) {
Expand All @@ -175,21 +176,29 @@ body {
@media (min-width: 1090px) {
.slider-wrapper .copy-donation {
float: left;
width: 80%;
width: 70%;
}
.slider-wrapper .amount-donation {
float: right;
width: 18%;
width: 28%;
}
}
@media (min-width: 1200px) {
.slider-wrapper {
margin: 0 auto;
}
.slider-donation {
background-color: #4d4f53;
width: 100%;
}
@media (min-width: 1235px) {
.slider-wrapper {
margin: 0 auto;
}
.slider-donation {
background-color: #4d4f53;
width: 100%;
}
.slider-wrapper .copy-donation {
float: left;
width: 80%;
}
.slider-wrapper .amount-donation {
float: right;
width: 18%;
}
}

.survey-results {
Expand Down Expand Up @@ -234,12 +243,13 @@ body {
color: #ffffff;
}
.slider-wrapper .copy-donation.bps-banner {
width: 70%;
margin-left:15px;
}
.slider-wrapper .copy-donation.bps-banner h2 {
color: #f3edbe;
color: #ffffff;
margin-bottom: 10px;
margin-top: 20px;
font-size: 1.1em;
}
.slider-wrapper .copy-donation.bps-banner p {
color: #f9f7f7;
Expand All @@ -251,13 +261,12 @@ body {
color: #f5e98e;
text-shadow: 1px 1px #831212;
}
.slider-wrapper .amount-donation.bps-banner {
width: 25%;
}

.slider-wrapper .amount-donation.bps-banner .donate-cta a {
background-color: #b31b1b;
margin: 10px 5px;
color: #000000;
font-size: 1em;
}
.slider-wrapper .amount-donation.bps-banner .donate-cta a:hover {
opacity: 1;
Expand Down Expand Up @@ -287,9 +296,26 @@ body {
text-decoration: none;
}

@media (max-width: 768px) {
.slider-wrapper .amount-donation{
display: flex;
justify-content: center;
}
.slider-wrapper .donate-cta {
float: none;
}
.slider-wrapper .copy-donation.bps-banner {
width: 90%;
text-align: center;
}
}


/*Forum banner style overrides*/
/*banner style overrides*/
.slider-wrapper.bps-banner.special-color {
background-color: #000;
color: #ffffff;
}
.slider-wrapper.bps-banner.forum {
background-color: #000;
color: #ffffff;
Expand Down
10 changes: 5 additions & 5 deletions browse/static/js/donate.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//version 1.11
//last update 12/11/24
function setCookie(){
var delay_days = 5;
var delay_days = 40;
var date = new Date();
date.setTime(date.getTime()+(delay_days*3600*24*1000));
var expires = "; expires="+date.toGMTString();
document.cookie = 'seentheDonateBanner=1' + expires + '; path=/; domain=' + window.location.hostname + ';';
document.cookie = 'seenthePrivacyBanner=1' + expires + '; path=/; domain=' + window.location.hostname + ';';
}

function hasCookie(){
return document.cookie.indexOf('seentheDonateBanner=') != -1;
return document.cookie.indexOf('seenthePrivacyBanner=') != -1;
}

$(document).ready(
Expand All @@ -19,7 +19,7 @@ $(document).ready(
$(".slider-wrapper").slideUp();
}

$(".close-slider").click(function() {
$(".do-close-slider").click(function() {
$("#cu-identity").slideDown();
$(".slider-wrapper").slideUp();
setCookie();
Expand Down
2 changes: 1 addition & 1 deletion browse/static/js/toggle-labs.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $(document).ready(function() {
"gotitpub": $('#gotitpub-toggle').data('script-url'),
"alphaxiv": $('#alphaxiv-toggle').data('script-url'),
"bibex": {
"url": "https://static.arxiv.org/js/bibex/bibex.js?20210223",
"url": $('#bibex-toggle').data('script-url'),
"container": "#bib-main"
},
"core-recommender": {
Expand Down
3 changes: 2 additions & 1 deletion browse/templates/abs/labs_tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ <h1>Bibliographic and Citation Tools</h1>
<div class="columns is-mobile lab-row">
<div class="column lab-switch">
<label class="switch">
<input id="bibex-toggle" type="checkbox" class="lab-toggle">
<input id="bibex-toggle" type="checkbox" class="lab-toggle"
data-script-url="{{ url_for('static', filename='bibex/bibex.js') }}?20241202">
<span class="slider"></span>
<span class="is-sr-only">Bibliographic Explorer Toggle</span>
</label>
Expand Down
12 changes: 6 additions & 6 deletions browse/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{%- import 'base/macros.html' as base_macros -%}
{%- import 'user_banner.html' as user_banner -%}
{%- set rd_int = request_datetime.strftime("%Y%m%d%H%M")|int -%}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<!DOCTYPE html>
<html lang="en">

<head>
{%- block head -%}
Expand All @@ -16,7 +15,7 @@
<link rel="mask-icon" href="{{ url_for('static', filename='images/icons/safari-pinned-tab.svg') }}" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<link rel="stylesheet" type="text/css" media="screen" href="{{ url_for('static', filename='css/arXiv.css') }}?v=20240822" />
<link rel="stylesheet" type="text/css" media="screen" href="{{ url_for('static', filename='css/arXiv.css') }}?v=20241206" />
<link rel="stylesheet" type="text/css" media="print" href="{{ url_for('static', filename='css/arXiv-print.css') }}?v=20200611" />
<link rel="stylesheet" type="text/css" media="screen" href="{{ url_for('static', filename='css/browse_search.css') }}" />
<script language="javascript" src="{{ url_for('static', filename='js/accordion.js') }}" /></script>
Expand Down Expand Up @@ -83,8 +82,9 @@

<div id="header" class="is-hidden-mobile">
{% block header %}
{#- The ignore_me link is not meant to be visible to users; it is meant to catch robots/crawlers not respecting robots.txt. aria-hidden prevents screenreaders from being caught. -#}
<a aria-hidden="true" href="/IgnoreMe"></a>
{#- The ignore_me link is not meant to be visible to users; it is meant to catch robots/crawlers not respecting robots.txt.
aria-hidden prevents screenreaders from being caught, and tabindex prevents it from being selectable via the tab key. -#}
<a aria-hidden="true" tabindex="-1" href="/IgnoreMe"></a>
{% block header_h1 %}<h1><img src="{{ url_for('static', filename='images/arxiv-logo-one-color-white.svg') }}" alt="arxiv logo" style="height:60px;"/></h1>{% endblock header_h1%}
{% block login_link %}{% endblock %}
{{ base_macros.compactsearch() }}
Expand Down
Loading

0 comments on commit a5285fa

Please sign in to comment.