database defined art on index page, added splash text

This commit is contained in:
aj 2019-02-19 22:31:18 +00:00
parent a0e8fd91a8
commit 8309709583
2 changed files with 18 additions and 13 deletions

24
main.py
View File

@ -10,7 +10,20 @@ staticbucketurl = 'https://storage.googleapis.com/sarsooxyzstatic/'
@app.route('/') @app.route('/')
def main(): def main():
return render_template('index.html', staticroot = staticbucketurl)
index_doc = db.collection(u'pages').document(u'index')
doc = index_doc.get()
index_dict = doc.to_dict()
splashtext = index_dict['splash_text']
art = []
for image in index_dict['art']:
art.append(image.get().to_dict())
print(index_dict['art'][0].get().to_dict())
return render_template('index.html', staticroot = staticbucketurl, splash = splashtext, art=art)
@app.route('/music') @app.route('/music')
def music(): def music():
@ -22,7 +35,6 @@ def art():
art_tags_collection = db.collection(u'art_tags') art_tags_collection = db.collection(u'art_tags')
try: try:
#pics = art_collection.get()
tags = art_tags_collection.get() tags = art_tags_collection.get()
except google.cloud.exceptions.NotFound: except google.cloud.exceptions.NotFound:
return 'no such document' return 'no such document'
@ -42,14 +54,6 @@ def art():
#sections.append({tag_dict['name']: image_list}) #sections.append({tag_dict['name']: image_list})
sections.append({'images': image_list, 'name': tag_dict['name'], 'description': tag_dict['description'], 'index': tag_dict['index']}) sections.append({'images': image_list, 'name': tag_dict['name'], 'description': tag_dict['description'], 'index': tag_dict['index']})
#print(sections[0])
images = []
for doc in pics:
#image = doc.to_dict()
images.append(doc.to_dict())
#categories[categories.index(image['tag'])].append(image)
return render_template('art.html', staticroot = staticbucketurl, tags=sections) return render_template('art.html', staticroot = staticbucketurl, tags=sections)
@app.route('/dev') @app.route('/dev')

View File

@ -9,6 +9,7 @@
<p>electronic engineering student / disney intern</p> <p>electronic engineering student / disney intern</p>
<p>proficient in C, Java, Python</p> <p>proficient in C, Java, Python</p>
{% if splash %}<p>{{ splash }}</p>{% endif %}
</div> </div>
<div class="col-3 profile"> <div class="col-3 profile">
<img src="{{ staticroot }}me.jpg" height=150> <img src="{{ staticroot }}me.jpg" height=150>
@ -17,8 +18,8 @@
</div> </div>
<div class="gallerystrip row"> <div class="gallerystrip row">
<img src="{{ staticroot }}art/freddie.jpg" alt="freddie gibbs" class="col-pad-4"> {% for image in art %}
<img src="{{ staticroot }}art/self.jpg" alt="me" class="col-pad-4"> <img src="{{ staticroot }}art/{{ image.file_name }}.jpg" alt="{{ image.file_name }}" class="col-pad-4">
<img src="{{ staticroot }}art/horse.jpg" alt="tempation of saint anthony" class="col-pad-4"> {% endfor %}
</div> </div>
{% endblock %} {% endblock %}