Skip to content

Commit

Permalink
feat: Update social icons for ietf website (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgax authored Dec 18, 2023
1 parent 5f43f47 commit b959ad9
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 19 deletions.
16 changes: 15 additions & 1 deletion ietf/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from operator import itemgetter
from django.conf import settings
from wagtail.models import Site

from ietf.blog.models import BlogIndexPage
from ietf.home.models import HomePage, IABHomePage
from ietf.utils.models import MenuItem
from ietf.utils.models import MenuItem, SocialMediaSettings


def home_page(site):
Expand Down Expand Up @@ -36,13 +37,26 @@ def secondary_menu(site):
return items


def social_menu(site):
social = SocialMediaSettings.for_site(site)
links = [
{"url": social.linkedin, "icon": "linkedin"},
{"url": social.twitter, "icon": "twitter"},
{"url": social.youtube, "icon": "youtube"},
{"url": social.mastodon, "icon": "mastodon"},
{"url": social.github, "icon": "github"},
]
return filter(itemgetter("url"), links)


def global_pages(request):
site = Site.find_for_request(request)
return {
"HOME": home_page(site),
"BLOG_INDEX": BlogIndexPage.objects.first(),
"MENU": menu(site),
"SECONDARY_MENU": secondary_menu(site),
"SOCIAL_MENU": social_menu(site),
"BASE_URL": getattr(settings, "WAGTAILADMIN_BASE_URL", ""),
"DEBUG": getattr(settings, "DEBUG", ""),
"FB_APP_ID": getattr(settings, "FB_APP_ID", ""),
Expand Down
25 changes: 16 additions & 9 deletions ietf/templates/includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
{% endfor %}
</ul>

<ul class="navbar-nav col-12 col-xl-auto">
<ul class="navbar-nav col-xl-auto">
{% for item in SECONDARY_MENU %}
{% if item.is_dropdown %}
<li class="nav-item btn-group">
Expand Down Expand Up @@ -124,15 +124,22 @@
Search
</a>
</li>
<li class="nav-item btn-group d-lg-none">
<a
href="/endowment/donate-ietf-endowment/"
class="nav-link btn btn-primary text-white"
>
Donate
</a>
</li>
</ul>
<div class="d-flex justify-content-center ms-lg-auto me-lg-4">
{% for item in SOCIAL_MENU %}
<a class="d-block text-dark px-2" href="{{ item.url }}" rel="me">
<i class="bi bi-{{ item.icon }}"></i>
</a>
{% endfor %}
</div>
<div class="d-lg-none d-grid gap-2 mt-2">
<a
href="/endowment/donate-ietf-endowment/"
class="btn btn-primary"
>
Donate
</a>
</div>
</div>
<div class="bg-primary rounded nav-item">
<a
Expand Down
38 changes: 38 additions & 0 deletions ietf/utils/migrations/0008_socialmediasettings_github_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 4.2.7 on 2023-12-14 09:20

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('utils', '0007_auto_20230524_0551'),
]

operations = [
migrations.AddField(
model_name='socialmediasettings',
name='github',
field=models.CharField(blank='True', help_text='Link to GitHub profile', max_length=255, verbose_name='GitHub link'),
),
migrations.AlterField(
model_name='socialmediasettings',
name='linkedin',
field=models.CharField(blank='True', help_text='Link to LinkedIn profile', max_length=255, verbose_name='LinkedIn link'),
),
migrations.AlterField(
model_name='socialmediasettings',
name='mastodon',
field=models.CharField(blank='True', help_text='Link to Mastodon profile', max_length=255, verbose_name='Mastodon link'),
),
migrations.AlterField(
model_name='socialmediasettings',
name='twitter',
field=models.CharField(blank='True', help_text='Link to Twitter profile', max_length=255, verbose_name='Twitter link'),
),
migrations.AlterField(
model_name='socialmediasettings',
name='youtube',
field=models.CharField(blank='True', help_text='Link to YouTube account', max_length=255, verbose_name='Youtube link'),
),
]
25 changes: 16 additions & 9 deletions ietf/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,41 +186,48 @@ class SocialMediaSettings(BaseSiteSetting):
help_text="Site name, used by facebook open graph.",
)

twitter = models.CharField(
linkedin = models.CharField(
max_length=255,
help_text="Link to twitter profile",
help_text="Link to LinkedIn profile",
blank="True",
verbose_name="Twitter link"
verbose_name="LinkedIn link"
)
linkedin = models.CharField(
twitter = models.CharField(
max_length=255,
help_text="Link to linkedin profile",
help_text="Link to Twitter profile",
blank="True",
verbose_name="LinkedIn link"
verbose_name="Twitter link"
)
youtube = models.CharField(
max_length=255,
help_text="Link to youtube account",
help_text="Link to YouTube account",
blank="True",
verbose_name="Youtube link"
)
mastodon = models.CharField(
max_length=255,
help_text="Link to mastodon profile",
help_text="Link to Mastodon profile",
blank="True",
verbose_name="Mastodon link"
)
github = models.CharField(
max_length=255,
help_text="Link to GitHub profile",
blank="True",
verbose_name="GitHub link"
)

panels = [
FieldPanel("twitter_handle"),
FieldPanel("facebook_app_id"),
FieldPanel("default_sharing_text"),
FieldPanel("default_sharing_image"),
FieldPanel("site_name"),
FieldPanel("twitter"),
FieldPanel("linkedin"),
FieldPanel("twitter"),
FieldPanel("youtube"),
FieldPanel("mastodon"),
FieldPanel("github"),
]


Expand Down

0 comments on commit b959ad9

Please sign in to comment.