ubyssey / ubyssey.ca

The code that powers www.ubyssey.ca
GNU General Public License v2.0
35 stars 40 forks source link

add both mobile and desktop ads to template, change inline ad styling #1413

Closed SamuelmdLow closed 4 months ago

SamuelmdLow commented 4 months ago

When we build the template for articlepages we run a django template filter ubyssey_ad_filters.py which inserts ads between the p tags. The size of the ads is determined by checking the user agent so that we insert mobile sized ads (mobile leaderboard) when the user is on a mobile device and desktop sized (banner) when the user is on desktop.

After the template is built for the first time, caching saves the rendered page and delivers it without having to rebuild again. This means desktop versions of the page which desktop ads can be delivered to users on mobile devices and vice verca. This could ruined the page size on mobile or have the ads not show on desktop.

To fix this I added both ad sizes to the template and determine if they are displayed through media queries in the style sheet.