Skip to content

Commit f8a20de

Browse files
committed
Break out some templates for easy override, clean up search on dashboard
Breaks out templates to base and extended templates, so that we can easily override the blocks.
1 parent ae0d896 commit f8a20de

File tree

7 files changed

+283
-246
lines changed

7 files changed

+283
-246
lines changed

media/css/core.css

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,29 @@ div.menu-user div.menu-dropdown.menu-dropped {
323323
/* Success Model Item */
324324
.module-item .success { float: right; }
325325

326+
/* dashboard */
327+
div.module.search-dashboard {
328+
overflow: auto;
329+
border: 0px;
330+
margin-bottom: 24px;
331+
}
332+
333+
div.module.search-dashboard div.search {
334+
border: 0px;
335+
}
336+
337+
div.module.search-dashboard input {
338+
display: block;
339+
padding-left: 40px;
340+
height: 2.5em;
341+
box-sizing: border-box;
342+
-moz-box-sizing: border-box;
343+
-webkit-box-sizing: border-box;
344+
background-image: url('../images/search.png');
345+
background-repeat: no-repeat;
346+
background-position: 8px center;
347+
background-size: 24px 24px;
348+
}
326349

327350
/* project bar */
328351

@@ -341,10 +364,6 @@ div.menu-user div.menu-dropdown.menu-dropped {
341364
line-height: 1em;
342365
}
343366

344-
#project_bar .project-title span.project-breadcrumb:after {
345-
content: " \bb";
346-
}
347-
348367
/* options */
349368
#project_bar .options { padding: 20px 0 0 0; }
350369
#project_bar .options ul li { float: left; display: block; margin-right: 10px; }

media/images/search.png

1.28 KB
Loading

readthedocs/projects/templatetags/projects_tags.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@ def sort_version_aware(versions):
1414
return sorted(versions,
1515
key=lambda v: (mkversion(v) or fallback),
1616
reverse=True)
17+
18+
19+
@register.filter
20+
def is_project_user(user, project):
21+
"""
22+
Return if user is a member of project.users
23+
"""
24+
return user in project.users.all()
Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,9 @@
1+
{% extends 'core/project_bar_base.html' %}
2+
{% load projects_tags %}
13
{% load i18n %}
2-
{% load core_tags %}
3-
{% load privacy_tags %}
4-
{% load gravatar %}
54

6-
<!-- BEGIN project bar -->
7-
<div id="project_bar">
8-
<div class="wrapper">
9-
10-
<div class="project-title">
11-
<h1>
12-
<span class="project-breadcrumb quiet">
13-
<a href="{% url "projects_dashboard" %}">{% trans "Projects" %}</a>
14-
</span>
15-
<a href="{{ project.get_absolute_url }}">{{ project }}</a>
16-
</h1>
17-
</div>
18-
19-
<div class="options">
20-
21-
<ul>
22-
<li class="{{ overview_active }}"><a href="{{ project.get_absolute_url }}">{% trans "Overview" %}</a></li>
23-
{% if project.has_good_build %}
24-
<li><a href="{{ project.get_docs_url }}">{% trans "View Docs" %}</a></li>
25-
{% endif %}
26-
27-
<li class="{{ downloads_active }}"><a href="{% url "project_downloads" project.slug %}" rel="nofollow,noindex">{% trans "Downloads" %}</a></li>
28-
29-
<li class="{{ search_active }}"><a href="{% url "elastic_project_search" project.slug %}" rel="nofollow,noindex">{% trans "Search" %}</a></li>
30-
31-
<li class="{{ builds_active }}"><a href="{{ project.get_builds_url }}">{% trans "Builds" %}</a></li>
32-
33-
{% if request.user|is_admin:project %}
34-
<li class="{{ edit_active }}"><a href="{% url "projects_edit" project.slug %}"><i class="gear"></i>{% trans "Admin" %}</a></li>
35-
{% endif %}
36-
37-
38-
</ul>
39-
</div>
40-
41-
</div>
42-
</div>
43-
<!-- END project bar -->
5+
{% block project-breadcrumb %}
6+
{% if request.user|is_project_user:project %}
7+
<a href="{% url "projects_dashboard" %}">{% trans "Projects" %}</a>&nbsp;&gt;
8+
{% endif %}
9+
{% endblock %}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{% load i18n %}
2+
{% load core_tags %}
3+
{% load privacy_tags %}
4+
{% load gravatar %}
5+
6+
<!-- BEGIN project bar -->
7+
<div id="project_bar">
8+
<div class="wrapper">
9+
10+
<div class="project-title">
11+
<h1>
12+
<span class="project-breadcrumb quiet">
13+
{% block project-breadcrumb %}
14+
<a href="{% url "projects_dashboard" %}">{% trans "Projects" %}</a>&nbsp;&gt;
15+
{% endblock %}
16+
</span>
17+
<a href="{{ project.get_absolute_url }}">{{ project }}</a>
18+
</h1>
19+
</div>
20+
21+
<div class="options">
22+
<ul>
23+
<li class="{{ overview_active }}"><a href="{{ project.get_absolute_url }}">{% trans "Overview" %}</a></li>
24+
{% if project.has_good_build %}
25+
<li><a href="{{ project.get_docs_url }}">{% trans "View Docs" %}</a></li>
26+
{% endif %}
27+
28+
<li class="{{ downloads_active }}"><a href="{% url "project_downloads" project.slug %}" rel="nofollow,noindex">{% trans "Downloads" %}</a></li>
29+
30+
<li class="{{ search_active }}"><a href="{% url "elastic_project_search" project.slug %}" rel="nofollow,noindex">{% trans "Search" %}</a></li>
31+
32+
<li class="{{ builds_active }}"><a href="{{ project.get_builds_url }}">{% trans "Builds" %}</a></li>
33+
34+
{% if request.user|is_admin:project %}
35+
<li class="{{ edit_active }}"><a href="{% url "projects_edit" project.slug %}"><i class="gear"></i>{% trans "Admin" %}</a></li>
36+
{% endif %}
37+
</ul>
38+
</div>
39+
40+
</div>
41+
</div>
42+
<!-- END project bar -->
Lines changed: 1 addition & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -1,201 +1 @@
1-
{% extends "base.html" %}
2-
{% load i18n %}
3-
{% load pagination_tags %}
4-
5-
{% block title %}{% trans "Project Dashboard" %}{% endblock %}
6-
7-
{% block dash-nav-projects %}active{% endblock %}
8-
9-
{% block content %}
10-
{% url "projects_import" as projects_import_url %}
11-
{% url "socialaccount_connections" as social_accounts %}
12-
13-
<!-- BEGIN your projects list -->
14-
<div class="col-major project-dashboard-right">
15-
{% if project_list %}
16-
17-
{% if filter|length > 0 %}
18-
<div class="module-header">
19-
<h3>{% trans "Important Versions" %}</h3>
20-
</div>
21-
22-
<div class="filter">
23-
{% autopaginate filter 15 %}
24-
25-
<!-- BEGIN filter list -->
26-
<div class="module">
27-
<div class="module-wrapper">
28-
29-
<div class="module-list">
30-
<div class="module-list-wrapper">
31-
<ul>
32-
{% include "core/filter_list.html" %}
33-
</ul>
34-
</div>
35-
</div>
36-
37-
</div>
38-
</div>
39-
<!-- END filter list -->
40-
41-
{% paginate %}
42-
43-
</div>
44-
{% endif %}
45-
46-
<div class="module">
47-
<div class="module-wrapper">
48-
49-
<div class="module-header">
50-
<form method="get" action="{{ projects_import_url }}">
51-
<input type="submit" value="Import a Project" />
52-
</form>
53-
<h3>{% trans "Projects" %}</h3>
54-
</div>
55-
56-
<div class="module-list">
57-
<div class="module-list-wrapper">
58-
59-
<ul>
60-
{% for project in project_list %}
61-
<li class="module-item col-span">
62-
<a href="{% url "projects_manage" project.slug %}">
63-
{{ project.name }}
64-
{% with builds=project.builds.count %}
65-
{% if builds == 0 %}
66-
<span class="right quiet">
67-
{% trans "No builds yet" %}
68-
</span>
69-
{% else %}
70-
<span class="right quiet">
71-
<span class="build-count">
72-
{% if builds == 1 %}
73-
{% trans "1 build" %}
74-
{% else %}
75-
{{ builds }} {% trans "builds" %}
76-
{% endif %}
77-
</span>
78-
{% with build=project.get_latest_build %}
79-
{% if build.success %}
80-
<span class="build-state build-state-passing">{% trans "passing" %}</span>
81-
{% else %}
82-
<span class="build-state build-state-failing">{% trans "failing" %}</span>
83-
{% endif %}
84-
{% endwith %}
85-
</span>
86-
{% endif %}
87-
{% endwith %}
88-
</a>
89-
</li>
90-
{% endfor %}
91-
</ul>
92-
93-
</div>
94-
</div>
95-
</div>
96-
</div>
97-
98-
{% else %}
99-
100-
<!-- BEGIN onboard import project -->
101-
<div class="module onboard onboard-import-project">
102-
<h2>Ready to share your documentation{% if request.user.first_name %}, {{ request.user.first_name }}{% endif %}?</h2>
103-
104-
{% with getting_started_url="http://docs.readthedocs.org/en/latest/getting_started.html" %}
105-
<form method="get" action="{{ projects_import_url }}">
106-
<p>
107-
{% blocktrans %}
108-
You don't have any projects yet, but you can start building documentation by importing one.
109-
Not sure how to start documenting your project?
110-
Check out the <a href="{{ getting_started_url }}">Getting Started Guide</a> to learn how.
111-
{% endblocktrans %}
112-
</p>
113-
114-
<input type="submit" value="Import a Project" />
115-
</form>
116-
{% endwith %}
117-
</div>
118-
<!-- END onboard import project -->
119-
120-
{% endif %}
121-
</div>
122-
<!-- END your projects list -->
123-
124-
<!-- BEGIN project side bar -->
125-
<div class="col-minor project-dashboard-right">
126-
127-
<div class="module onboard onbard-accounts">
128-
129-
<!-- BEGIN search form -->
130-
<form action="{% url 'search' %}" method="GET">
131-
<div class="text-input-wrapper">
132-
<input type="text" name="q" style="width: 10em;" id="id_elastic_project_search">
133-
{% if type %}
134-
<input type="hidden" name="type" value="{{ type }}">
135-
{% endif %}
136-
{% if taxonomy %}
137-
<input type="hidden" name="taxonomy" value="{{ taxonomy }}">
138-
{% endif %}
139-
</div>
140-
<div class="submit-input-wrapper">
141-
{% comment %}Translators: This is about starting a search{% endcomment %}
142-
<input type="submit" value="{% trans "Search" %}">
143-
</div>
144-
</form>
145-
<!-- END search form -->
146-
147-
{% if request.user.socialaccount_set.count == 0 %}
148-
<h3>Connect your Accounts</h3>
149-
150-
<p>
151-
{% blocktrans %}
152-
Have a Github account? Connect your account and import your existing projects automatically.
153-
{% endblocktrans %}
154-
</p>
155-
156-
<form method="get" action="{{ social_accounts }}">
157-
<input type="submit" value="Connect to Github" />
158-
</form>
159-
</div>
160-
{% else %}
161-
<p>
162-
<form method="get" action="{% url 'projects_import_github' %}">
163-
<input type="submit" value="Import from GitHub" />
164-
</form>
165-
</p>
166-
167-
{% endif %}
168-
169-
<div class="module info info-docs">
170-
<p>
171-
Check out the <a href="http://docs.readthedocs.org/en/latest/index.html">documentation for Read the Docs</a>.
172-
It contains lots of information about how to get the most out of RTD.
173-
</p>
174-
</div>
175-
</div>
176-
<!-- END project side bar -->
177-
178-
{% comment %}
179-
{% if bookmark_list %}
180-
<!-- BEGIN marks list -->
181-
<div class="module">
182-
<div class="module-wrapper">
183-
<div class="module-header">
184-
<h3>{% trans "Recently Bookmarked Docs" %} <span class="small_head"><a href="{% url "user_bookmarks" %}">{% trans "(All My Bookmarks)" %}</a></span></h3>
185-
</div>
186-
187-
<div class="module-list">
188-
<div class="module-list-wrapper">
189-
<ul>
190-
{% include "core/bookmark_list_detailed.html" %}
191-
</ul>
192-
</div>
193-
</div>
194-
195-
</div>
196-
</div>
197-
<!-- END marks list -->
198-
{% endif %}
199-
{% endcomment %}
200-
201-
{% endblock %}
1+
{% extends 'projects/project_dashboard_base.html' %}

0 commit comments

Comments
 (0)