We're no longer using this. We're instead using the ruby version of this project, here: https://github.com/lbcclib/newbooks
This set of python code reads in data from Evergreen ILS, creates a Web site featuring recently purchased books, and sends emails notifying folks on campus when books in their disciplines arrive.
Here's how to get this running for yourself:
- Make sure that Python 2.7.x is running on your computer
- Install the correct libraries.
pip install email lxml pyyaml
- Move the
publicdirectory to a directory that might be served up by a web server.
- Correctly configure all the YAML files in the
confdirectorycover_images.ymlwill probably need no changesemail.ymlis set up to be friendly to gmail addresses. It might take some development to support cases in which a user's SMTP username is different than the user's email addressemail.ymlalso includes a setting calledlink. This will provide a link in the email to an HTML document in your public directory. Change it to whatever URL will take folks to yourpublicdirectory.evergreen.ymlis an important file to change.num_items_to_fetchwill depend on how often you add new items to your system, and how often you plan to send out emails (it's best not to have too much repitition, but you also don't want to miss out on items that might be of interest to folks).shelving_locationshould be the shelving location the database ID of the shelving location your patrons are interested in (e.g. Adult Nonfiction might be represented by the number 143).opac_hostmust be a valid hostname from somewhere in your consortium. And theorg_unitis your org unit's shortname (e.g. ABCLIB).output.ymlincludes a setting calledjson_output_path, which is where the script will generate a JSON file containing the new books. This path needs to be somewhere within yourpublicdirectory, and also in a directory where the user you'll run the script as has write permissions. By default, the HTML file looks for a JSON file in the same folder with the namenewbooks.json, so the easiest configuration is to set this value to/path/to/public/directory/newbooks.json.departments.ymllists all the departments, what call number ranges they like, and what email addresses are included. At minimum, you should add the correct email addresses todepartments.yml. If multiple people will receive one notification, you can just add them as separate members of an array. Your institution almost certainly has different departments and interests than ours does, so you will also probably have to modify existing or create new regular expressions.
- You may wish to send books to certain folks based on some characteristic other than call number ranges. To do this:
- Add some code to the
__init__method in theBookclass to make sure that all Book objects contain enough data to identify them. - Using the
SpanishInterestGroupclass as an example, add an inherited class todepartment.py. - Add the name of your new inherited class to the appropriate
importstatement infaculty_notifications.py - Also in
faculty_notifications.py, append an object of your new class to thedepartmentslist.
- Add some code to the
cdto the directory that containsfaculty_notifications.py- Run
python faculty_notifications.py
- Sign in to GitHub.
- Click "Fork" to make your own working copy of the repo.
- Follow the installation instructions.
- Make your changes.
- Submit a pull request to get your changes incorporated. This sounds complicated, but it's actually pretty simple:
- Go to your forked repository.
- Click the pull requests tab
- Click New Pull Request.
- Verify your changes, then click "Create pull request".