Skip to content

Commit

Permalink
Merge pull request #4 from datopian/sync
Browse files Browse the repository at this point in the history
Finish automation (update html with paths to bundles)
  • Loading branch information
zelima authored Nov 10, 2020
2 parents b6c87d9 + dacfb15 commit 02fde97
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions ckanext/datapub/templates/datapub/snippets/upload_module.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{RESOURCES}}

<div id="ResourceEditor"
data-dataset-id="{{ pkg_name }}"
data-api="{{ base_url }}"
data-lfs="{{ h.extstorage_lfs_url() }}"
data-auth-token="{{ api_key }}"
data-organization-id="{{ h.extstorage_organization_name(pkg_name) }}"
data-resource-id="{{ resource_id }}">
</div>
19 changes: 12 additions & 7 deletions sync.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
git clone [email protected]: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

0 comments on commit 02fde97

Please sign in to comment.