capsiums / capsium-webextension

Chrome extension to load Capsium packages
0 stars 1 forks source link

Make the Capsium package webextension work #1

Open ronaldtse opened 3 weeks ago

ronaldtse commented 3 weeks ago

A Capsium package (*.cap) is basically a zip file that contains all files necessary for a static site.

A "not yet working" draft is uploaded to this repository. You can use Chrome and click on "Load unpacked" to see that there is an issue with the import statement since it is not allowed in a module webextension.

The goal is to load a Capsium package and render the index inside the browser, with all links working.

These are files that belong to a Capsium package:

spec/fixtures/bare_package/
├── content/
│   ├── example.html
│   ├── example.css
│   └── example.js
├── metadata.json
├── manifest.json
└── routes.json

metadata.json

{
  "name": "bare_package",
  "version": "0.1.0",
  "dependencies": []
}

manifest.json

{
  "content": {
    "index.html": "text/html",
    "example.css": "text/css",
    "example.js": "application/javascript"
  }
}

routes.json

{
  "routes": [
    {
      "path": "/",
      "target": {
        "file": "index.html"
      }
    },
    {
      "path": "/index",
      "target": {
        "file": "index.html"
      }
    },
    {
      "path": "/index.html",
      "target": {
        "file": "index.html"
      }
    },
    {
      "path": "/example.css",
      "target": {
        "file": "example.css"
      }
    },
    {
      "path": "/example.js",
      "target": {
        "file": "example.js"
      }
    }
  ]
}

All the files listed in the manifest.json file are stored under content/:

The whole package directory is stored under a compressed Zip file named with a .cap extension.

These are Capsium packages for testing whether the extension can load them:

ronaldtse commented 3 weeks ago

This is absolutely doable given that many open source ePub readers exist as web extensions: