Give the component it's own CSS file
authorKarl O. Pinc <kop@karlpinc.com>
Tue, 20 Aug 2024 00:56:09 +0000 (19:56 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Tue, 20 Aug 2024 00:56:09 +0000 (19:56 -0500)
MANIFEST.in
src/pgwui_sql/pgwui_sql.py
src/pgwui_sql/static/pgwui_sql.css [new file with mode: 0644]
src/pgwui_sql/templates/sql.mak
tests/test_pgwui_sql.py

index 49cb29af718c024fb66eba1f19d7bc6d248577ac..53186a642cb5f541266c1d94ff8777fc19611d79 100644 (file)
@@ -5,5 +5,6 @@ include .coveragerc
 include LICENSE.txt
 include Makefile
 include src/pgwui_sql/VERSION
+include src/pgwui_sql/static/*.css
 include src/pgwui_sql/templates/*.mak
 include tox.ini
index 2c67e3a6908925197489db4142227b3e2bf9d743..54bf21c3b1ff96b4e30507249b75ccd0e8b865ef 100644 (file)
@@ -41,5 +41,9 @@ def includeme(config):
     '''Pyramid configuration for PGWUI_SQL
     '''
     establish_settings(config)
+    config.add_static_view(
+        f'static/{PGWUI_COMPONENT}',
+        f'{PGWUI_COMPONENT}:static/',
+        cache_max_age=3600)
     config.add_route(PGWUI_COMPONENT, DEFAULT_SQL_ROUTE)
     config.scan()
diff --git a/src/pgwui_sql/static/pgwui_sql.css b/src/pgwui_sql/static/pgwui_sql.css
new file mode 100644 (file)
index 0000000..c40d47d
--- /dev/null
@@ -0,0 +1,27 @@
+/* Copyright (C) 2024 The Meme Factory, Inc.  http://www.karlpinc.com/
+ *
+ * This file is part of PGWUI_Common.
+ *
+ * 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/>.
+ *
+ * Required style sheet for PGWUI programs.
+ *
+ * Karl O. Pinc <kop@karlpinc.com>
+ */
+
+/* The SQL entry window. */
+.sqltext { height: 40em;
+           width: 80em; }
+
index b63ba179e556b1ca34bda48e224bbd8a3b558e60..3d548df4bc9a24135befa9f3fe080ae64eca550c 100644 (file)
         content="PostgreSQL Web User Interface, Interactive SQL execution" />
 </%block>
 
+<%block name="stylesheet_links">
+  ${parent.stylesheet_links()}
+  <link rel="stylesheet"
+        href="${request.static_url('pgwui_sql:static/pgwui_sql.css')}"
+        type="text/css" />
+</%block>
+
 <%block name="action_success">
   <p><em class="success">Executed SQL without errors</em>,
   from a file<em class="success">!</em>
index 355ae5b726f2814db5609b38745f223c75c4923b..f14720a33e0e28968b709ced803a905abd91cb17 100644 (file)
@@ -81,20 +81,24 @@ mock_establish_settings = testing.make_mock_fixture(
 
 # includeme()
 
+mock_add_static_view = testing.late_instance_mock_fixture('add_static_view')
 mock_add_route = testing.late_instance_mock_fixture('add_route')
 mock_scan = testing.late_instance_mock_fixture('scan')
 
 
 @pytest.mark.unittest
-def test_includeme(mock_establish_settings, mock_add_route, mock_scan):
+def test_includeme(mock_establish_settings, mock_add_static_view,
+                   mock_add_route, mock_scan):
     '''establish_settings, add_route, and scan are all called
     '''
     with pyramid.testing.testConfig() as config:
+        mocked_add_static_view = mock_add_static_view(config)
         mocked_add_route = mock_add_route(config)
         mocked_scan = mock_scan(config)
 
         pgwui_sql.includeme(config)
 
         mock_establish_settings.assert_called_once()
+        mocked_add_static_view.assert_called_once()
         mocked_add_route.assert_called_once()
         mocked_scan.assert_called_once()