Pārlūkot izejas kodu

added 'country' to random and search

solr_update
Simon Bowie pirms 2 gadiem
vecāks
revīzija
79c10532be
3 mainītis faili ar 26 papildinājumiem un 0 dzēšanām
  1. +10
    -0
      web/app/solr.py
  2. +8
    -0
      web/app/templates/record.html
  3. +8
    -0
      web/app/templates/search.html

+ 10
- 0
web/app/solr.py Parādīt failu

import re import re
import urllib import urllib
import random import random
import pycountry
from . import ops from . import ops


# get config variables from OS environment variables: set in env file passed through Docker Compose # get config variables from OS environment variables: set in env file passed through Docker Compose
year = re.search('=D[^\s]*\s[^\s]*\s[^\s]*\s[^\s]*\s(\d{4})', input) year = re.search('=D[^\s]*\s[^\s]*\s[^\s]*\s[^\s]*\s(\d{4})', input)
if year is not None: if year is not None:
output['year'] = year.group(1) output['year'] = year.group(1)

# search for the country in the content element and display it
country_code = re.search('FT=D[^\s]*\s(\w{2})', input)
country = pycountry.countries.get(alpha_2=country_code.group(1))
if country is None:
country = pycountry.historic_countries.get(alpha_2=country_code.group(1))
if country is not None:
output['country'] = country

return output return output


def get_random_record(core): def get_random_record(core):

+ 8
- 0
web/app/templates/record.html Parādīt failu

</p> </p>
{% endif %} {% endif %}


{% if result['country'] is defined %}
<p class="mb-2">
Country:
{{ result['country'].name }}
{{ result['country'].flag }}
</p>
{% endif %}

{% if result['original_title'] is defined %} {% if result['original_title'] is defined %}
<p class="mb-2"> <p class="mb-2">
Original language title: Original language title:

+ 8
- 0
web/app/templates/search.html Parādīt failu

</p> </p>
{% endif %} {% endif %}


{% if result['country'] is defined %}
<p class="mb-2">
<span class="emphasis">Country:</span>
{{ result['country'].name }}
{{ result['country'].flag }}
</p>
{% endif %}

{% if result['abstract'] is defined %} {% if result['abstract'] is defined %}
<p class="mb-2"> <p class="mb-2">
<span class="emphasis">Abstract:</span> <span class="emphasis">Abstract:</span>

Notiek ielāde…
Atcelt
Saglabāt