Skip to content

Commit

Permalink
Merge pull request #296 from uploadcare/feat/update-file-uploader
Browse files Browse the repository at this point in the history
feat(file-uploader): Updated @uploadcare/blocks to @uploadcare/file-u…
  • Loading branch information
rsedykh authored Sep 24, 2024
2 parents 114d177 + ef90940 commit f80dfc5
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 76 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a
Changelog](https://keepachangelog.com/en/1.0.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [6.0.0](https://github.com/uploadcare/pyuploadcare/compare/v5.1.0...v6.0.0) - 2024-09-19

### Changed
- [File Uploader](https://github.com/uploadcare/file-uploader) have been updated to [v1](https://github.com/uploadcare/file-uploader/releases)

## [5.1.0](https://github.com/uploadcare/pyuploadcare/compare/v5.0.1...v5.1.0) - 2024-04-09

### Added
Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ run_django:

update_bundled_static:
blocks_version=$$(DJANGO_SETTINGS_MODULE=tests.test_project.settings poetry run python -c "from pyuploadcare.dj.conf import DEFAULT_CONFIG; print(DEFAULT_CONFIG['widget']['version'])"); \
curl "https://cdn.jsdelivr.net/npm/@uploadcare/blocks@$${blocks_version}/web/blocks.min.js" -o pyuploadcare/dj/static/uploadcare/blocks.min.js; \
curl "https://cdn.jsdelivr.net/npm/@uploadcare/blocks@$${blocks_version}/web/lr-file-uploader-inline.min.css" -o pyuploadcare/dj/static/uploadcare/lr-file-uploader-inline.min.css; \
curl "https://cdn.jsdelivr.net/npm/@uploadcare/blocks@$${blocks_version}/web/lr-file-uploader-minimal.min.css" -o pyuploadcare/dj/static/uploadcare/lr-file-uploader-minimal.min.css; \
curl "https://cdn.jsdelivr.net/npm/@uploadcare/blocks@$${blocks_version}/web/lr-file-uploader-regular.min.css" -o pyuploadcare/dj/static/uploadcare/lr-file-uploader-regular.min.css
curl "https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@$${blocks_version}/web/file-uploader.min.js" -o pyuploadcare/dj/static/uploadcare/file-uploader.min.js; \
curl "https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@$${blocks_version}/web/uc-file-uploader-inline.min.css" -o pyuploadcare/dj/static/uploadcare/uc-file-uploader-inline.min.css; \
curl "https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@$${blocks_version}/web/uc-file-uploader-minimal.min.css" -o pyuploadcare/dj/static/uploadcare/uc-file-uploader-minimal.min.css; \
curl "https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@$${blocks_version}/web/uc-file-uploader-regular.min.css" -o pyuploadcare/dj/static/uploadcare/uc-file-uploader-regular.min.css



23 changes: 14 additions & 9 deletions docs/django-widget.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Below is the full default configuration:
"use_legacy_widget": False,
"use_hosted_assets": True,
"widget": {
"version": "0.36.0",
"version": "1",
"variant": "regular",
"build": "min",
"options": {},
Expand All @@ -58,17 +58,22 @@ PyUploadcare takes assets from CDN by default, e.g.:

.. code-block:: html

<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@1/web/uc-file-uploader-regular.min.css"
>


<script type="module">
import * as LR from "https://cdn.jsdelivr.net/npm/@uploadcare/[email protected]/web/blocks.min.js";
LR.registerBlocks(LR);
import * as UC from "https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@1/web/file-uploader.min.js";
UC.defineComponents(UC);
</script>

<!-- ... -->

<lr-file-uploader-inline
css-src="https://cdn.jsdelivr.net/npm/@uploadcare/[email protected]/web/lr-file-uploader-regular.min.css"
<uc-file-uploader-inline
ctx-name="my-uploader"
></lr-file-uploader-inline>
></uc-file-uploader-inline>

If you don't want to use hosted assets you have to turn off this feature:

Expand All @@ -91,9 +96,9 @@ widget url:
"widget": {
"override_js_url": "http://path.to/your/blocks.js",
"override_css_url": {
"regular": "http://path.to/your/lr-file-uploader-regular.css",
"inline": "http://path.to/your/lr-file-uploader-inline.css",
"minimal": "http://path.to/your/lr-file-uploader-minimal.css",
"regular": "http://path.to/your/uc-file-uploader-regular.css",
"inline": "http://path.to/your/uc-file-uploader-inline.css",
"minimal": "http://path.to/your/uc-file-uploader-minimal.css",
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,5 @@ In version 5.0, we introduce a new `file uploader`_, which is now the default fo
Additionally, please take note that some settings have been renamed in this update. For example, ``UPLOADCARE["widget_version"]`` has been changed to ``UPLOADCARE["legacy_widget"]["version"]``. You can find the full list of these changes in the `changelog for version 5.0.0`_.

.. _file uploader: https://uploadcare.com/docs/file-uploader/
.. _@uploadcare/blocks: https://www.npmjs.com/package/@uploadcare/blocks
.. _@uploadcare/file-uploader: https://www.npmjs.com/package/@uploadcare/file-uploader
.. _changelog for version 5.0.0: https://github.com/uploadcare/pyuploadcare/blob/main/HISTORY.md#500---2023-12-28
24 changes: 13 additions & 11 deletions pyuploadcare/dj/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class SettingsType(typing_extensions.TypedDict):
"use_legacy_widget": False,
"use_hosted_assets": True,
"widget": {
"version": "0.36.0",
"version": "1",
"variant": "regular",
"build": "min",
"options": {},
Expand Down Expand Up @@ -131,12 +131,13 @@ def get_legacy_widget_js_url() -> str:

def get_widget_js_url() -> str:
widget_config = config["widget"]
filename = "blocks.{0}.js".format(widget_config["build"]).replace(
"..", "."
)
hosted_url = "https://cdn.jsdelivr.net/npm/@uploadcare/blocks@{version}/web/{filename}".format(
version=widget_config["version"], filename=filename
)
filename = "file-uploader.{0}.min.js".format(
widget_config["build"]
).replace("..", ".")
hosted_url = (
"https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@{version}"
+ "/web/{filename}"
).format(version=widget_config["version"], filename=filename)
local_url = "uploadcare/{filename}".format(filename=filename)
override_url = widget_config["override_js_url"]
if override_url:
Expand All @@ -149,12 +150,13 @@ def get_widget_js_url() -> str:

def get_widget_css_url(variant: WidgetVariantType) -> str:
widget_config = config["widget"]
filename = "lr-file-uploader-{0}.{1}.css".format(
filename = "uc-file-uploader-{0}.{1}.min.css".format(
variant, widget_config["build"]
).replace("..", ".")
hosted_url = "https://cdn.jsdelivr.net/npm/@uploadcare/blocks@{version}/web/{filename}".format(
version=widget_config["version"], filename=filename
)
hosted_url = (
"https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@{version}"
+ "/web/{filename}"
).format(version=widget_config["version"], filename=filename)
local_url = "uploadcare/{filename}".format(filename=filename)
override_url = widget_config["override_css_url"][variant]
if override_url:
Expand Down
Loading

0 comments on commit f80dfc5

Please sign in to comment.