[%- USE u = Utils -%] [%- USE JavaScript -%] [%- PROCESS 'components/rating-macros.tt' -%] [%-# This next could use localization for alternating comma/period use per locale -%] [%~ MACRO add_commas(n) GET n.chunk(-3).join(',') -%] [%~ MACRO replace(text, search, replace) BLOCK; text | replace(search, replace); END -%] [%~ MACRO url_escape(url) BLOCK; url | url; END -%] [%~ MACRO html_escape(url) BLOCK; url | html; END -%] [%~ MACRO bracketed(text) BLOCK; l(' ({text})', { text => text }); END -%] [%~ MACRO js_escape(text) BLOCK; text | js; END ~%] [%~ MACRO display_url(url) BLOCK; PROCESS _unescaped_display_url | html; END -%] [%~ BLOCK _unescaped_display_url; IF url.pretty_name; url.pretty_name; ELSE; url | uri_decode; END; END -%] [%- USE UserDate(c.user.preferences, current_language) -%] [%- USE Countdown -%] [%~ MACRO doc_link(to) BLOCK -%][% c.uri_for('/doc', to) %][%- END -%] [%~ MACRO va_doc_link BLOCK -%] [%- doc_link('Style/Unknown_and_untitled/Special_purpose_artist#List_of_official_SPAs') -%] [%- END -%] [%~ MACRO yesno(b) BLOCK; b ? l('Yes') : l('No'); END ~%] [%~ MACRO isolate_text(text) BLOCK; INCLUDE _wrap_text options=['isolate', 'escape'] content=text; END ~%] [%~ MACRO wiki_history_link(server, id, version) BLOCK -%] //[%- server -%]/[%- id -%]?oldid=[%- version -%] [%- END -%] [%- USE Translation('mb_server') -%] [%~ MACRO l(text, args) BLOCK; Translation.l(text, args); END; -%] [%~ MACRO lp(text, context, args) BLOCK; Translation.lp(text, context, args); END; -%] [%#- There is a bug in this implementation fo ngettext that is easier to fix by policy that's why it's not fixed yet. The problem surfaces when an unfinished translation file is used, in this case a plural translation would apply language-specific plural construction rules to the untranslated english string. If a translation language has more than two plural forms, then the first plural form (germanic plural) is chosen for every form other than the first two. -%] [%~ MACRO ln(text, plural, num, args) BLOCK; Translation.ln(text, plural, num, args); END; -%] [%~ MACRO N_ln(text, plural) BLOCK; Translation.N_ln(text, plural); END; -%] [%~ MACRO display_age(age, person) BLOCK; IF person AND age.0; l('aged {num}', { num => age.0 }); ELSE; IF age.0; ln('{num} year', '{num} years', age.0, { num => age.0 }); ELSIF age.1; ln('{num} month', '{num} months', age.1, { num => age.1 }); ELSE; ln('{num} day', '{num} days', age.2, { num => age.2 }); END; END; END -%] [%~ MACRO display_age_ago(age) BLOCK; IF age.0; ln('{num} year ago', '{num} years ago', age.0, { num => age.0 }); ELSIF age.1; ln('{num} month ago', '{num} months ago', age.1, { num => age.1 }); ELSE; ln('{num} day ago', '{num} days ago', age.2, { num => age.2 }); END; END -%] [%~ MACRO artwork_hover(artwork) BLOCK -%] [%- IF artwork.l_types; comma_only_list(artwork.l_types) | html; END %][% IF artwork.comment %] ([% artwork.comment | html%])[% END -%] [%- END -%] [%- USE JavaScript -%] [%~ MACRO display_artwork_image(artwork, fallback, message) BLOCK -%] [% END %] [%~ MACRO display_artwork(artwork, fallback, message, rel) BLOCK -%] [%~ IF artwork.mime_type == "application/pdf" ~%]
[% l("PDF file") %]
[%~ END ~%] [% display_artwork_image(artwork, fallback, message) %]
[%- END -%] [%~ MACRO cover_art_links(artwork) BLOCK -%] [% IF artwork.small_thumbnail %][% l('250px') %] |[% END %] [% IF artwork.large_thumbnail %][% l('500px') %] |[% END %] [% l('original') %] [%- END -%] [%~ MACRO cover_art_url(url) BLOCK; IF c.req.secure; url | coverart_https; ELSE; url; END; END -%] [%~ MACRO comma_list(items) BLOCK -%] [% IF items.size == 1 %] [% items.0 %] [% ELSE %] [%- output = l('{almost_last_list_item} and {last_list_item}', {last_list_item => items.last, almost_last_list_item => items.reverse.slice(1).first}) -%] [%- FOREACH item IN items.reverse.slice(2) -%] [%- output = l('{list_item}, {rest}', {list_item => item, rest => output}) -%] [%- END -%] [%- output -%] [% END %] [%- END -%] [%~ MACRO comma_only_list(items) BLOCK -%] [%- output = l('{last_list_item}', {last_list_item => items.last}) -%] [%- FOREACH item IN items.reverse.slice(1) -%] [%- output = l('{commas_only_list_item}, {rest}', {commas_only_list_item => item, rest => output}) -%] [%- END -%] [%- output -%] [%- END -%] [%-# Take type and return pluralized word form, avoids problems with '|% type %|s' #-%] [%~ MACRO get_plural_type(entity) SWITCH entity; CASE 'release'; l('releases'); CASE 'artist'; l('artists'); CASE 'area'; l('areas'); CASE 'event'; l('events'); CASE 'instrument'; l('instruments'); CASE 'label'; l('labels'); CASE 'place'; l('places'); CASE 'track'; l('tracks'); CASE 'recording'; l('recordings'); CASE 'release_group'; l('release groups'); CASE 'series'; lp('series', 'plural'); CASE 'editor'; l('editors'); CASE 'work'; l('works'); CASE 'url'; l('URLs'); CASE DEFAULT; l('Error: Unknown Type'); END -%] [%~ MACRO disambiguation(entity) BLOCK -%] [%- IF entity.isa('MusicBrainz::Server::Entity::Event') -%] [%- cancelled(entity) -%] [%- END -%] [%- IF entity.comment -%] [%- ' (' _ html_escape("${entity.comment}") _ ')' -%] [%- END -%] [%- IF entity.isa('MusicBrainz::Server::Entity::Area') -%] [%- historical(entity) -%] [%- END -%] [%- END -%] [%~ MACRO historical(entity) BLOCK -%] [%- IF entity.ended -%] ( [%- IF entity.begin_date.has_year && entity.end_date.has_year -%] [%- l("historical, {begin}-{end}", { begin => entity.begin_date.year, end => entity.end_date.year }) -%] [%- ELSIF entity.end_date.has_year -%] [%- l("historical, until {end}", { end => entity.end_date.year }) -%] [%- ELSE -%] [%- l("historical") -%] [%- END -%] [%- -%]) [%- END -%] [%- END -%] [%~ MACRO cancelled(entity) BLOCK -%] [%- IF entity.cancelled -%] ( [%~ l("cancelled") ~%] ) [%- END -%] [%- END -%] [%~ MACRO artist_credit(ac, opts) BLOCK -%] [%- FOREACH name IN ac.names -%] [%- IF name.artist.gid && !opts.plain -%] [%- link_artist(name.artist, 'show', name.name) -%] [%- ELSE -%] [%- name.name | html -%] [%- END -%] [%- name.join_phrase | html -%] [%- END -%] [%- END -%] [%~ MACRO expanded_artist_credit(ac) IF ac -%] [%- artist_credit(ac) -%]
[%- IF ac.name != ac.names.0.artist.name || ac.names.size > 1 || ac.names.0.artist.comment -%] [%- SET artist_list = []; SET show_list = 0; FOR name=ac.names; IF name.artist.name != name.name; artist_list.push(l('{artist} as {name}', { artist => descriptive_link(name.artist), name => name.name})); SET show_list = 1; ELSE; artist_list.push(descriptive_link(name.artist)); IF name.artist.comment; SET show_list = 1; END; END; END; -%] [%- IF show_list -%][%- comma_only_list(artist_list) -%][%- END -%] [% END %] [%- END -%] [%~ MACRO entity_exists(entity) BLOCK; entity.gid.defined; END -%] [%~ MACRO link_entity(entity, action, text) BLOCK; IF entity.gid; IF entity.isa('MusicBrainz::Server::Entity::Artist'); link_artist(entity, action, text); ELSIF entity.isa('MusicBrainz::Server::Entity::Area'); link_area(entity, action, text); ELSIF entity.isa('MusicBrainz::Server::Entity::Collection'); link_collection(entity, action, text); ELSIF entity.isa('MusicBrainz::Server::Entity::Work'); link_work(entity, action, text); ELSIF entity.isa('MusicBrainz::Server::Entity::Event'); link_event(entity, action, text); ELSIF entity.isa('MusicBrainz::Server::Entity::Instrument'); link_instrument(entity, action, text); ELSIF entity.isa('MusicBrainz::Server::Entity::Label'); link_label(entity, action, text); ELSIF entity.isa('MusicBrainz::Server::Entity::Place'); link_place(entity, action, text); ELSIF entity.isa('MusicBrainz::Server::Entity::Release'); link_release(entity, action, text); ELSIF entity.isa('MusicBrainz::Server::Entity::ReleaseGroup'); link_release_group(entity, action, text); ELSIF entity.isa('MusicBrainz::Server::Entity::Recording'); link_recording(entity, action, text); ELSIF entity.isa('MusicBrainz::Server::Entity::Series'); link_series(entity, action, text); ELSIF entity.isa('MusicBrainz::Server::Entity::URL'); link_url(entity, action, text); END; ELSIF entity.isa('MusicBrainz::Server::Entity::URL'); simple_link(url_escape(entity.url), display_url(entity.url)); ' '; link_deleted(undef, '[' _ l('info') _ ']'); ELSIF entity.isa('MusicBrainz::Server::Entity::Editor'); link_editor(entity, action, text); ELSE; link_deleted(entity, text); END; disambiguation(entity) IF text == ''; END -%] [%~ MACRO link_deleted(entity, text) BLOCK; caption = allow_new ? l("This entity will be created when edits are entered.") : l("This entity has been removed, and cannot be displayed correctly."); '' _ (html_escape(entity.name) || text || l('[removed]')) _ ''; END; -%] [%~ MACRO descriptive_link(entity) IF entity.artist_credit.defined; l('{entity} by {artist}', { entity => link_entity(entity), artist => artist_credit(entity.artist_credit) }); ELSIF get_entity_type(entity) == 'place' && entity.area.defined; l('{place} in {area}', { place => link_entity(entity), area => link_area_with_containment(entity.area) }); ELSIF get_entity_type(entity) == 'area' && entity.gid; link_area_with_containment(entity); ELSE; link_entity(entity); END; -%] [%~ MACRO get_entity_type(entity) BLOCK; IF entity.isa('MusicBrainz::Server::Entity::Artist'); "artist"; ELSIF entity.isa('MusicBrainz::Server::Entity::Area'); "area"; ELSIF entity.isa('MusicBrainz::Server::Entity::Collection'); "collection"; ELSIF entity.isa('MusicBrainz::Server::Entity::Work'); "work"; ELSIF entity.isa('MusicBrainz::Server::Entity::Event'); "event"; ELSIF entity.isa('MusicBrainz::Server::Entity::Instrument'); "instrument"; ELSIF entity.isa('MusicBrainz::Server::Entity::Label'); "label"; ELSIF entity.isa('MusicBrainz::Server::Entity::Place'); "place"; ELSIF entity.isa('MusicBrainz::Server::Entity::Release'); "release"; ELSIF entity.isa('MusicBrainz::Server::Entity::ReleaseGroup'); "release_group"; ELSIF entity.isa('MusicBrainz::Server::Entity::Recording'); "recording"; ELSIF entity.isa('MusicBrainz::Server::Entity::Series'); "series"; ELSIF entity.isa('MusicBrainz::Server::Entity::URL'); "url"; END; END -%] [%~ BLOCK _wrap_text; FOR option = options.reverse; content = SWITCH option; CASE 'isolate'; '' _ content _ ''; CASE 'escape'; html_escape(content); CASE 'link'; # add. parameter: link, hover SET hover = ' title="' _ hover _ '"' IF hover != ''; '' _ content _ ''; CASE 'code'; '' _ content _ ''; CASE 'edits_pending'; '' _ content _ ''; CASE 'name_variation'; '' _ content _ ''; CASE 'flagclass'; # add. parameter: flag '' _ content _ ''; CASE 'info_link'; # add. parameter: infolink content _ ' [' _ l('info') _ ']'; CASE 'show_dates'; dates ? content _ bracketed(dates) : content; CASE 'avatar'; # add. parameter: avatar '' _ content; END; END; content; END -%] [%~ BLOCK _link_mbid_entity; # parameters: content, entity, type, action, default_content, hover, namevar, noescape DEFAULT action = 'show'; link = c.uri_for_action('/' _ type _ '/' _ action, [ entity.gid ]); mod_content = content; options = ['link', 'isolate']; options.push('escape') UNLESS noescape; IF content == ''; mod_content = default_content.defined ? default_content : entity.name; END; IF namevar AND action == 'show' AND content != '' AND (noescape ? content.remove(']*>') : content) != entity.name; options.unshift('name_variation'); hover = hover != '' ? l('{name} – {additional_info}', { name => html_escape(entity.name), additional_info => hover }) : html_escape(entity.name); END; options.unshift('edits_pending') IF entity.edits_pending AND action == 'show'; IF action == 'show' AND entity.iso_3166_1.0; options.unshift('flagclass'); flag = entity.iso_3166_1.0; END; IF type == 'event' AND content == ''; options.unshift('show_dates'); dates = entity.formatted_date; END; IF type == 'url' AND content == ''; mod_content = INCLUDE _unescaped_display_url url=entity; options.unshift('info_link'); infolink = link; link = entity.href_url; END; INCLUDE _wrap_text options=options content=mod_content link=link hover=hover flag=flag infolink=infolink dates=dates; END -%] [%~ BLOCK _link_other_entity; # parameters: content, action, type, default_content, action_params, edits_pending, code_tag, avatar DEFAULT action = 'show'; SET action_params = [] UNLESS action_params.size; action_params.push(default_content); link = c.uri_for_action('/' _ type _ '/' _ action, action_params); mod_content = content != '' ? content : default_content; options = ['escape']; options.unshift('code') IF code_tag; options.unshift('isolate'); options.unshift('avatar') IF avatar; options.unshift('link'); options.unshift('edits_pending') IF edits_pending AND action == 'show'; INCLUDE _wrap_text options=options content=mod_content link=link avatar=avatar image_size=image_size; END -%] [%~ MACRO link_work(work, action, text) BLOCK; INCLUDE _link_mbid_entity entity=work type='work' action=action content=text; END -%] [%~ MACRO link_instrument(instrument, action, text) BLOCK; INCLUDE _link_mbid_entity entity=instrument type='instrument' action=action content=text default_content=instrument.l_name; END -%] [%~ MACRO link_label(label, action, text) BLOCK; INCLUDE _link_mbid_entity entity=label type='label' action=action content=text; END -%] [%~ MACRO link_artist(artist, action, text) BLOCK; hover = html_escape(artist.sort_name); SET hover = hover _ bracketed(html_escape(artist.comment)) IF artist.comment; INCLUDE _link_mbid_entity entity=artist type='artist' action=action content=text hover=hover namevar=1; END -%] [%~ MACRO link_area(area, action, text) BLOCK; INCLUDE _link_mbid_entity entity=area type='area' action=action content=text default_content=area.l_name; END -%] [%~ MACRO link_area_containment(area) BLOCK; areas = []; IF area.parent_city; areas.push({link => link_area(area.parent_city), depth => area.parent_city_depth}); END; IF area.parent_subdivision; areas.push({link => link_area(area.parent_subdivision), depth => area.parent_subdivision_depth}); END; IF area.parent_country; areas.push({link => link_area(area.parent_country), depth => area.parent_country_depth}); END; areas = areas.nsort('depth'); link_areas = []; FOR area=areas; link_areas.push(area.link); END; comma_only_list(link_areas); END -%] [%~ MACRO link_area_with_containment(area, action, text) BLOCK; link_entity(area, action, text); IF link_area_containment(area); ', ' _ link_area_containment(area); END; END -%] [%~ MACRO link_place(place, action, text) BLOCK; INCLUDE _link_mbid_entity entity=place type='place' action=action content=text; END -%] [%~ MACRO link_collection(collection, action, text) BLOCK; INCLUDE _link_mbid_entity entity=collection type='collection' action=action content=text; END -%] [%~ MACRO link_event(event, action, text) BLOCK; INCLUDE _link_mbid_entity entity=event type='event' action=action content=text; END -%] [%~ MACRO link_release(release, action, text) BLOCK; INCLUDE _link_mbid_entity entity=release type='release' action=action content=text; END -%] [%~ MACRO link_release_group(rg, action, text) BLOCK; INCLUDE _link_mbid_entity entity=rg type='release_group' action=action content=text; END -%] [%~ MACRO link_recording(recording, action, text, no_escape) BLOCK; INCLUDE _link_mbid_entity entity=recording type='recording' action=action content=text namevar=1 noescape=no_escape; END -%] [%~ MACRO link_series(series, action, text) BLOCK; INCLUDE _link_mbid_entity entity=series type='series' action=action content=text; END -%] [%~ MACRO link_url(url, action, text) BLOCK; INCLUDE _link_mbid_entity entity=url type='url' action=action content=text; END -%] [%~ MACRO link_tag(tag, action, text) BLOCK; INCLUDE _link_other_entity content=text action=action type='tag' default_content=tag.name; END -%] [%~ MACRO link_isrc(isrc, action, text) BLOCK; INCLUDE _link_other_entity content=text action=action type='isrc' default_content=isrc.isrc edits_pending=isrc.edits_pending code_tag=1; END -%] [%~ MACRO link_iswc(iswc, action, text) BLOCK; INCLUDE _link_other_entity content=text action=action type='iswc' default_content=iswc.iswc edits_pending=iswc.edits_pending code_tag=1; END -%] [%~ MACRO link_cdtoc(cdtoc, action, text) BLOCK; INCLUDE _link_other_entity content=text action=action type='cdtoc' default_content=cdtoc.discid; END -%] [%~ MACRO link_cdstub(cdstub, action, text) BLOCK; INCLUDE _link_other_entity content=text action=action type='cdstub' default_content=cdstub.discid; END -%] [%~ MACRO link_freedb(freedb, action, text) BLOCK; INCLUDE _link_other_entity content=text action=action type='freedb' default_content=freedb.discid action_params=[freedb.category]; END -%] [%~ MACRO gravatar(email) FILTER gravatar; email; END -%] [%~ MACRO link_editor(editor, action, text, size) BLOCK; DEFAULT action = 'profile'; DEFAULT size = 12; IF editor.preferences.show_gravatar; image_url = gravatar(editor.email) _ '&s=' _ size*2; ELSE; image_url = '//gravatar.com/avatar/placeholder?d=mm&s=' _ size*2; END; INCLUDE _link_other_entity content=text action=action type='user' default_content=editor.name avatar=image_url image_size=size; END -%] [%~ MACRO editor_type_info(editor) BLOCK; -%] [% IF editor.is_limited; '(' _ l('limited user') _ ')'; END %] [% IF editor.is_bot; '(' _ l('bot') _ ')'; END %] [%- END -%] [%~ MACRO link_edit(edit, action, text) BLOCK; INCLUDE _link_other_entity content=text action=action type='edit' default_content=edit.id; END -%] [%~ MACRO link_searchable_property(search_field, search_value, entity_type, text) BLOCK -%] [%- text = text == '' ? search_value : text -%] [%- -%] [%- text -%] [%- END -%] [%~ MACRO login_url(redirect) BLOCK; c.uri_for_action('/user/login', { uri => c.req.query_params.uri || redirect || c.relative_uri }); END -%] [%~ MACRO simple_link(url, text) BLOCK; INCLUDE _wrap_text options=['link'] content=text link=url; END -%] [%~ MACRO request_login(text) BLOCK; simple_link(login_url(), text || l('Log in')); END -%] [%~ MACRO tagger_icon(entity) BLOCK -%] [%- IF entity.isa('MusicBrainz::Server::Entity::Release') -%] [% USE date %] [% l('Tagger') %] [%- ELSIF entity.isa('MusicBrainz::Server::Entity::Recording') -%] [% l('Tagger') %] [%- END -%] [%- END -%] [%~ MACRO release_label_list(labels) BLOCK; out = []; seen = {}; FOR label=labels; IF label.label.gid AND !seen.${ label.label.gid }; out.push(link_entity(label.label)); seen.${ label.label.gid } = 1; END; END; comma_only_list(out); END -%] [%~ MACRO release_catno_list(labels) BLOCK; out = []; seen = {}; FOR label=labels; IF label.catalog_number AND !seen.${ label.catalog_number }; out.push('' _ label.catalog_number _ ''); seen.${ label.catalog_number } = 1; END; END; comma_only_list(out); END -%] [%~ MACRO sortable_table_header(name, label) BLOCK -%] [% label %] [%- IF order == name %] ▴[% ELSIF order == '-' _ name %] ▾[% END %] [%- END -%] [%~ MACRO entity_label(type) BLOCK; IF type == 'artist'; l('Artist:'); ELSIF type == 'area'; l('Area:'); ELSIF type == 'event'; l('Event:'); ELSIF type == 'instrument'; l('Instrument:'); ELSIF type == 'label'; l('Label:'); ELSIF type == 'place'; l('Place:'); ELSIF type == 'release'; l('Release:'); ELSIF type == 'release_group'; l('Release group:'); ELSIF type == 'recording'; l('Recording:'); ELSIF type == 'series'; lp('Series:', 'singular'); ELSIF type == 'work'; l('Work:'); ELSIF type == 'url'; l('URL:'); END; END -%] [%~ MACRO format_entity_type_name(type_name) BLOCK -%] [%- IF type_name == 'artist'; l('Artist'); ELSIF type_name == 'area'; l('Area'); ELSIF type_name == 'event'; l('Event'); ELSIF type_name == 'collection'; l('Collection'); ELSIF type_name == 'instrument'; l('Instrument'); ELSIF type_name == 'place'; l('Place'); ELSIF type_name == 'release'; l('Release'); ELSIF type_name == 'recording'; l('Recording'); ELSIF type_name == 'release_group'; l('Release Group'); ELSIF type_name == 'series'; lp('Series', 'singular'); ELSIF type_name == 'work'; l('Work'); ELSIF type_name == 'label'; l('Label'); ELSIF type_name == 'url'; l('URL'); END -%] [%- END -%] [%~ MACRO format_plural_entity_type_name(type_name) BLOCK -%] [%- IF type_name == 'artist'; l('Artists'); ELSIF type_name == 'area'; l('Areas'); ELSIF type_name == 'event'; l('Events'); ELSIF type_name == 'collection'; l('Collections'); ELSIF type_name == 'instrument'; l('Instruments'); ELSIF type_name == 'place'; l('Places'); ELSIF type_name == 'release'; l('Releases'); ELSIF type_name == 'recording'; l('Recordings'); ELSIF type_name == 'release_group'; l('Release Groups'); ELSIF type_name == 'series'; lp('Series', 'plural'); ELSIF type_name == 'work'; l('Works'); ELSIF type_name == 'label'; l('Labels'); ELSIF type_name == 'url'; l('URLs'); END -%] [%- END -%] [%~ MACRO quality_name(quality) SWITCH quality; CASE 0; l('Low'); CASE 1; l('Normal'); CASE -1; l('Normal'); CASE 2; l('High'); END -%] [%~ MACRO edit_conditions(expire_action) SWITCH expire_action; CASE 1; l('Accept upon expiration'); CASE 2; l('Reject upon expiration'); END -%] [%-# See /lib/MusicBrainz/Server/Edit/Utils.pm for status names -%] [%~ MACRO edit_status_description(edit) SWITCH edit.status; CASE 1; l('This edit is open and awaiting votes before it can be applied.'); CASE 2; l('This edit has been successfully applied.'); CASE 3; l('This edit failed because there were insufficient "yes" votes.'); CASE 4; l('This edit failed either because an entity it was modifying no longer exists, or the entity can not be modified in this manner anymore.'); CASE 5; l('This edit failed due to an internal error and may need to be entered again.'); CASE 6; l('This edit failed because the data it was changing was modified after this edit was created. This may happen when the same edit is entered in twice; one will pass but the other will fail.'); CASE 7; l('This edit failed because it affected high quality data and did not receive any votes.'); CASE 8; l('This edit was recently cancelled.'); CASE 9; l('This edit was cancelled.'); END -%] [%~ MACRO expiration_time(datetime) BLOCK -%] [%- IF Countdown.in_the_future(datetime) # Make sure datetime is a "countdownable" date -%] [%- IF Countdown.days(datetime) > 0 # If the date is far away, only display days -%] [%- ln('Expires in {num} day', 'Expires in {num} days', Countdown.days(datetime), { num => Countdown.days(datetime), exactdate => UserDate.format(datetime) }) -%] [%- ELSIF Countdown.hours(datetime) > 0 # Show hours -%] [%- ln('Expires in {num} hour', 'Expires in {num} hours', Countdown.hours(datetime), { num => Countdown.hours(datetime), exactdate => UserDate.format(datetime) }) -%] [%- ELSE # Only show minutes -%] [%- ln('Expires in {num} minute', 'Expires in {num} minutes', Countdown.minutes(datetime), { num => Countdown.minutes(datetime), exactdate => UserDate.format(datetime) }) -%] [%- END -%] [%- ELSE -%] [%- l('Already expired') -%] [%- END -%] [%- END -%] [%~ MACRO vote_tally(edit) BLOCK -%] [%- IF edit.auto_edit; '' _ l('automatically applied') _ ''; ELSE; l('{yes} yes : {no} no', { yes => '' _ edit.yes_votes _ '', no => '' _ edit.no_votes _ '' }); END -%] [%- END -%] [%~ MACRO display_relationship(relationship, phrase_field) BLOCK; -%] [%- phrase_field = phrase_field || 'phrase'; extra_attributes_field = "extra_${phrase_field}_attributes"; IF relationship.edits_pending; ''; END; relationship.${ phrase_field }; ' '; descriptive_link(relationship.target); IF !relationship.link.begin_date.is_empty; ' '; IF !relationship.link.end_date.is_empty; IF relationship.link.begin_date.format == relationship.link.end_date.format; IF relationship.link.begin_date.day; l('on {date}', { date => relationship.link.begin_date.format }); ELSE; l('in {date}', { date => relationship.link.begin_date.format }); END; ELSE; l('from {begin_date} until {end_date}', { begin_date => relationship.link.begin_date.format, end_date => relationship.link.end_date.format }); END; ELSIF relationship.link.ended; l('from {date} to ????', { date => relationship.link.begin_date.format }); ELSE; l('from {date} to present', { date => relationship.link.begin_date.format }); END; ELSIF !relationship.link.end_date.is_empty; ;' '; l('until {date}', { date => relationship.link.end_date.format }); ELSIF relationship.link.ended; ' '; l('ended'); END; IF relationship.${extra_attributes_field}; ' (' _ relationship.${extra_attributes_field} _ ')'; END; -%] [%- END -%] [%~ MACRO favicon_class(url) BLOCK -%] [%- matching_class = '' -%] [%- FOREACH icon IN favicon_css_classes -%] [%- IF (icon.key.search('/') AND url.url.as_string.search(icon.key)) OR url.url.host.search(icon.key) -%] [%- matching_class = icon.value -%] [%- LAST -%] [%- END -%] [%- END -%] [%- (matching_class OR 'no') _ '-favicon' -%] [%- END -%] [%~ MACRO license_class(url) IF url.url.as_string.search('creativecommons.org/publicdomain/zero/'); 'CC0'; ELSIF url.url.as_string.search('creativecommons.org/licenses/publicdomain/'); 'CCPD'; ELSIF url.url.as_string.search('creativecommons.org/licenses/by-nc-sa/'); 'CCBYNCSA'; ELSIF url.url.as_string.search('creativecommons.org/licenses/by-nc-nd/'); 'CCBYNCND'; ELSIF url.url.as_string.search('creativecommons.org/licenses/by-sa/'); 'CCBYSA'; ELSIF url.url.as_string.search('creativecommons.org/licenses/by-nc/'); 'CCBYNC'; ELSIF url.url.as_string.search('creativecommons.org/licenses/by-nd/'); 'CCBYND'; ELSIF url.url.as_string.search('creativecommons.org/licenses/by/'); 'CCBY'; ELSIF url.url.as_string.search('creativecommons.org/licenses/nc-sampling\\+/'); 'CCNCSamplingPlus'; ELSIF url.url.as_string.search('creativecommons.org/licenses/sampling\\+/'); 'CCSamplingPlus'; ELSIF url.url.as_string.search('creativecommons.org/licenses/sampling/'); 'CCSampling'; ELSIF url.url.as_string.search('artlibre.org/licence/lal'); 'ArtLibre'; ELSE; ''; END -%] [%~ MACRO css_class_name(name) BLOCK; name | lower | replace('[^a-z]+', '-') | remove('^-|-$'); END -%] [%~ MACRO warning_icon BLOCK -%] [%- END -%] [%~ MACRO error(message, class) BLOCK -%]
[%- warning_icon %]

[% l('Error:') %] [% message %]

[%- END -%] [%~ MACRO warning(message, class) BLOCK -%]
[%- warning_icon %]

[% l('Warning:') %] [% message %]

[%- END -%] [%~ MACRO javascript_required BLOCK ~%] [%~ END ~%] [%~ MACRO wiki_link(server, id) BLOCK -%] //[%- server -%]/[%- id -%] [%- END -%] [%~ MACRO script_manifest(manifest) BLOCK ~%] [%~ END ~%] [%~ MACRO css_manifest(manifest) BLOCK ~%] [%~ END ~%] [%~ MACRO format_length(n) BLOCK; n | format_length; END -%] [%~ MACRO medium_format_name(medium) BLOCK -%] [% medium.l_format_name or l("Medium") | html %] [%- END -%] [%~ MACRO medium_link(medium) BLOCK; args = { medium_format => medium_format_name(medium), position => medium.position, release => descriptive_link(medium.release) }; IF medium.name != ''; args.medium_name = isolate_text(medium.name); l('{medium_format} {position}: {medium_name} on {release}', args); ELSE; l('{medium_format} {position} on {release}', args); END; END ~%] [%~ MACRO medium_in_release(release, medium) BLOCK -%] [%- fragment = "disc" _ medium.position -%] [%~ medium_format_name(medium) =%] [%= medium.position ~%] [%~ IF medium.name ~%]: [%= medium.name | html ~%] [%~ END ~%] [%- END -%] [%~ MACRO filter_button BLOCK -%]
[% l("Filter") %]
[%- END -%] [%~ MACRO wikidoc_search_box BLOCK -%] [%- END -%] [%~ MACRO artist_begin_label_from_type(type_id) BLOCK ~%] [%~ type_id == 1 ? l('Born:') : (type_id == 2 || type_id == 5 || type_id == 6) ? l('Founded:') : l('Begin date:') ~%] [%~ END -%] [%~ MACRO artist_begin_area_label_from_type(type_id) BLOCK ~%] [%~ type_id == 1 ? l('Born in:') : (type_id == 2 || type_id == 5 || type_id == 6) ? l('Founded in:') : l('Begin area:') ~%] [%~ END -%] [%~ MACRO artist_end_label_from_type(type_id) BLOCK ~%] [%~ type_id == 1 ? l('Died:') : (type_id == 2 || type_id == 5 || type_id == 6) ? l('Dissolved:') : l('End date:') ~%] [%~ END -%] [%~ MACRO artist_end_area_label_from_type(type_id) BLOCK ~%] [%~ type_id == 1 ? l('Died in:') : (type_id == 2 || type_id == 5 || type_id == 6) ? l('Dissolved in:') : l('End area:') ~%] [%~ END -%] [%~ MACRO show_wikipedia_extract BLOCK -%] [%- IF wikipedia_extract -%] [%- INCLUDE 'components/wikipedia_extract.tt' -%] [%- ELSIF wikipedia_extract_url -%] [%- END -%] [%- END -%] [%~ MACRO show_image BLOCK -%] [%- IF image -%] [%- INCLUDE 'components/commons-image.tt' -%] [%- ELSIF image_url -%] [%- END -%] [%- END -%] [%~ MACRO track_duration_changes(loop_over, old_base, new_base, old_prop, new_prop) BLOCK -%] [% USE Diff %] [%- FOR i = loop_over %] [%- IF old_prop; old_length = old_base.${ loop.index }.${ old_prop } | format_length; ELSE; old_length = old_base.${ loop.index } | format_length; END; IF new_prop; new_length = new_base.${ loop.index }.${ new_prop } | format_length; ELSE; new_length = new_base.${ loop.index } | format_length; END %]
[%- Diff.diff_side(old_length, new_length, '-', '') -%]
[%- Diff.diff_side(old_length, new_length, '+', '') -%]
[%- END -%] [%- END -%] [%~ MACRO relationship_target_links(rel) BLOCK; '' IF rel.edits_pending; IF rel.target.artist_credit AND rel.target.artist_credit.name == hide_ac; link_entity(rel.target); ELSE; descriptive_link(rel.target); END; bracketed(rel.extra_phrase_attributes) IF rel.extra_phrase_attributes; bracketed(rel.link.formatted_date) IF rel.link.formatted_date; '' IF rel.edits_pending; END ~%] [%~ MACRO release_countries(release_events) BLOCK; IF release_events.size; ''; END; END -%] [%~ MACRO release_dates(release_events) BLOCK; IF release_events.size; ''; END; END -%] [%~ MACRO release_events(release_events) BLOCK; IF release_events.size; ''; END; END -%] [%~ MACRO release_event(event) BLOCK; date = event.date; country = event.country; parts = []; parts.push(link_entity(country)) IF country.id; parts.push('' _ date.format _ '') UNLESS date.is_empty; parts.join('
'); END -%] [%~ MACRO format_isni(isni) BLOCK; isni.replace('(.{4})(.{4})(.{4})(.{4})', '$1 $2 $3 $4'); END -%] [%~ MACRO link_isni(isni) BLOCK -%] [%- format_isni(isni.isni) -%] [%- END -%] [%~ MACRO country_abbr(country) BLOCK -%] [% country.primary_code %] [%- END -%] [%~ MACRO set_header BLOCK -%] [%- END -%] [%~ MACRO add_colon(variable) BLOCK; l('{variable}:', { variable => variable }); END -%] [%~ MACRO work_attributes_list(work) BLOCK -%] [%- IF work.attributes %] [%- END %] [%- END -%] [%~ MACRO link_type_cardinality_name(cardinality) BLOCK ~%] [%~ IF cardinality == 0; l('Few relationships'); ELSIF cardinality == 1; l('Many relationships'); ELSE; l('Unknown'); END %] ([% cardinality %]) [%~ END ~%] [%~ USE Canonicalize ~%] [%~ MACRO replace_gid(new_gid) BLOCK ~%] [%~ Canonicalize.replace_gid(c, new_gid) ~%] [%~ END ~%] [%~ MACRO data_track_icon BLOCK ~%]
[%~ END ~%]