diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-07-08 15:58:49 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-07-08 15:58:49 +0200 |
| commit | 2b8cf9e695414eb19104ab8bbff64673842b4202 (patch) | |
| tree | 60e2f4d2f6c8820e4812df99689a3738a39158c8 /animism-align | |
| parent | bbcf48825bec60dab7a4de955bc4831eadb37792 (diff) | |
fix timeline util issue
Diffstat (limited to 'animism-align')
| -rw-r--r-- | animism-align/cli/app/server/web.py | 2 | ||||
| -rw-r--r-- | animism-align/cli/app/settings/__pycache__/app_cfg.cpython-37.pyc | bin | 1531 -> 0 bytes | |||
| -rw-r--r-- | animism-align/frontend/util/index.js | 3 | ||||
| -rw-r--r-- | animism-align/frontend/views/align/align.util.js | 27 | ||||
| -rw-r--r-- | animism-align/frontend/views/align/containers/timeline.container.js | 2 | ||||
| -rw-r--r-- | animism-align/frontend/views/media/components/media.form.js | 36 |
6 files changed, 38 insertions, 32 deletions
diff --git a/animism-align/cli/app/server/web.py b/animism-align/cli/app/server/web.py index a20d40c..a0527ef 100644 --- a/animism-align/cli/app/server/web.py +++ b/animism-align/cli/app/server/web.py @@ -26,7 +26,7 @@ def create_app(script_info=None): functional pattern for creating the flask app """ logging.debug("Starting Flask app...") - + # print(app_cfg.SERVER_NAME) app = Flask(__name__, static_folder=app_cfg.DIR_STATIC, static_url_path='/static') app.config['SQLALCHEMY_DATABASE_URI'] = connection_url app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False diff --git a/animism-align/cli/app/settings/__pycache__/app_cfg.cpython-37.pyc b/animism-align/cli/app/settings/__pycache__/app_cfg.cpython-37.pyc Binary files differdeleted file mode 100644 index f153ad1..0000000 --- a/animism-align/cli/app/settings/__pycache__/app_cfg.cpython-37.pyc +++ /dev/null diff --git a/animism-align/frontend/util/index.js b/animism-align/frontend/util/index.js index a4a8537..d723910 100644 --- a/animism-align/frontend/util/index.js +++ b/animism-align/frontend/util/index.js @@ -49,7 +49,8 @@ export const pad = (n, m) => { } export const courtesyS = (n, s) => n + ' ' + (n === 1 ? s : s + 's') - +export const capitalize = s => s.split(' ').map(capitalizeWord).join(' ') +export const capitalizeWord = s => s.substr(0, 1).toUpperCase() + s.substr(1) export const padSeconds = n => n < 10 ? '0' + n : n export const timestamp = (n = 0, fps = 1, ms = false) => { diff --git a/animism-align/frontend/views/align/align.util.js b/animism-align/frontend/views/align/align.util.js index d7b4c39..91af64c 100644 --- a/animism-align/frontend/views/align/align.util.js +++ b/animism-align/frontend/views/align/align.util.js @@ -31,17 +31,22 @@ export const timeToPosition = (ts, { start_ts, zoom, duration }) => { } export const getFirstPunctuationMarkIndex = text => { - return Math.min( - text.indexOf('. '), - text.indexOf('? '), - text.indexOf('! '), - text.indexOf('." '), - text.indexOf('?" '), - text.indexOf('!" '), - text.indexOf('.” '), - text.indexOf('?” '), - text.indexOf('!” '), - ) + 1 + const indexes = [ + text.indexOf('. '), + text.indexOf('? '), + text.indexOf('! '), + text.indexOf('." '), + text.indexOf('?" '), + text.indexOf('!" '), + text.indexOf('.” '), + text.indexOf('?” '), + text.indexOf('!” '), + ] + + return indexes.reduce((a, b) => { + if (b < 0) return a + return Math.min(a, b) + }, Infinity) + 1 } export const cutFirstSentence = text => { diff --git a/animism-align/frontend/views/align/containers/timeline.container.js b/animism-align/frontend/views/align/containers/timeline.container.js index ba6b7e0..69f2496 100644 --- a/animism-align/frontend/views/align/containers/timeline.container.js +++ b/animism-align/frontend/views/align/containers/timeline.container.js @@ -85,7 +85,7 @@ class Timeline extends Component { let { deltaY } = e let secondsPerPixel = ZOOM_STEPS[zoom] * 0.1 // 0.1 sec / step let widthTimeDuration = INNER_HEIGHT * secondsPerPixel // secs per pixel - start_ts += Math.round((deltaY / 8) * ZOOM_STEPS[zoom]) + start_ts += Math.round((deltaY) * ZOOM_STEPS[zoom]) start_ts = clamp(start_ts, 0, Math.max(0, duration - widthTimeDuration / 2)) if (e.shiftKey) { if (Math.abs(deltaY) < 2) return diff --git a/animism-align/frontend/views/media/components/media.form.js b/animism-align/frontend/views/media/components/media.form.js index ed96e6e..848d1f8 100644 --- a/animism-align/frontend/views/media/components/media.form.js +++ b/animism-align/frontend/views/media/components/media.form.js @@ -2,12 +2,13 @@ import React, { Component } from 'react' import { Link } from 'react-router-dom' import { session } from '../../../session' +import { capitalize } from '../../../util' -import { TextInput, LabelDescription, TextArea, Checkbox, SubmitButton, Loader } from '../../../common' +import { TextInput, LabelDescription, Select, TextArea, Checkbox, SubmitButton, Loader } from '../../../common' const newMedia = () => ({ - type: '', - tag: '', + type: 'image', + tag: 'media', url: '', title: '', author: '', @@ -20,6 +21,10 @@ const newMedia = () => ({ settings: {}, }) +const MEDIA_TYPES = [ + 'image', 'video' +].map(name => ({ name, label: capitalize(name) })) + export default class MediaForm extends Component { state = { title: "", @@ -44,22 +49,8 @@ export default class MediaForm extends Component { } handleChange(e) { - const { errorFields } = this.state const { name, value } = e.target - if (errorFields.has(name)) { - errorFields.delete(name) - } - let sanitizedValue = value - if (name === 'path') { - sanitizedValue = sanitizedValue.toLowerCase().replace(/ /, '-').replace(/[!@#$%^&*()[\]{}]/, '-').replace(/-+/, '-') - } - this.setState({ - errorFields, - data: { - ...this.state.data, - [name]: sanitizedValue, - } - }) + this.handleSelect(name, value) } handleSelect(name, value) { @@ -107,10 +98,19 @@ export default class MediaForm extends Component { tag: '', url: '', */ + console.log(data) return ( <div className='form'> <h1>{title}</h1> <form onSubmit={this.handleSubmit.bind(this)}> + <Select + title='Media Type' + name='type' + selected={data.type} + options={MEDIA_TYPES} + onChange={this.handleSelect} + /> + <TextInput title="Author" name="author" |
