fd
This commit is contained in:
parent
9b68b619d3
commit
3acec6c7fc
8 changed files with 1084 additions and 212 deletions
|
@ -17,7 +17,7 @@ import gevent
|
||||||
from redis import ConnectionPool
|
from redis import ConnectionPool
|
||||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||||
|
|
||||||
app = Flask(__name__, template_folder='./templates', static_folder='./static')
|
app = Flask(__name__, template_folder='./templates')
|
||||||
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=3)
|
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=3)
|
||||||
app.url_map.strict_slashes = False
|
app.url_map.strict_slashes = False
|
||||||
app.jinja_env.cache = {}
|
app.jinja_env.cache = {}
|
||||||
|
|
1078
files/assets/js/bundle2.js
Normal file
1078
files/assets/js/bundle2.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -212,47 +212,3 @@ def validate_formkey(f):
|
||||||
|
|
||||||
wrapper.__name__ = f.__name__
|
wrapper.__name__ = f.__name__
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
def api(*scopes, no_ban=False):
|
|
||||||
|
|
||||||
def wrapper_maker(f):
|
|
||||||
|
|
||||||
def wrapper(*args, **kwargs):
|
|
||||||
|
|
||||||
if request.path.startswith(('/api/v1','/api/v2')):
|
|
||||||
|
|
||||||
v = kwargs.get('v')
|
|
||||||
|
|
||||||
result = f(*args, **kwargs)
|
|
||||||
|
|
||||||
if isinstance(result, dict):
|
|
||||||
resp = result['api']()
|
|
||||||
else:
|
|
||||||
resp = result
|
|
||||||
|
|
||||||
if not isinstance(resp, RespObj):
|
|
||||||
resp = make_response(resp)
|
|
||||||
|
|
||||||
return resp
|
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
result = f(*args, **kwargs)
|
|
||||||
|
|
||||||
if not isinstance(result, dict):
|
|
||||||
return result
|
|
||||||
|
|
||||||
try:
|
|
||||||
if request.path.startswith('/inpage/'):
|
|
||||||
return result['inpage']()
|
|
||||||
elif request.path.startswith(('/api/vue/','/test/')):
|
|
||||||
return result['api']()
|
|
||||||
else:
|
|
||||||
return result['html']()
|
|
||||||
except KeyError:
|
|
||||||
return result
|
|
||||||
|
|
||||||
wrapper.__name__ = f.__name__
|
|
||||||
return wrapper
|
|
||||||
|
|
||||||
return wrapper_maker
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ def shop(v):
|
||||||
elif v.patron == 4: val["price"] = int(val["price"]*0.75)
|
elif v.patron == 4: val["price"] = int(val["price"]*0.75)
|
||||||
else: val["price"] = int(val["price"]*0.70)
|
else: val["price"] = int(val["price"]*0.70)
|
||||||
|
|
||||||
return render_template("shop.html", owned=owned, awards=list(AWARDS.values()), v=v)
|
return render_template("settings_shop.html", owned=owned, awards=list(AWARDS.values()), v=v)
|
||||||
|
|
||||||
@app.post("/buy/<award>")
|
@app.post("/buy/<award>")
|
||||||
@auth_required
|
@auth_required
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
const vm = new Vue({
|
|
||||||
el: '#vm',
|
|
||||||
delimiters: ['[[', ']]'],
|
|
||||||
data: {
|
|
||||||
greeting: 'Hello, Vue!'
|
|
||||||
}
|
|
||||||
})
|
|
|
@ -1,152 +1,5 @@
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
|
<script src='/assets/js/bundle2.js'></script>
|
||||||
|
|
||||||
<input type="hidden" id="awardTarget" value="" />
|
<input type="hidden" id="awardTarget" value="" />
|
||||||
<div class="modal fade" id="awardModal" tabindex="-1" role="dialog" aria-labelledby="awardModalTitle" aria-hidden="true">
|
<div class="modal fade" id="svelte-app2" tabindex="-1" role="dialog" aria-labelledby="awardModalTitle" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered" role="document">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title">Give Award</h5>
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
||||||
<span aria-hidden="true"><i class="far fa-times"></i></span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="awardModalBody" class="modal-body">
|
|
||||||
<form v-if="loaded" id="sex" class="pt-3 pb-0">
|
|
||||||
<div class="card-columns awards-wrapper">
|
|
||||||
<div v-for="(award, index) in awards" :key="index">
|
|
||||||
<input type="radio" :id="index" :value="index" v-model="picked" :disabled="award.owned < 1">
|
|
||||||
<label class="card" :for="index" :class="{ disabled: award.owned < 1 }">
|
|
||||||
<i :class="award.icon+' '+award.color"></i><br />
|
|
||||||
<span class="d-block pt-2" style="font-weight: bold; font-size: 14px;">[[ award.title ]]</span>
|
|
||||||
<span class="text-muted">[[ award.owned ]] owned</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="picked !== null">
|
|
||||||
<div class="award-desc p-3">
|
|
||||||
<i style="font-size: 35px;" :class="pickedAward.icon+' '+pickedAward.color"></i>
|
|
||||||
<div style="margin-left: 15px;">
|
|
||||||
<strong>[[ pickedAward.title ]] Award</strong><br />
|
|
||||||
<span class="text-muted">[[ pickedAward.description ]]</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<label for="note" class="pt-4">Note (optional):</label>
|
|
||||||
<textarea id="note" name="note" v-model="note" class="form-control" placeholder="Note to include in award notification"></textarea>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<div v-else-if="error" class="p-5 text-center">
|
|
||||||
<h4>Failed to fetch awards</h4>
|
|
||||||
<button class="btn btn-primary">Retry</button>
|
|
||||||
</div>
|
|
||||||
<div v-else class="p-5 text-center">
|
|
||||||
<h4>Loading...</h4>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-link text-muted" data-dismiss="modal">Cancel</button>
|
|
||||||
<button v-if="pending" class="btn btn-warning" type="button" disabled>
|
|
||||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
|
||||||
Gifting...
|
|
||||||
</button>
|
|
||||||
<button v-else type="submit" class="btn btn-link" id="awardButton" @click="submit" :disabled="pickedAward === null">Give Award</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.awards-wrapper input[type="radio"] {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.awards-wrapper label {
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 15px;
|
|
||||||
text-align: center;
|
|
||||||
text-transform: none!important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.awards-wrapper label i {
|
|
||||||
font-size: 45px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.awards-wrapper label.disabled {
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.awards-wrapper label:hover {
|
|
||||||
/*background-color: rgba(173, 226, 255, 0.7)!important;*/
|
|
||||||
background-color: var(--primary)!important;
|
|
||||||
background-opacity: 0.4;
|
|
||||||
}
|
|
||||||
|
|
||||||
.awards-wrapper input[type="radio"]:checked+label {
|
|
||||||
/*background-color: rgba(173, 226, 255, 0.9)!important;*/
|
|
||||||
background-color: var(--primary)!important;
|
|
||||||
background-opacity: 0.9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.award-desc {
|
|
||||||
border-radius: 5px;
|
|
||||||
background-color: rgba(221, 221, 221, 0.23);
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
new Vue({
|
|
||||||
el: "#awardModal",
|
|
||||||
delimiters: ['[[', ']]'],
|
|
||||||
data: {
|
|
||||||
loaded: false,
|
|
||||||
error: false,
|
|
||||||
pending: false,
|
|
||||||
awards: [],
|
|
||||||
picked: null,
|
|
||||||
note: ""
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
pickedAward: function() {
|
|
||||||
if (this.picked !== null) {
|
|
||||||
return this.awards[this.picked];
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async submit() {
|
|
||||||
this.pending = true;
|
|
||||||
|
|
||||||
const target = document.getElementById("awardTarget").value;
|
|
||||||
|
|
||||||
const f = new FormData();
|
|
||||||
f.append("formkey", formkey());
|
|
||||||
f.append("kind", this.pickedAward.kind || "");
|
|
||||||
f.append("note", this.note)
|
|
||||||
|
|
||||||
let response = await fetch(target, {
|
|
||||||
method: "POST",
|
|
||||||
body: f
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.ok) {
|
|
||||||
location.reload();
|
|
||||||
} else {
|
|
||||||
this.pending = false;
|
|
||||||
let s = await response.json();
|
|
||||||
alert(s.error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
fetch('/awards')
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(json => {
|
|
||||||
this.awards = json;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.loaded = true;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<body>
|
|
||||||
<div id="vm">
|
|
||||||
<p>{{greeting}}</p>
|
|
||||||
<p>[[ greeting ]]</p>
|
|
||||||
</div>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
|
||||||
<script src="{{url_for('static', filename='index.js')}}"></script>
|
|
||||||
</body>
|
|
Loading…
Add table
Add a link
Reference in a new issue