- HTML 61.6%
- JavaScript 34.4%
- CSS 4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
On a phone, sending the page meant Copy, switching to the chat and pasting. Where the browser has the Web Share API (Chrome on Android, Safari on iOS and macOS, Edge and Chrome on Windows), a Share button next to Copy opens the system share sheet with the same link, question included. Elsewhere, Firefox on the desktop for one, it stays hidden. The link row now wraps, so the buttons go under the link instead of squeezing it: at 280px the Russian and Ukrainian pages already left the field 70px wide, showing "https://a", before a second button. |
||
| .github/workflows | ||
| css | ||
| i18n | ||
| img | ||
| lan | ||
| src | ||
| test | ||
| 404.html | ||
| build.mjs | ||
| index.html | ||
| LICENSE | ||
| README.md | ||
"Learn to Google" website
Russian | English | Azerbaijani | Ukrainian | Uzbek
The main purpose of the site is to explain the advantages of googling questions in a polite way to people who are too lazy to Google for unknown reasons.
How it behaves
- The form at the bottom of the page makes a link for whoever asked: pick the language, optionally paste their question, and copy (Enter copies too). Where the browser can pass a link to another app, as on most phones, a Share button next to Copy opens its share sheet. The question travels as
?q=, for example/lan/en/?q=What+is+polymorphism%3F, and the page shows it first among the example questions, with a button that searches Google for it. - Each translation has its own URL, and a link always opens in the language it was shared in. If none of the reader's browser languages is the page's but one of them is another translation, a bar at the top offers that one; it stays away once they close it or pick a language.
- The theme follows the system's light or dark setting; the button in the header overrides it, and the choice is remembered.
- A link from before April 2021, when the translations lived at
/en/,/az/and/ua/instead of under/lan/, is forwarded by the 404 page to where that page is now. - Everything works without JavaScript except the form, the question, the language offer and the theme button, which simply do not appear.
Editing
Every translation is rendered from one template, so a change to the page is made once:
src/page.mjsis the page;src/share.jsis the script behind the form, inlined into it.i18n/<lang>.mjsholds the text of one translation;i18n/index.mjslists them.css/main.cssis the stylesheet. It is inlined into every page as well, so rebuild after changing it.
The HTML that gets served (index.html, lan/*/index.html and 404.html) is generated. Edit the sources, regenerate, and commit both:
node build.mjs
node build.mjs --check writes nothing and fails if a page is out of date or links to a local file that does not exist. The build needs Node 18 or newer and has no dependencies; GitHub Pages serves the committed files as they are, so nothing is built on deploy.
Every push runs that check and two more, which are worth running before you commit:
node --test
npx html-validate@11.16.2 "*.html" "lan/*/index.html"
The tests in test/ run the site's own scripts (the one in <head> that sets the theme and offers a language, the one that shows the question from ?q=, the form in src/share.js, and the 404 page's, which forwards old links) against stand-ins for the page, so they need no browser. html-validate checks the generated pages' markup.
To add a language, copy one of the files in i18n/, translate it, give it its own lang and dir, add it to i18n/index.mjs and run the build. A new string goes into every file in i18n/: the build stops and names the string if a translation is missing one, has one the others do not, or leaves one empty.
Each picture is a PNG (bad-good.png, kept for share previews and the full-size link) with two WebP copies next to it, which is what browsers actually download: bad-good.webp at full size and bad-good-800.webp 800px wide, both at quality 80. If you replace a PNG, keep it under 300 KB, or WhatsApp may leave the picture out of its preview (oxipng -o max --strip safe -Z bad-good.png makes one smaller without changing a pixel), and make the WebP copies again, for example with cwebp -q 80 -m 6 bad-good.png -o bad-good.webp and the same with -resize 800 0 for the smaller one.
Contributors
- @byrvr for help with the website and translation into the Azerbaijani language.
- @devule for help with the website and translation into the Ukrainian language.
Author
by Azer Sadykhzadeh, 2020.