From 16801f1b1442eb8706b8996a7cf370fc753a55ad Mon Sep 17 00:00:00 2001
From: Tor-Einar Skog <tor-einar.skog@nibio.no>
Date: Thu, 13 Jun 2024 14:42:02 +0200
Subject: [PATCH] Add FIBL app, support bespoke frontpage and layout

---
 VIPSWeb/local_settings_sample.py      |   6 ++
 VIPSWeb/settings.py                   |   1 +
 VIPSWeb/static/css/vipsweb.css        |   4 ++
 VIPSWeb/templates/base.html           |   4 +-
 fibl/__init__.py                      |   0
 fibl/admin.py                         |   3 +
 fibl/apps.py                          |   6 ++
 fibl/migrations/__init__.py           |   0
 fibl/models.py                        |   3 +
 fibl/static/fibl/css/fibl.css         |   7 +++
 fibl/static/fibl/images/fibl_logo.png | Bin 0 -> 1660 bytes
 fibl/templates/fibl/fibl_base.html    |  24 ++++++++
 fibl/templates/fibl/index.html        |  30 ++++++++++
 fibl/tests.py                         |   3 +
 fibl/urls.py                          |  80 ++++++++++++++++++++++++++
 fibl/views.py                         |  10 ++++
 16 files changed, 179 insertions(+), 2 deletions(-)
 create mode 100644 fibl/__init__.py
 create mode 100644 fibl/admin.py
 create mode 100644 fibl/apps.py
 create mode 100644 fibl/migrations/__init__.py
 create mode 100644 fibl/models.py
 create mode 100644 fibl/static/fibl/css/fibl.css
 create mode 100644 fibl/static/fibl/images/fibl_logo.png
 create mode 100644 fibl/templates/fibl/fibl_base.html
 create mode 100644 fibl/templates/fibl/index.html
 create mode 100644 fibl/tests.py
 create mode 100644 fibl/urls.py
 create mode 100644 fibl/views.py

