diff --git a/glottolog3/templates/source/detail_html.mako b/glottolog3/templates/source/detail_html.mako index 8ea5beb..a36bf02 100644 --- a/glottolog3/templates/source/detail_html.mako +++ b/glottolog3/templates/source/detail_html.mako @@ -1,98 +1,121 @@ <%inherit file="../${context.get('request').registry.settings.get('clld.app_template', 'app.mako')}"/> <%namespace name="util" file="../util.mako"/> <%! active_menu_item = "sources" %> +<%! multirow = True %> <%! from itertools import groupby %> + <%block name="title">${ctx.name} -

${ctx.name} ${h.contactmail(req, ctx, title='report a problem')}

-## +
+
+ +

${ctx.name} ${h.contactmail(req, ctx, title='report a problem')}

+ ## ${ctx.coins(request)|n} -% if ctx.jsondata.get('thanks'): -
- This record was contributed by ${ctx.jsondata['thanks']}. -
-% endif + % if ctx.jsondata.get('thanks'): +
+ This record was contributed by ${ctx.jsondata['thanks']}. +
+ % endif -
- -
- <% bibrec = ctx.bibtex() %> -
-

${bibrec.text()}

- % if ctx.datadict().get('Additional_information'): -

- ${ctx.datadict().get('Additional_information')} -

- % endif -
    - % if ctx.author == 'ISO 639-3 Registration Authority': -
  • ${u.format_external_link_in_label(ctx.howpublished, 'ISO 639-3')}
  • - % endif - % if ctx.url: -
  • ${u.format_external_link_in_label(ctx.url)}
  • - % elif ctx.jsondata.get('doi'): -
  • ${u.format_external_link_in_label('http://dx.doi.org/%s' % ctx.jsondata['doi'], 'DOI')}
  • - % endif - % if ctx.gbid: -
  • ${u.format_external_link_in_label('https://books.google.com/books?id=%s' % ctx.gbid.split('id=')[-1], label='Google Books')}
  • - % endif - <% oclc = ctx.jsondata.get('oclc') %> - % if oclc: -
  • ${u.format_external_link_in_label('http://www.worldcat.org/oclc/{0}'.format(oclc), 'WorldCat')}
  • - % endif - ##<% isbn = ctx.jsondata.get('isbn') %> +
    + +
    + <% bibrec = ctx.bibtex() %> +
    +

    ${bibrec.text()}

    + % if ctx.datadict().get('Additional_information'): +

    + ${ctx.datadict().get('Additional_information')} +

    + % endif +
      + % if ctx.author == 'ISO 639-3 Registration Authority': +
    • ${u.format_external_link_in_label(ctx.howpublished, 'ISO 639-3')}
    • + % endif + % if ctx.url: +
    • ${u.format_external_link_in_label(ctx.url)}
    • + % elif ctx.jsondata.get('doi'): +
    • ${u.format_external_link_in_label('http://dx.doi.org/%s' % ctx.jsondata['doi'], 'DOI')}
    • + % endif + % if ctx.gbid: +
    • ${u.format_external_link_in_label('https://books.google.com/books?id=%s' % ctx.gbid.split('id=')[-1], label='Google Books')}
    • + % endif + <% oclc = ctx.jsondata.get('oclc') %> + % if oclc: +
    • ${u.format_external_link_in_label('http://www.worldcat.org/oclc/{0}'.format(oclc), 'WorldCat')}
    • + % endif + ##<% isbn = ctx.jsondata.get('isbn') %> ##% if isbn: ## ${util.gbs_links(['ISBN:{0}'.format(isbn)])} ##% endif
    - % if ctx.iaid: -
    - - % endif -
    -
    ${bibrec}
    + % if ctx.iaid: +
    + + % endif +
    +
    +
    ${bibrec}
    +
    +
    +
-
-<%def name="sidebar()"> -% if ctx.doctypes: -<%util:well> -

Document types${u.format_ca_icon(req, ctx, 'doctype')}

- - -% endif -% if ctx.languages: -<%util:well> - ${u.format_language_header(request, ctx, level=3)} - - -% endif -<%util:well> -

Providers

- - - +
+ + % if ctx.doctypes: + <%util:well> +

Document types${u.format_ca_icon(req, ctx, 'doctype')}

+
    + % for dt in ctx.doctypes: +
  • + ${u.format_label_link(request.route_url('home.glossary', _anchor='doctype-' + dt.id), dt.name.capitalize().replace('_', ' '), title=dt.description)} +
  • + % endfor +
+ + % endif + % if ctx.languages: + <%util:well> + ${u.format_language_header(request, ctx, level=3)} + + + + + + + + + % for names, links in u.format_languages(request, ctx): + + + + + % endfor + + +
Name in sourceGlottolog languoid
${names}${links}
+ + % endif + <%util:well> +

Providers

+
    + % for p, keys in groupby(ctx.bibkeys, lambda bk: bk.provider): +
    +
    ${h.link(request, p)}
    + % for k in keys: +
    ${k.id}
    + % endfor +
    + % endfor +
+ +
+
diff --git a/glottolog3/templates/source/snippet_html.mako b/glottolog3/templates/source/snippet_html.mako index 1d9508b..b05af47 100644 --- a/glottolog3/templates/source/snippet_html.mako +++ b/glottolog3/templates/source/snippet_html.mako @@ -20,9 +20,21 @@ $(document).ready(function() { % if ctx.languages: ${u.format_language_header(request, ctx, level=4)} - + + + + + + + + + % for names, links in u.format_languages(request, ctx): + + + + + % endfor + + +
Name in sourceGlottolog languoid
${names}${links}
% endif diff --git a/glottolog3/util.py b/glottolog3/util.py index 8e13002..558cc01 100644 --- a/glottolog3/util.py +++ b/glottolog3/util.py @@ -289,30 +289,26 @@ def format_languages(req, ref): ldict = {l.hid: l for l in ref.languages} ldict.update({l.id: l for l in ref.languages}) in_note = set() - lnotes = map(normalize_language_explanation, (ref.jsondata.get('lgcode', '')).split('],')) + lnotes = map(normalize_language_explanation, (ref.jsondata.get('lgcode', '')).split(',')) for lnote in lnotes: - note = [] + note, links = [], [] start = 0 m = None for m in LANG_PATTERN.finditer(lnote): note.append(lnote[start:m.start()]) - note.append('[') if m.group('id') in ldict: in_note.add(m.group('id')) lang = ldict[m.group('id')] - note.append(link(req, lang, label=lang.id, title=lang.name)) + links.append(link(req, lang, label=lang.name, title=lang.id)) else: - note.append(m.group('id')) - note.append(']') + note.extend(['[', m.group('id'), ']']) start = m.end() - if m: - note.append(lnote[m.end():]) - yield HTML.li(*note) + note.append(lnote[m.end():] if m else lnote) + yield ''.join(note), HTML.ul(*[HTML.li(li) for li in links], **dict(class_="inline")) for lang in set(ldict.values()): if (lang.hid not in in_note) and (lang.id not in in_note): - yield HTML.li( - lang.name + ' [', link(req, lang, label=lang.id, title=lang.name), ']') + yield '', link(req, lang, label=lang.name, title=lang.id) def format_label_link(href, label, title=None):