diff --git a/MANIFEST.in b/MANIFEST.in index 0e1e797..bc3778b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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 * diff --git a/README.md b/README.md index 9be0fbf..9a4f67f 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,30 @@ It would: data-resource-id="{{ resource_id }}"> ``` +## 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" %} + +
+
+``` \ No newline at end of file diff --git a/ckanext/datapub/fanstatic/webassets.yml b/ckanext/datapub/fanstatic/webassets.yml new file mode 100644 index 0000000..7029304 --- /dev/null +++ b/ckanext/datapub/fanstatic/webassets.yml @@ -0,0 +1,9 @@ +datapub-css: + output: datapub/main.css + contents: + - css/*.*.*.css +datapub-js: + output: datapub/main.js + contents: + - js/*.*.*.js + - js/*.*.js diff --git a/sync.sh b/sync.sh index 2a6b12d..e277fce 100644 --- a/sync.sh +++ b/sync.sh @@ -1,7 +1,8 @@ #!/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 @@ -9,9 +10,21 @@ wget https://raw.githubusercontent.com/johanhaleby/bash-templater/master/templat 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 ..