]> BookStack Code Mirror - api-scripts/blob - php-book-to-static-site/readme.md
Added bsfs to community project list
[api-scripts] / php-book-to-static-site / readme.md
1 # Book to Static Site
2
3 This script will export all chapters and pages within a given book to a folder
4 of basic HTML and image files which could act as a static site.
5
6 Once ran, you should be able to open `index.html` within the output folder to start browsing.
7
8 **This is a very simplistic single-script-file example of using the book, chapter and pages
9 API together**, the output lacks a lot of detail including styling and inter-content link transforming. 
10
11 ## Requirements
12
13 You will need php (~7.2+) installed on the machine you want to run this script on.
14 You will also need BookStack API credentials (TOKEN_ID & TOKEN_SECRET) at the ready.
15
16 ## Running
17
18 ```bash
19 # Downloading the script
20 curl https://raw.githubusercontent.com/BookStackApp/api-scripts/main/php-book-to-static-site/book-to-static.php > book-to-static.php
21
22 # Setup
23 # ALTERNATIVELY: Open the script and edit the variables at the top.
24 export BS_URL=https://bookstack.example.com # Set to be your BookStack base URL
25 export BS_TOKEN_ID=abc123 # Set to be your API token_id
26 export BS_TOKEN_SECRET=123abc # Set to be your API token_secret
27
28 # Running the script
29 php book-to-static.php <book_url_slug> <output_dir>
30 ```
31
32 ## Examples
33
34 ```bash
35 # Export a book with URL slug of my_book to an "out" directory
36 php book-to-static.php my_book ./out
37 ```