Merge pull request #34 from mjanez/patch/resourcedictionary

Patch/resourcedictionary
This commit is contained in:
mjanez 2023-04-19 13:14:08 +02:00 committed by GitHub
commit 75b7e7378c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 107 additions and 40 deletions

View File

View File

@ -1,4 +1,4 @@
name: Build & Push CKAN-Spatial Docker master image name: Build & Push ckan-spatial - master
on: on:
# Trigger the workflow after build.yml # Trigger the workflow after build.yml

View File

@ -1,4 +1,4 @@
name: Build & Push ckan-spatial Tag image name: Build & Push ckan-spatial - ckan-*.*.*
on: on:
push: push:

3
.gitignore vendored
View File

@ -11,3 +11,6 @@ local/*
__pycache__ __pycache__
log log
metadata metadata
# environment
.env

View File

@ -57,7 +57,7 @@ Optional HTTP Endpoint ([`docker-compose.nginx.yml`](/docker-compose.nginx.yml))
| [`docker-compose.nginx.yml`](/docker-compose.nginx.yml) | NGINX 1.22.1 | base image | [`nginx:stable-alpine`](https://hub.docker.com/layers/library/nginx/stable-alpine/images/sha256-ff2a5d557ca22fa93669f5e70cfbeefda32b98f8fd3d33b38028c582d700f93a?context=explore) | 9.74 MB | No routing, only CKAN. Custom Dockerfile: [`nginx/Dockerfile`](/nginx/Dockerfile) | | [`docker-compose.nginx.yml`](/docker-compose.nginx.yml) | NGINX 1.22.1 | base image | [`nginx:stable-alpine`](https://hub.docker.com/layers/library/nginx/stable-alpine/images/sha256-ff2a5d557ca22fa93669f5e70cfbeefda32b98f8fd3d33b38028c582d700f93a?context=explore) | 9.74 MB | No routing, only CKAN. Custom Dockerfile: [`nginx/Dockerfile`](/nginx/Dockerfile) |
The site is configured using environment variables that you can set in the `.env` file for an Apache HTTP Server and ckan-pycsw deployment, or replace it with the [`.env.nginx.example`](/samples/.env.nginx.example) for a NGINX and CKAN-only deployment using the Docker Compose file: [`docker-compose.nginx.yml`](/docker-compose.nginx.yml). The site is configured using environment variables that you can set in the `.env` file for an Apache HTTP Server and ckan-pycsw deployment (default `.env.example`), or replace it with the [`.env.nginx.example`](/samples/.env.nginx.example) for a NGINX and CKAN-only deployment using the Docker Compose file: [`docker-compose.nginx.yml`](/docker-compose.nginx.yml).
### ckan-docker roadmap ### ckan-docker roadmap
@ -170,45 +170,49 @@ docker compose [-p <my_project>] down
### Base mode ### Base mode
Use this if you are a maintainer and will not be making code changes to CKAN or to CKAN extensions. Use this if you are a maintainer and will not be making code changes to CKAN or to CKAN extensions.
Clone project 1. Clone project
```shell ```shell
cd /path/to/my/project cd /path/to/my/project
git clone https://github.com/mjanez/ckan-docker.git git clone https://github.com/mjanez/ckan-docker.git
``` ```
Modify [`.env`](/.env) depending on your own needs. 2. Copy the `.env.example` template (or use another from [`/samples/`](/samples/)) and modify the resulting `.env` to suit your needs.
- **Apache HTTP Server & CKAN/ckan-pycsw endpoints**: Modifiy the variables about the site URL or locations (`CKAN_SITE_URL` `CKAN_URL`, `PYCSW_URL`, `CKANEXT__DCAT__BASE_URI`, `APACHE_SERVER_NAME`, `APACHE_CKAN_LOCATION`, `APACHE_PYCSW_LOCATION`, etc.). ```shell
cp .env.example .env
```
- **NGINX only CKAN**: Replace the [`.env`](/.env) with the [`.env.nginx.example`](/samples/.env.nginx.example) and modify the variables as needed. - **Apache HTTP Server & CKAN/ckan-pycsw endpoints**: Modifiy the variables about the site URL or locations (`CKAN_SITE_URL` `CKAN_URL`, `PYCSW_URL`, `CKANEXT__DCAT__BASE_URI`, `APACHE_SERVER_NAME`, `APACHE_CKAN_LOCATION`, `APACHE_PYCSW_LOCATION`, etc.).
>**Note**:<br> - **NGINX only CKAN**: Replace the [`.env`](/.env) with the [`/samples/.env.nginx.example`](/samples/.env.nginx.example) and modify the variables as needed.
> Please note that when accessing CKAN directly (via a browser) ie: not going through Apache/NGINX you will need to make sure you have "ckan" set up to be an alias to localhost in the local hosts file. Either that or you will need to change the `.env` entry for `CKAN_SITE_URL`
>**Warning**:<br> >**Note**:<br>
> Using the default values on the `.env` file will get you a working CKAN instance. There is a sysadmin user created by default with the values defined in `CKAN_SYSADMIN_NAME` and `CKAN_SYSADMIN_PASSWORD`(`ckan_admin` and `test1234` by default). **This should be obviously changed before running this setup as a public CKAN instance.** > Please note that when accessing CKAN directly (via a browser) ie: not going through Apache/NGINX you will need to make sure you have "ckan" set up to be an alias to localhost in the local hosts file. Either that or you will need to change the `.env` entry for `CKAN_SITE_URL`
To build the images: >**Warning**:<br>
```bash > Using the default values on the `.env` file will get you a working CKAN instance. There is a sysadmin user created by default with the values defined in `CKAN_SYSADMIN_NAME` and `CKAN_SYSADMIN_PASSWORD`(`ckan_admin` and `test1234` by default). **This should be obviously changed before running this setup as a public CKAN instance.**
docker compose build
``` 3. Build the images:
>**Note**<br> ```bash
> NGINX CKAN without ckan-pycsw and Apache: docker compose build
>```bash ```
>docker compose -f docker-compose.nginx.yml build >**Note**<br>
>``` > NGINX CKAN without ckan-pycsw and Apache:
>```bash
>docker compose -f docker-compose.nginx.yml build
>```
To start the containers: 4. Start the containers:
```bash ```bash
docker compose up docker compose up
``` ```
>**Note**<br> >**Note**<br>
> NGINX CKAN without ckan-pycsw and Apache: > NGINX CKAN without ckan-pycsw and Apache:
>```bash >```bash
>docker compose -f docker-compose.nginx.yml up >docker compose -f docker-compose.nginx.yml up
>``` >```
This will start up the containers in the current window. By default the containers will log direct to this window with each container This will start up the containers in the current window. By default the containers will log direct to this window with each container
using a different colour. You could also use the -d "detach mode" option ie: `docker compose up -d` if you wished to use the current using a different colour. You could also use the -d "detach mode" option ie: `docker compose up -d` if you wished to use the current

View File

@ -15,9 +15,9 @@ RUN if ! [ /usr/share/zoneinfo/${TZ} -ef /etc/localtime ]; then \
### Harvester - v1.5.1 ### ### Harvester - v1.5.1 ###
### Geoview - v0.0.20 ### ### Geoview - v0.0.20 ###
### Spatial - v2.0.0 ### ### Spatial - v2.0.0 ###
### DCAT - master (GeoDCAT-AP extended version) ### ### DCAT - 1.0.0-geodcatap (GeoDCAT-AP extended version) ###
### Scheming - master (GeoDCAT-AP extended version) ### ### Scheming - 1.0.0-geodcatap (GeoDCAT-AP extended version) ###
### Resource dictionary (Fix version) - main ### ### Resource dictionary - 1.0.1 ###
### Pages - v0.5.1 ### ### Pages - v0.5.1 ###
### PDFView - v0.0.8 ### ### PDFView - v0.0.8 ###
RUN echo "ckan/ckanext-xloader" && \ RUN echo "ckan/ckanext-xloader" && \
@ -33,12 +33,12 @@ RUN echo "ckan/ckanext-xloader" && \
pip3 install -e 'git+https://github.com/ckan/ckanext-spatial.git@v2.0.0#egg=ckanext-spatial' && \ pip3 install -e 'git+https://github.com/ckan/ckanext-spatial.git@v2.0.0#egg=ckanext-spatial' && \
pip3 install -r https://raw.githubusercontent.com/ckan/ckanext-spatial/bae9290395b252ee8e40056256fa694569d1d78b/requirements.txt && \ pip3 install -r https://raw.githubusercontent.com/ckan/ckanext-spatial/bae9290395b252ee8e40056256fa694569d1d78b/requirements.txt && \
echo "mjanez/ckanext-dcat (GeoDCAT-AP extended version)" && \ echo "mjanez/ckanext-dcat (GeoDCAT-AP extended version)" && \
pip3 install -e git+https://github.com/mjanez/ckanext-dcat.git#egg=ckanext-dcat && \ pip3 install -e git+https://github.com/mjanez/ckanext-dcat.git@1.0.0-geodcatap#egg=ckanext-dcat && \
pip3 install -r https://raw.githubusercontent.com/mjanez/ckanext-dcat/master/requirements.txt && \ pip3 install -r https://raw.githubusercontent.com/mjanez/ckanext-dcat/master/requirements.txt && \
echo "mjanez/ckanext-scheming (GeoDCAT-AP extended version)" && \ echo "mjanez/ckanext-scheming (GeoDCAT-AP extended version)" && \
pip3 install -e git+https://github.com/mjanez/ckanext-scheming.git#egg=ckanext-scheming && \ pip3 install -e git+https://github.com/mjanez/ckanext-scheming.git@1.0.0-geodcatap#egg=ckanext-scheming && \
echo "mjanez/ckanext-resourcedictionary" && \ echo "mjanez/ckanext-resourcedictionary" && \
pip3 install -e 'git+https://github.com/mjanez/ckanext-resourcedictionary.git#egg=ckanext-resourcedictionary' && \ pip3 install -e 'git+https://github.com/mjanez/ckanext-resourcedictionary.git@1.0.1#egg=ckanext-resourcedictionary' && \
echo "ckan/ckanext-pages" && \ echo "ckan/ckanext-pages" && \
pip3 install -e git+https://github.com/ckan/ckanext-pages.git@v0.5.1#egg=ckanext-pages && \ pip3 install -e git+https://github.com/ckan/ckanext-pages.git@v0.5.1#egg=ckanext-pages && \
echo "ckan/ckanext-pdfview" && \ echo "ckan/ckanext-pdfview" && \

View File

@ -0,0 +1,60 @@
diff --git a/ckan/templates/package/resource_read.html b/ckan/templates/package/resource_read.html
index 7c8c6f9..6f2342a 100644
--- a/ckan/templates/package/resource_read.html
+++ b/ckan/templates/package/resource_read.html
@@ -40,12 +40,14 @@
<i class="fa fa-key"></i> {{ _('API Endpoint') }}
{% elif not res.has_views and not res.url_type == 'upload' %}
<i class="fa fa-external-link"></i> {{ _('Go to resource') }}
+ {% elif res.has_views and not res.url_type == 'upload' %}
+ <i class="fa fa-external-link"></i> {{ _('Go to resource') }}
{% else %}
<i class="fa fa-arrow-circle-o-down"></i> {{ _('Download') }}
{% endif %}
</a>
{% block download_resource_button %}
- {% if res.datastore_active %}
+ {% if res.datastore_active and res.url_type == 'datastore' %}
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
@@ -224,4 +226,4 @@
{% block resource_license %}
{% snippet "snippets/social.html" %}
{% endblock %}
-{% endblock %}
+{% endblock %}
\ No newline at end of file
diff --git a/ckanext/datastore/templates-bs2/package/resource_read.html b/ckanext/datastore/templates-bs2/package/resource_read.html
index 3c77876..1d856e0 100644
--- a/ckanext/datastore/templates-bs2/package/resource_read.html
+++ b/ckanext/datastore/templates-bs2/package/resource_read.html
@@ -2,7 +2,7 @@
{% block resource_actions_inner %}
{{ super() }}
- {% if res.datastore_active %}
+ {% if res.datastore_active and res.url_type == 'datastore' %}
<li>{% snippet 'package/snippets/data_api_button.html', resource=res %}</li>
{% endif %}
{% endblock %}
@@ -34,4 +34,4 @@
</div>
{% endif %}
{{ super() }}
-{% endblock %}
+{% endblock %}
\ No newline at end of file
diff --git a/ckanext/datastore/templates/package/resource_read.html b/ckanext/datastore/templates/package/resource_read.html
index 2e1fdef..9caad53 100644
--- a/ckanext/datastore/templates/package/resource_read.html
+++ b/ckanext/datastore/templates/package/resource_read.html
@@ -2,7 +2,7 @@
{% block resource_actions_inner %}
{{ super() }}
- {% if res.datastore_active %}
+ {% if res.datastore_active and res.url_type == 'datastore' %}
<li>{% snippet 'package/snippets/data_api_button.html', resource=res %}</li>
{% endif %}
{% endblock %}