Merge ~ines-almeida/launchpad:frontpage-revamp-remove-top-project into launchpad:master

Proposed by Ines Almeida
Status: Merged
Approved by: Ines Almeida
Approved revision: 6848973a9c2a0fc4663eb9adf246ba4310f7429c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ines-almeida/launchpad:frontpage-revamp-remove-top-project
Merge into: launchpad:master
Diff against target: 203 lines (+12/-87)
4 files modified
lib/lp/app/browser/doc/root-views.rst (+8/-29)
lib/lp/app/browser/root.py (+0/-20)
lib/lp/app/stories/launchpad-root/xx-featuredprojects.rst (+4/-23)
lib/lp/app/templates/root-index.pt (+0/-15)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+460809@code.launchpad.net

Commit message

Remove top featured project from homepage

Description of the change

The plan is to make all featured projects more prominent instead of just one.

This is just an intermediary step to make the next merge proposals cleaner. It can be merged with the remaining changes if we so choose to, or it can be merged before.

Here is the before, after and end-goal: https://pasteboard.co/DxhkktVntx2m.png

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

That looks great, thank you!

Could we please check whether all those featured projects are actually still active?

Do we need a fixed number of featured projects or will the new layout be flexible to have say 6 or 7 or 9 or 10 featured projects?

This is possible a discussion for the follow-up MP, though.

review: Approve
Revision history for this message
Ines Almeida (ines-almeida) wrote :

The list of featured projects could maybe use a review (from my quick look there might be a couple that are not that active).

That list can be changed by admins from the frontend, and there is no size restriction.

Regarding the new layout (not in this MP), it "works" with any number of projects, but it is clearly made for multiples of 3... Here is how it looks currently with 11 featured projects: https://pasteboard.co/FMVvp1mc0efY.png

Solutions here are:
 - Whoever updates these (once every few years) should keep it to a multiple of 3
 - We can only display randomly the max number of featured projects that are a multiple of three
 - We can try to make it look nicer with different numbers, but that would mean changing the Vanilla component that this is using and that is used in other places in Canonical

