def get() -> Union[tuple[Resource, int], Response]: parser = language.parse_args() lang = parser['lang'] content = { 'intro': get_translation('intro_for_frontend', lang), 'contact': get_translation('contact_for_frontend', lang), 'siteName': get_translation('site_name_for_frontend', lang), 'imageSizes': app.config['IMAGE_SIZE'], 'legalNotice': get_translation('legal_notice_for_frontend', lang)} if parser['download']: return download(content, content_template(), 'content') return marshal(content, content_template()), 200
def display_content_translation(_context: str, text: str) -> str: return get_translation(text)
def display_citation_example(code: str) -> str: if code != 'reference': return '' if text := get_translation('citation_example'): return Markup(f'<h1>{uc_first(_("citation_example"))}</h1>{text}')
def overview() -> str: tabs = { 'info': Tab('info'), 'bookmarks': Tab('bookmarks', table=Table(['name', 'class', 'begin', 'end'])), 'notes': Tab('notes', table=Table( ['date', _('visibility'), 'entity', 'class', _('note')])) } tables = { 'overview': Table(paging=False, defs=[{ 'className': 'dt-body-right', 'targets': 1 }]), 'latest': Table(paging=False, order=[[0, 'desc']]) } if current_user.is_authenticated and hasattr(current_user, 'bookmarks'): for entity_id in current_user.bookmarks: entity = Entity.get_by_id(entity_id) tabs['bookmarks'].table.rows.append([ link(entity), entity.class_.label, entity.first, entity.last, bookmark_toggle(entity.id, True) ]) for note in User.get_notes_by_user_id(current_user.id): entity = Entity.get_by_id(note['entity_id']) tabs['notes'].table.rows.append([ format_date(note['created']), uc_first(_('public') if note['public'] else _('private')), link(entity), entity.class_.label, note['text'], f'<a href="{url_for("note_view", id_=note["id"])}">' f'{uc_first(_("view"))}</a>' ]) for name, count in Entity.get_overview_counts().items(): if count: url = url_for('index', view=g.class_view_mapping[name]) if name == 'administrative_unit': url = f"{url_for('node_index')}#menu-tab-places" elif name == 'type': url = url_for('node_index') elif name == 'find': url = url_for('index', view='artifact') elif name in [ 'feature', 'human_remains', 'stratigraphic_unit', 'source_translation' ]: url = '' tables['overview'].rows.append([ link(g.classes[name].label, url) if url else g.classes[name].label, format_number(count) ]) for entity in Entity.get_latest(8): tables['latest'].rows.append([ format_date(entity.created), link(entity), entity.class_.label, entity.first, entity.last, link(logger.get_log_for_advanced_view(entity.id)['creator']) ]) tabs['info'].content = render_template('index/index.html', intro=get_translation('intro'), tables=tables) return render_template('tabs.html', tabs=tabs, crumbs=['overview'])
def index_content(item: str) -> str: return render_template('index/content.html', text=get_translation(item), title=_(_(item)), crumbs=[_(item)])