Repository: pypi/warehouse

Issue:
Do not show links bar if no links are present on the project
We want to avoid this situation (see second grey - empty - div):

![screenshot from 2016-07-02 21-32-31](https://cloud.githubusercontent.com/assets/3323703/16542367/941c45f4-409c-11e6-8813-e006537601ac.png)

This should be as simple as wrapping the div in an if statement checking that links exist.

Do not show links bar if no links are present on the project
We want to avoid this situation (see second grey - empty - div):

![screenshot from 2016-07-02 21-32-31](https://cloud.githubusercontent.com/assets/3323703/16542367/941c45f4-409c-11e6-8813-e006537601ac.png)

This should be as simple as wrapping the div in an if statement checking that links exist.



Discussion:

Resolving patch:
diff --git a/warehouse/config.py b/warehouse/config.py
--- a/warehouse/config.py
+++ b/warehouse/config.py
@@ -218,6 +218,10 @@ def configure(settings=None):
     filters.setdefault("readme", "warehouse.filters:readme")
     filters.setdefault("shorten_number", "warehouse.filters:shorten_number")
     filters.setdefault("urlparse", "warehouse.filters:urlparse")
+    filters.setdefault(
+        "contains_valid_uris",
+        "warehouse.filters:contains_valid_uris"
+    )
 
     # We also want to register some global functions for Jinja
     jglobals = config.get_settings().setdefault("jinja2.globals", {})
diff --git a/warehouse/filters.py b/warehouse/filters.py
--- a/warehouse/filters.py
+++ b/warehouse/filters.py
@@ -27,6 +27,8 @@
 
 from pyramid.threadlocal import get_current_request
 
+from warehouse.utils.http import is_valid_uri
+
 
 def _camo_url(camo_url, camo_key, url):
     camo_key = camo_key.encode("utf8")
@@ -136,3 +138,10 @@ def format_classifiers(classifiers):
     structured = collections.OrderedDict(sorted(structured.items()))
 
     return structured
+
+
+def contains_valid_uris(items):
+    """Returns boolean representing whether the input list contains any valid
+    URIs
+    """
+    return any(is_valid_uri(i) for i in items)


Test patch:
diff --git a/tests/functional/test_templates.py b/tests/functional/test_templates.py
--- a/tests/functional/test_templates.py
+++ b/tests/functional/test_templates.py
@@ -39,6 +39,7 @@ def test_templates_for_empty_titles():
         "readme": "warehouse.filters:readme",
         "shorten_number": "warehouse.filters:shorten_number",
         "urlparse": "warehouse.filters:urlparse",
+        "contains_valid_uris": "warehouse.filters:contains_valid_uris"
     })
 
     for dir_, _, files in os.walk(dir_name):
diff --git a/tests/unit/test_filters.py b/tests/unit/test_filters.py
--- a/tests/unit/test_filters.py
+++ b/tests/unit/test_filters.py
@@ -207,3 +207,24 @@ def test_format_tags(inp, expected):
 )
 def test_format_classifiers(inp, expected):
     assert list(filters.format_classifiers(inp).items()) == expected
+
+
+@pytest.mark.parametrize(
+    ("inp", "expected"),
+    [
+        (
+            ["abcdef", "ghijkl"],
+            False
+        ),
+        (
+            ["https://github.com/example/test", "https://pypi.io/"],
+            True
+        ),
+        (
+            ["abcdef", "https://github.com/example/test"],
+            True
+        )
+    ]
+)
+def test_contains_valid_uris(inp, expected):
+    assert filters.contains_valid_uris(inp) == expected