parent
a1af1bcf04
commit
2d2698598c
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
@ -78,6 +79,13 @@ class XMLishFormatter (BaseFormatter.BaseFormatter):
|
|||
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 (
|
||||
'honeypot_send', id = dc.project_gutenberg_id, filetype = file_.filetype)
|
||||
|
|
|
@ -320,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>
|
||||
|
@ -352,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">e.base_dir</td>
|
||||
<td/>
|
||||
<td class="noprint"><!--! dropbox column --></td>
|
||||
<td class="noprint"><!--! gdrive column --></td>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue