diff --git a/haitidata/context_processors/__init__.py b/haitidata/context_processors/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/haitidata/context_processors/clipped_geotiff.py b/haitidata/context_processors/clipped_geotiff.py new file mode 100644 index 0000000..745545d --- /dev/null +++ b/haitidata/context_processors/clipped_geotiff.py @@ -0,0 +1,13 @@ +from os.path import basename, splitext +from os import walk +from django.conf import settings + + +def clipped_geotiff(request): + geotiff_filename = [] + for (dirpath, dirnames, filenames) in walk( + settings.CLIPPED_DIRECTORY): + filenames = splitext(filenames[0]) + geotiff_filename.append(filenames[0]) + + return {'CLIPPED_LAYERNAME': geotiff_filename} diff --git a/haitidata/context_processors/project_setting.py b/haitidata/context_processors/project_setting.py new file mode 100644 index 0000000..8948eb1 --- /dev/null +++ b/haitidata/context_processors/project_setting.py @@ -0,0 +1,5 @@ +from django.conf import settings # import the settings file + + +def project_setting(request): + return {'GEOSERVER_BASE_URL': settings.GEOSERVER_BASE_URL} diff --git a/haitidata/templates/clip-and-ship/clip-page.html b/haitidata/templates/clip-and-ship/clip-page.html new file mode 100644 index 0000000..4002173 --- /dev/null +++ b/haitidata/templates/clip-and-ship/clip-page.html @@ -0,0 +1,41 @@ +{% extends "site_base.html" %} +{% load leaflet_tags %} +{% load staticfiles %} + + +{% block title %}{{ block.super }}{% endblock %} +{% block page-title %}{{ geotiffname }}{% endblock %} + +{% block body_class %}layers{% endblock %} + +{% block body_outer %} +
+ + + + +{% endblock %} + +{% block extra_script %} + {% leaflet_js %} + {% leaflet_css %} + + + + + {% include 'clip-and-ship/download-clip.html' %} +{% endblock extra_script %} diff --git a/haitidata/templates/clip-and-ship/download-clip.html b/haitidata/templates/clip-and-ship/download-clip.html new file mode 100644 index 0000000..7d16d0e --- /dev/null +++ b/haitidata/templates/clip-and-ship/download-clip.html @@ -0,0 +1,156 @@ +{% load staticfiles %} + + + + + diff --git a/haitidata/utils.py b/haitidata/utils.py new file mode 100644 index 0000000..ca8b373 --- /dev/null +++ b/haitidata/utils.py @@ -0,0 +1,22 @@ +# coding=utf-8 + +"""Helpers for settings.""" +import os + +# Absolute filesystem path to the Django project directory: +DJANGO_ROOT = os.path.dirname( + os.path.dirname( + os.path.dirname(os.path.abspath(__file__)) + )) + + +def absolute_path(*args): + """Get an absolute path for a file that is relative to the django root. + + :param args: List of path elements. + :type args: list + + :returns: An absolute path. + :rtype: str + """ + return os.path.join(DJANGO_ROOT, *args)