forked from Ugric/Komodo-Hub
converted featured species to function in python, now displays images again, converted search bar to macro
This commit is contained in:
1 parent
d4c2b70201
commit
bd7aae94c9
6 files changed
+35
-16
No files matched your search
+3
-4
@@ -1,16 +1,15 @@
|
||||
from flask import render_template, Blueprint
|
||||
import configparser
|
||||
from utilities.featured_species import featured_species_function
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
# config = configparser.ConfigParser()
|
||||
|
||||
page = Blueprint("home", __name__, url_prefix="/")
|
||||
|
||||
|
||||
@page.route("/")
|
||||
def home():
|
||||
config.read('config.ini')
|
||||
featured_species = list(dict(config["homepage"]).values())
|
||||
# print(f'Featured species: {species1}, {species2}, {species3}')
|
||||
featured_species = featured_species_function('config.ini')
|
||||
return render_template(
|
||||
"home/home.jinja",
|
||||
featured_species=featured_species
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from flask import render_template, Blueprint, request
|
||||
import configparser
|
||||
|
||||
from database.db_commands import get_all_species, search_species
|
||||
from database.db_commands import get_all_species, search_species, get_species_by_name
|
||||
from utilities.featured_species import featured_species_function
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
@@ -9,10 +10,8 @@ page = Blueprint("species", __name__, url_prefix="/species")
|
||||
|
||||
# species database page
|
||||
@page.route("")
|
||||
def all_species():
|
||||
config.read('config.ini')
|
||||
|
||||
featured_species = list(dict(config["homepage"]).values())
|
||||
def all_species():
|
||||
featured_species = featured_species_function('config.ini')
|
||||
|
||||
species_list = get_all_species()
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
<div
|
||||
style="display: flex; flex-wrap: wrap; gap: 20px; margin-top: 30px; text-decoration: none; justify-content: space-evenly">
|
||||
{%for species in featured_species%}
|
||||
<a href="/species/{{species}}" class="container-lite">
|
||||
<h3 class="plain-white-text">{{species}}</h3>
|
||||
<div style="background-image: url('images/species_database/{{species}}.jpg');" class="div-image">
|
||||
<a href="/species/{{ species['species_english'] }}" class="container-lite">
|
||||
<h3 class="plain-white-text">{{ species['species_english'] }}</h3>
|
||||
<div style="background-image: url('images/species_database/{{ species['photoid'] }}.jpg');" class="div-image">
|
||||
</div>
|
||||
|
||||
</a>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{% macro search_bar(destination)%}
|
||||
{# input the url of the page containing the backend for the search #}
|
||||
{# e.g. for the species search: "/species/search" #}
|
||||
{# used in species.jinja #}
|
||||
<form action="{{destination}}" method="GET" class="search">
|
||||
<input type="text" name="search-query" placeholder="Search all species..." class="bar">
|
||||
<input type="submit" value="Search" class="button">
|
||||
</form>
|
||||
{% endmacro %}
|
||||
@@ -6,6 +6,7 @@
|
||||
{% from 'button.jinja' import button %}
|
||||
{% from 'featured_species.jinja' import featured_species_section %}
|
||||
{% from 'display_items.jinja' import display_all_items %}
|
||||
{% from 'search_bar.jinja' import search_bar%}
|
||||
<section class="title">
|
||||
Species Database
|
||||
</section>
|
||||
@@ -14,10 +15,7 @@ Species Database
|
||||
{{featured_species_section(featured_species, False)}}
|
||||
{# All Species #}
|
||||
<div>
|
||||
<form action="/species/search" method="GET" class="search">
|
||||
<input type="text" name="search-query" placeholder="Search all species..." class="bar">
|
||||
<input type="submit" value="Search" class="button">
|
||||
</form>
|
||||
{{search_bar("/species/search")}}
|
||||
</div>
|
||||
<h2 style="text-align: center; margin-top: 30px;">All Species</h2>
|
||||
{{display_all_items(species)}}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import configparser
|
||||
|
||||
from database.db_commands import get_species_by_name
|
||||
|
||||
def featured_species_function(config_file):
|
||||
config = configparser.ConfigParser()
|
||||
config.read(config_file)
|
||||
featured_species_list = list(dict(config["homepage"]).values())
|
||||
featured_species = []
|
||||
for species in featured_species_list:
|
||||
featured_species.append(get_species_by_name(species))
|
||||
|
||||
return featured_species
|
||||
|
||||
Reference in new issue
Block a user