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

Fix "Previews available in:" sometimes displayed without any preview languages #6408 #6410

Merged
merged 5 commits into from
Apr 14, 2022

Conversation

constantinazouni
Copy link
Contributor

Made the caption "Previews available in:" appear only when they are available preview languages.

Closes #6408

Screenshot

image

Stakeholders

@jimchamp

constantinazouni and others added 2 commits April 10, 2022 22:59
Made the caption "Previews available in:" appear only when they are available preview languages.
Previews available in:
$for e in previews:
$if len(e.languages)!=0:
Previews available in:
Copy link
Member

Choose a reason for hiding this comment

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

Question, will this result in the words "Previews available in" being displayed multiple times in the page?

Copy link
Member

Choose a reason for hiding this comment

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

I see! We have a second for loop and are using breaks, that can work!

Copy link
Member

@mekarpeles mekarpeles Apr 12, 2022

Choose a reason for hiding this comment

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

By default, any non-zero number will be a True value, so can use len(e.languages) as an a equivalent to len(e.languages)!=0.

Another option is... on line L269 we can turn this into a list comprehension where we do something like...

$if previews and any([len(e.languages) for e in previews)]:
    <p class="preview-languages">
        Previews available in:
        $for e in previews:
            $if e.languages[0].name not in seen:
                $ seen.add(e.languages[0].name)
                <a href="$work.key?edition=$(e.ocaid)">$e.languages[0].name</a>            
   </p>

This way we don't render <p class="preview-languages"> if its not going to be used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! Do you want me to change it in the way that you suggested?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I implemented the changes

@jimchamp jimchamp added the On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing label Apr 14, 2022
Copy link
Collaborator

@jimchamp jimchamp left a comment

Choose a reason for hiding this comment

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

@jimchamp jimchamp merged commit 4cebeb7 into internetarchive:master Apr 14, 2022
@jimchamp jimchamp removed the On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing label May 16, 2022
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.

"Previews available in:" sometimes displayed without any preview languages
3 participants