cleanup width / height
This commit is contained in:
24
pub.py
24
pub.py
@@ -5,6 +5,7 @@ import hashlib
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from functools import cache
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
|
|
||||||
@@ -37,18 +38,25 @@ def cache_length(ext):
|
|||||||
else:
|
else:
|
||||||
return '31536000'
|
return '31536000'
|
||||||
|
|
||||||
|
@cache
|
||||||
|
def current_keys():
|
||||||
|
print('Fetching existing keys in {}'.format(BUCKET))
|
||||||
|
existing = s3.list_objects_v2(Bucket=BUCKET)
|
||||||
|
keys = set([content['Key'] for content in existing['Contents']])
|
||||||
|
while existing['IsTruncated']:
|
||||||
|
existing = s3.list_objects_v2(Bucket=BUCKET, ContinuationToken=existing['NextContinuationToken'])
|
||||||
|
keys = keys.union(set([content['Key'] for content in existing['Contents']]))
|
||||||
|
|
||||||
|
return keys
|
||||||
|
|
||||||
def upload_file(filename, overwrite=True):
|
def upload_file(filename, overwrite=True):
|
||||||
print('Uploading {} to {}/{}'.format(filename, BUCKET, filename))
|
|
||||||
ext = filename.split('.')[-1]
|
ext = filename.split('.')[-1]
|
||||||
|
|
||||||
if not overwrite:
|
if not overwrite and filename in current_keys():
|
||||||
try:
|
print('Skipping existing key {}'.format(filename))
|
||||||
existing = s3.get_object(Bucket=BUCKET, Key=filename)
|
return
|
||||||
print('\tSkipping existing key ', filename)
|
|
||||||
return
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
print('Uploading {} to {}/{}'.format(filename, BUCKET, filename))
|
||||||
s3.upload_file(filename, BUCKET, filename, ExtraArgs={
|
s3.upload_file(filename, BUCKET, filename, ExtraArgs={
|
||||||
'ACL': 'public-read',
|
'ACL': 'public-read',
|
||||||
'ContentType': TYPE_MAP[ext],
|
'ContentType': TYPE_MAP[ext],
|
||||||
|
|||||||
@@ -21,33 +21,24 @@ export class Root extends React.PureComponent<Props, State> {
|
|||||||
// innerWidth gets messed up when rotating phones from landscape -> portrait,
|
// innerWidth gets messed up when rotating phones from landscape -> portrait,
|
||||||
// and chrome seems to not report innerWidth correctly when scrollbars are present
|
// and chrome seems to not report innerWidth correctly when scrollbars are present
|
||||||
private _viewWidth = (): number => {
|
private _viewWidth = (): number => {
|
||||||
// iOS Safari does not set outerWidth/outerHeight
|
|
||||||
if (!window.outerWidth) {
|
|
||||||
return window.innerWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Math.min(
|
return Math.min(
|
||||||
window.innerWidth,
|
window.innerWidth,
|
||||||
window.outerWidth,
|
window.outerWidth || Infinity,
|
||||||
document.getElementById("mount")!.clientWidth
|
document.getElementById("mount")!.clientWidth || Infinity
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
private _viewHeight = (): number => {
|
|
||||||
// iOS Safari does not set outerWidth/outerHeight
|
|
||||||
if (!window.outerHeight) {
|
|
||||||
return window.innerHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private _viewHeight = (): number => {
|
||||||
return Math.min(
|
return Math.min(
|
||||||
window.innerHeight,
|
window.innerHeight,
|
||||||
window.outerHeight,
|
window.outerHeight || Infinity,
|
||||||
document.body.clientHeight
|
document.body.clientHeight || Infinity
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
state: State = {
|
state: State = {
|
||||||
gridHeights: [],
|
gridHeights: [],
|
||||||
pageBottom: window.innerHeight + window.pageYOffset,
|
pageBottom: this._viewHeight() + window.pageYOffset,
|
||||||
width: this._viewWidth(),
|
width: this._viewWidth(),
|
||||||
height: this._viewHeight()
|
height: this._viewHeight()
|
||||||
};
|
};
|
||||||
@@ -123,7 +114,7 @@ export class Root extends React.PureComponent<Props, State> {
|
|||||||
|
|
||||||
private _onViewChange = () => {
|
private _onViewChange = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
pageBottom: window.innerHeight + window.pageYOffset,
|
pageBottom: this._viewHeight() + window.pageYOffset,
|
||||||
width: this._viewWidth(),
|
width: this._viewWidth(),
|
||||||
height: this._viewHeight(),
|
height: this._viewHeight(),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user