You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
4.7 KiB
Python

import datetime, os, re
from bottle import error, response, route, run, static_file, template, TEMPLATE_PATH
def find_gallery(name):
2 years ago
gal = [name]
if name == "Aloin":
gal.append([["name.jpg","alt text"]])
if name == "Angel":
gal.append([["name.jpg","alt text"]])
if name == "Aristen":
2 years ago
gal.append([["menu.jpg","Aristen's fancy set with bright colors and an obi belt"], ["scarf.jpg", "Newbie Aristen with her orange scarf"], ["marine.jpg","Aristen in the Epheria Marine Classic Set, a goofy marine pinup costume."]])
if name == "Calder":
gal.append([["name.jpg","alt text"]])
if name == "Fifi":
gal.append([["name.jpg","alt text"]])
if name == "Helia":
gal.append([["name.jpg","alt text"]])
if name == "Lune":
gal.append([["ArcheageGuild.jpg","Lune as a dwarf ghost girl with gold-dipped hair and a frilly gown, sitting among her old guildmates"]])
if name == "Rune":
gal.append([["name.jpg","alt text"]])
if name == "Silke":
gal.append([["name.jpg","alt text"]])
if name == "Tessa":
gal.append([["name.jpg","alt text"]])
if name == "WISE":
gal.append([["name.jpg","alt text"]])
2 years ago
return gal
2 years ago
def prepare_profile(loc, char_name):
string = ""
with open(loc + char_name) as f:
lines = f.readlines()
for line in lines:
string += line
return string
def find_year():
now = datetime.datetime.now()
return now.strftime('%Y')
4 years ago
## Static ##
4 years ago
# Serve CSS
@route('/static/css/<filename:path>')
def serve_css(filename):
return static_file(filename, root='static/css')
4 years ago
# Serve images
@route('/static/img/<filename:path>')
def serve_img(filename):
return static_file(filename, root='static/img')
# Serve XML
2 years ago
@route('/static/xml/<filename:path>')
def serve_xml(filename):
return static_file(filename, root='static/xml', mimetype='text/xml')
4 years ago
## Routes ##
3 years ago
# Error Page
@error(404)
def error404(error):
return "unfortunately, a 404 error. the page you're searching for doesn't exist. (or is it just in hiding?) try another page! "
3 years ago
@error(500)
def error500(error):
3 years ago
return "unfortunately, a 500 error. something is wrong with the page you're trying to find, if it exists at all. try another page! <a href=https://www.blessfrey.me/>return to blessfrey.me.</a>"
3 years ago
@error(502)
def error502(error):
3 years ago
return "unfortunately, a 502 error. this was likely due to website maintenance. usually it'll be back up before you finish reading this, but otherwise, I'll notice something's wrong soon! <a href=https://www.blessfrey.me/>return to blessfrey.me.</a>"
2 years ago
@route('/char/<char_name:path>')
def char(char_name):
"""character page"""
loc = 'char/'
info = {'css': 'char', 'title': 'blessfrey - meet ' + char_name, 'year': find_year(), 'profile': prepare_profile(loc, char_name), 'gallery': find_gallery(char_name)}
2 years ago
abs_app_dir_path = os.path.dirname(os.path.realpath(__file__))
abs_views_path = os.path.join(abs_app_dir_path, 'views')
TEMPLATE_PATH.insert(0, abs_views_path )
return template(os.path.join(abs_views_path,'char.tpl'), info)
# Blessfrey Demo Page
@route('/demo')
def demo():
"""demo"""
info = {'css': 'demo', 'title': 'blessfrey demo', 'year': find_year()}
return template('demo.tpl', info)
2 years ago
# Fashion Page
@route('/diary')
def diary():
"""diary"""
info = {'css': 'diary', 'title': 'chimchooree\'s diary', 'year': find_year()}
return template('diary.tpl', info)
# Fashion Page
@route('/fashion')
def fashion():
"""fashion"""
info = {'css': 'fashion', 'title': 'blessfrey fashion', 'year': find_year()}
return template('fashion.tpl', info)
4 years ago
# Home Page - Index Template
@route('/')
def home():
"""home"""
info = {'css': 'index', 'title': 'chimchooree\'s dev space - blessfrey', 'year': find_year(), 'news':[["link","website update"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"],["link2","about blessfrey rpg"]]} #list_headlines(sort_files(gather_files(loc))[0:10])}
return template('index.tpl', info)
# Me Page
@route('/me')
def me():
"""me"""
info = {'css': 'me', 'title': 'about me', 'year': find_year(), 'chars': ["Helia", "Angel", "Rune", "Tessa", "WISE", "Silke", "Calder", "Aloin", "Fifi", "Lune", "Aristen"]}
return template('me.tpl', info)
2 years ago
4 years ago
## Main ##
if __name__ == '__main__':
run(host='127.0.0.1', port=9001)