14. Adding a Book¶
Now that you have done all the work to get your servers configured, you are also going to want one or more books for testing. Lets add a book to your setup.
Note
Keep Docker Running
In everything that follows we assume that docker and all of the services are running. If you have stopped docker then you will need to start it again. docker compose up -d If you are not sure if docker is running then you can check with docker ps
14.1. Prerequisites¶
To build a book using the runestone or pretext commands that are part of the rs monorepo you need to make sure you have the following installed:
npm(node package manager) On a Mac you can use homebrew to install this.brew install npmon linux there are many articles such as this one that walk you through it.All of the javascript dependencies in the
package.jsonfile found inbases/rsptx/interactives. You can install these by runningnpm installfrombases/rsptx/interactives.Package all of the runestone javascript dependencies into bundle. You can do this by running
npm run buildfrombases/rsptx/interactives. This will create many files in therunestone/distfolder.
Note: There is an alternative to the above steps that involves simply using pip install runestone in a separate virtual environment. But then you will have to remember to switch back and forth between the different environments. So I don’t really recommend it.
14.2. Building the Book¶
Go to your
$BOOK_PATHfolder and clone a book. Lets take our simple overview book as an example. run the commandgit clone https://github.com/RunestoneInteractive/overview.gitYou should see a new folder calledoverviewThe over view book is already in the database, so the only thing we need to do is build it.
cd overviewand then runrunestone build --all deployIf the command fails, make sure you have your virtual environment activated. You can do this by runningsource .venv/bin/activatefrom the top level directory (rs).
This builds the book and deploys it to overview/published/overview This is the location that the Runestone server will look for it. Important: The book name and the folder name must match. So if you want to build a book called mybook then you need to clone it into a folder called mybook and then build it into mybook/published/mybook.
The overview book is an easy example because the database already contains a course called overview by default. Lets look at a more complicated scenario. Lets say you want to build the active calculus book, and that you are going to want to use your server to support your department’s calculus courses.
Clone the book into your
$BOOK_PATHfolder.git clone https://github.com/active-calculus/active-calculus-single-mbx.git ac-singleWe need to add ac-single to the database of known courses with the
rsmanagecommand.
$ rsmanage addbookauthor
Loaded .env file from /Users/bmiller/rs
You have defined docker compose specific environment variables
Using configuration: development
Database connection successful
document-id or basecourse : ac-single
Runestone username of an author or admin: : testuser1
Book added to DB successfully
Now we can build the book using the
rsmanagecommand.rsmanage build --ptx ac-singleIf you are running the database in docker then you should usedocker compose run rsmanage rsmanage build --ptx ac-singleThis will build the book and deploy it toac-single/published/ac-singleThe Active Calculus book should now be visible in the library.Notice that we used
ac-singlefor the course name as well as the base course name. You should not use this course for your own courses. Instead you should use the runestone web interface to create a custom course from theac-singlebase course. But first you will need to make the book available to the web interface. You do this by setting a flag in the library table of the database. For now you need to do this by hand. This really should be another rsmanage subcommand but instead runpsql $DEV_DBURL
$ rsmanage library forclass --show
You can show the main library settings for any book with rsmanage library show document-id You can also hide/show books in the library with library visible --show/hide
rsmanage library show ac-single ─╯
INFO - 2023-09-13 14:10:52,417 - Settings - Error path is /Users/bmiller/Runestone/books/tickets
Loaded .env file
You have defined docker compose specific environment variables
Using configuration: development
Using database: runestone_dev
Title: Active Calculus
Authors: Matt Boelkins
shelf sections: Mathematics
description: Active Calculus Single Variable supports an active learning approach in the first two semesters of calculus. Every section of Active Calculus Single Variable offers engaging activities for students to complete before and during class; additional exercises that challenge students to connect and assimilate core concepts; interactive WeBWorK exercises; opportunities for students to develop conceptual understanding and improve their skills at communicating mathematical idea. The text is free and open-source, available in HTML, PDF, and print formats. Ancillary materials for instructors are also available.
-----------------
for_classes: True
is_visible: True
Now if you go to the create a course page Active Calculus will be a choice for you to use.