E-Book Enlightenment

The Pathagar Book Server

default_1.png

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 a future version of the Get Books Activity.
This is what the website looks like:

Pathagar 

As of this writing Pathagar is missing some important features:

  • The site lists out books in the order that they were entered into the system.  You can search the books, but there is no way to simply list them out by author, title or subject.
  • You can easily add books to the site, but there is no way to remove books or update existing book entries.
  • The OPDS feed works, but the current Get Books Activity only works with OPDS feeds from the Internet Archive and from Feedbooks.  There is no way to add a new OPDS feed to the 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:

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 all 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 use Git to download the source code for pathagar.  Open a terminal, make the directory where you want to put the software your current directory, and issue this command:

git clone http://github.com/sayamindu/pathagar.git

This will copy pathagar to the current directory.  One of the files will be named settings.py.  You'll need to change some lines in that file before you can run pathagar.  This is what my settings.py looks like, with the lines you might want to modify in bold:

# Django settings for pathagar project.

ITEMS_PER_PAGE = 5      # Number of books shown per page in the OPDS catalog and in the HTML page

DEBUG = False
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    ('James Simmons', 'nicestep@gmail.com'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'sqlite3'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'database.db'             # Or path to database file if using sqlite3.
DATABASE_USER = ''             # Not used with sqlite3.
DATABASE_PASSWORD = ''         # Not used with sqlite3.
DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = './static_media'

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = 'http://127.0.0.1:8000/e-books'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = '7ks@b7+gi^c4adff)6ka228#rd4f62v*g_dtmo*@i62k)qn=cs'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',
#     'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware'
    # 'debug_toolbar.middleware.DebugToolbarMiddleware',
)

ROOT_URLCONF = 'pathagar.urls'

INTERNAL_IPS = ('127.0.0.1',)

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    '/home/jim/olpc/pathagar/pathagar/templates'
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    # 'debug_toolbar',
    'pathagar.books'
)


DEBUG_TOOLBAR_PANELS = (
    'debug_toolbar.panels.version.VersionDebugPanel',
    'debug_toolbar.panels.timer.TimerDebugPanel',
    'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
    'debug_toolbar.panels.headers.HeaderDebugPanel',
    'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
    'debug_toolbar.panels.template.TemplateDebugPanel',
    'debug_toolbar.panels.sql.SQLDebugPanel',
    'debug_toolbar.panels.signals.SignalDebugPanel',
    'debug_toolbar.panels.logger.LoggingPanel',
)

The reason for modifying most of these lines should be apparent, except for the ones involving debugging.  In Python lines that begin with '#' are comments, and you can remove a line of code from a program by making it a comment.  The developers of Pathagar use a Python package called debug_toolbar for debugging purposes.  This package is not included with every Linux distribution, and if you aren't intending to debug the code there is no need to have it.  Comment out the lines as I have shown and you'll be fine without debug_toolbar.

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 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 sever does not run by itself.   Instead it runs under the Apache web server using mod_wsgi.  You can set up Pathagar to run that way using instructions found here:

http://docs.djangoproject.com/en/1.2/howto/deployment/modwsgi/#howto-deployment-modwsgi

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.