-
Notifications
You must be signed in to change notification settings - Fork 43
Add promotional banner for iframe-embedded games #144
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
Merged
+112
−11
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
10345aa
feat: add promotional banner for iframe-embedded games
Hugo0 002590c
refactor: simplify embed banner code after review
Hugo0 2c3ec59
merge: resolve conflict with main (keep Android PWA safe-area fix)
Hugo0 cb6757d
fix: use correct language_code attribute in embed banner URL
Hugo0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /** | ||
| * Embed Module - Shows a banner when the game is loaded inside an iframe | ||
| * Promotes wordle.global to users playing via third-party iframe embeds | ||
| */ | ||
|
|
||
| import { isStandalone } from './pwa'; | ||
|
|
||
| const DISMISS_DURATION_MS = 30 * 24 * 60 * 60 * 1000; // 30 days | ||
|
|
||
| export const isEmbedded: boolean = (() => { | ||
| try { | ||
| return window.top !== window.self; | ||
| } catch { | ||
| // Cross-origin iframe throws SecurityError — that means we're embedded | ||
| return true; | ||
| } | ||
| })(); | ||
|
|
||
| const isDismissed = (): boolean => { | ||
| try { | ||
| const dismissedAt = localStorage.getItem('embed_banner_dismissed_at'); | ||
| if (!dismissedAt) return false; | ||
| const elapsed = Date.now() - parseInt(dismissedAt, 10); | ||
| return elapsed < DISMISS_DURATION_MS; | ||
| } catch { | ||
| // localStorage may throw in private browsing mode | ||
| return false; | ||
| } | ||
| }; | ||
|
|
||
| const getBanner = (): HTMLElement | null => document.getElementById('embed-banner'); | ||
|
|
||
| export const hideBanner = (): void => { | ||
| const banner = getBanner(); | ||
| if (banner) banner.style.display = 'none'; | ||
| }; | ||
|
|
||
| export const showBanner = (): void => { | ||
| if (!isEmbedded || isDismissed() || isStandalone()) return; | ||
| const banner = getBanner(); | ||
| if (banner) { | ||
| banner.style.display = 'flex'; | ||
| } | ||
| }; | ||
|
|
||
| export const dismiss = (): void => { | ||
| try { | ||
| localStorage.setItem('embed_banner_dismissed_at', Date.now().toString()); | ||
| } catch { | ||
| // localStorage may throw in private browsing mode | ||
| } | ||
| hideBanner(); | ||
| }; | ||
|
|
||
| const embed = { | ||
| isEmbedded, | ||
| showBanner, | ||
| hideBanner, | ||
| dismiss, | ||
| }; | ||
|
|
||
| export default embed; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical:
language.codeattribute does not exist — link will be broken.The
Languageclass definesself.language_code(seewebapp/app.pyline 647), notself.code. This will cause the "Visit" link to render incorrectly (empty or error).Compare with line 2 of this template which correctly uses
language.language_code, and lines 49/55/59/71/87 which uselanguage.config.language_code.🐛 Proposed fix
🤖 Prompt for AI Agents