This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am jamesoutterside on github. | |
* I am jamesoutterside (https://keybase.io/jamesoutterside) on keybase. | |
* I have a public key ASBoFVr9GglrK_KJFobXH_LcrZW40NO9FwhYkqArlL5bpQo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_for_mashup(request, mashups, filename): | |
""" | |
request - django request object | |
mashup - dict of items to mash from dlms, containin django content_type, title and link | |
filename - output name | |
""" | |
book = django_epub.EpubBook() | |
book.setTitle('Dynamic Learning Maps - Resource Mashup') | |
book.addCreator('Dynamic Learning Maps - https://learning-maps.ncl.ac.uk/') | |
book.addMeta('date', datetime.datetime.now(), event = 'publication') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zipfile | |
def get_epub_info(fname): | |
zip = zipfile.ZipFile(fname) | |
# find the contents metafile | |
txt = zip.read('META-INF/container.xml') | |
tree = etree.fromstring(txt) | |
cfname = tree.xpath('n:rootfiles/n:rootfile/@full-path',namespaces=NS)[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stanp a license bar at the bottom of an image | |
from PIL import Image, ImageFont, ImageDraw | |
import settings | |
def stamp_image(in_filepath, out_filepath,text): | |
im = Image.open(in_filepath) | |
# get size | |
original_size = im.size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sample structure of saving resources from a Learning registry node. | |
# The original code was developed for the RIDLR project using django, | |
# the code below has had all references of django removed so it will run as | |
# a standalone python script. | |
# The removed code saved/updated the resource dictonary in a database, in this case DC_MAP was used | |
# to map db fields to dublin core fields | |
# requires http://pypi.python.org/pypi/BeautifulSoup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
############################ | |
# | |
# bare bones script to upload a dict of resources to oerbookmarking.ncl.ac.uk | |
# | |
# http://oerbookmarking.ncl.ac.uk/api/ | |
# | |
# Developer = [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to export DLMs oai resources to an LR node. | |
import urllib2 | |
import json | |
import settings | |
from oaipmh.client import Client | |
from oaipmh.metadata import MetadataRegistry, oai_dc_reader | |
DEBUG = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
import json as simplejson | |
BOOKMARKING_BASE_CONFIG = {'base_url':'http://oerbookmarking.ncl.ac.uk', | |
'api_key':'{{OER_BOOKMARKING_API_KEY}}', | |
'api_username':'{{OER_BOOKMARKING_API_USERNAME}}', | |
'api_format':'json', | |
'bookmark_path':'/api/v1/bookmark/' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2012, Bin Tan | |
# This file is distributed under the BSD Licence. See python-epub-builder-license.txt for details. | |
# James Outterside - Modified code from http://code.google.com/p/python-epub-builder/source/browse/trunk/epub.py to use | |
# use django templates instead of genshi | |
import itertools | |
import mimetypes | |
import os | |
import shutil |