Skip to content

Commit

Permalink
Switch to ESM and Baseline2024
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Oct 29, 2024
1 parent b852632 commit 368999b
Show file tree
Hide file tree
Showing 15 changed files with 1,157 additions and 309 deletions.
52 changes: 35 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,45 @@ jobs:
dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: actions/checkout@v4
- run: python -m pip install --upgrade pip build wheel twine
- run: python -m build --sdist --wheel
- run: python -m twine check dist/*

standardjs:
js-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '14.x'
node-version-file: .nvmrc
- name: Install Node dependencies
run: npm ci
- run: npm run lint:js


js-test:
runs-on: ubuntu-latest
needs:
- js-lint
steps:
- uses: actions/checkout@v4
- id: cache-npm
uses: actions/cache@v4
- uses: actions/setup-node@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
node-version-file: .nvmrc
- name: Install Node dependencies
run: npm ci
- run: npm run lint:js
- run: node --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.txt
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: javascript
file: lcov.txt

lint:
py-lint:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -59,20 +71,19 @@ jobs:

pytest:
needs:
- lint
- standardjs
- py-lint
- dist
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
django-version:
- "3.2"
- "4.2"
- "5.0"
- "5.1"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -90,12 +101,16 @@ jobs:
curl -qO "https://chromedriver.storage.googleapis.com/$(curl -q https://chromedriver.storage.googleapis.com/LATEST_RELEASE)/chromedriver_linux64.zip"
unzip chromedriver_linux64.zip -d bin
- run: python -m pip install .[test] codecov
- run: python -m pip install .[test]
- run: python -m pip install django~=${{ matrix.django-version }}.0
- run: python -m pytest -m "not selenium"
env:
PATH: $PATH:$(pwd)/bin
- run: codecov
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: python


selenium:
needs:
Expand All @@ -120,6 +135,9 @@ jobs:
- run: python -m pip install -e .[test]
- run: python -m pytest -m selenium
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: selenium


analyze:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ htmlcov/
.cache
nosetests.xml
coverage.xml
lcov.txt

# Translations
*.mo
Expand Down
49 changes: 1 addition & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,59 +140,12 @@ to your CORS policy.
]
```

### Progress Bar

S3File does emit progress signals that can be used to display some kind
of progress bar. Signals named `progress` are emitted for both each
individual file input as well as for the form as a whole.

The progress signal carries the following details:

```javascript
console.log(event.detail)

{
progress: 0.4725307607171312 // total upload progress of either a form or single input
loaded: 1048576 // total upload progress of either a form or single input
total: 2219064 // total bytes to upload
currentFile: File {…} // file object
currentFileName: "text.txt" // file name of the file currently uploaded
currentFileProgress: 0.47227834703299176 // upload progress of that file
originalEvent: ProgressEvent {…} // the original XHR onprogress event
}
```

The following example implements a Boostrap progress bar for upload
progress of an entire form.

```html
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
</div>
```

```javascript
(function () {
var form = document.getElementsByTagName('form')[0]
var progressBar = document.getElementsByClassName('progress-bar')[0]

form.addEventListener('progress', function (event) {
// event.detail.progress is a value between 0 and 1
var percent = Math.round(event.detail.progress * 100)

progressBar.setAttribute('style', 'width:' + percent + '%')
progressBar.setAttribute('aria-valuenow', percent)
progressBar.innerText = percent + '%'
})
})()
```

### Using S3File in development

Using S3File in development can be helpful especially if you want to use
the progress signals described above. Therefore, S3File comes with a AWS
S3 dummy backend. It behaves similar to the real S3 storage backend. It
is automatically enabled, if the `DEFAULT_FILE_STORAGE` setting is set
is automatically enabled, if the `STORAGES["default"]` setting is set
to `FileSystemStorage`.

To prevent users from accidentally using the `FileSystemStorage` and the
Expand Down
Loading

0 comments on commit 368999b

Please sign in to comment.