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

feat: serve content without header and footer for mobile app #11245

Merged
merged 6 commits into from
Jan 17, 2025

Conversation

stephanegigandet
Copy link
Contributor

This PR is for better display of content pages in the mobile app. It removes the header or the footer if:

  • the user agent contains "Smoothie" (can also be faked by passing the ?user_agent=smoothie)
  • we have a ?content_only=1 parameter

@stephanegigandet stephanegigandet requested a review from a team as a code owner January 15, 2025 10:45
@github-actions github-actions bot added 🧪 tests Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes. Display labels Jan 15, 2025
@codecov-commenter
Copy link

codecov-commenter commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 49.34%. Comparing base (c5cda35) to head (ccec926).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
lib/ProductOpener/Display.pm 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11245      +/-   ##
==========================================
+ Coverage   49.15%   49.34%   +0.19%     
==========================================
  Files          79       79              
  Lines       22502    22504       +2     
  Branches     5386     5387       +1     
==========================================
+ Hits        11061    11105      +44     
+ Misses      10076    10038      -38     
+ Partials     1365     1361       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@teolemon teolemon added 🤳🥫 mobile apps static content This lives at https://github.com/openfoodfacts/openfoodfacts-web labels Jan 15, 2025
@stephanegigandet
Copy link
Contributor Author

/update_tests_results

Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

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

Great idea.

I approve to avoid slowing you down but I have some complains still ;-)

Comment on lines 7621 to 7625
my $template = 'web/common/site_layout.tt.html';
# ?content_only=1 -> only the content, no header, footer, etc.
if (($user_agent =~ /smoothie/) or (single_param('content_only'))) {
$template = 'web/common/content_only.tt.html';
}
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: I think it would be worth isolating in a get_site_layout method

Copy link
Member

Choose a reason for hiding this comment

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

Can't we avoid a full rewrite of the content template ?

Isn't it possible to separate common parts in another template and include it in both ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's possible, but then it makes tons of small files.. I think it would be better to use [% IF ! content_only %] directives to remove what we don't want in fact.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexgarel I think it's better that way: ebee79c

@stephanegigandet
Copy link
Contributor Author

/update_tests_results

@stephanegigandet stephanegigandet merged commit 662a96b into main Jan 17, 2025
15 checks passed
@stephanegigandet stephanegigandet deleted the content-only branch January 17, 2025 10:01
stephanegigandet pushed a commit that referenced this pull request Jan 17, 2025
🤖 I have created a release *beep* *boop*
---


##
[2.55.0](v2.54.0...v2.55.0)
(2025-01-17)


### Features

* determine packaging components in contact with food
([#11238](#11238))
([c5cda35](c5cda35))
* serve content without header and footer for mobile app
([#11245](#11245))
([662a96b](662a96b))


### Bug Fixes

* Green-Score attributes/panels titles and subtitles
([#11244](#11244))
([1eb84a5](1eb84a5))
* more positive messages for Nova 4
([#11231](#11231))
([79e63cd](79e63cd))
* Update fundraiser text to 2025
([#11248](#11248))
([b88f43e](b88f43e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Display 🤳🥫 mobile apps Site layout static content This lives at https://github.com/openfoodfacts/openfoodfacts-web Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes. 🧪 tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants