35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from django import template
|
|
from django.urls import reverse
|
|
|
|
register = template.Library()
|
|
|
|
navbar_options = {
|
|
"Home": ["Home", "GeoffreyHome"],
|
|
"Player": ["Players", "GeoffreyPlayers"],
|
|
"Shop": ["Shops", "GeoffreyShops"],
|
|
"Base": ["Bases", "GeoffreyBases"],
|
|
"Town": ["Towns", "GeoffreyTowns"],
|
|
"ItemListing": ["Item Listings", "GeoffreyItems"],
|
|
"PublicFarm": ["Public Farms", "GeoffreyPublicFarms"],
|
|
"Market": ["Markets", "GeoffreyMarkets"],
|
|
"PointOfInterest": ["Points of Interest", "GeoffreyPointOfInterest"],
|
|
"Attractions": ["Attractions", "GeoffreyAttraction"]
|
|
}
|
|
|
|
option_format = '<li class="nav-item{}"> <a class="nav-link" href="{}">{} </a> </li>'
|
|
|
|
|
|
@register.simple_tag
|
|
def get_navbar(page):
|
|
navbar = ""
|
|
|
|
for option in navbar_options.keys():
|
|
if page == option:
|
|
active = ' active'
|
|
else:
|
|
active = ''
|
|
|
|
navbar += option_format.format(active, reverse(navbar_options[option][1]), navbar_options[option][0])
|
|
|
|
return navbar
|