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

Migrate to font-awesome v5 #3050

Merged
merged 6 commits into from
Feb 28, 2018

Conversation

SaptakS
Copy link
Contributor

@SaptakS SaptakS commented Feb 21, 2018

Status

Ready for review

Description of Changes

In this PR, I have made changes in the font files, the font-awesome sass file and changed the classes in the templates as required.

One of the reasons for doing this is using the updated globe icon of font-awesome v5 in the language dropdown.

Testing

How should the reviewer test this PR?
Check for the icons in the journalist and source interface.

Checklist

If you made changes to the app code:

  • Unit and functional tests pass on the development VM

@SaptakS SaptakS requested a review from a user February 21, 2018 17:06
@ghost ghost added feature UX labels Feb 21, 2018
@ghost
Copy link

ghost commented Feb 21, 2018

@SaptakS thanks for preparing four well separated commits: makes the life of the reviewer soooo much easier :-)

The class modifications is the delicate part to review. To that end it would be great if you could explain (in the commit message) how you proceeded to make sure all v4 class are accounted for. And also, for each class that was replaced how you selected the replacement.

@SaptakS
Copy link
Contributor Author

SaptakS commented Feb 21, 2018

@dachary I used this link which says about upgrading to v5 and enlists all the changed classes to change the icon names in the classes as required. I will update the same in the commit message.

@ghost
Copy link

ghost commented Feb 21, 2018

Ran

./bin/dev-shell ./bin/run-test -v tests/pages-layout

and

cd tests/pages-layout/screenshots/en_US ; geeqie

to visually verify screenshots still look good. I wish I had a way to see the screenshots side by side, before and after. That will be for another time though ;-)

@codecov-io
Copy link

codecov-io commented Feb 21, 2018

Codecov Report

Merging #3050 into develop will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3050   +/-   ##
========================================
  Coverage    88.22%   88.22%           
========================================
  Files           32       32           
  Lines         1852     1852           
  Branches       212      212           
========================================
  Hits          1634     1634           
  Misses         168      168           
  Partials        50       50

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2195ac6...b548db5. Read the comment docs.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good. One thing before we can merge this: install_files/ansible-base/roles/build-securedrop-app-code-deb-pkg/files/usr.sbin.apache2 must be updated with the list of all files. Otherwise access will be denied when using them in a hardened environment.

And a comment added to the Font Awesome v5 migrate: Modify classes in the html template file commit with a link to https://fontawesome.com/how-to-use/upgrading-from-4#icon-name-changes-complete-list

@ghost
Copy link

ghost commented Feb 21, 2018

I still see many occurrences of the fa prefix although the documentation reads Keep in mind you’ll need to change all brand icons from version 4 to us the new fab prefix instead of the old fa prefix.

Am I mistaken ?

