Skip to content

Commit 9c94c2c

Browse files
committed
2426: refactor demo data
1 parent 96d14ab commit 9c94c2c

1 file changed

Lines changed: 42 additions & 63 deletions

File tree

core/views.py

Lines changed: 42 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,37 +2089,12 @@ def get_context_data(self, **kwargs):
20892089
# "few" stays under the 3-row cap (no scroll); "many" exceeds it.
20902090
_intro_avatar = large_static("img/v3/demo-page/avatar.png")
20912091
_intro_bio = "Big C++ fan. Not quite kidney-donation level, but close."
2092-
context["library_intro_few"] = {
2093-
"library_name": "Boost.Core.",
2094-
"description": (
2095-
"Lightweight utilities that power dozens of other Boost libraries"
2096-
),
2097-
"authors": [
2098-
{
2099-
"name": "Vinnie Falco",
2100-
"role": "Author",
2101-
"avatar_url": _intro_avatar,
2102-
"badge": "",
2103-
"bio": _intro_bio,
2104-
"profile_url": "",
2105-
},
2106-
{
2107-
"name": "Alex Wells",
2108-
"role": "Contributor",
2109-
"avatar_url": _intro_avatar,
2110-
"badge": "",
2111-
"bio": _intro_bio,
2112-
"profile_url": "",
2113-
},
2114-
],
2115-
"cta_url": "#",
2116-
}
2117-
context["library_intro_three"] = {
2118-
"library_name": "Boost.Asio.",
2119-
"description": (
2120-
"Lightweight utilities that power dozens of other Boost libraries"
2121-
),
2122-
"authors": [
2092+
_intro_description = (
2093+
"Lightweight utilities that power dozens of other Boost libraries"
2094+
)
2095+
2096+
def _intro_authors(*names_and_roles):
2097+
return [
21232098
{
21242099
"name": name,
21252100
"role": role,
@@ -2128,39 +2103,43 @@ def get_context_data(self, **kwargs):
21282103
"bio": _intro_bio,
21292104
"profile_url": "",
21302105
}
2131-
for name, role in [
2132-
("Vinnie Falco", "Author"),
2133-
("Alex Wells", "Maintainer"),
2134-
("Dave Abrahams", "Contributor"),
2135-
]
2136-
],
2137-
"cta_url": "#",
2138-
}
2139-
context["library_intro_many"] = {
2140-
"library_name": "Boost.Beast.",
2141-
"description": (
2142-
"Lightweight utilities that power dozens of other Boost libraries"
2106+
for name, role in names_and_roles
2107+
]
2108+
2109+
def _intro_card(library_name, authors):
2110+
return {
2111+
"library_name": library_name,
2112+
"description": _intro_description,
2113+
"authors": authors,
2114+
"cta_url": "#",
2115+
}
2116+
2117+
context["library_intro_few"] = _intro_card(
2118+
"Boost.Core.",
2119+
_intro_authors(
2120+
("Vinnie Falco", "Author"),
2121+
("Alex Wells", "Contributor"),
21432122
),
2144-
"authors": [
2145-
{
2146-
"name": name,
2147-
"role": role,
2148-
"avatar_url": _intro_avatar,
2149-
"badge": "",
2150-
"bio": _intro_bio,
2151-
"profile_url": "",
2152-
}
2153-
for name, role in [
2154-
("Vinnie Falco", "Author"),
2155-
("Alex Wells", "Maintainer"),
2156-
("Dave Abrahams", "Contributor"),
2157-
("Beman Dawes", "Contributor"),
2158-
("Hartmut Kaiser", "Contributor"),
2159-
("Andrey Semashev", "Contributor"),
2160-
]
2161-
],
2162-
"cta_url": "#",
2163-
}
2123+
)
2124+
context["library_intro_three"] = _intro_card(
2125+
"Boost.Asio.",
2126+
_intro_authors(
2127+
("Vinnie Falco", "Author"),
2128+
("Alex Wells", "Maintainer"),
2129+
("Dave Abrahams", "Contributor"),
2130+
),
2131+
)
2132+
context["library_intro_many"] = _intro_card(
2133+
"Boost.Beast.",
2134+
_intro_authors(
2135+
("Vinnie Falco", "Author"),
2136+
("Alex Wells", "Maintainer"),
2137+
("Dave Abrahams", "Contributor"),
2138+
("Beman Dawes", "Contributor"),
2139+
("Hartmut Kaiser", "Contributor"),
2140+
("Andrey Semashev", "Contributor"),
2141+
),
2142+
)
21642143

21652144
latest = Version.objects.most_recent()
21662145
if latest:

0 commit comments

Comments
 (0)