Skip to content

Commit

Permalink
Move the apihelp to the static folder and move the static folder to t…
Browse files Browse the repository at this point in the history
…he config
  • Loading branch information
sbrunner committed Jun 27, 2019
1 parent 38ceade commit 185d8ef
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 14 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/``.
6 changes: 3 additions & 3 deletions geoportal/c2cgeoportal_geoportal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,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 +564,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 @@ -31,6 +31,7 @@ RUN mv /tmp/config/bin/* /usr/bin/ && \
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/ && \
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
geoportal/static
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
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

0 comments on commit 185d8ef

Please sign in to comment.