securedrop/journalist_templates/_source_row.html:8:              formaction="{{ url_for('col.remove_star', filesystem_id=source.filesystem_id) }}"><i class="fa fa-star"></i></button>
securedrop/journalist_templates/_source_row.html:13:        formaction="{{ url_for('col.add_star', filesystem_id=source.filesystem_id) }}"><i class="fa fa-star"></i></button>
securedrop/journalist_templates/_source_row.html:23:        <a class="btn small" href="/download_unread/{{ source.filesystem_id }}"><i class="fa fa-download"></i> {{ gettext('{num_unread} unread').format(num_unread=source.num_unread) }}</a>
securedrop/journalist_templates/admin.html:6:  <button class="sd-button" type="submit" class="btn" id="add-user"><i class="fa fa-plus"></i>{{ gettext('ADD USER') }}</button>
securedrop/journalist_templates/admin.html:25:        <td><a href="/admin/edit/{{ user.id }}" class="plain" data-username="{{ user.username }}"><i class="fa fa-edit" title="{{ gettext('Edit user {username}').format(username=user.username) }}"></i></a></td>
securedrop/journalist_templates/admin_add_user.html:39:  <button type="submit" class="sd-button"><i class="fa fa-plus"></i>{{ gettext('ADD USER') }}</button>
securedrop/journalist_templates/col.html:11:      <i class="fa fa-chevron-right"></i>
securedrop/journalist_templates/col.html:26:        <button type="submit" name="action" value="download" class="small"><i class="fa fa-download"></i> {{ gettext('Download Selected') }}</button>
securedrop/journalist_templates/col.html:38:                <span title="Unread" class="icon"><i class="fa fa-envelope"></i></span>
securedrop/journalist_templates/col.html:41:                <span class="icon"><i class="fa fa-envelope-open"></i></span>
securedrop/journalist_templates/col.html:53:                    <i class="fa fa-download"></i> <span class="filename">{{ doc.filename }}</span></a></span>
securedrop/journalist_templates/col.html:59:              <i title="{{ gettext('Reply') }}" class="fa fa-reply pull-right"></i>
securedrop/journalist_templates/col.html:92:  <h3><i class="fa fa-reply"></i> {{ gettext('Reply') }}</h3>
securedrop/journalist_templates/config.html:15:    <i class="fa fa-bell"></i>{{ gettext('SEND TEST OSSEC ALERT') }}
securedrop/journalist_templates/flag.html:4:  <i class="fa fa-info-circle pull-left"></i>
securedrop/journalist_templates/index.html:11:        <button type="submit" name="action" value="download-unread" class="small"><i class="fa fa-download"></i> {{ gettext('Download Unread') }}</button>
securedrop/journalist_templates/index.html:12:        <button type="submit" name="action" value="download-all" class="small"><i class="fa fa-download"></i> {{ gettext('Download') }}</button>
securedrop/journalist_templates/index.html:13:        <button type="submit" name="action" value="star" class="small"><i class="fa fa-star"></i> {{ gettext('Star') }}</button>
securedrop/static/js/journalist.js:10:  $('div#select-container').html('<span id="select_all" class="select"><i class="fa fa-check-square-o"></i> ' + get_string("select-all-string") + '</span> <span id="select_unread" class="select"><i class="fa fa-check-square-o"></i> ' + get_string("select-unread-string") + '</span> <span id="select_none" class="select"><i class="fa fa-square-o"></i> ' + get_string("select-none-string") + '</span>');
securedrop/static/js/journalist.js:12:  $('div#index-select-container').replaceWith('<span id="select_all" class="select"><i class="fa fa-check-square-o"></i> ' + get_string("select-all-string") + '</span> <span id="select_none" class="select"><i class="fa fa-square-o"></i> ' + get_string("select-none-string") + '</span>');

@SaptakS
Copy link
Contributor Author

SaptakS commented Feb 22, 2018

@dachary that is only for the brand icons. As far as I have checked, we don't use any brand icons. We mostly use solid or regular icons. Solid icons can either have the prefix fa or fas. Both of them works. Hence I didn't change all those fa prefix.

…match with v5

The class names have been updated following the list of changed class names
present here: https://fontawesome.com/how-to-use/upgrading-from-4#icon-name-changes-complete-list
Update the list of files in install_files/ansible-base/roles/build-securedrop-app-code-deb-pkg/files/usr.sbin.apache2
to prevent access denied in hardened environments.
@SaptakS SaptakS force-pushed the migrate/font-awesome-v5 branch from 7b9829a to b548db5 Compare February 22, 2018 06:12
@ghost
Copy link

ghost commented Feb 22, 2018

@SaptakS in order to verify no class was left behind, will I be exhaustive in my review if I do the following:

git --no-pager grep --color -nH -i '\<\(fa\|fa[rlsb]\) '

to see all lines with a fontawesome class that could be in the list of name to change, extract each name, make a list, remove duplicates which leads to:

fa-arrow-alt-circle-right
fa-bell
fa-check-square-o
fa-download
fa-edit
fa-envelope
fa-envelope-open
fa-file-alt
fa-file-archive
fa-info-circle
fa-plus
fa-reply
fa-star
fa-star-half
fa-trash-alt

and then verify for each of them they are converted as suggested

fa-arrow-alt-circle-right ok
fa-bell ok
fa-check-square-o should be fa-check-square
fa-download not found means no conversion ?
fa-edit not found means no conversion ?
fa-envelope ok
fa-envelope-open ok
fa-file-alt ok
fa-file-archive ok
fa-info-circle not found means no conversion ?
fa-plus not found means no conversion ?
fa-reply not found means no conversion ?
fa-star ok
fa-star-half ok
fa-trash-alt ok

The fa-check-square-o is in js files, reason why you missed it. What about the ones I did not find ? Does that mean they stay as they are ?

@SaptakS
Copy link
Contributor Author

SaptakS commented Feb 22, 2018

