Skip to content

Commit 8f1bf22

Browse files
authored
Add links to Addons documentation (#662)
This also makes the Analytics pages not show download buttons or graphs with no data. This feels much cleaner. Old <img width="625" height="662" alt="Screenshot 2025-10-30 at 8 12 28 AM" src="https://github.com/user-attachments/assets/630e03dd-5aa9-41a7-b26d-e5cccd07a61e" /> New <img width="725" height="391" alt="Screenshot 2025-10-30 at 8 11 46 AM" src="https://github.com/user-attachments/assets/5494dbef-f9f0-4936-abe4-ce8c612f4688" />
1 parent 20c1a4e commit 8f1bf22

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

readthedocsext/theme/templates/projects/partials/edit/traffic_list.html

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{% extends "includes/crud/table_list.html" %}
22

3-
{% load blocktrans trans from i18n %}
3+
{% load trans blocktrans from i18n %}
44

55
{% block top_left_menu_items %}
66
{% endblock top_left_menu_items %}
77

88
{% block create_button %}
9-
<a class="ui button" href="?download=true">
10-
<i class="fa-duotone fa-download icon"></i>
11-
{% trans "Download traffic data" %}
12-
</a>
9+
{% if objects %}
10+
<a class="ui button" href="?download=true">
11+
<i class="fa-duotone fa-download icon"></i>
12+
{% trans "Download traffic data" %}
13+
</a>
14+
{% endif %}
1315
{% endblock create_button %}
1416

1517
{% block list_placeholder_icon_class %}
@@ -23,11 +25,17 @@
2325
{% blocktrans trimmed %}
2426
Traffic data will be accumulated as readers view your documentation.
2527
{% endblocktrans %}
28+
{% if show_addons_link %}
29+
{% url 'projects_addons' project.slug as addons_url %}
30+
{% blocktrans with url=addons_url trimmed %}
31+
Traffic analytics must be enabled in your project's <a href="{{ url }}">Addons settings</a>.
32+
{% endblocktrans %}
33+
{% endif %}
2634
</div>
2735
{% endblock list_placeholder_header %}
2836
{% block list_placeholder_text %}
2937
<a class="ui button"
30-
href="https://docs.readthedocs.io/en/stable/analytics.html"
38+
href="https://docs.readthedocs.io/en/stable/traffic-analytics.html"
3139
aria-label="{% trans "Learn more about traffic analytics in our documentation" %}"
3240
target="_blank">{% trans "Learn more" %}</a>
3341
{% endblock list_placeholder_text %}

readthedocsext/theme/templates/projects/traffic_analytics.html

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@
2626
<div class="{% if not enabled %}ui basic fitted disabled segment{% endif %}"
2727
data-bind="using: ProjectTrafficAnalyticsView()">
2828

29-
{% include "projects/partials/edit/traffic_list.html" with objects=top_pages_200 %}
29+
{% include "projects/partials/edit/traffic_list.html" with objects=top_pages_200 show_addons_link=True %}
3030

31-
<h3 class="ui small header">
32-
{% trans "Overview" %}
33-
<div class="sub header">{% trans "For the last month" %}</div>
34-
</h3>
31+
{% if top_pages_200 %}
32+
<h3 class="ui small header">
33+
{% trans "Overview" %}
34+
<div class="sub header">{% trans "For the last month" %}</div>
35+
</h3>
3536

36-
<div class="ui loading segment" data-bind="css: {loading: is_loading()}">
37-
<canvas width="400" height="150" data-bind="chart: config"></canvas>
38-
<script type="application/json" data-bind="jsonInit: config">
37+
<div class="ui loading segment" data-bind="css: {loading: is_loading()}">
38+
<canvas width="400" height="150" data-bind="chart: config"></canvas>
39+
<script type="application/json" data-bind="jsonInit: config">
3940
{
4041
"type": "line",
4142
"data": {
@@ -62,14 +63,15 @@ <h3 class="ui small header">
6263
}
6364
}
6465
}
65-
</script>
66-
</div>
66+
</script>
67+
</div>
6768

68-
<h3 class="ui small header">
69-
{% trans "Not found pages (404)" %}
70-
<div class="sub header">{% trans "For the last month" %}</div>
71-
</h3>
72-
{% include "projects/partials/edit/traffic_list.html" with objects=top_pages_404 %}
69+
<h3 class="ui small header">
70+
{% trans "Not found pages (404)" %}
71+
<div class="sub header">{% trans "For the last month" %}</div>
72+
</h3>
73+
{% include "projects/partials/edit/traffic_list.html" with objects=top_pages_404 %}
74+
{% endif %}
7375

7476
</div>
7577
{% endblock project_edit_content %}

0 commit comments

Comments
 (0)