Skip to content

Commit ef8766c

Browse files
authored
Task 2396: Migrate Large Static Images to S3 Bucket (#2415)
1 parent 9327083 commit ef8766c

58 files changed

Lines changed: 90 additions & 91 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ak/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from core.calendar import extract_calendar_events, events_by_month, get_calendar
1111
from core.mixins import V3Mixin
12+
from core.templatetags.custom_static import large_static
1213
from libraries.constants import LATEST_RELEASE_URL_PATH_STR
1314
from libraries.mixins import ContributorMixin
1415
from news.models import Entry
@@ -128,7 +129,7 @@ def get_v3_context_data(self, **kwargs):
128129
"primary_button_label": "View the Release Calendar",
129130
"secondary_button_url": "www.example.com",
130131
"secondary_button_label": "Secondary Button",
131-
"image": f"{settings.STATIC_URL}/img/v3/demo_page/Calendar.png",
132+
"image": large_static("img/v3/demo-page/calendar.png"),
132133
}
133134
ctx["info_card"] = {
134135
"title": "How we got here",

core/mock_data.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from django.utils.text import slugify
55

66
from core.constants import BadgeToken, SLACK_MEMBER_COUNT
7+
from core.templatetags.custom_static import large_static
78
from libraries.utils import commit_data_to_stats_bars
89

910

@@ -233,7 +234,7 @@ class SharedResources:
233234
"author": {
234235
"name": "Prof. Sven G. Bilén, Ph.D.",
235236
"profile_url": "#",
236-
"avatar_url": "/static/img/v3/demo_page/Avatar.png",
237+
"avatar_url": large_static("img/v3/demo_page/avatar.png"),
237238
"role": "The Pennsylvania State University",
238239
"badge": BadgeToken.TIER_3,
239240
},
@@ -360,8 +361,8 @@ class SharedResources:
360361
"author": {
361362
"name": "Ipsum Loremson",
362363
"profile_url": "#",
363-
"avatar_url": "/static/img/v3/demo_page/Avatar.png",
364-
"role": "Lorem Ipsum Industries",
364+
"avatar_url": large_static("img/v3/demo-page/avatar.png"),
365+
"role": "Maintainer",
365366
"badge": BadgeToken.TIER_3,
366367
},
367368
"content": """
@@ -385,20 +386,20 @@ class SharedResources:
385386
{
386387
"name": "Vinnie Falco",
387388
"role": "Author",
388-
"avatar_url": f"{settings.STATIC_URL}img/v3/demo_page/Avatar.png",
389+
"avatar_url": large_static("img/v3/demo-page/avatar.png"),
389390
"badge": BadgeToken.TIER_3,
390391
"bio": "Big C++ fan. Not quite kidney-donation level, but close.",
391392
},
392393
{
393394
"name": "Alex Wells",
394395
"role": "Contributor",
395-
"avatar_url": f"{settings.STATIC_URL}img/v3/demo_page/Avatar.png",
396+
"avatar_url": large_static("img/v3/demo-page/avatar.png"),
396397
"bio": "C++ enthusiast who has worked at Intel and Microsoft.",
397398
},
398399
{
399400
"name": "Dave Abrahams",
400401
"role": "Maintainer",
401-
"avatar_url": f"{settings.STATIC_URL}img/v3/demo_page/Avatar.png",
402+
"avatar_url": large_static("img/v3/demo-page/avatar.png"),
402403
"badge": BadgeToken.TIER_3,
403404
"bio": "Contributor to Boost since 2009.",
404405
},
@@ -415,19 +416,13 @@ class SharedResources:
415416
"button_label": "See license details",
416417
}
417418

418-
hero_legacy_image_url_light = f"{settings.STATIC_URL}img/v3/home-page/heros.png"
419+
hero_legacy_image_url_light = large_static("img/v3/home-page/heros.png")
419420

420-
hero_legacy_image_url_dark = (
421-
f"{settings.STATIC_URL}img/v3/home-page/heros_light.png"
422-
)
421+
hero_legacy_image_url_dark = large_static("img/v3/home-page/heros_light.png")
423422

424-
hero_image_url = f"{settings.STATIC_URL}img/v3/home-page/home-page-foreground.png"
425-
hero_image_url_light = (
426-
f"{settings.STATIC_URL}img/v3/home-page/home-page-foreground.png"
427-
)
428-
hero_image_url_dark = (
429-
f"{settings.STATIC_URL}img/v3/home-page/home-page-foreground.png"
430-
)
423+
hero_image_url = large_static("img/v3/home-page/home-page-foreground.png")
424+
hero_image_url_light = large_static("img/v3/home-page/home-page-foreground.png")
425+
hero_image_url_dark = large_static("img/v3/home-page/home-page-foreground.png")
431426

432427
library_about_code = (
433428
"int main()\n"

core/views.py

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from django.views.decorators.cache import never_cache
3131
from django.views.generic import TemplateView
3232

33+
from core.templatetags.custom_static import large_static
3334
from config.settings import ENABLE_DB_CACHE
3435
from libraries.constants import LATEST_RELEASE_URL_PATH_STR
3536
from libraries.mixins import VersionAlertMixin
@@ -160,7 +161,9 @@ def get_v3_context_data(self, **kwargs):
160161
"author": {
161162
"name": "Character Name",
162163
"role": "Contributor",
163-
"avatar_url": "/static/img/v3/community-page/avatar-beaver-character.png",
164+
"avatar_url": large_static(
165+
"img/v3/community-page/avatar-beaver-character.png"
166+
),
164167
},
165168
},
166169
{
@@ -171,7 +174,9 @@ def get_v3_context_data(self, **kwargs):
171174
"author": {
172175
"name": "Character Name",
173176
"role": "Author",
174-
"avatar_url": "/static/img/v3/community-page/avatar-mouse-character.png",
177+
"avatar_url": large_static(
178+
"img/v3/community-page/avatar-mouse-character.png"
179+
),
175180
},
176181
},
177182
{
@@ -182,7 +187,9 @@ def get_v3_context_data(self, **kwargs):
182187
"author": {
183188
"name": "Character Name",
184189
"role": "Maintainer",
185-
"avatar_url": "/static/img/v3/community-page/avatar-cheetah-character.png",
190+
"avatar_url": large_static(
191+
"img/v3/community-page/avatar-cheetah-character.png"
192+
),
186193
},
187194
},
188195
{
@@ -193,7 +200,9 @@ def get_v3_context_data(self, **kwargs):
193200
"author": {
194201
"name": "Character Name",
195202
"role": "Contributor",
196-
"avatar_url": "/static/img/v3/community-page/avatar-fish-character.png",
203+
"avatar_url": large_static(
204+
"img/v3/community-page/avatar-fish-character.png"
205+
),
197206
},
198207
},
199208
]
@@ -323,9 +332,8 @@ def get_v3_context_data(self, **kwargs):
323332
"<li>Recent activity feed</li>"
324333
"</ul>"
325334
)
326-
ctx["create_account_card_preview_url"] = (
327-
f"{settings.STATIC_URL}img/v3/community-page/"
328-
"community-create-account-preview.png"
335+
ctx["create_account_card_preview_url"] = large_static(
336+
"img/v3/community-page/community-create-account-preview.png"
329337
)
330338
now = timezone.now()
331339
ctx["recent_threads_url"] = (
@@ -509,8 +517,10 @@ def get_v3_context_data(self, **kwargs):
509517
],
510518
"url": "https://www.example.com",
511519
"label": "Learn more about Boost",
512-
"image_src": f"{ settings.STATIC_URL }/img/v3/examples/Learn_Card_Image.png",
513-
"mobile_image_src": f"{ settings.STATIC_URL }/img/v3/examples/Cheetah_Mobile.png",
520+
"image_src": large_static("/img/v3/learn-page/learn-cheetah.png"),
521+
"mobile_image_src": large_static(
522+
"/img/v3/learn-page/cheetah-mobile.png"
523+
),
514524
},
515525
{
516526
"title": "I want to learn:",
@@ -525,8 +535,10 @@ def get_v3_context_data(self, **kwargs):
525535
],
526536
"url": "https://www.example.com",
527537
"label": "Learn more about Boost",
528-
"image_src": f"{ settings.STATIC_URL}img/v3/examples/Learn_Octopus.png",
529-
"mobile_image_src": f"{ settings.STATIC_URL }/img/v3/examples/Octopus_Mobile.png",
538+
"image_src": large_static("img/v3/learn-page/learn-octopus.png"),
539+
"mobile_image_src": large_static(
540+
"/img/v3/learn-page/octopus-mobile.png"
541+
),
530542
},
531543
]
532544

@@ -602,7 +614,7 @@ def get_v3_context_data(self, **kwargs):
602614
"primary_button_label": "View the Release Calendar",
603615
"secondary_button_url": "www.example.com",
604616
"secondary_button_label": "Secondary Button",
605-
"image": f"{ settings.STATIC_URL }/img/v3/demo_page/Calendar.png",
617+
"image": large_static("/img/v3/demo-page/calendar.png"),
606618
}
607619
ctx["info_card"] = {
608620
"title": "How we got here",
@@ -628,7 +640,7 @@ def get_v3_context_data(self, **kwargs):
628640
"name": "Richard Thomson",
629641
"role": "Contributor",
630642
"show_badge": True,
631-
"avatar_url": "/static/img/v3/demo_page/Avatar.png",
643+
"avatar_url": large_static("img/v3/demo-page/avatar.png"),
632644
},
633645
}
634646
],
@@ -650,7 +662,7 @@ def get_v3_context_data(self, **kwargs):
650662
"name": "Richard Thomson",
651663
"role": "Contributor",
652664
"show_badge": True,
653-
"avatar_url": "/static/img/v3/demo_page/Avatar.png",
665+
"avatar_url": large_static("img/v3/demo-page/avatar.png"),
654666
},
655667
}
656668
],
@@ -1768,8 +1780,8 @@ def get_context_data(self, **kwargs):
17681780
context["create_account_card_preview_url"] = (
17691781
f"{settings.STATIC_URL}img/checker.png"
17701782
)
1771-
context["hero_background_image_url"] = (
1772-
f"{settings.STATIC_URL}img/v3/home-page/home-page-background.png"
1783+
context["hero_background_image_url"] = large_static(
1784+
"img/v3/home-page/home-page-background.png"
17731785
)
17741786
context["hero_legacy_image_url_light"] = (
17751787
SharedResources.hero_legacy_image_url_light
@@ -1787,7 +1799,7 @@ def get_context_data(self, **kwargs):
17871799
"primary_button_label": "Primary Button",
17881800
"secondary_button_url": "www.example.com",
17891801
"secondary_button_label": "Secondary Button",
1790-
"image": "/static/img/v3/demo_page/Calendar.png",
1802+
"image": large_static("img/v3/demo-page/calendar.png"),
17911803
}
17921804

17931805
context["horizontal_card_data"] = SharedResources.build_anything_with_boost
@@ -1875,8 +1887,8 @@ def get_context_data(self, **kwargs):
18751887
],
18761888
"url": "https://www.example.com",
18771889
"label": "Get started with Boost",
1878-
"image_src": f"{settings.STATIC_URL}img/v3/examples/Learn_Card_Image.png",
1879-
"mobile_image_src": f"{settings.STATIC_URL}img/v3/examples/Cheetah_Mobile.png",
1890+
"image_src": large_static("img/v3/learn-page/learn-cheetah.png"),
1891+
"mobile_image_src": large_static("img/v3/learn-page/cheetah-mobile.png"),
18801892
}
18811893

18821894
context["testimonial_data"] = {
@@ -1979,7 +1991,7 @@ def get_context_data(self, **kwargs):
19791991
"name": "John Doe",
19801992
"profile_url": "#",
19811993
"role": "Author",
1982-
"avatar_url": f"{settings.STATIC_URL}img/v3/demo_page/Avatar.png",
1994+
"avatar_url": large_static("img/v3/demo-page/avatar.png"),
19831995
"badge": BadgeToken.TIER_3,
19841996
"bio": "",
19851997
},
@@ -2011,15 +2023,15 @@ def get_context_data(self, **kwargs):
20112023
"name": "Peter Dimov",
20122024
"profile_url": "#",
20132025
"role": "Maintainer",
2014-
"avatar_url": f"{settings.STATIC_URL}img/v3/demo_page/Avatar.png",
2026+
"avatar_url": large_static("img/v3/demo-page/avatar.png"),
20152027
"badge": BadgeToken.STAR_TIER_5,
20162028
"bio": "",
20172029
},
20182030
{
20192031
"name": "Vinnie Falco",
20202032
"profile_url": "#",
20212033
"role": "Author",
2022-
"avatar_url": f"{settings.STATIC_URL}img/v3/demo_page/Avatar.png",
2034+
"avatar_url": large_static("img/v3/demo-page/avatar.png"),
20232035
"badge": BadgeToken.BOOST_DAY,
20242036
"bio": "Boost Day contributor.",
20252037
},
@@ -2030,7 +2042,7 @@ def get_context_data(self, **kwargs):
20302042
"name": "John Doe",
20312043
"profile_url": "#",
20322044
"role": "Author",
2033-
"avatar_url": f"{settings.STATIC_URL}img/v3/demo_page/Avatar.png",
2045+
"avatar_url": large_static("img/v3/demo-page/avatar.png"),
20342046
"badge": BadgeToken.TIER_3,
20352047
"bio": "",
20362048
}
@@ -2059,18 +2071,16 @@ def get_context_data(self, **kwargs):
20592071
{
20602072
"name": "Vinnie Falco",
20612073
"role": "Author",
2062-
"avatar_url": f"{settings.STATIC_URL}img/v3/demo_page/Avatar.png",
2063-
"badge_url": (
2064-
f"{settings.STATIC_URL}img/v3/badges/badge-first-place.png"
2065-
),
2074+
"avatar_url": large_static("img/v3/demo-page/avatar.png"),
2075+
"badge_url": large_static("img/v3/badges/badge-first-place.png"),
20662076
"badge": "",
20672077
"bio": "Big C++ fan. Not quite kidney-donation level, but close.",
20682078
"profile_url": "",
20692079
},
20702080
{
20712081
"name": "Alex Wells",
20722082
"role": "Contributor",
2073-
"avatar_url": f"{settings.STATIC_URL}img/v3/demo_page/Avatar.png",
2083+
"avatar_url": large_static("img/v3/demo-page/avatar.png"),
20742084
"badge_url": "",
20752085
"badge": "",
20762086
"bio": "C++ enthusiast who has worked at Intel and Microsoft.",
@@ -2079,8 +2089,8 @@ def get_context_data(self, **kwargs):
20792089
{
20802090
"name": "Dave Abrahams",
20812091
"role": "Contributor",
2082-
"avatar_url": f"{settings.STATIC_URL}img/v3/demo_page/Avatar.png",
2083-
"badge_url": f"{settings.STATIC_URL}img/v3/badges/badge-bronze.png",
2092+
"avatar_url": large_static("img/v3/demo-page/avatar.png"),
2093+
"badge_url": large_static("img/v3/badges/badge-bronze.png"),
20842094
"badge": "",
20852095
"bio": "Contributor to Boost since 2009.",
20862096
"profile_url": "",

libraries/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from config import settings
2020
from core.custom_model_fields import NullableFileField
21+
from core.templatetags.custom_static import large_static
2122
from core.markdown import process_md
2223
from core.models import RenderedContent
2324
from core.asciidoc import convert_adoc_to_html
@@ -549,7 +550,7 @@ def author_details(self):
549550
"name": author.display_name if author else "Unknown",
550551
"role": "Author",
551552
"avatar_url": author.get_avatar_url() if author else "",
552-
"badge_url": f"{settings.STATIC_URL}img/v3/badges/badge-first-place.png",
553+
"badge_url": large_static("img/v3/badges/badge-first-place.png"),
553554
}
554555

555556
def get_cpp_standard_minimum_display(self):
-2.31 MB
Binary file not shown.
-2.04 MB
Binary file not shown.

static/img/v3/badges/boost_day.png

-4.27 KB
Binary file not shown.
-2.94 KB
Binary file not shown.
-2.91 KB
Binary file not shown.
-2.97 KB
Binary file not shown.

0 commit comments

Comments
 (0)