The Pathagar Book Server
The Pathagar Book Server is a project of developers from Sugar Labs specifically made to publish e-books to computers running Sugar. It is a work in progress and should be judged as such. It does two things:
- It creates an attractive website that you can use with the Browse Activity to look for books and download them to the Journal. (Of course computers not running Sugar can download the books too). The website is maintained using web forms.
- It creates an OPDS (Open Publication and Distribution System) feed that can be searched by the Get Books Activity.
This software has a lot of potential, but isn't ready for actual use yet. If you'd like to play with it anyway, you'll need to install the following on your computer:
- The Apache Web Server: http://httpd.apache.org/
- Apache mod_wsgi: http://code.google.com/p/modwsgi/
- DJango Web Framework: http://www.djangoproject.com/
- Django-sendfile: http://www.sensibledevelopment.com/2010/11/django-sendfile-an-for-abstraction-large-file-serving-in-django/
- SQLLite: http://www.sqlite.org/ (also included with Python)
- Python: http://www.python.org/
- Git: http://git-scm.com/
All of these things can be installed on Windows and on the Macintosh, but for the easiest setup you'll want to use Linux. Any recent Linux distribution includes most of the above software, much of it installed by default and the rest available with no more work than checking a checkbox. An old, discarded PC with a 14 inch monitor that has seen better days will work just fine as a book server, and Linux is very simple to install these days.
Assuming that you have all of the above ready the next step is to get the source code for Pathagar. Currently this is stored in something called a Git repository. You can find out the location of this repository by looking here:http://wiki.sugarlabs.org/go/Book_Server
The URL on this page will take you to a site that lets you browse the code and which has a Downloads button that lets you download the code as a Zip file or a tar.gz file. Choose whichever you prefer and unpack it. It will probably unpack into a directory that is not named pathagar. Rename it to pathagar before you continue or it won't work.
One of the files in this directory will be named settings.py. You'll want to change some lines in that file before you can run pathagar. The only lines that really need changing are these:
ADMINS = ( ('James Simmons', 'email@example.com'), )
Next you'll need to run this from the command line:
python manage.py syncdb
This creates database tables and only needs to be done once. Now you can try running the server:
python manage.py runserver
This starts a server going on port 8000. (You can start it on a different port by putting the port number after runserver). You can open up a web browser on the same machine and point it to http://localhost:8000 and it should bring up the Pathagar Book Server. When you're done looking at Pathagar you can go back to the terminal and quit out of the server command by holding down the Ctrl key and typing 'c'.
This is not the normal way you would run Pathagar. Normally the server does not run by itself. Instead it runs under the Apache web server using a virtual host. Here is a virtual host entry I created for my home installation:
<VirtualHost *:9000> # ServerName sugarlabs.simmons ServerAdmin firstname.lastname@example.org <Location "/"> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE pathagar.settings PythonDebug On PythonPath "['/home/jim/src'] + sys.path" </Location> ErrorLog /var/log/apache2/pathagar-error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/pathagar-access.log combined ServerSignature On </VirtualHost>
I have chosen to run Pathagar on port 9000 because I have Booki using port 8000 and OBJAVI 2 using port 80. I am using mod_python here. Make sure that everything that needs to be written to can be written to by the apache web server, and make sure that settings.py is executable.
The lines in bold are important. The directory specified in PythonPath must contain the directory named pathagar that contains the code for Pathagar. In my own case I'm running the code from my home directory, in a subdirectory called src which I use for unpacking source code archives. If I wanted to do a more finished installation I would create a directory /var/www/pathagar and copy everything there, and use a PythonPath of /var/www.
I have chosen to define my virtual host as being anything with port 9000, which is a simple solution for a home setup. A better way would be to create separate DNS names for each Virtual Host and run everything on port 80. That way you could use the name pathagar.myschool.edu or something like that for Pathagar.
Should you decide to imitate my own example and use port numbers, remember to specify Listen directives in the Apache conf file for all the ports you're using, like this:
Listen 80 Listen 8000 Listen 9000
One final tip: when you create images for your e-books, use The GIMP to resize them to 100 pixels wide. If you don't do this your web browser will try to display your images as if they were 100 pixels wide, and the results will be noticeably less readable than if you had resized the image yourself. It is not necessary to have an image for every book. Pathagar supplies a default image for books that don't provide their own.