Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update python.org socialize menu to include a link to the PSF Mastodon account #2323

Merged
merged 2 commits into from
Nov 14, 2023

Conversation

mlcohen
Copy link
Contributor

@mlcohen mlcohen commented Nov 12, 2023

Updated socialize menu to include a link to the official PSF Mastodon account.

Details:

  • Added a Mastodon icon to the Pythonicon font family. Used IcoMoon to generate fonts
  • Updated all related CSS and Sass files
  • Updated the socialize menu in the base.html template

To see all rendered Pythonicon fonts, open static/fonts/demo.html

Related Github issue: #2322

Before Update

Screenshot 2023-11-12 at 1 02 07 PM

After Update

Screenshot 2023-11-12 at 12 48 59 PM

(Screenshot was taken from localhost)

…n account

Updated socialize menu to include a link to the official PSF Mastodon account.

Details:

- Added Mastodon icon to Pythonicon font family. Used IcoMoon to generate icons
- Updated all related CSS and Sass files
- Updated the socialize menu in the base.html template

To see all rendered Pythonicon fonts, open `static/fonts/demo.html`
@hugovk
Copy link
Member

hugovk commented Nov 12, 2023

Thanks!

  • Added a Mastodon icon to the Pythonicon font family. Used IcoMoon to generate fonts

For future reference, please could you give a brief overview of how to do this?

@mlcohen
Copy link
Contributor Author

mlcohen commented Nov 13, 2023

could you give a brief overview of how to do this?

Sure thing!

Here's what I did to get the Mastodon icon added to the collection of Pythonicon fonts...

First, I started by opening the IcoMoon web app (it's free to use). In the app, I created a new empty set.

Next, I imported the Pythonicon.json file in the static/fonts folder.

Screenshot 2023-11-12 at 9 24 37 PM

Once imported, I selected the Twitter icon and downloaded the individual SVG file to use as a template to create the Mastodon icon. To create the icon, I used Inkscape.

Screenshot 2023-11-12 at 1 52 16 PM

Using the Twitter SVG icon, I deleted the bird and kept the background. I then downloaded the official Mastodon icon (SVG file). I copied the Mastodon SVG path, scaled it up, and centered it within the background box. Finally, I used the path exclusion command to subtract the Mastodon path from the background path. Once done, I saved it as a new SVG file (mastodon.svg).

Screenshot 2023-11-12 at 1 59 00 PM

Back in the IcoMoon app, I imported the mastodon SVG using the 'Import to Set' command. This will place the Mastodon SVG icon to the start on the icon set. Check that the Mastodon icon's tag and name are both set to "mastodon".

To keep the icon order the same, I moved the Mastodon icon to the end of the set. I also moved the last pythonicons set containing the bullhorn icon to the top.

Screenshot 2023-11-12 at 9 27 07 PM

Last step is to generate the fonts. I selected all the icons and then clicked the 'Generate Font' command at the bottom of the app. This will open the generate font workspace. In the workspace, you should see all the icons you want to be part of your font file collection.

Screenshot 2023-11-12 at 9 27 43 PM

You shouldn't have to make any modifications. Do verify that the help icon is assigned unicode character 3f (?) and the close icon is assigned unicode character 58 (X).

The final step I took before creating the fonts was to open the font setting and changing the font name to "Pythonicon". I also kept the support IE8 option on.

Screenshot 2023-11-12 at 8 04 52 PM

With that, click the 'Download' button. You'll get a zip file with font files .eot, .ttf, .woff and .svg.

The zip also includes a style.css file that you'll use to copy over some of the CSS directives into the repo's static/sass folder. The style.css file does not inline the TTF and WOFF fonts as base64 encoded. You'll have to do that which is simple to do. Just run base64

$ cat Pythonicon.ttf | base64 > Pythonicon.ttf.base64

You can then copy the file content and update the style.css file, like so:

@font-face {
  font-family: 'Pythonicon';
  src:url('Pythonicon.eot');
}
@font-face {
  font-family: 'Pythonicon';
  src: 
     url(data:application/x-font-woff;charset=utf-8;base64,<YOUR BASE64 WOFF CONTENT HERE>) format('woff'),
     url(data:application/x-font-ttf;charset=utf-8;base64,<YOUR BASE64 TTF CONTENT HERE>) format('truetype');
  font-weight: normal;
  font-style: normal;
}

Something else to note: When updating the CSS and Sass, be sure to reassign the content value for the search icons. For .icon-search:before should have content value "\e613" and .icon-search-alt:before should have content value "\e612". This will assure that the right search icon is being used. Admittedly I could have changed this when generating the fonts but it wasn't apparent until I ran the python app on my local machine. Updating the CSS was simple to do.

Help icon is now assigned unicode `\3f` (`?`). Close icon is now assigned unicode `\58` (`X`). Required regenerating fonts and updating CSS + Sass files.
@hugovk
Copy link
Member

hugovk commented Nov 13, 2023

Thank you for the work and for the instructions!

It almost seems worth replacing it with an icon library, but that's another discussion.

@ewdurbin
Copy link
Member

Excellent work thank you @mlcohen.

@ewdurbin ewdurbin merged commit ad5e23f into python:main Nov 14, 2023
1 check passed
@mlcohen mlcohen deleted the add-mastondon-link-to-socialize-menu branch November 14, 2023 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants