Merge branch 'master' into gutenberg2

gut2-dev
eric 2019-09-09 13:01:45 -04:00
commit 46a00bf461
9 changed files with 21 additions and 55 deletions

View File

@ -464,13 +464,7 @@ class OpenSearch (object):
if self.protocol not in VALID_PROTOCOLS:
self.protocol = 'https'
self.urlgen = routes.URLGenerator (
cherrypy.routes_mapper,
{
'HTTP_HOST': self.host,
'HTTPS': 1 ,
}
)
self.urlgen = routes.URLGenerator ( cherrypy.routes_mapper, {'HTTP_HOST': self.host})
self.set_format (k.get ('format'))
@ -617,13 +611,13 @@ class OpenSearch (object):
self.mobile_search = self.url ('search', format = 'mobile')
self.json_search = self.url ('suggest', format = None)
self.base_url = self.protocol_relative (self.url (host = self.host))
self.base_url = self.url (host = self.file_host)
# for google, fb etc.
self.canonical_url = self.url_carry (host = self.file_host, format = None)
self.desktop_url = self.protocol_relative (self.url_carry (host = self.desktop_host, format = None))
self.mobile_url = self.protocol_relative (self.url_carry (host = self.mobile_host, format = 'mobile'))
self.desktop_url = self.url_carry (host = self.desktop_host, format = None)
self.mobile_url = self.url_carry (host = self.mobile_host, format = 'mobile')
self.osd_url = self.qualify ('/catalog/osd-books.xml')
@ -696,14 +690,6 @@ class OpenSearch (object):
return urllib.parse.urljoin (self.base_url, url)
def protocol_relative (self, url):
""" Make absolute url protocol relative. """
offset = url.find ('//')
if offset > -1:
return url[offset:]
return url
def set_format (self, format_):
""" Sanity check and set the parameter we got from the user.
Calc format and mediatype to send to the client. """
@ -939,9 +925,7 @@ class OpenSearch (object):
def format_thumb_url (self, row):
""" Generate the thumb url in results. """
if row.coverpages:
return urllib.parse.urljoin ('//' + self.file_host, row.coverpages[0])
# return self.url ('bibrec', host = self.file_host, id = row.pk,
# format = 'cover.small')
return row.coverpages[0]
return None
def format_icon (self, dummy_row):

View File

@ -57,7 +57,7 @@ class BibrecPage (Page.Page):
dc.icon = 'audiobook'
os.title_icon = dc.icon
os.twit = os.title
os.qrcode_url = '//%s/cache/epub/%d/pg%d.qrcode.png' % (os.file_host, os.id, os.id)
os.qrcode_url = '/cache/epub/%d/pg%d.qrcode.png' % (os.id, os.id)
os.entries.append (dc)

View File

