cosmetic refactor, removed index js

This commit is contained in:
aj 2019-06-18 14:20:35 +01:00
parent ab2e37a2e0
commit 2350b12c4c
9 changed files with 32 additions and 59 deletions

View File

@ -1,36 +1,36 @@
from flask import Blueprint, jsonify, abort
from sarsoo.art import db
from sarsoo.art.art import getAssetUrl
from sarsoo.art.art import get_asset_url
art_api_print = Blueprint('artapi', __name__)
@art_api_print.route('/', methods=['GET'])
def collections():
def get_all_collections():
tagdicts = db.getTagDicts()
tagdicts = db.pull_all_tags()
collections = []
art_collections = []
for dict in tagdicts:
collections.append({
'name': dict['name'],
'id': dict['doc_name'],
'description': dict['description'],
'index': dict['index'],
'splash_url': getAssetUrl(dict['splash']['file_name'])
for tag_dict in tagdicts:
art_collections.append({
'name': tag_dict['name'],
'id': tag_dict['doc_name'],
'description': tag_dict['description'],
'index': tag_dict['index'],
'splash_url': get_asset_url(tag_dict['splash']['file_name'])
})
response = {'collections': collections}
response = {'collections': art_collections}
return jsonify(response)
@art_api_print.route('/<id>', methods=['GET'])
def getcollection(id):
def get_named_collection(art_id):
try:
tagdict = db.getPopulatedTagDict(id)
tagdict = db.pull_named_tag(art_id)
except TypeError as e:
abort(404)
@ -38,7 +38,7 @@ def getcollection(id):
for image in tagdict['images']:
artlist.append({
'file_url': getAssetUrl(image['file_name']),
'file_url': get_asset_url(image['file_name']),
'date': image['date'].strftime('%d %B %y')
})

View File

@ -7,7 +7,7 @@ dev_api_print = Blueprint('devapi', __name__)
@dev_api_print.route('/', methods=['GET'])
def collections():
def get_all_collections():
dev_collection = fs.collection(u'dev')

View File

@ -1,6 +1,6 @@
from flask import Blueprint, render_template
from .db import getTagDicts, getPopulatedTagDict, getPopulatedTagDicts
from .db import pull_all_tags, pull_named_tag, get_populated_tags
staticbucketurl = 'https://storage.googleapis.com/sarsooxyzstatic/'
urlprefix = 'art'
@ -9,23 +9,22 @@ art_print = Blueprint('art', __name__, template_folder='templates')
@art_print.route('/')
def root():
tags = getTagDicts()
#print(tags)
return render_template('art/index.html', tags = tags, staticroot = staticbucketurl, urlprefix = urlprefix)
def view_root():
tags = pull_all_tags()
return render_template('art/index.html', tags=tags, staticroot=staticbucketurl, urlprefix=urlprefix)
@art_print.route('/<tag>')
def tag_view(tag):
tags = getPopulatedTagDict(tag)
return render_template('art/all.html', staticroot = staticbucketurl, tags = [tags])
def view_named_tag(tag):
tags = pull_named_tag(tag)
return render_template('art/all.html', staticroot=staticbucketurl, tags=[tags])
@art_print.route('/all')
def all():
sections = getPopulatedTagDicts()
return render_template('art/all.html', staticroot = staticbucketurl, tags=sections)
def view_all_tags():
sections = get_populated_tags()
return render_template('art/all.html', staticroot=staticbucketurl, tags=sections)
def getAssetUrl(name):
def get_asset_url(name):
return staticbucketurl + 'art/' + name + '.jpg'

View File

@ -6,7 +6,7 @@ staticbucketurl = 'https://storage.googleapis.com/sarsooxyzstatic/'
fs = firestore.Client()
def getTagDicts():
def pull_all_tags():
art_tags_collection = fs.collection(u'art_tags')
@ -23,7 +23,7 @@ def getTagDicts():
return sorted(dicts, key=lambda k: k['index'])
def getPopulatedTagDict(name):
def pull_named_tag(name):
name_doc = fs.document(u'art_tags/{}'.format(name))
@ -38,9 +38,9 @@ def getPopulatedTagDict(name):
return tag_dicts
def getPopulatedTagDicts():
def get_populated_tags():
tag_dicts = getTagDicts()
tag_dicts = pull_all_tags()
for tag in tag_dicts:
image_list = []

View File

@ -33,9 +33,7 @@ def main():
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)
return render_template('index.html', staticroot=staticbucketurl, splash=splashtext, art=art)
@app.route('/dev')

View File

@ -13,7 +13,6 @@
<p>electronic engineering student / disney intern</p>
<p>proficient in C, Java, Python</p>
<p id="root"></p>
{% if splash %}<p>{{ splash }}</p>{% endif %}
</div>
<div class="col-3 profile">
@ -27,5 +26,4 @@
<img src="{{ staticroot }}art/{{ image.file_name }}.jpg" alt="{{ image.file_name }}" class="pad-4">
{% endfor %}
</div>
<script src="{{ url_for('static', filename='js/index.bundle.js') }}"></script>
{% endblock %}

View File

@ -1,15 +0,0 @@
import React, { Component } from "react";
class App extends Component{
render(){
return(
<div className="App">
<h1> hello world!!!!! </h1>
</div>
);
}
}
export default App;

View File

@ -1,6 +0,0 @@
import React from "react";
import ReactDOM from "react-dom";
import App from "./App.js";
ReactDOM.render(<App />, document.getElementById('root'));

View File

@ -3,7 +3,6 @@ const webpack = require('webpack');
module.exports = {
entry: {
index: './src/js/index/index.js',
dev: './src/js/dev/dev.js'
},
module: {