Skip to content

Commit

Permalink
Merge pull request #12 from datopian/feature/support-ckan-29
Browse files Browse the repository at this point in the history
Support for CKAN 2.9
  • Loading branch information
mariorodeghiero committed Apr 2, 2021
2 parents 438494c + 872faca commit b8ade88
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 6 deletions.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include README.md
include LICENSE
include requirements.txt
recursive-include ckanext/datapub *.html *.json *.js *.less *.css *.mo
recursive-include ckanext/datapub/templates *
recursive-include ckanext/datapub/fanstatic *
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,30 @@ It would:
data-resource-id="{{ resource_id }}">
</div>
```
## CKAN >= 2.9 support

CKAN >= 2.9 uses webassets to manage all the bundles and the tag changed from `resource` to `asset`.

In order to build an `upload_module.html` that runs on CKAN >= 2.9 you can pass `webassets` as third parameter.

Example:

```
sh sync.sh https://github.com/datopian/datapub master webassets
```

This will create an `upload_module.html` like the following one:

```html
{% asset "datapub/datapub-js" %}
{% asset "datapub/datapub-css" %}

<div id="ResourceEditor"
data-dataset-id="{{ pkg_name }}"
data-api="{{ base_url }}"
data-lfs="{{ h.blob_storage_lfs_url() }}"
data-auth-token="{{ api_key }}"
data-organization-id="{{ h.blob_storage_organization_name(pkg_name) }}"
data-resource-id="{{ resource_id }}">
</div>
```
9 changes: 9 additions & 0 deletions ckanext/datapub/fanstatic/webassets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
datapub-css:
output: datapub/main.css
contents:
- css/*.*.*.css
datapub-js:
output: datapub/main.js
contents:
- js/*.*.*.js
- js/*.*.js
23 changes: 18 additions & 5 deletions sync.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
#!/bin/bash

DATAPUB_APP=${1:='https://github.com/datopian/datapub'}
DATAPUB_VERSION=${2:='master'}
DATAPUB_APP=${1-'https://github.com/datopian/datapub'}
DATAPUB_VERSION=${2-'master'}
TAG=${3-'resources'}
UPLOAD_MODULE_PATH=ckanext/datapub/templates/blob_storage/snippets/upload_module

git clone --branch $DATAPUB_VERSION $DATAPUB_APP datapub
wget https://raw.githubusercontent.com/johanhaleby/bash-templater/master/templater.sh

cd datapub
npm install . && npm run build
for x in $(ls build/static/js/*.js build/static/css/*.css); do
bundles=$bundles"\{\% resource \"${x}\" \%\}"\\n
done

if [ $TAG = 'webassets' ]
then
echo "Creating asset tags"
assets="datapub/datapub-js datapub/datapub-css"
for x in $assets; do
bundles=$bundles"\{\% asset \"${x}\" \%\}"\\n
done
else
echo "Creating resource tags"
for x in $(ls build/static/js/*.js build/static/css/*.css); do
bundles=$bundles"\{\% resource \"${x}\" \%\}"\\n
done
fi

cp -r build/static/* ../ckanext/datapub/fanstatic/
cd ..

Expand Down

0 comments on commit b8ade88

Please sign in to comment.