Skip to content

Commit c7ed8c6

Browse files
committed
Refactor package search and discover page
- Use compact table for package listing - Redesign package search template Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 83d5dae commit c7ed8c6

5 files changed

Lines changed: 73 additions & 26 deletions

File tree

fedcode/forms.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,8 @@ class SearchPackageForm(forms.Form):
110110
label=False,
111111
widget=forms.TextInput(
112112
attrs={
113-
"placeholder": "Please enter a valid purl ex: pkg:maven/org.apache.commons/io",
114-
"class": "input is-rounded",
115-
"style": "width: 90%;",
113+
"placeholder": "Search a package...",
114+
"class": "input ",
116115
},
117116
),
118117
)

fedcode/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ def __str__(self):
295295
def followers_count(self):
296296
return Follow.objects.filter(package=self).count()
297297

298+
@property
299+
def notes_count(self):
300+
return Note.objects.filter(acct=self.acct).count()
301+
298302
@property
299303
def followers(self):
300304
return Follow.objects.filter(package=self).values("person_id")

fedcode/pipes/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020

2121
def create_note(pkg, note_dict):
22+
# TODO: also take argument for source of the note ideally github blob for
23+
# for file.
2224
note, _ = Note.objects.get_or_create(acct=pkg.acct, content=saneyaml.dump(note_dict))
2325
pkg.notes.add(note)
2426
create_activity = CreateActivity(actor=pkg.to_ap, object=note.to_ap)

fedcode/templates/pkg_list.html

Lines changed: 64 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,82 @@
44
All Packages
55
{% endblock %}
66

7+
{% block extra-head %}
8+
<style>
9+
/* Remove the border below the table header */
10+
thead th {
11+
border-bottom: none !important;
12+
}
13+
14+
tbody tr:hover {
15+
background-color: #e0e0e0 !important;
16+
cursor: pointer;
17+
}
18+
19+
tbody tr:nth-child(even):hover {
20+
background-color: #d3d3d3 !important;
21+
}
22+
</style>
23+
{% endblock %}
24+
725
{% block content %}
826
<div class="columns">
927
<div class="column">
1028
</div>
1129

1230
<div class="column is-two-thirds">
1331
<div class="content is-normal">
14-
<h1>Package List</h1>
32+
<h1>Discover Packages</h1>
1533
<hr />
1634
</div>
17-
<form method="get" class="has-text-centered box" action="">
18-
{{ form }}
19-
<button type="submit" class="button is-link is-rounded">Search</button>
20-
</form>
21-
{% for package in package_list %}
22-
<article class="media box mt-4 ">
23-
<div class="media-left has-text-centered">
24-
<h4>Number of Followers</h4>
25-
<p>{{ package.followers_count }}</p>
26-
</div>
27-
<div class="media-content ">
28-
<div class="content" style="border-left: 4px solid black;">
29-
<h4 class="ml-3 mr-3"><a href="{% url 'purl-profile' package.purl %}"> {{ package.purl }} </a></h4>
30-
<small class="ml-2">Created by @{{ package.service.user.username }}</small>
31-
<br>
35+
<form method="get" class="box px-6 mx-0" action="">
36+
<div class="field has-addons">
37+
<div class="control is-expanded">
38+
{{ form.search }}
39+
</div>
40+
<div class="control">
41+
<button type="submit" class="button is-info">Search</button>
3242
</div>
3343
</div>
34-
</article>
35-
{% endfor %}
44+
</form>
45+
<div class="box">
46+
<table class="table is-striped is-hoverable is-fullwidth">
47+
<thead>
48+
<tr>
49+
<th colspan="3">
50+
<div class="box is-small">
51+
<div class="columns">
52+
<div class="column is-three-fifths">Package URL</div>
53+
<div class="column is-one-fifth">Activity</div>
54+
<div class="column is-one-fifth">Followers</div>
55+
</div>
56+
</div>
57+
</th>
58+
</tr>
59+
</thead>
60+
<tbody>
61+
{% for package in package_list %}
62+
<tr>
63+
<td colspan="3">
64+
<a href="{% url 'purl-profile' package.purl %}" class="has-text-info">
65+
<div class="columns px-5">
66+
<div class="column is-three-fifths">{{ package.purl }}</div>
67+
<div class="column is-one-fifth">{{ package.notes_count }}</div>
68+
<div class="column is-one-fifth">{{ package.followers_count }}</div>
69+
</div>
70+
</a>
71+
</td>
72+
</tr>
73+
{% empty %}
74+
<tr>
75+
<td colspan="3" class="has-text-centered">No packages found.</td>
76+
</tr>
77+
{% endfor %}
78+
</tbody>
79+
</table>
80+
</div>
3681
{% if is_paginated %}
37-
<nav class="pagination is-centered" role="navigation" aria-label="pagination">
82+
<nav class="pagination is-centered px-5" role="navigation" aria-label="pagination">
3883
{% if page_obj.has_previous %}
3984
<a class="pagination-previous" href="?page={{ page_obj.previous_page_number }}">Previous</a>
4085
{% endif %}
@@ -51,7 +96,6 @@ <h4 class="ml-3 mr-3"><a href="{% url 'purl-profile' package.purl %}"> {{ packag
5196
</nav>
5297
{% endif %}
5398
</div>
54-
5599
<div class="column"></div>
56100
</div>
57101
{% endblock %}

fedcode/templates/user_profile.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,15 @@
2222
<i class="fas fa-external-link-alt fa-xs"></i>
2323
</span>
2424
</a>
25-
to generate your profile picture based on your email address — {{ person.user.email }}
25+
to create your profile picture using your email address — {{ person.user.email }}
2626
</p>
27-
2827
<nav class="level">
2928
<div class="level-item has-text-centered">
3029
<div>
3130
<p class="heading">Following</p>
3231
<p class="title">{{ follow_count }}</p>
3332
</div>
3433
</div>
35-
3634
<div class="level-item has-text-centered">
3735
<div>
3836
<p class="heading">reputation</p>

0 commit comments

Comments
 (0)