Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(file-uploader): Updated @uploadcare/blocks to @uploadcare/file-u… #296

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading