From 7e1c5eeec91c29087080cb09fd31c7166b61db4a Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 17 Nov 2014 11:51:36 -0500 Subject: [PATCH] add github and wikibooks to allowed ebook sources --- core/models.py | 8 ++++++-- frontend/forms.py | 2 +- frontend/templates/edition_upload.html | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/models.py b/core/models.py index 5fa698dc..f7d81494 100755 --- a/core/models.py +++ b/core/models.py @@ -1822,7 +1822,7 @@ class Ebook(models.Model): if not url: return None # provider derived from url. returns provider value. remember to call save() afterward - if url.startswith('http://books.google.com/'): + if url.startswith('https?://books.google.com/'): provider='Google Books' elif url.startswith('http://www.gutenberg.org/'): provider='Project Gutenberg' @@ -1830,8 +1830,12 @@ class Ebook(models.Model): provider='Internet Archive' elif url.startswith('http://hdl.handle.net/2027/') or url.startswith('http://babel.hathitrust.org/'): provider='Hathitrust' - elif re.match('http://\w\w\.wikisource\.org/', url): + elif re.match('https?://\w\w\.wikisource\.org/', url): provider='Wikisource' + elif re.match('https?://\w\w\.wikibooks\.org/', url): + provider='Wikibooks' + elif re.match('https://github\.com/\w+/\w+/raw/\w+', url): + provider='Github' else: provider=None return provider diff --git a/frontend/forms.py b/frontend/forms.py index 6ae57cda..f1f76dea 100644 --- a/frontend/forms.py +++ b/frontend/forms.py @@ -223,7 +223,7 @@ class EbookForm(forms.ModelForm): def clean_provider(self): new_provider= Ebook.infer_provider(self.data[self.prefix + '-url']) if not new_provider: - raise forms.ValidationError(_("At this time, ebook URLs must point at Internet Archive, Wikisources, Hathitrust, Project Gutenberg, or Google Books.")) + raise forms.ValidationError(_("At this time, ebook URLs must point at Internet Archive, Wikisources, Wikibooks, Hathitrust, Project Gutenberg, raw files at Github, or Google Books.")) return new_provider def clean_url(self): diff --git a/frontend/templates/edition_upload.html b/frontend/templates/edition_upload.html index 5aef6bf1..9695afd7 100644 --- a/frontend/templates/edition_upload.html +++ b/frontend/templates/edition_upload.html @@ -13,7 +13,7 @@

Add an eBook for this Edition:

- If you know that this edition is available as a public domain or Creative Commons ebook, you can enter the link here and "unglue" it. Right now, we're only accepting URLs that point to Internet Archive, Wikisources, Hathitrust, Project Gutenberg, or Google Books. + If you know that this edition is available as a public domain or Creative Commons ebook, you can enter the link here and "unglue" it. Right now, we're only accepting URLs that point to Internet Archive, Wikisources, Wikibooks, Hathitrust, Project Gutenberg, raw files at Github, or Google Books.
{% csrf_token %}{{ edition.ebook_form.edition.errors }}{{ edition.ebook_form.edition }}{{ edition.ebook_form.user.errors }}{{ edition.ebook_form.user }}{{ edition.ebook_form.provider.errors }}{{ edition.ebook_form.provider }}