include Makefile
include src/pgwui_sql/VERSION
include src/pgwui_sql/static/*.css
+include src/pgwui_sql/static/*.js
include src/pgwui_sql/templates/*.mak
include tox.ini
/* Copyright (C) 2024 The Meme Factory, Inc. http://www.karlpinc.com/
*
- * This file is part of PGWUI_Common.
+ * This file is part of PGWUI_SQL.
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*
- * Required style sheet for PGWUI programs.
+ * Required style sheet for PGWUI_SQL.
*
* Karl O. Pinc <kop@karlpinc.com>
*/
--- /dev/null
+/* Copyright (C) 2024 The Meme Factory, Inc. http://www.karlpinc.com/
+
+ This file is part of PGWUI_SQL.
+
+ 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/>.
+
+ Javascript for the sql results window.
+
+ Karl O. Pinc <kop@karlpinc.com>
+
+ See sql.mak for the script that defines
+*/
+
+function openSqlEdit() {
+ window.open(
+ pgwuiSqlEditRoute(),
+ 'sql_edit',
+ 'popup=true,width=' + window.innerWidth
+ + ',height=' + window.innerHeight
+ + ',left=' + (window.screenLeft + window.outerWidth)
+ + ',top=' + window.screenTop)
+ .focus();
+}
+function whitespaceDisplay(checked) {
+ if (checked) {
+ globalThis.tdSqltextSheet.disabled = false;
+ } else {
+ globalThis.tdSqltextSheet.disabled = true;
+ }
+}
+function getTdSqltextSheet() {
+ const url = pgwuiSqlShowWhitespaceURL();
+ for (const sheet of document.styleSheets) {
+ if (sheet.href === url) {
+ return sheet;
+ }}}
+
+globalThis.tdSqltextSheet = getTdSqltextSheet();
+const show_spaces = document.getElementById('show_spaces_id');
+if (show_spaces !== null) {
+ whitespaceDisplay(show_spaces.checked);
+}
--- /dev/null
+/* Copyright (C) 2024 The Meme Factory, Inc. http://www.karlpinc.com/
+ *
+ * This file is part of PGWUI_SQL.
+ *
+ * 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/>.
+ *
+ * Style sheet that shows whitespace in the SQL results
+ *
+ * Karl O. Pinc <kop@karlpinc.com>
+ */
+
+td.sqltext { text-decoration-line: underline;
+ text-decoration-color: silver;
+ text-decoration-style: double; }
+
<%inherit file="${sql_base_mak}" />
+<script>
+ // Functions for delivering "static" content that comes from templating.
+ function pgwuiSqlEditRoute() {
+ return '${request.route_path("pgwui_sql_edit")|n}';
+ }
+ function pgwuiSqlShowWhitespaceURL() {
+ return '${request.static_url(
+ "pgwui_sql:static/show_whitespace.css")}';
+ }
+ // Set window name so that the sql_edit window can vary the target
+ // by db/user/etc. and have multiple result windows open at once.
+ window.name='${self.sql_results_target()}';
+</script>
+
<%block name="title" filter="trim">
% if havecreds:
sql -- Results
% endif
</%block>
+<%block name="stylesheet_links">
+ ${parent.stylesheet_links()}
+ <link rel="stylesheet"
+ href="${request.static_url('pgwui_sql:static/show_whitespace.css')}"
+ type="text/css" />
+</%block>
+
<%block name="action_success">
<p><em class="success">No errors</em>${
f', from file ({filename})' if upload_sql else ''
</self.lib:td_label>
<self.lib:td_input tab_index="${tab_index}">
<input name="show_spaces"
+ id="show_spaces_id"
tabindex="${tab_index.val}"
type="checkbox"
${show_spaces | n}
</form>
</%def>
-<script>
- window.name='${self.sql_results_target()}';
- function open_sql_edit() {
- window.open(
- '${request.route_path("pgwui_sql_edit")|n}',
- 'sql_edit',
- 'popup=true,width=' + window.innerWidth
- + ',height=' + window.innerHeight
- + ',left=' + (window.screenLeft + window.outerWidth)
- + ',top=' + window.screenTop)
- .focus();
- }
- function whitespaceDisplay(checked) {
- const tdSqltextSheet = document.adoptedStyleSheets[0];
-
- if (checked) {
- tdSqltextSheet.disabled = false;
- } else {
- tdSqltextSheet.disabled = true;
- }
- }
-
- // See: https://web.dev/articles/constructable-stylesheets
- function setupCSS() {
- tdSqltextSheet = new CSSStyleSheet(disabled=true);
- tdSqltextSheet.replaceSync(
- 'td.sqltext {
- text-decoration-line: underline;
- text-decoration-color: silver;
- text-decoration-style: double; }');
- document.adoptedStyleSheets = [tdSqltextSheet];
- }
-
- if (document.readyState === "loading") {
- // Loading hasn't finished yet
- document.addEventListener("DOMContentLoaded", setupCSS);
- } else {
- // `DOMContentLoaded` has already fired
- setupCSS();
- }
-</script>
-
<noscript>
<p class="error">ALERT: This page requires JavaScript be turned on.</p>
</noscript>
<input value="Login" tabindex="${tab_index.val}" type="submit" />
% else:
<button type="button" tabindex="${tab_index.val}"
- onclick="open_sql_edit();"
+ onclick="openSqlEdit();"
>New SQL Entry Window</button>
% endif
<% tab_index.inc() %>
<% tab_index = self.attr.TabIndex() %>
${render_results()}
${self.main_form(tab_index)}
+
+<script defer
+ src="${request.static_url('pgwui_sql:static/pgwui_sql.js')}">
+</script>