@dachary yes. That is what they mean. If it is not there in the change list, it works with the old class. I will still re-check to confirm I am not missing anything. And I will fix the fa-check-square-o

The class names have been updated in the js files following the list of changed class names
present here: https://fontawesome.com/how-to-use/upgrading-from-4#icon-name-changes-complete-list
@ghost
Copy link

ghost commented Feb 22, 2018

Visually verified the classes changed by Font Awesome v5 migrate: Update js files with the new class names work as advertized by:

  • make -C securedrop dev
  • firefox localhost:8080 and submit a message
  • firefox localhost:8081 and login
  • see the select all / none icons show square with check / without check
  • got to a collection and see all / unread / none icons show square with check / without check

@ghost
Copy link

ghost commented Feb 22, 2018

the CircleCI failure looks like a transient error, like the machine breaking down. I'm not sure why anything in this PR would make tests hang for more than 10 min doing nothing. https://circleci.com/gh/freedomofpress/securedrop/8957?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

    TASK [Run application tests] ***************************************************
    Thursday 22 February 2018  13:10:37 +0000 (0:00:00.037)       0:01:07.570 *****
Makefile:20: recipe for target 'ci-go' failed
make: *** [ci-go] Terminated
Too long with no output (exceeded 10m0s)

@ghost
Copy link

ghost commented Feb 22, 2018

Hum, browsing the source directory I found i/font-awesome/fa-arrow-circle-o-right-white.png and I wonder what it is. Should it be updated ? And how did it get there ? @redshiftzero do you remember ?

@SaptakS relevant PRs could be #1567 and #1480 but I did not look into them.

@redshiftzero
Copy link
Contributor

