What is a recipe?
Recipes are the primary source of web urls for Pagehop. Mostly, recipes are used to make searches or acquire content, usually doing so by either scraping pages, or using web services.
Recipe’s file structure (scaffold)
Every recipe is required to have these 3 files:
Pagehop will not be able to load a recipe, that doesn’t have all of these files.
How does it work?
In a nut-shell, page-loop.js and scrape.js are scripts that can use all node packages compliant with browserify, specified as dependencies in the package.json, and your recipe project can use absolutely all node packages for testing (devDependencies in the package.json).
Pagehop “compiles” (more like “links”) page-loop and scrape using browserify, producing self-contained (no external dependencies) scripts.
To correctly load and execute your recipes, Pagehop uses the metadata in the package.json.
Scaffold a new recipe with the pagehop CLI
If you haven’t set your development environment, yet, check the Development Overview to see how to do that.
To init a new recipe in the current dir, you simply run:
You can (optionally) specify a path:
After the project files are created, run this in the root of the project:
This way, all dependencies (only devDependencies are added by default - inspect the created package.json) are installed.
If you want to run the tests (there are few actual tests on the sample recipe) and lint (jsHint is used) the code, run this (there should be no errors):
Validate project structure and package.json
To validate the structure of your recipe (including package.json’s required properties’ presence and type):
And again, you can specify a path: