Skip to content

Instantly share code, notes, and snippets.

@karenc
karenc / dump_book.py
Last active July 19, 2019 22:49
Dump and load a book from server for development
#!/var/cnx/venvs/archive/bin/python
"""
This script attempts to dump a book from the server and load it into a
development database.
1. You need to download this script onto the server, e.g. staging08.cnx.org,
that runs archive.
2. Use `./dump_book.py dump_book caa57dab-41c7-455e-bd6f-f443cda5519c@19.3` to
dump the prealgebra book.
@karenc
karenc / node-lower-memory-usage.md
Last active June 18, 2019 21:14
Lowering memory usage for a node app

My experience with lowering memory usage for a node app

Baked styles / Baked pdf / Bakery CLI

You might have heard of this project called baked styles, or baked pdf, generating pdfs for openstax books on cnx.org. It takes books in cnxml format, transform them to html, assemble the whole book into one html file, apply a recipe to collate the book, convert the math elements to svg, and finally, feed

  • Clone cnx-recipes with the default master branch:

    git clone https://github.com/openstax/cnx-recipes.git   # which copies the repository to a new directory called cnx-recipes
    cd cnx-recipes   # switch to the cnx-recipes directory
    

    Or, to clone cnx-recipes with a specific branch, e.g. cli-master:

SCRIPT BAKED PDF (updated on April 25, 2019):
0. SETUP
Only prerequisite for the script baked pdf is that docker is installed.
This can be done by running ./script/install-docker
No need for ./script/setup or yarn
Remove any outdated images (this step is only necessary once in a while once the code is stable):

The following are commands in neb in PRs right now. This is not how the textbook developers will create a pdf. The textbook developers will use scripts in cnx-recipes as they have been doing before. We will change the scripts to use neb under the hood.


  1. Download the "Introduction to Business" book from production using neb get:

    neb get prod col25734 1.8.5         
    
press/errors.py:
- Undo collection.xml change restriction
press/legacy_publishing/collection.py:
- Detect major/minor rev
- Undo collection.xml change restriction
- collxml parser
press/legacy_publishing/litezip.py:
- Undo collection.xml change restriction

CNX Pipeline

Broadly speaking, there are 2 parts to generate pdfs:

  1. cnxml -> single html

    1. module cnxml files -> module html files
    2. module html files -> epub -> one single html file
  2. single html -> pdf

keystone installed:
alabaster==0.7.9
alembic==0.8.8
amqp==1.4.9
anyjson==0.3.3
appdirs==1.4.0
astroid==1.4.8
Babel==2.3.4
backports.functools-lru-cache==1.3
boto==2.43.0

Redirects for cnx-archive contents API

master

--2016-01-21 20:11:33--  http://trusty.local:6543/contents/55_943-0:IJ3rHxpG
Resolving trusty.local (trusty.local)... 192.168.122.251
Connecting to trusty.local (trusty.local)|192.168.122.251|:6543... connected.
@karenc
karenc / cnxarchive-users-to-accounts.md
Created December 11, 2015 14:17
Creating users in accounts using the users table from cnx-archive database

To create users in accounts using the users table in the cnx-archive database:

This assumes that you have accounts running and have created a oauth application for cnx (e.g. "OpenStax CNX").

  1. Download the sql file for exporting the cnx-archive users table to a csv file: