Skip to content

Commit

Permalink
Merge pull request #5098 from camptocamp/move-apihelp
Browse files Browse the repository at this point in the history
Move the apihelp to the static folder and move the static folder to t…
  • Loading branch information
sbrunner authored Jun 27, 2019
2 parents 9e724eb + 3d7b16a commit c2c740e
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 126 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ APPS_SASS_FILES_ALT += $(addprefix $(APPS_PACKAGE_PATH_ALT)/static-ngeo/js/apps/
APPS_SASS_FILES_ALT += $(addprefix $(APPS_PACKAGE_PATH_ALT)/static-ngeo/js/apps/sass/vars_, $(addsuffix .scss, $(APPS_ALT)))
APPS_FILES_ALT = $(APPS_HTML_FILES_ALT) $(APPS_JS_FILES_ALT) $(APPS_SASS_FILES_ALT)

API_FILES = $(APPS_PACKAGE_PATH)/static-ngeo/api/api.css $(APPS_PACKAGE_PATH)/static-ngeo/api/apihelp
API_FILES = $(APPS_PACKAGE_PATH)/static-ngeo/api/api.css $(APPS_PACKAGE_PATH)/static/apihelp

.PHONY: build
build: \
Expand Down Expand Up @@ -194,18 +194,18 @@ $(APPS_PACKAGE_PATH)/static-ngeo/api/api.css: /usr/lib/node_modules/ngeo/api/src
mkdir --parent $(dir $@)
cp $< $@

$(APPS_PACKAGE_PATH)/static-ngeo/api/apihelp: /usr/lib/node_modules/ngeo/api/dist/apihelp
$(APPS_PACKAGE_PATH)/static/apihelp: /usr/lib/node_modules/ngeo/api/dist/apihelp
rm --recursive --force $@
cp -r $< $@
mv $@/apihelp.html $@/index.html.tmpl_tmpl
sed -i -e 's#https://geomapfish-demo-2-4.camptocamp.com/#$${VISIBLE_WEB_PROTOCOL}://$${VISIBLE_WEB_HOST}$${VISIBLE_ENTRY_POINT}#g' $@/index.html.tmpl_tmpl
sed -i -e 's#var map = new demo.Map#var map = new {{package}}.Map#g' $@/index.html.tmpl_tmpl
sed -i -e 's#\.\./api\.js#../api.js?version=2#g' $@/index.html.tmpl_tmpl
sed -i -e 's#github\.css#../static-ngeo/api/apihelp/github.css#g' $@/index.html.tmpl_tmpl
sed -i -e 's#rainbow-custom\.min\.js#../static-ngeo/api/apihelp/rainbow-custom.min.js#g' $@/index.html.tmpl_tmpl
sed -i -e 's#"data\.txt"#"../static-ngeo/api/apihelp/data.txt"#g' $@/index.html.tmpl_tmpl
sed -i -e "s#'data\.txt'#'../static-ngeo/api/apihelp/data.txt'#g" $@/index.html.tmpl_tmpl
sed -i -e 's#img/#../static-ngeo/api/apihelp/img/#g' $@/index.html.tmpl_tmpl
sed -i -e 's#github\.css#../static/apihelp/github.css#g' $@/index.html.tmpl_tmpl
sed -i -e 's#rainbow-custom\.min\.js#../static/apihelp/rainbow-custom.min.js#g' $@/index.html.tmpl_tmpl
sed -i -e 's#"data\.txt"#"../static/apihelp/data.txt"#g' $@/index.html.tmpl_tmpl
sed -i -e "s#'data\.txt'#'../static/apihelp/data.txt'#g" $@/index.html.tmpl_tmpl
sed -i -e 's#img/#../static/apihelp/img/#g' $@/index.html.tmpl_tmpl

.PRECIOUS: geoportal/c2cgeoportal_geoportal/scaffolds%update/CONST_create_template/
geoportal/c2cgeoportal_geoportal/scaffolds%update/CONST_create_template/: \
Expand Down
2 changes: 1 addition & 1 deletion doc/integrator/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ In the file ``geoportal/demo_geoportal/static-ngeo/api/index.js`` you can custom
config.extent = [<the map extent>];
config.backgroundLayer = '<the background layer name>';
The API help is in the folder ``geoportal/<package>_geoportal/static-ngeo/api/apihelp/``.
The API help is in the folder ``geoportal/<package>_geoportal/static/apihelp/``.
8 changes: 3 additions & 5 deletions geoportal/c2cgeoportal_geoportal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,6 @@ def handle(event: InvalidateCacheEvent): # pylint: disable=unused-variable
add_mako_renderer(config, ".html")
add_mako_renderer(config, ".js")

package = config.get_settings()["package"]

# Add the "geojson" renderer
config.add_renderer("geojson", GeoJSON())

Expand Down Expand Up @@ -446,7 +444,7 @@ def add_api_route(name: str, attr: str, path: str, renderer: str):
add_api_route('favicon', 'favicon', '/favicon.ico', 'js/apps/image/favicon.ico')
add_api_route('apijsmap', 'apijsmap', '/api.js.map', "api.js.map")
add_api_route('apicss', 'apicss', '/api.css', "api.css")
add_api_route('apihelp', 'apihelp', '/apihelp/index.html', "api/apihelp/index.html")
add_api_route('apihelp', 'apihelp', '/apihelp/index.html', "apihelp/index.html")
c2cgeoportal_geoportal.views.add_redirect(
config, 'apihelp_redirect', '/apihelp.html', '/apihelp/index.html'
)
Expand Down Expand Up @@ -564,10 +562,10 @@ def add_api_route(name: str, attr: str, path: str, renderer: str):
from c2cgeoportal_geoportal.lib.cacheversion import version_cache_buster
config.add_static_view(
name="static",
path="{}_geoportal:static".format(package),
path="/etc/geomapfish/static",
cache_max_age=int(config.get_settings()["default_max_age"]),
)
config.add_cache_buster("{}_geoportal:static".format(package), version_cache_buster)
config.add_cache_buster("/etc/geomapfish/static", version_cache_buster)

# Add the project static view without cache buster
config.add_static_view(
Expand Down
2 changes: 1 addition & 1 deletion geoportal/c2cgeoportal_geoportal/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_url2(name, url, request, errors):
proj = url_split.netloc
package = request.registry.settings["package"]
if proj == "":
proj = "{}_geoportal:static".format(package)
proj = "/etc/geomapfish/static"
elif ":" not in proj:
if proj == "static-ngeo":
errors.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
!geoportal/vars*.yaml
!geoportal/CONST_vars.yaml
!geoportal/CONST_config-schema.yaml
!geoportal/{{package}}_geoportal/static
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ RUN mv /tmp/config/bin/* /usr/bin/ && \
if [ -e /tmp/config/front_dev ]; then mv /tmp/config/front_dev /etc/haproxy_dev; fi && \
mkdir --parent /usr/local/tomcat/webapps/ROOT/ && \
if [ -e /tmp/config/print ]; then mv /tmp/config/print/print-apps /usr/local/tomcat/webapps/ROOT/; fi && \
chmod g+w -R /etc /usr/local/tomcat/webapps && \
cd /tmp/config/geoportal && \
mkdir --parent /etc/geomapfish/ && \
c2c-template --vars ${VARS_FILE} --get-config /tmp/_config.yaml ${CONFIG_VARS} && \
pykwalify --data-file /tmp/_config.yaml --schema-file CONST_config-schema.yaml && \
mv /tmp/_config.yaml /etc/geomapfish/config.yaml && \
mv /tmp/config/geoportal/{{package}}_geoportal/static /etc/geomapfish/ && \
chmod g+w -R /etc /usr/local/tomcat/webapps && \
adduser www-data root

VOLUME /etc/geomapfish \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ Dockerfile
vars*.yaml
CONST_vars.yaml
CONST_config-schema.yaml
{{package}}_geoportal/static

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ COPY --from=builder /usr/lib/node_modules/ngeo/dist/* \
COPY --from=builder /etc/static-ngeo/* /etc/static-ngeo/
COPY --from=builder /app/alembic.ini /app/alembic.yaml ./
RUN chmod go+w /etc/static-ngeo/ \
/app/{{package}}_geoportal/static-ngeo/api/apihelp/ \
/app/{{package}}_geoportal/locale/ \
/app/{{package}}_geoportal/locale/*/LC_MESSAGES/{{package}}_geoportal-client.po

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ upgrade_files:
- CONST_Makefile
- CONST_vars.yaml
- project.yaml.mako
- geoportal/{{package}}_geoportal/static/apihelp/images
- action: move
from: Makefile
to: geoportal/Makefile
Expand Down Expand Up @@ -113,3 +114,22 @@ upgrade_files:
- action: move
from: scripts/deploy-docker
to: scripts/publish-docker
- action: move
from: geoportal/{{package}}_geoportal/static-ngeo/api/apihelp/index.html
to: geoportal/{{package}}_geoportal/static/apihelp/index.html
- action: move
from: geoportal/{{package}}_geoportal/static-ngeo/api/apihelp/rainbow-custom.min.js
to: geoportal/{{package}}_geoportal/static/apihelp/rainbow-custom.min.js
- action: move
from: geoportal/{{package}}_geoportal/static-ngeo/api/apihelp/github.css
to: geoportal/{{package}}_geoportal/static/apihelp/github.css
- action: move
from: geoportal/{{package}}_geoportal/static-ngeo/api/apihelp/data.txt
to: geoportal/{{package}}_geoportal/static/apihelp/data.txt
- action: move
from: geoportal/{{package}}_geoportal/static-ngeo/api/apihelp/img
to: geoportal/{{package}}_geoportal/static/apihelp/img
- action: remove
paths:
- geoportal/{{package}}_geoportal/static/apihelp/track0.gpx
- geoportal/{{package}}_geoportal/static-ngeo/api/apihelp/
2 changes: 1 addition & 1 deletion geoportal/c2cgeoportal_geoportal/views/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ def _themes(self, interface="desktop", filter_themes=True, min_levels=1):
"The Theme '{}'".format(theme.name),
theme.icon, self.request, errors,
) if theme.icon is not None and len(theme.icon) > 0 else self.request.static_url(
"{}_geoportal:static/images/blank.png".format(self.request.registry.settings["package"])
"/etc/geomapfish/static/images/blank.png"
)

t = {
Expand Down
2 changes: 1 addition & 1 deletion geoportal/tests/functional/test_themes_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def static_url(url, **kwargs):
"time": "10:36:28",
"datetime": "2003-09-25T10:36:28",
"url1": "http://example.com/hi?a=b#c",
"url2": "http://dummy.org/tests_geoportal:static/path/icon.png",
"url2": "http://dummy.org//etc/geomapfish/static/path/icon.png",
"url3": "http://dummy.org/tests_geoportal:static/path/icon.png",
"url4": "http://dummy.org/tests_geoportal:cgxp/path/icon.png",
"url5": "http://dummy.org/project:static/path/icon.png",
Expand Down
Loading

0 comments on commit c2c740e

Please sign in to comment.