Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def link(href, label, img, alt=None):
return HTML.li(
HTML.a(
HTML.img(
src=req.static_url('glottolog3:static/' + img),
height="20",
width="20",
alt=alt or label),
' ',
label,
href=href,
target = "_blank",
title=label,
)
def img(spec):
return HTML.img(
src=svg.data_url(svg.icon(spec)), height='20', width='20', style='margin-left: 0.5em;')
f['geometry']['coordinates'][0] = f['geometry']['coordinates'][0] - 360
return geojson
geojson = requests.get(url + '.geojson').json()
id_ = '-'.join([app, pid])
if geojson['properties']['domain'] and not geojson['features']:
for de in geojson['properties']['domain']:
yield Layer(
'-'.join([id_, de['id']]),
'%s: %s - %s' % (app, geojson['properties']['name'], de['name']),
normalize(
requests.get(url + '.geojson?domainelement=' + de['id']).json()),
size=size,
link=url,
marker=HTML.img(src=de['icon'], width=size, height=size))
else:
yield Layer(
id_,
'%s: %s' % (app, geojson['properties']['name']),
normalize(geojson),
size=size,
link=url,
domain=geojson['properties']['domain'])
def marker_img(src, **kw):
kw.setdefault('height', MARKER_IMG_DIM)
kw.setdefault('width', MARKER_IMG_DIM)
return HTML.img(src=src, **kw)
'by': 'Creative Commons Attribution License',
'by-nc': 'Creative Commons Attribution-NonCommercial License',
'by-nc-nd': 'Creative Commons Attribution-NonCommercial-NoDerivatives License',
'by-nc-sa': 'Creative Commons Attribution-NonCommercial-ShareAlike License',
'by-nd': 'Creative Commons Attribution-NoDerivatives License',
'by-sa': 'Creative Commons Attribution-ShareAlike License'}
if comps[2] not in known:
return
icon = 'cc-' + comps[2] + ('-small' if button == 'small' else '') + '.png'
img_attrs = dict(
alt=known[comps[2]],
src=req.static_url('clld:web/static/images/' + icon))
height, width = (15, 80) if button == 'small' else (30, 86)
img_attrs.update(height=height, width=width)
return HTML.a(HTML.img(**img_attrs), href=license_url, rel='license')
if de.languages:
yield Layer(
de.id,
de.name,
GeoJsonCombinationDomainElement(de).render(de, self.req, dump=False),
marker=HTML.img(src=de.icon.url(self.req), height='20', width='20'))
if self.ctx.multiple:
# yield another layer which can be used to mark languages with multiple
# values, because this may not be visible when markers are stacked on top
# of each other.
icon_url = self.req.registry.getUtility(IIcon, 'tff0000').url(self.req)
yield Layer(
'__multiple__',
'Languages with multiple values',
GeoJsonMultiple(None).render(self.ctx.multiple, self.req, dump=False),
marker=HTML.img(src=icon_url, height='20', width='20'))
def gbs_link(source, pages=None):
"""Format Google-Books information for source as HTML."""
if not source or not source.google_book_search_id or not source.jsondata.get('gbs'):
return ''
if source.jsondata['gbs']['accessInfo']['viewability'] in ['NO_PAGES']:
return ''
pg = 'PP1'
if pages:
match = re.search('(?P[0-9]+)', pages)
if match:
pg = 'PA' + match.group('startpage')
return HTML.a(
HTML.img(src="https://www.google.com/intl/en/googlebooks/images/"
"gbs_preview_button1.gif"),
href="https://books.google.com/books?id=%s&lpg=PP1&pg=%s" % (
source.google_book_search_id, pg)
)
def gbs_link(source, pages=None):
"""Format Google-Books information for source as HTML."""
if not source or not source.google_book_search_id or not source.jsondata.get('gbs'):
return ''
if source.jsondata['gbs']['accessInfo']['viewability'] in ['NO_PAGES']:
return ''
pg = 'PP1'
if pages:
match = re.search('(?P[0-9]+)', pages)
if match:
pg = 'PA' + match.group('startpage')
return HTML.a(
HTML.img(src="https://www.google.com/intl/en/googlebooks/images/"
"gbs_preview_button1.gif"),
href="http://books.google.com/books?id=%s&lpg=PP1&pg=%s" % (
source.google_book_search_id, pg)
)
def logo(req, width='20'):
return HTML.img(
src=req.static_url('clld:web/static/images/glottolog.png'),
width=width,
style="margin-top: -2px")