feat: add --mobile flag for readable archives of legacy sites
Cloning a 1990s/2000s site like paulgraham.com and opening it in Kiwix on a phone produces microscopic text: the pages use <font size="2">, table layouts, and no viewport declaration, so the mobile browser shrinks everything to desktop scale and then the font-size attribute makes it smaller still. kage clone --mobile injects two things into every saved page: - <meta name="viewport" content="width=device-width, initial-scale=1"> so the browser stops shrinking the page - a <style> block that lifts the base font to 18px, inherits it through <font> elements (overriding the in-HTML size/face attributes), caps the content width at 720px, loosens line height to 1.7, and hides image-map nav elements whose source GIFs 404 offline The style block goes last in <head> to win specificity ties, and ensureViewport skips pages that already carry a viewport meta. Two tests cover the happy path and the no-duplicate case.
This commit is contained in:
+5
-2
@@ -39,8 +39,9 @@ type cloneFlags struct {
|
||||
noRobots bool
|
||||
noSitemap bool
|
||||
headful bool
|
||||
keepNoscript bool
|
||||
chromeBin string
|
||||
keepNoscript bool
|
||||
mobileReadable bool
|
||||
chromeBin string
|
||||
controlURL string
|
||||
noResume bool
|
||||
refresh bool
|
||||
@@ -86,6 +87,7 @@ func newCloneCmd() *cobra.Command {
|
||||
fs.BoolVar(&f.noSitemap, "no-sitemap", false, "do not seed URLs from sitemap.xml")
|
||||
fs.BoolVar(&f.headful, "headful", false, "run Chrome with a visible window (debugging)")
|
||||
fs.BoolVar(&f.keepNoscript, "keep-noscript", false, "unwrap <noscript> content instead of dropping it")
|
||||
fs.BoolVar(&f.mobileReadable, "mobile", false, "inject viewport and CSS overrides so legacy sites read comfortably on a phone")
|
||||
fs.StringVar(&f.chromeBin, "chrome", "", "path to the Chrome/Chromium binary")
|
||||
fs.StringVar(&f.controlURL, "control-url", "", "attach to an existing Chrome DevTools endpoint")
|
||||
fs.BoolVar(&f.noResume, "no-resume", false, "do not reuse or write resume state")
|
||||
@@ -140,6 +142,7 @@ func runClone(ctx context.Context, arg string, f *cloneFlags) error {
|
||||
cfg.FollowSitemap = !f.noSitemap
|
||||
cfg.Headless = !f.headful
|
||||
cfg.KeepNoscript = f.keepNoscript
|
||||
cfg.MobileReadable = f.mobileReadable
|
||||
cfg.ChromeBin = f.chromeBin
|
||||
cfg.ControlURL = f.controlURL
|
||||
cfg.Resume = !f.noResume
|
||||
|
||||
Reference in New Issue
Block a user