Ah that icon is used by the source interface, it does not need to be updated. For context, back when we started recommending sources to turn the Tor Browser security slider to its safest setting (#1480), we knew that all Font Awesome icons would not render (as this would be disabled by Tor Browser), so we replaced the Font Awesome icons used on the source interface with identical PNGs (#1567). In some files - like the one you point out - the "fa" substring from the Font Awesome icon name may still be there. We can always change the name for clarity if it helps

@ghost
Copy link

ghost commented Feb 22, 2018

recommending sources to turn the Tor Browser security slider to its safest setting

It makes sense now, thank you. And I see the securedrop/static/fonts/ (i.e. font-awesome ttf etc.) files are only used by the journalist interface.

@ghost
Copy link

ghost commented Feb 22, 2018

Verified that securedrop/.rsync-filter has

include static/fonts/
include static/fonts/**

meaning all files from the fonts directory will be packaged, not a selection that would need to be updated.

@ghost
Copy link

ghost commented Feb 22, 2018

I tested in the staging environment, it would be great if you could do the same @SaptakS to verify all works as it should in an environment that is almost as production (modulo SSH access but that's entirely unrelated to this PR). Instructions on how to setup a staging environment are at https://docs.securedrop.org/en/latest/development/virtual_environments.html#staging-vms but I'd be happy to answer any questions you may have.

You will need a to cherry-pick the two commits from #3062 otherwise it won't work. They are not related to this PR, the problem existed before.

@SaptakS
Copy link
Contributor Author

SaptakS commented Feb 23, 2018

@dachary ok. will check in the staging environment

@ghost
Copy link

ghost commented Feb 26, 2018

@SaptakS in case that helps you'll find in another post detailed instructions on how to setup a staging environment.

@redshiftzero
Copy link
Contributor

Hi @SaptakS - this looks great. One last thing prior to merge: can you provide a link to where the webfonts files in this PR were downloaded from?

Copy link
Contributor

@redshiftzero redshiftzero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking as changes requested for now - just this question to address

@SaptakS
Copy link
Contributor Author

SaptakS commented Feb 28, 2018

@redshiftzero the font files came with the zip downloaded from here

@redshiftzero
Copy link
Contributor

Are you sure v5.0.7 is the correct version? Here are the SHA256 hashes of the font files in this PR:

75a8d21d405fc02922bf4e5910c02da8c69e1422c54eace016902f8d13f24cc3  fa-brands-400.eot
981c7b389bbd9de156f6b92bb4f65f4e66d329b9d3503277d4fe6eef1008f3f4  fa-brands-400.svg
345def96ebbc01d79e677848420a94ca0653961c03b30977714fa62395553569  fa-brands-400.ttf
0d9317d5559d4091516c1e240689589122ad9b101f030ef7aee8c01a9fc5a78c  fa-brands-400.woff
155963e3fb06f13011705c65bc52ed31f9989b87309c945948a76b35f8e7da67  fa-brands-400.woff2
e73d73f67b277568ab01d56322d1a01d66409a8f947735dd738fe2dcb6bb0c58  fa-regular-400.eot
42e44be1cfd7bfab3031546e1f656418e9c835230a2f69b7a34594815d0e0a80  fa-regular-400.svg
8721a523848f5d583c554552d6daeaaacefc8eb9239ba0c998a09492667f5c75  fa-regular-400.ttf
4773adbb080c5189d52e31d83658b6d9743bdf7337e53bb8a4706de8dc116ffd  fa-regular-400.woff
a36d4f83add2176a3c6243bd57a32a387a1906227e286689530ff878de1994eb  fa-regular-400.woff2
f5d00bfd4457c03601f28e200ed5db6e5bf58b332164a1e630fa6aafcfab6bcb  fa-solid-900.eot
b0f3ece320e40f6c55b19378e123f198a3ef5f2e8fbd9ab7906ce04198770fdf  fa-solid-900.svg
9ae2e3bc1545ee5fd1f72e0f4d0656f8054d1ead2e51c28f8f0730f85f688bed  fa-solid-900.ttf
6f43ff9f2fb98cc65e18f73ee16951bacfb055f76e68e06f7d91989fd770fa71  fa-solid-900.woff
62554277d07b20c6bfae7c6267b3198b4846f604a37d4085bf9f54c392210b56  fa-solid-900.woff2

and in the v5.0.7 Font Awesome download:

bb778c6ffcd7120b289b886ea5b46d645eb67430ea893e9618d41b5fcef44e1c  fa-brands-400.eot
4a89d1f1adb4083284b6d514b75b6d6c188419816b96267e5ef5536e69c37087  fa-brands-400.svg
f8c00fb60d9e80851f77db7eafa8fabef5939591b62dd5aed09192e0f4efa9f6  fa-brands-400.ttf
b738e3dafd06be4426b02769f0082ab59d0d7cae881639b43d42705a51eec687  fa-brands-400.woff
abbcb43a4cf5b5c586d440527b87830cc4d6d069e2eabaeb7e0c433ca0edf8d5  fa-brands-400.woff2
7c6b79ee3da2438dc9c1f85b4c4a03ea8223c52d354fbfc07a2044867b25b182  fa-regular-400.eot
1503181a2699f0d3b6e0061e08a50dbe585cdb03aaa3c3c173b3adf80e960c84  fa-regular-400.svg
0465105ae513d3be4a7d102c2827d057ad7832733f34b5038c8978bac549a83e  fa-regular-400.ttf
74d63644acecb753b532914d7f5bc9c47c7a4f8277fe1f963de0050aa3bae3f2  fa-regular-400.woff
a7c95dca8cd84819f8a72cf87efdfbbd889de284690477f391d080e6252352ac  fa-regular-400.woff2
4132816d1cfb7edaa141960478adffc5903a9fb3e6178b30af50a09373b9297c  fa-solid-900.eot
81120ce8a215dc6ecf8fd7b11de5a53d67caa1940adeed5df89088cfb154c522  fa-solid-900.svg
0f24078d012d58bce65e7dcb6e7511d65b5db18b07bff7fad6a4c3d00a5b3887  fa-solid-900.ttf
8864d9c9bb487295db8e93d55c5a52e360b4553d8685fc29a9870fad6cd5a26d  fa-solid-900.woff
ececd30b13956872441d17b03b9de4c032b5983f0932051e763a0a6d0250842b  fa-solid-900.woff2

@SaptakS
Copy link
Contributor Author

SaptakS commented Feb 28, 2018

@redshiftzero sorry. Seems the one I used in this PR was v5.0.6 and they updated to v5.0.7 after that. I will update to v5.0.7 if need be. Sorry for the inconvenience. Didn't notice they have pushed in a new release.

Copy link
Contributor

@redshiftzero redshiftzero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirming these font files are from v5.0.6 of Font Awesome. Thanks @SaptakS!

@redshiftzero
Copy link
Contributor

No need to update, I just wanted to cross-check the hashes prior to merge. All looks good!

@redshiftzero redshiftzero merged commit 650ab5b into freedomofpress:develop Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants