add github and wikibooks to allowed ebook sources
parent
db969f859d
commit
7e1c5eeec9
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<h2>Add an eBook for this Edition:</h2>
|
||||
|
||||
<span>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.</span>
|
||||
<span>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.</span>
|
||||
|
||||
<form method="POST" action="#add_ebook">
|
||||
{% 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 }}
|
||||
|
|
Loading…
Reference in New Issue