But yes, let's discuss that in the follow-up MP when the new layout is actually added!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/app/browser/doc/root-views.rst b/lib/lp/app/browser/doc/root-views.rst
2index 8782f3f..f5c996e 100644
3--- a/lib/lp/app/browser/doc/root-views.rst
4+++ b/lib/lp/app/browser/doc/root-views.rst
5@@ -12,7 +12,7 @@ special data needed for the layout.
6 ...
7 >>> LaunchpadRootIndexView._get_day_of_year = staticmethod(day)
8
9-The view has a provides a list of featured projects and a top project.
10+The view has a provides a list of featured projects.
11
12 >>> from lp.services.webapp.interfaces import ILaunchpadRoot
13
14@@ -21,36 +21,15 @@ The view has a provides a list of featured projects and a top project.
15 >>> for project in view.featured_projects:
16 ... print(project.name)
17 ...
18- applets bazaar firefox gentoo gnome-terminal mozilla thunderbird ubuntu
19-
20- >>> print(view.featured_projects_top.name)
21+ applets
22+ bazaar
23+ firefox
24+ gentoo
25 gnome
26-
27-The featured_projects_top property is set by a helper method that pops the
28-project from the list of featured_projects.
29-
30- >>> featured_projects = list(view.featured_projects)
31- >>> featured_projects_top = view.featured_projects_top
32- >>> view._setFeaturedProjectsTop()
33- >>> print(view.featured_projects_top.name)
34 gnome-terminal
35-
36- >>> for project in view.featured_projects:
37- ... print(project.name)
38- ...
39- applets bazaar firefox gentoo mozilla thunderbird ubuntu
40-
41-If there are no featured projects, the top featured project is None.
42-
43- >>> view.featured_projects = []
44- >>> view.featured_projects_top = None
45- >>> view._setFeaturedProjectsTop()
46- >>> print(view.featured_projects_top)
47- None
48-
49- # Put the projects back as they were.
50- >>> view.featured_projects = featured_projects
51- >>> view.featured_projects_top = featured_projects_top
52+ mozilla
53+ thunderbird
54+ ubuntu
55
56 The view provides the counts of branches, Git repositories, bugs,
57 projects, translations, blueprints, and answers registered in Launchpad.
58diff --git a/lib/lp/app/browser/root.py b/lib/lp/app/browser/root.py
59index 2a87d2b..154b6a5 100644
60--- a/lib/lp/app/browser/root.py
61+++ b/lib/lp/app/browser/root.py
62@@ -57,21 +57,11 @@ class LaunchpadRootIndexView(HasAnnouncementsView, LaunchpadView):
63
64 page_title = "Launchpad"
65 featured_projects: List[Any] = []
66- featured_projects_top = None
67
68 # Used by the footer to display the lp-arcana section.
69 is_root_page = True
70 has_watermark = False
71
72- @staticmethod
73- def _get_day_of_year():
74- """Calculate the number of the current day.
75-
76- This method gets overridden in tests to make the selection of the
77- top featured project deterministic.
78- """
79- return time.gmtime()[7]
80-
81 def initialize(self):
82 """Set up featured projects list and the top featured project."""
83 super().initialize()
84@@ -80,16 +70,6 @@ class LaunchpadRootIndexView(HasAnnouncementsView, LaunchpadView):
85 self.featured_projects = list(
86 getUtility(IPillarNameSet).featured_projects
87 )
88- self._setFeaturedProjectsTop()
89-
90- def _setFeaturedProjectsTop(self):
91- """Set the top featured project and remove it from the list."""
92- project_count = len(self.featured_projects)
93- if project_count > 0:
94- top_project = self._get_day_of_year() % project_count
95- self.featured_projects_top = self.featured_projects.pop(
96- top_project
97- )
98
99 @cachedproperty
100 def apphomes(self):
101diff --git a/lib/lp/app/stories/launchpad-root/xx-featuredprojects.rst b/lib/lp/app/stories/launchpad-root/xx-featuredprojects.rst
102index e0ff0f6..79c90bd 100644
103--- a/lib/lp/app/stories/launchpad-root/xx-featuredprojects.rst
104+++ b/lib/lp/app/stories/launchpad-root/xx-featuredprojects.rst
105@@ -11,31 +11,14 @@ page and managed via a special admin-only page.
106 The home page listing
107 ---------------------
108
109-Featured projects are visible to everyone on the home page. One project is
110-featured as "project of the day" depending on the current day. As we do not
111-know the current day, we replace that selection method in the view with a
112-constant value.
113-
114- >>> def fake_get_day_of_year():
115- ... return 4
116- ...
117- >>> from lp.app.browser.root import LaunchpadRootIndexView
118- >>> LaunchpadRootIndexView._get_day_of_year = staticmethod(
119- ... fake_get_day_of_year
120- ... )
121-
122 Anonymous users will see the list of featured projects with links to the
123-projects' pages in Launchpad. The "project of the day" is listed separately.
124+projects' pages in Launchpad.
125
126 >>> anon_browser.open("http://launchpad.test/")
127 >>> featured = find_tag_by_id(anon_browser.contents, "homepage-featured")
128 >>> print(extract_text(featured.h2))
129 Featured projects
130
131- >>> top_project = featured.find("", "featured-project-top")
132- >>> print(extract_text(top_project.h3))
133- GNOME
134-
135 >>> featured_list = featured.find("", "featured-projects-list")
136 >>> for link in featured_list.find_all("a"):
137 ... print(extract_text(link))
138@@ -44,6 +27,7 @@ projects' pages in Launchpad. The "project of the day" is listed separately.
139 Bazaar
140 Mozilla Firefox
141 Gentoo
142+ GNOME
143 GNOME Terminal
144 The Mozilla Project
145 Mozilla Thunderbird
146@@ -98,10 +82,6 @@ is now at index '4' and is therefore displayed as the top project:
147
148 >>> anon_browser.open("http://launchpad.test/")
149 >>> featured = find_tag_by_id(anon_browser.contents, "homepage-featured")
150- >>> top_project = featured.find("", "featured-project-top")
151- >>> print(extract_text(top_project.h3))
152- Gentoo
153-
154 >>> featured_list = featured.find("", "featured-projects-list")
155 >>> for link in featured_list.find_all("a"):
156 ... print(extract_text(link))
157@@ -110,6 +90,7 @@ is now at index '4' and is therefore displayed as the top project:
158 Gnome Applets
159 Bazaar
160 Mozilla Firefox
161+ Gentoo
162 GNOME
163 GNOME Terminal
164 The Mozilla Project
165@@ -136,11 +117,11 @@ that Apache has been removed:
166 >>> for link in featured.find_all("a"):
167 ... print(extract_text(link))
168 ...
169- GNOME
170 Gnome Applets
171 Bazaar
172 Mozilla Firefox
173 Gentoo
174+ GNOME
175 GNOME Terminal
176 The Mozilla Project
177 Mozilla Thunderbird
178diff --git a/lib/lp/app/templates/root-index.pt b/lib/lp/app/templates/root-index.pt
179index da9fac2..ee51d55 100644
180--- a/lib/lp/app/templates/root-index.pt
181+++ b/lib/lp/app/templates/root-index.pt
182@@ -215,21 +215,6 @@
183
184 <div id="homepage-featured" class="homepage-portlet">
185 <h2>Featured projects</h2>
186-
187- <div class="featured-project-top"
188- tal:define="topproject view/featured_projects_top"
189- tal:condition="topproject">
190- <h3>
191- <a tal:attributes="href topproject/fmt:url"
192- tal:content="structure topproject/image:logo"><img /></a>
193- <a tal:attributes="href topproject/fmt:url"
194- tal:content="topproject/displayname">Foo project</a>
195- </h3>
196- <p tal:content="structure view/featured_projects_top/summary/fmt:shorten/200">
197- Foo project is great...
198- </p>
199- </div>
200-
201 <div class="two-column-list">
202 <ul class="featured-projects-list">
203 <li tal:repeat="project view/featured_projects">

Subscribers

People subscribed via source and target branches

to status/vote changes: