From dacfb15e05d1e8d524bd44bf89ce353e8a7bcb5f Mon Sep 17 00:00:00 2001 From: zelima Date: Tue, 10 Nov 2020 19:13:16 +0400 Subject: [PATCH] Finish automation (update html with paths to bundles) --- README.md | 13 ------------- .../datapub/snippets/upload_module.template | 10 ++++++++++ sync.sh | 19 ++++++++++++------- 3 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 ckanext/datapub/templates/datapub/snippets/upload_module.template diff --git a/README.md b/README.md index 0134673..f27cf25 100644 --- a/README.md +++ b/README.md @@ -21,21 +21,8 @@ It would: * build * update JS modules in fanstatic -Next, you need to update the template to include correct bundles. In `/templates/datapub/snippets/upload_module.html`, edit the file names of the modules. - **Note:** -- If you are importing a component from the datapub library, when running `yarn build` will generate two CSS files. Both of these CSS files should be added In `/templates/datapub/snippets/upload_module.html` be able to render external components imported. - -e.g. -``` -{% resource 'datapub/css/2.13e0d705.chunk.css' %} -{% resource 'datapub/css/main.c6297111.chunk.css' %} -{% resource 'datapub/js/runtime-main.95a62798.js' %} -{% resource 'datapub/js/2.bfcaf294.chunk.js' %} -{% resource 'datapub/js/main.d1dbf6f8.chunk.js' %} -``` - - if you are developing a React app, e.g., custom `datapub` app, you can use the following attributes passed from the `/templates/datapub/snippets/upload_module.html`: ```html diff --git a/ckanext/datapub/templates/datapub/snippets/upload_module.template b/ckanext/datapub/templates/datapub/snippets/upload_module.template new file mode 100644 index 0000000..9990f34 --- /dev/null +++ b/ckanext/datapub/templates/datapub/snippets/upload_module.template @@ -0,0 +1,10 @@ +{{RESOURCES}} + +
+
diff --git a/sync.sh b/sync.sh index 402d7aa..ab9180f 100644 --- a/sync.sh +++ b/sync.sh @@ -1,7 +1,12 @@ -git clone git@github.com:datopian/datapub.git -cd datapub -yarn -yarn build -cd - -rm -r ckanext/datapub/fanstatic/**/* -cp -r datapub/build/static/* ckanext/datapub/fanstatic/ +DATAPUB_APP={$DATAPUB_APP:=https://github.com/datopian/datapub} +git clone $DATAPUB_APP‌ +cd datapub-gdx && npm install . && npm run build +cd datapub-gdx +wget https://raw.githubusercontent.com/johanhaleby/bash-templater/master/templater.sh +for x in $(ls build/static/js/*.js build/static/css/*.css); do + bundles=$bundles"\{\% resource $x \%\}"\\n +done + +cp -r build/static/* datapub/fanstatic/ +export RESOURCES=$(python -c "import sys;print(sys.argv[1].replace('build/static','datapub/fanstatic'))" "$bundles") +bash templater.sh ../ckanext/datapub/templates/datapub/snippets/upload_module.template > ../ckanext/datapub/templates/datapub/snippets/upload_module.html