Skip to content

Commit 3e635a2

Browse files
ewdurbindi
andauthored
add floss.fund manifest provenance (#18494)
* add floss.fund manifest provenance The PSF is going to be applying to https://floss.fund, this file is necessary to establish the relationship between this repository and the PSF PyPI sponsorship program. ref: https://fundingjson.org/#wellknown * simplify --------- Co-authored-by: Dustin Ingram <[email protected]>
1 parent 0e57edc commit 3e635a2

File tree

6 files changed

+45
-2
lines changed

6 files changed

+45
-2
lines changed

tests/functional/test_basic.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
import webtest
77

88

9+
def test_funding_manifest_urls(app_config):
10+
testapp = webtest.TestApp(app_config.make_wsgi_app())
11+
resp = testapp.get("/.well-known/funding-manifest-urls")
12+
assert resp.status_code == HTTPStatus.OK
13+
assert resp.content_type == "text/plain"
14+
assert resp.body.decode(resp.charset) == "https://www.python.org/funding.json"
15+
16+
917
@pytest.mark.parametrize(
1018
("domain", "indexable"), [("pypi.org", True), ("test.pypi.org", False)]
1119
)

tests/unit/test_routes.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ def add_redirect_rule(*args, **kwargs):
6969
pretend.call("locale", "/locale/", domain=warehouse),
7070
pretend.call("favicon.ico", "/favicon.ico", domain=warehouse),
7171
pretend.call("robots.txt", "/robots.txt", domain=warehouse),
72+
pretend.call(
73+
"funding-manifest-urls",
74+
"/.well-known/funding-manifest-urls",
75+
domain=warehouse,
76+
),
7277
pretend.call("opensearch.xml", "/opensearch.xml", domain=warehouse),
7378
pretend.call("index.sitemap.xml", "/sitemap.xml", domain=warehouse),
7479
pretend.call("bucket.sitemap.xml", "/{bucket}.sitemap.xml", domain=warehouse),

tests/unit/test_views.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
forbidden_api,
3535
forbidden_include,
3636
force_status,
37+
funding_manifest_urls,
3738
health,
3839
httpexception_view,
3940
index,
@@ -378,6 +379,13 @@ def test_robotstxt(pyramid_request):
378379
assert pyramid_request.response.content_type == "text/plain"
379380

380381

382+
def test_funding_manifest_urls(pyramid_request):
383+
response = funding_manifest_urls(pyramid_request)
384+
assert response.text == "https://www.python.org/funding.json"
385+
assert response.content_type == "text/plain"
386+
assert response.charset == "utf-8"
387+
388+
381389
def test_opensearchxml(pyramid_request):
382390
assert opensearchxml(pyramid_request) == {}
383391
assert pyramid_request.response.content_type == "text/xml"

warehouse/locale/messages.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ msgid ""
1010
" action."
1111
msgstr ""
1212

13-
#: warehouse/views.py:322
13+
#: warehouse/views.py:341
1414
msgid "Locale updated"
1515
msgstr ""
1616

warehouse/routes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def includeme(config):
2020
config.add_route("locale", "/locale/", domain=warehouse)
2121
config.add_route("favicon.ico", "/favicon.ico", domain=warehouse)
2222
config.add_route("robots.txt", "/robots.txt", domain=warehouse)
23+
config.add_route(
24+
"funding-manifest-urls", "/.well-known/funding-manifest-urls", domain=warehouse
25+
)
2326
config.add_route("opensearch.xml", "/opensearch.xml", domain=warehouse)
2427
config.add_route("index.sitemap.xml", "/sitemap.xml", domain=warehouse)
2528
config.add_route("bucket.sitemap.xml", "/{bucket}.sitemap.xml", domain=warehouse)

warehouse/views.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from pyramid.i18n import make_localizer
2727
from pyramid.interfaces import ITranslationDirectories
2828
from pyramid.renderers import render_to_response
29-
from pyramid.response import FileResponse
29+
from pyramid.response import FileResponse, Response
3030
from pyramid.view import (
3131
exception_view_config,
3232
forbidden_view_config,
@@ -241,6 +241,25 @@ def robotstxt(request):
241241
return {}
242242

243243

244+
@view_config(
245+
route_name="funding-manifest-urls",
246+
decorator=[
247+
cache_control(1 * 24 * 60 * 60), # 1 day
248+
origin_cache(
249+
1 * 24 * 60 * 60, # 1 day
250+
stale_while_revalidate=6 * 60 * 60, # 6 hours
251+
stale_if_error=1 * 24 * 60 * 60, # 1 day
252+
),
253+
],
254+
)
255+
def funding_manifest_urls(request):
256+
return Response(
257+
"https://www.python.org/funding.json",
258+
content_type="text/plain",
259+
charset="utf-8",
260+
)
261+
262+
244263
@view_config(
245264
route_name="opensearch.xml",
246265
renderer="warehouse:templates/opensearch.xml",

0 commit comments

Comments
 (0)