diff --git a/VIPSWeb/local_settings_sample.py b/VIPSWeb/local_settings_sample.py
index 466a2c16..bb5d07d2 100755
--- a/VIPSWeb/local_settings_sample.py
+++ b/VIPSWeb/local_settings_sample.py
@@ -106,6 +106,12 @@ CACHES = {
 # Site name - appears in header of all pages. HTML is allowed
 SITE_NAME = "Example site title"
 
+# Path to the site's logo. 
+# E.g. "images/logo_vips_newest.png" -> /VIPSWeb/static/images/logo_vips_newest.png
+# E.g. "fibl/images/fibl_logo.png" -> /fibl/static/fibl_images/fibl_logo.png
+SITE_LOGO_PATH = "fibl/images/fibl_logo.png"
+
+
 # Insert Web Analytics Script?
 # Could have more than 1
 INSERT_WEB_ANALYTICS = False
diff --git a/VIPSWeb/settings.py b/VIPSWeb/settings.py
index ee36cbb4..f83623ba 100755
--- a/VIPSWeb/settings.py
+++ b/VIPSWeb/settings.py
@@ -154,6 +154,7 @@ INSTALLED_APPS = (
     'security',
     'spatial',
     'mock',
+    'fibl',
     'VIPSWeb'
 )
 
diff --git a/VIPSWeb/static/css/vipsweb.css b/VIPSWeb/static/css/vipsweb.css
index b2d983cf..c0e3b997 100755
--- a/VIPSWeb/static/css/vipsweb.css
+++ b/VIPSWeb/static/css/vipsweb.css
@@ -755,6 +755,10 @@ td.dateCell {
 	display: none;
 }
 
+div.containerBackground {
+	background-color: #d9e6e4;
+}
+
 #loginAndLanguageInfo {
 	position: absolute;
     top: 0px;
diff --git a/VIPSWeb/templates/base.html b/VIPSWeb/templates/base.html
index 77361848..84befff5 100755
--- a/VIPSWeb/templates/base.html
+++ b/VIPSWeb/templates/base.html
@@ -61,7 +61,7 @@
 	      <span class="icon-bar"></span>
 	      <span class="icon-bar"></span>
 	    </button>
-	    <a class="navbar-brand" href="/"><img src="{% static "images/logo_vips_newest.png" %}" alt="VIPS logo"/></a><span id="siteTitle" class="navbar-brand">{{settings.SITE_NAME|safe}}</span>
+	    <a class="navbar-brand" href="/"><img src="{% static settings.SITE_LOGO_PATH %}" alt="VIPS logo"/></a><span id="siteTitle" class="navbar-brand">{{settings.SITE_NAME|safe}}</span>
 	    {% if settings.SYSTEM_TIME_OFFSET_MONTHS != 0 or settings.SYSTEM_TIME_EXACT != None %}
 	    <span class="navbar-brand" style="margin-left: 0px; padding-left: 0px; padding-top: 15px; font-size: 0.8em">[{% get_system_time "%Y-%m-%d" %}]</span>
 	    {% endif %}
@@ -107,7 +107,7 @@
 		</div>
 	</nav>
 </div>
-<div style="background-color: #d9e6e4;">
+<div class="containerBackground">
 <div class="container" id="contentContainer" >
 	<div class="row">
 		<!-- Start contents container -->
diff --git a/fibl/__init__.py b/fibl/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/fibl/admin.py b/fibl/admin.py
new file mode 100644
index 00000000..8c38f3f3
--- /dev/null
+++ b/fibl/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/fibl/apps.py b/fibl/apps.py
new file mode 100644
index 00000000..db54cf93
--- /dev/null
+++ b/fibl/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class FiblConfig(AppConfig):
+    default_auto_field = 'django.db.models.BigAutoField'
+    name = 'fibl'
diff --git a/fibl/migrations/__init__.py b/fibl/migrations/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/fibl/models.py b/fibl/models.py
new file mode 100644
index 00000000..71a83623
--- /dev/null
+++ b/fibl/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/fibl/static/fibl/css/fibl.css b/fibl/static/fibl/css/fibl.css
new file mode 100644
index 00000000..f6b7cc02
--- /dev/null
+++ b/fibl/static/fibl/css/fibl.css
@@ -0,0 +1,7 @@
+body {
+    /*background-color: black;*/
+}
+
+div.containerBackground {
+	background-color: #bcd3dd;
+}
diff --git a/fibl/static/fibl/images/fibl_logo.png b/fibl/static/fibl/images/fibl_logo.png
new file mode 100644
index 0000000000000000000000000000000000000000..d96df21defdc289ca3124d3ba274411fd011fd58
GIT binary patch
literal 1660
zcmeAS@N?(olHy`uVBq!ia0y~yV3^6kz~Icm#=yYP|8x0g1_lO}VkgfK4h{~E8jh3>
z1_lPn64!{5;QX|b^2DN4hV;Dr+*IA-<f7EnyyA@flK0H}?HCvs^g)W8i&7IyGV}8k
zLNaqx8A|f?6by~^6tYV5G8K#rj7$`=bHF0TCJNdHMg|6_9`6)kU|_xM>EaktG3V`E
ze~;Vg636$;Hvci2#3ribtFm`Se3>DiR5l-1_YUW|!2yZvZ`aO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fibl_base.html
new file mode 100644
index 00000000..101980a4
--- /dev/null
+++ b/fibl/templates/fibl/fibl_base.html
@@ -0,0 +1,24 @@
+{% extends "base.html" %}
+{% load static %}
+{% comment %}
+
+#
+# Copyright (c) 2024 NIBIO <http://www.nibio.no/>. 
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+ 
+{% endcomment %}
+{% block extendCSS %}
+<link rel="stylesheet" href="{% static "fibl/css/fibl.css" %}">
+{% endblock %}
diff --git a/fibl/templates/fibl/index.html b/fibl/templates/fibl/index.html
new file mode 100644
index 00000000..9ceaa4a7
--- /dev/null
+++ b/fibl/templates/fibl/index.html
@@ -0,0 +1,30 @@
+{% extends "fibl/fibl_base.html" %}
+{% load static %}
+{% comment %}
+
+#
+# Copyright (c) 2024 NIBIO <http://www.nibio.no/>. 
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+ 
+{% endcomment %}
+{% load i18n l10n %}
+{% block title%}{% trans "FIBL" %}{%endblock%}
+{% block content %}
+Testing,testing
+{% endblock %}
+
+{% block customJS %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/fibl/tests.py b/fibl/tests.py
new file mode 100644
index 00000000..7ce503c2
--- /dev/null
+++ b/fibl/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/fibl/urls.py b/fibl/urls.py
new file mode 100644
index 00000000..542c94d4
--- /dev/null
+++ b/fibl/urls.py
@@ -0,0 +1,80 @@
+#
+# Copyright (c) 2013-2023 NIBIO.
+#
+# This file is part of VIPSWeb 
+# (see https://gitlab.nibio.no/VIPS/VIPSWeb).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#
+
+
+from django.urls import re_path, path, include
+#from django.views.generic import TemplateView
+from django.views.static import serve
+from django.views.i18n import JavaScriptCatalog
+from django.conf import settings
+from fibl import views
+from VIPSWeb import views as VIPSWebViews
+
+# Uncomment the next two lines to enable the admin:
+from django.contrib import admin
+admin.autodiscover()
+
+# Enabling translation in JavaScript files
+# See https://docs.djangoproject.com/en/1.5/topics/i18n/translation/#internationalization-in-javascript-code
+js_info_dict = {
+    'packages': ['forecasts','vips_messages','VIPSWeb','roughage', 'spatial'],
+    'domain': 'djangojs',
+}
+
+#print "settings.MAINTENANCE_MODE=%s" % settings.MAINTENANCE_MODE
+
+if settings.MAINTENANCE_MODE is True:
+    urlpatterns = [
+                           re_path(r'^$', views.maintenance, name='maintenance')
+    ]
+else:
+    urlpatterns = [
+        # Examples:
+        # url(r'^$', 'VIPSWeb.views.home', name='home'),
+        # url(r'^VIPSWeb/', include('VIPSWeb.foo.urls')),
+    
+        # Uncomment the admin/doc line below to enable admin documentation:
+        # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
+
+        #re_path(r'^spatial/', include('spatial.urls')),
+	    #re_path(r'^cydiapomonella/', include('cydiapomonella.urls')),
+        #re_path(r'^forecasts/', include('forecasts.urls', namespace = "forecasts")),
+        re_path(r'^messages/', include('vips_messages.urls', namespace = "vips_messages")),
+        re_path(r'^observations/', include('observations.urls', namespace = "observations")),
+        re_path(r'^information/', include('information.urls', namespace = "information")),
+        re_path(r'^security/', include('security.urls', namespace = "security")),
+        #re_path(r'^mock/', include('mock.urls', namespace = "mock")),
+        # Uncomment the next line to enable the admin:
+        re_path(r'^admin/', admin.site.urls),
+        re_path(r'^tinymce/', include('tinymce.urls')),
+        # Static serving of media files
+        re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
+        # Enabling translation in JavaScript files
+        # See https://docs.djangoproject.com/en/1.6/topics/i18n/translation/#internationalization-in-javascript-code
+        path('jsi18n/', JavaScriptCatalog.as_view(packages=js_info_dict['packages']), name='javascript-catalog'),
+        #path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
+        re_path(r'^i18n/', include('django.conf.urls.i18n')),
+        path('settings.js', VIPSWebViews.settings_js, name="VIPSWebViews.settings_js"),
+        re_path(r'^vipslogicproxy/(?P<path>.*)$', VIPSWebViews.vipslogicproxy),
+        # Default view is index
+        re_path(r'^$', views.index, name='index'),
+        #url(r'^$', TemplateView.as_view(template_name="index.html"))
+    ]
diff --git a/fibl/views.py b/fibl/views.py
new file mode 100644
index 00000000..2ec15325
--- /dev/null
+++ b/fibl/views.py
@@ -0,0 +1,10 @@
+from django.shortcuts import render
+from django.conf import settings
+
+# Create your views here.
+
+def index(request):
+    context = {
+        "site_logo_path" : settings.SITE_LOGO_PATH
+    }
+    return render(request, 'fibl/index.html', context)
\ No newline at end of file
-- 
GitLab