Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,4 @@ dist
# Build output and local browser check screenshots
_site/
shots/
.pwa-profile-*/
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Source of [tools.halit.org](https://tools.halit.org/): small browser tools Halit
- `scripts/build.mjs` writes static HTML into `_site/`. Page copy lives in `scripts/content.mjs`; change those, never the output. No framework and no runtime dependencies; esbuild is the one dev dependency and minifies the page scripts.
- `tokens.css` (the personal design standard, see `DESIGN.md`) and `public/site.css` are joined and minified into one `site.css`.
- Each tool is a pure module in `src/` (tested with `node:test`) plus a small page script. Pages ship a Content Security Policy whose only outside connection is the Cloudflare Web Analytics beacon. Keep it that way: the pages promise that pasted text never leaves the device.
- The site is an installable app. Each language has its own manifest (`/site.webmanifest`, `/tr/site.webmanifest`) and `src/sw.js` is the service worker: pages network first with the cached copy as the offline fallback, everything else cache first. The build names the cache after a hash of every precached file and adds `?v=<hash>` to CSS and JS URLs, so a deploy always installs a fresh cache. A new page script goes into `SCRIPTS` in `build.mjs`. Geist is self-hosted in `public/fonts/`.
- `public/db8734a2d48c2e0e5cf2ef632940201f.txt` is the IndexNow key. After a deploy that adds or changes pages, post their URLs to `https://api.indexnow.org/indexnow` with that key.
- `.github/workflows/pages.yml` tests and builds every PR and deploys `main` to GitHub Pages. `public/CNAME` holds the custom domain; DNS is a DNS-only CNAME `tools -> halitsever.github.io` in the halit.org Cloudflare zone.

Expand All @@ -23,6 +24,8 @@ Source of [tools.halit.org](https://tools.halit.org/): small browser tools Halit
npm test && npm run check
```

`npm run check:pwa` is the lighter check for the app side: manifests, service worker, every page offline, cache turnover after a deploy and the install button.

## Conventions

- Conventional-commit subject lines only, in English, with no body or trailer.
Expand Down
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Small tools Halit Sever uses himself, at tools.halit.org. They run in your brows
- [**Kelime ve karakter sayacı**](https://tools.halit.org/tr/karakter-sayaci/) - word and character counter: words, characters with and without spaces, letters, sentences and paragraphs as you type, a reading time at a speed you set, a character limit and a count for the selected part. Words follow Unicode word boundaries (UAX #29), so apostrophes such as İstanbul'da keep a word whole; characters are grapheme clusters, so an emoji counts once. Turkish only.
- [**Word frequency counter**](https://tools.halit.org/word-frequency-counter/) - ranks every word in a text by how often it appears, with its count and its share of all words (keyword density). Counts two- and three-word phrases inside one sentence, leaves out English stop words on request, has a Turkish casing option for I and İ, and copies the table for a spreadsheet or downloads it as CSV. English only.
- **Stays on your device** - every tool is plain JavaScript in the page. A Content Security Policy blocks connections to any server except the Cloudflare Web Analytics page-view beacon, so pasted text cannot be sent anywhere.
- **Installable and offline** - Chrome and Edge can install the site as an app, and iPhone or iPad can add it to the home screen. After one visit a service worker keeps every tool and the Geist font cached, so the tools work without a connection.
- **English and Turkish** - each page has a Turkish twin written in Turkish, paired with `hreflang`.

<p align="center" >
Expand All @@ -49,7 +50,7 @@ npm test # unit tests for the cleaning functions (node:test)
npm run build # writes the site to _site/
```

`npm run check` builds and then drives the pages in headless Chrome at 1440 and 390 px. It needs `playwright-core` and Chrome on the machine; set `PLAYWRIGHT_CORE` and `CHROME` if they are not in the default places. `npm run og` renders the social images into `public/og/` the same way.
`npm run check` builds and then drives the pages in headless Chrome at 1440 and 390 px; `npm run check:pwa` checks the manifests, the service worker, offline use of every page and the install button. It needs `playwright-core` and Chrome on the machine; set `PLAYWRIGHT_CORE` and `CHROME` if they are not in the default places. `npm run og` renders the social images into `public/og/` the same way.

The Pages workflow tests and builds every pull request and deploys `main` to [tools.halit.org](https://tools.halit.org/).

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "node scripts/build.mjs",
"test": "node --test test/*.test.mjs",
"check": "node scripts/build.mjs && node scripts/browser-check.mjs",
"check:pwa": "node scripts/build.mjs && node scripts/pwa-check.mjs",
"og": "node scripts/og.mjs"
},
"engines": {
Expand Down
93 changes: 93 additions & 0 deletions public/fonts/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font.git)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file added public/fonts/geist-cyrillic-ext.woff2
Binary file not shown.
Binary file added public/fonts/geist-cyrillic.woff2
Binary file not shown.
Binary file added public/fonts/geist-latin-ext.woff2
Binary file not shown.
Binary file added public/fonts/geist-latin.woff2
Binary file not shown.
Binary file added public/fonts/geist-vietnamese.woff2
Binary file not shown.
149 changes: 149 additions & 0 deletions public/site.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
/* Geist is served from this site so the tools keep their font offline and no page talks to Google. License: /fonts/OFL.txt */

@font-face {
font-family: "Geist";
font-style: normal;
font-weight: 400 700;
font-display: swap;
src: url(/fonts/geist-cyrillic-ext.woff2) format("woff2");
unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
font-family: "Geist";
font-style: normal;
font-weight: 400 700;
font-display: swap;
src: url(/fonts/geist-cyrillic.woff2) format("woff2");
unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
font-family: "Geist";
font-style: normal;
font-weight: 400 700;
font-display: swap;
src: url(/fonts/geist-vietnamese.woff2) format("woff2");
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

@font-face {
font-family: "Geist";
font-style: normal;
font-weight: 400 700;
font-display: swap;
src: url(/fonts/geist-latin-ext.woff2) format("woff2");
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
font-family: "Geist";
font-style: normal;
font-weight: 400 700;
font-display: swap;
src: url(/fonts/geist-latin.woff2) format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* tools.halit.org components. Tokens come from tokens.css, which the build puts in front of this file. */

.sr-only {
Expand Down Expand Up @@ -205,6 +252,71 @@ ol {
background: var(--muted);
}

/* install button, shown by nav.js only where the browser can install the site */
.install {
position: relative;
}

.install[hidden],
.install-hint[hidden] {
display: none;
}

.install-btn {
display: inline-flex;
align-items: center;
gap: 6px;
height: var(--nav-h);
padding: 0;
border: 0;
background: none;
font: inherit;
color: var(--muted-foreground);
white-space: nowrap;
cursor: pointer;
transition: color var(--fast) var(--ease);
}

.install-btn:hover,
.install-btn[aria-expanded="true"] {
color: var(--foreground);
}

.install-icon {
flex: none;
width: 18px;
height: 18px;
}

.install-short {
display: none;
}

.install-hint {
position: absolute;
top: calc(100% - 8px);
right: 0;
z-index: 20;
width: 248px;
padding: 12px 14px;
border: 1px solid var(--border);
border-radius: var(--radius);
background: var(--background);
box-shadow: 0 4px 16px rgb(0 0 0 / 0.08);
color: var(--foreground);
font-size: 14px;
font-weight: 400;
line-height: 1.5;
white-space: normal;
}

.share-icon {
display: inline-block;
width: 18px;
height: 18px;
vertical-align: -4px;
}

/* the hairline keeps the white parts of a flag visible on the white menu */
.flag {
flex: none;
Expand Down Expand Up @@ -2203,6 +2315,31 @@ code {
display: inline;
}

.install {
position: static;
}

.install-long {
display: none;
}

.install-short {
display: inline;
}

.install-hint {
top: 100%;
left: 0;
right: 0;
width: auto;
padding: 12px var(--gutter) 16px;
border: 0;
border-bottom: 1px solid var(--border);
border-radius: 0;
box-shadow: 0 8px 16px rgb(0 0 0 / 0.06);
font-size: 16px;
}

.lang-list {
top: 100%;
left: 0;
Expand Down Expand Up @@ -2267,6 +2404,18 @@ code {
}
}

/* below 380px the label would squeeze the signature, so the icon stands alone with a full-size tap target */
@media (max-width: 380px) {
.install-short {
display: none;
}

.install-btn {
justify-content: center;
min-width: 44px;
}
}

@media (prefers-reduced-motion: reduce) {
*,
*::before,
Expand Down
2 changes: 1 addition & 1 deletion scripts/browser-check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const root = fileURLToPath(new URL("../_site/", import.meta.url));
const shots = process.argv[2] ?? "shots";
const pw = process.env.PLAYWRIGHT_CORE ?? `${process.env.HOME}/.cache/seo-cdp/node_modules/playwright-core/index.mjs`;
const { chromium } = await import(pathToFileURL(pw).href);
const TYPES = { ".html": "text/html; charset=utf-8", ".css": "text/css", ".js": "text/javascript", ".svg": "image/svg+xml", ".png": "image/png", ".ico": "image/x-icon", ".xml": "application/xml", ".txt": "text/plain", ".webmanifest": "application/manifest+json" };
const TYPES = { ".html": "text/html; charset=utf-8", ".css": "text/css", ".js": "text/javascript", ".svg": "image/svg+xml", ".png": "image/png", ".ico": "image/x-icon", ".xml": "application/xml", ".txt": "text/plain", ".webmanifest": "application/manifest+json", ".woff2": "font/woff2" };

const server = createServer(async (req, res) => {
let path = normalize(decodeURIComponent(new URL(req.url, "http://x").pathname));
Expand Down
Loading