@ -32,10 +32,10 @@ from i18n_tool import ugettext as _
NO_DESKTOP_FILETYPES = 'plucker qioo rdf rst rst.gen rst.master tei cover.medium cover.small'.split ()
# filetypes shown on mobile site
MOBILE_TYPES = (mt.epub, mt.plucker, mt.mobi, mt.pdf, 'text/html', mt.html, mt.qioo)
MOBILE_TYPES = (mt.epub, mt.mobi, mt.pdf, 'text/html', mt.html)
# filetypes which are usually handed over to a separate app on mobile devices
HANDOVER_TYPES = (mt.epub, mt.plucker, mt.mobi, mt.pdf, mt.qioo)
HANDOVER_TYPES = (mt.epub, mt.mobi, mt.pdf)
# self-contained files we can send to dropbox
CLOUD_TYPES = (mt.epub, mt.mobi, mt.pdf)
@ -58,6 +58,7 @@ class XMLishFormatter (BaseFormatter.BaseFormatter):
super (XMLishFormatter, self).fix_dc (dc, os)
# generated_files always [] AFAICT -esh
for file_ in dc.generated_files:
file_.help_topic = file_.hr_filetype
file_.compression = 'none'
@ -74,9 +75,12 @@ class XMLishFormatter (BaseFormatter.BaseFormatter):
file_.msdrive_url = os.url (
'msdrive_send', id = dc.project_gutenberg_id, filetype = file_.filetype)
if m in HANDOVER_TYPES:
file_.url = file_.url + '?' + urllib.parse.urlencode (
{ 'session_id': str (cherrypy.session.id) } )
# these are used as relative links
if file_.generated and not file_.filetype.startswith ('cover.'):
file_.filename = "ebooks/%d.%s" % (file_.id, file_.filetype)
if m in HANDOVER_TYPES:
file_.filename = file_.filename + '?' + urllib.parse.urlencode (
{ 'session_id': str (cherrypy.session.id) } )
for file_ in dc.files:
file_.honeypot_url = os.url (
@ -208,7 +212,7 @@ class MobileFormatter (XMLishFormatter):
cat.extra = file_.hr_extent
cat.charset = file_.encoding
cat.url = file_.url
cat.url = '/' + file_.filename
cat.icon = dc.icon
cat.icon2 = 'download'
cat.class_ += 'filelink'

View File

@ -60,7 +60,6 @@ THUMBS = {
'gdrive' : 'pics/gdrive-24x21.png',
'msdrive' : 'pics/msdrive-24x24.png',
'twitter' : 'pics/twitter_whiteonblue-20x20.png',
'gplus' : 'pics/gplus-20x20.png',
# 'hosted' : 'pics/ibiblio-hosted-110x32.png',
# 'apache' : 'pics/apache-powered-118x41.gif',

0
diagnostics.py Executable file → Normal file
View File

0
errors.py Executable file → Normal file
View File

View File

@ -117,9 +117,6 @@ Gutenberg metadata much faster than by scraping.
os.description.encode ('utf-8'), os.cover_thumb_url)}
</li>
-->
<li>
${gplus_share (os.canonical_url)}
</li>
<li>
${tw_share (os.canonical_url, os.twit)}
</li>
@ -323,7 +320,7 @@ Gutenberg metadata much faster than by scraping.
<td><span class="icon icon_${e.icon}" /></td>
<td property="dcterms:format" content="${file_.mediatypes[-1]}" datatype="dcterms:IMT"
class="unpadded icon_save"
><a href="${file_.url}" type="${file_.mediatypes[-1]}" charset="${file_.encoding}"
><a href="/${file_.filename}" type="${file_.mediatypes[-1]}" charset="${file_.encoding}"
class="link"
title="Download">${file_.hr_filetype}</a></td>
<td class="noscreen">${file_.url}</td>
@ -355,7 +352,7 @@ Gutenberg metadata much faster than by scraping.
<td><span class="icon icon_folder" /></td>
<td class="unpadded icon_file"><a href="${e.base_dir}" class="link"
i18n:comment="Link to the directory containing all files.">More Files…</a></td>
<td class="noscreen">https:${os.qualify (e.base_dir)}</td>
<td class="noscreen">${os.qualify (e.base_dir)}</td>
<td/>
<td class="noprint"><!--! dropbox column --></td>
<td class="noprint"><!--! gdrive column --></td>

View File

@ -110,7 +110,7 @@
<py:def function="copyright">
<div class="copyright" i18n:comment="The copyright notice on the footer of every page.">
© 20032012 Project Gutenberg Literary Archive Foundation — All Rights Reserved.
© 20032019 Project Gutenberg Literary Archive Foundation — All Rights Reserved.
</div>
</py:def>
@ -118,7 +118,7 @@
<div id="fb-root" />
<div id="print-head" class="noscreen">
<div class="center">https:${os.desktop_url}<br/><br/>${os.tagline}</div>
<div class="center">${os.desktop_url}<br/><br/>${os.tagline}</div>
</div>
<div id="screen-head" class="noprint">
@ -244,7 +244,7 @@
<input xml:lang="en" type="hidden" name="cmd" value="_s-xclick" />
<input xml:lang="en" type="hidden" name="hosted_button_id" value="XKAL6BZL3YPSN" />
<input type="image" name="submit"
src="//${cherrypy.config['file_host']}/pics/paypal/${os.paypal_lang}.gif"
src="/pics/paypal/${os.paypal_lang}.gif"
title="Send us money through PayPal." />
</div>
</form>

View File

@ -37,24 +37,6 @@
</py:def>
<py:def function="gplus_share(url)">
<!-- share without javascript -->
<?python
params = {
'url': url,
}
?>
<div class="social-button gplus-share-button">
<!--! https://developers.google.com/+/web/share/#sharelink -->
<a href="https://plus.google.com/share?${p (params)}"
title="Share on Google+"
onclick="open_share_popup(this.href, this.target, 640, 320)"
target="_gplus_share_popup">
<span class="icon icon_gplus" />
</a>
</div>
</py:def>
<py:def function="tw_share(url, text)">
<!-- tweet without javascript -->