Ответить этому.
From 5938f4e063353e4adbeeaf1587292a31f1a354bb Mon Sep 17 00:00:00 2001
From: Simple_Not <44047940+moonbaseDelta@users.noreply.github.com>
Date: Thu, 20 Jul 2023 01:24:15 +1000
Subject: [PATCH 60/80] we can send now?
---
app.py | 33 +++++++-
reqs.txt | 3 +-
static/src/htmx.js | 130 +++++++++++++++++++++++--------
templates/interactive-posts.html | 7 ++
4 files changed, 136 insertions(+), 37 deletions(-)
diff --git a/app.py b/app.py
index 9a7cb9a..c73ea13 100644
--- a/app.py
+++ b/app.py
@@ -5,8 +5,10 @@ from todo import todos
from threads import threads_lists
from threads_with_posts import open_threads
from arango import ArangoClient
+from minio import minioClient
+
+import socket, os
-import socket
app = Flask(__name__)
@@ -176,7 +178,34 @@ def post_to_post(post_key):
# def post_a_file():
# pass
-
+@app.route("/send_dudes", methods=["POST"])
+def upload_file():
+ if request.method == "POST":
+ uploaded_file = request.files["file"]
+ if uploaded_file:
+ bucket_name = "thread-pics"
+ size = os.fstat(uploaded_file.fileno()).st_size
+
+ minioClient.put_object(
+ bucket_name, uploaded_file.filename, uploaded_file, size
+ )
+
+ return """
+
stored
+
+ """
+
+ return """
+
Upload IPS File
+
+ """
+
if __name__ == "__main__":
diff --git a/reqs.txt b/reqs.txt
index 9156824..530e5ee 100644
--- a/reqs.txt
+++ b/reqs.txt
@@ -1,3 +1,4 @@
flask
flask-assets
-python-arango
\ No newline at end of file
+python-arango
+minio
\ No newline at end of file
diff --git a/static/src/htmx.js b/static/src/htmx.js
index c7ea3f4..2fb8b9c 100644
--- a/static/src/htmx.js
+++ b/static/src/htmx.js
@@ -44,6 +44,7 @@ return (function () {
defineExtension : defineExtension,
removeExtension : removeExtension,
logAll : logAll,
+ logNone : logNone,
logger : null,
config : {
historyEnabled:true,
@@ -71,6 +72,7 @@ return (function () {
defaultFocusScroll: false,
getCacheBusterParam: false,
globalViewTransitions: false,
+ methodsThatUseUrlParams: ["get"],
},
parseInterval:parseInterval,
_:internalEval,
@@ -82,7 +84,7 @@ return (function () {
sock.binaryType = htmx.config.wsBinaryType;
return sock;
},
- version: "1.9.2"
+ version: "1.9.3"
};
/** @type {import("./htmx").HtmxInternalApi} */
@@ -90,9 +92,11 @@ return (function () {
addTriggerHandler: addTriggerHandler,
bodyContains: bodyContains,
canAccessLocalStorage: canAccessLocalStorage,
+ findThisElement: findThisElement,
filterValues: filterValues,
hasAttribute: hasAttribute,
getAttributeValue: getAttributeValue,
+ getClosestAttributeValue: getClosestAttributeValue,
getClosestMatch: getClosestMatch,
getExpressionVars: getExpressionVars,
getHeaders: getHeaders,
@@ -105,6 +109,7 @@ return (function () {
mergeObjects: mergeObjects,
makeSettleInfo: makeSettleInfo,
oobSwap: oobSwap,
+ querySelectorExt: querySelectorExt,
selectAndSwap: selectAndSwap,
settleImmediately: settleImmediately,
shouldCancel: shouldCancel,
@@ -475,6 +480,10 @@ return (function () {
}
}
+ function logNone() {
+ htmx.logger = null
+ }
+
function find(eltOrSelector, selector) {
if (selector) {
return eltOrSelector.querySelector(selector);
@@ -902,6 +911,17 @@ return (function () {
return hash;
}
+ function deInitOnHandlers(elt) {
+ var internalData = getInternalData(elt);
+ if (internalData.onHandlers) {
+ for (let i = 0; i < internalData.onHandlers.length; i++) {
+ const handlerInfo = internalData.onHandlers[i];
+ elt.removeEventListener(handlerInfo.name, handlerInfo.handler);
+ }
+ delete internalData.onHandlers
+ }
+ }
+
function deInitNode(element) {
var internalData = getInternalData(element);
if (internalData.timeout) {
@@ -920,12 +940,7 @@ return (function () {
}
});
}
- if (internalData.onHandlers) {
- for (let i = 0; i < internalData.onHandlers.length; i++) {
- const handlerInfo = internalData.onHandlers[i];
- element.removeEventListener(handlerInfo.name, handlerInfo.handler);
- }
- }
+ deInitOnHandlers(element);
}
function cleanUpElement(element) {
@@ -950,7 +965,7 @@ return (function () {
newElt = eltBeforeNewContent.nextSibling;
}
getInternalData(target).replacedWith = newElt; // tuck away so we can fire events on it later
- settleInfo.elts = [] // clear existing elements
+ settleInfo.elts = settleInfo.elts.filter(e => e != target);
while(newElt && newElt !== target) {
if (newElt.nodeType === Node.ELEMENT_NODE) {
settleInfo.elts.push(newElt);
@@ -995,8 +1010,8 @@ return (function () {
}
}
- function maybeSelectFromResponse(elt, fragment) {
- var selector = getClosestAttributeValue(elt, "hx-select");
+ function maybeSelectFromResponse(elt, fragment, selectOverride) {
+ var selector = selectOverride || getClosestAttributeValue(elt, "hx-select");
if (selector) {
var newFragment = getDocument().createDocumentFragment();
forEach(fragment.querySelectorAll(selector), function (node) {
@@ -1070,12 +1085,12 @@ return (function () {
}
}
- function selectAndSwap(swapStyle, target, elt, responseText, settleInfo) {
+ function selectAndSwap(swapStyle, target, elt, responseText, settleInfo, selectOverride) {
settleInfo.title = findTitle(responseText);
var fragment = makeFragment(responseText);
if (fragment) {
handleOutOfBandSwaps(elt, fragment, settleInfo);
- fragment = maybeSelectFromResponse(elt, fragment);
+ fragment = maybeSelectFromResponse(elt, fragment, selectOverride);
handlePreservedElements(fragment);
return swap(swapStyle, elt, target, fragment, settleInfo);
}
@@ -1299,7 +1314,10 @@ return (function () {
var nodeData = getInternalData(elt);
nodeData.timeout = setTimeout(function () {
if (bodyContains(elt) && nodeData.cancelled !== true) {
- if (!maybeFilterEvent(spec, makeEvent('hx:poll:trigger', {triggerSpec:spec, target:elt}))) {
+ if (!maybeFilterEvent(spec, elt, makeEvent('hx:poll:trigger', {
+ triggerSpec: spec,
+ target: elt
+ }))) {
handler(elt);
}
processPolling(elt, handler, spec);
@@ -1361,11 +1379,11 @@ return (function () {
return getInternalData(elt).boosted && elt.tagName === "A" && evt.type === "click" && (evt.ctrlKey || evt.metaKey);
}
- function maybeFilterEvent(triggerSpec, evt) {
+ function maybeFilterEvent(triggerSpec, elt, evt) {
var eventFilter = triggerSpec.eventFilter;
if(eventFilter){
try {
- return eventFilter(evt) !== true;
+ return eventFilter.call(elt, evt) !== true;
} catch(e) {
triggerErrorEvent(getDocument().body, "htmx:eventFilter:error", {error: e, source:eventFilter.source});
return true;
@@ -1398,7 +1416,7 @@ return (function () {
if (explicitCancel || shouldCancel(evt, elt)) {
evt.preventDefault();
}
- if (maybeFilterEvent(triggerSpec, evt)) {
+ if (maybeFilterEvent(triggerSpec, elt, evt)) {
return;
}
var eventData = getInternalData(evt);
@@ -1650,6 +1668,9 @@ return (function () {
var sseEventSource = getInternalData(sseSourceElt).sseEventSource;
var sseListener = function (event) {
if (maybeCloseSSESource(sseSourceElt)) {
+ return;
+ }
+ if (!bodyContains(elt)) {
sseEventSource.removeEventListener(sseEventName, sseListener);
return;
}
@@ -1666,7 +1687,7 @@ return (function () {
var target = getTarget(elt)
var settleInfo = makeSettleInfo(elt);
- selectAndSwap(swapSpec.swapStyle, elt, target, response, settleInfo)
+ selectAndSwap(swapSpec.swapStyle, target, elt, response, settleInfo)
settleImmediately(settleInfo.tasks)
triggerEvent(elt, "htmx:sseMessage", event)
};
@@ -1770,7 +1791,7 @@ return (function () {
observer.observe(elt);
addEventListener(elt, handler, nodeData, triggerSpec);
} else if (triggerSpec.trigger === "load") {
- if (!maybeFilterEvent(triggerSpec, makeEvent("load", {elt:elt}))) {
+ if (!maybeFilterEvent(triggerSpec, elt, makeEvent("load", {elt: elt}))) {
loadImmediately(elt, handler, nodeData, triggerSpec.delay);
}
} else if (triggerSpec.pollInterval) {
@@ -1820,6 +1841,16 @@ return (function () {
return document.querySelector("[hx-boost], [data-hx-boost]");
}
+ function findHxOnWildcardElements(elt) {
+ if (!document.evaluate) return []
+
+ let node = null
+ const elements = []
+ const iter = document.evaluate('//*[@*[ starts-with(name(), "hx-on:") or starts-with(name(), "data-hx-on:") ]]', elt)
+ while (node = iter.iterateNext()) elements.push(node)
+ return elements
+ }
+
function findElementsToProcess(elt) {
if (elt.querySelectorAll) {
var boostedElts = hasChanceOfBeingBoosted() ? ", a, form" : "";
@@ -1879,7 +1910,7 @@ return (function () {
function processHxOn(elt) {
var hxOnValue = getAttributeValue(elt, 'hx-on');
- if (hxOnValue) {
+ if (hxOnValue && htmx.config.allowEval) {
var handlers = {}
var lines = hxOnValue.split("\n");
var currentEvent = null;
@@ -1903,6 +1934,22 @@ return (function () {
}
}
+ function processHxOnWildcard(elt) {
+ // wipe any previous on handlers so that this function takes precedence
+ deInitOnHandlers(elt)
+
+ for (const attr of elt.attributes) {
+ const { name, value } = attr
+ if (name.startsWith("hx-on:") || name.startsWith("data-hx-on:")) {
+ let eventName = name.slice(name.indexOf(":") + 1)
+ // if the eventName starts with a colon, prepend "htmx" for shorthand support
+ if (eventName.startsWith(":")) eventName = "htmx" + eventName
+
+ addHxOnEventHandler(elt, eventName, value)
+ }
+ }
+ }
+
function initNode(elt) {
if (elt.closest && elt.closest(htmx.config.disableSelector)) {
return;
@@ -1959,6 +2006,9 @@ return (function () {
elt = resolveTarget(elt);
initNode(elt);
forEach(findElementsToProcess(elt), function(child) { initNode(child) });
+ // Because it happens second, the new way of adding onHandlers superseeds the old one
+ // i.e. if there are any hx-on:eventName attributes, the hx-on attribute will be ignored
+ forEach(findHxOnWildcardElements(elt), processHxOnWildcard);
}
//====================================================================
@@ -2196,7 +2246,9 @@ return (function () {
swapInnerHTML(historyElement, fragment, settleInfo)
settleImmediately(settleInfo.tasks);
document.title = cached.title;
- window.scrollTo(0, cached.scroll);
+ setTimeout(function () {
+ window.scrollTo(0, cached.scroll);
+ }, 0); // next 'tick', so browser has time to render layout
currentPathForHistory = path;
triggerEvent(getDocument().body, "htmx:historyRestore", {path:path, item:cached});
} else {
@@ -2925,8 +2977,12 @@ return (function () {
var requestAttrValues = getValuesForElement(elt, 'hx-request');
var eltIsBoosted = getInternalData(elt).boosted;
+
+ var useUrlParams = htmx.config.methodsThatUseUrlParams.indexOf(verb) >= 0
+
var requestConfig = {
boosted: eltIsBoosted,
+ useUrlParams: useUrlParams,
parameters: filteredParameters,
unfilteredParameters: allParameters,
headers:headers,
@@ -2951,6 +3007,7 @@ return (function () {
headers = requestConfig.headers;
filteredParameters = requestConfig.parameters;
errors = requestConfig.errors;
+ useUrlParams = requestConfig.useUrlParams;
if(errors && errors.length > 0){
triggerEvent(elt, 'htmx:validation:halted', requestConfig)
@@ -2962,26 +3019,25 @@ return (function () {
var splitPath = path.split("#");
var pathNoAnchor = splitPath[0];
var anchor = splitPath[1];
- var finalPathForGet = null;
- if (verb === 'get') {
- finalPathForGet = pathNoAnchor;
+
+ var finalPath = path
+ if (useUrlParams) {
+ finalPath = pathNoAnchor;
var values = Object.keys(filteredParameters).length !== 0;
if (values) {
- if (finalPathForGet.indexOf("?") < 0) {
- finalPathForGet += "?";
+ if (finalPath.indexOf("?") < 0) {
+ finalPath += "?";
} else {
- finalPathForGet += "&";
+ finalPath += "&";
}
- finalPathForGet += urlEncode(filteredParameters);
+ finalPath += urlEncode(filteredParameters);
if (anchor) {
- finalPathForGet += "#" + anchor;
+ finalPath += "#" + anchor;
}
}
- xhr.open('GET', finalPathForGet, true);
- } else {
- xhr.open(verb.toUpperCase(), path, true);
}
+ xhr.open(verb.toUpperCase(), finalPath, true);
xhr.overrideMimeType("text/html");
xhr.withCredentials = requestConfig.withCredentials;
xhr.timeout = requestConfig.timeout;
@@ -3002,7 +3058,7 @@ return (function () {
xhr: xhr, target: target, requestConfig: requestConfig, etc: etc, boosted: eltIsBoosted,
pathInfo: {
requestPath: path,
- finalRequestPath: finalPathForGet || path,
+ finalRequestPath: finalPath,
anchor: anchor
}
};
@@ -3077,7 +3133,8 @@ return (function () {
});
});
triggerEvent(elt, 'htmx:beforeSend', responseInfo);
- xhr.send(verb === 'get' ? null : encodeParamsForBody(xhr, elt, filteredParameters));
+ var params = useUrlParams ? null : encodeParamsForBody(xhr, elt, filteredParameters)
+ xhr.send(params);
return promise;
}
@@ -3268,8 +3325,13 @@ return (function () {
// safari issue - see https://github.com/microsoft/playwright/issues/5894
}
+ var selectOverride;
+ if (hasHeader(xhr, /HX-Reselect:/i)) {
+ selectOverride = xhr.getResponseHeader("HX-Reselect");
+ }
+
var settleInfo = makeSettleInfo(target);
- selectAndSwap(swapSpec.swapStyle, target, elt, serverResponse, settleInfo);
+ selectAndSwap(swapSpec.swapStyle, target, elt, serverResponse, settleInfo, selectOverride);
if (selectionInfo.elt &&
!bodyContains(selectionInfo.elt) &&
diff --git a/templates/interactive-posts.html b/templates/interactive-posts.html
index 594b1f5..eccf724 100644
--- a/templates/interactive-posts.html
+++ b/templates/interactive-posts.html
@@ -16,6 +16,13 @@
{% include 'answer-post.html' %}
+
+
Upload IPS File
+
+
{% endblock content %}
\ No newline at end of file
From 25a99b45499632dc8cef53f51c9f6b128c5a7215 Mon Sep 17 00:00:00 2001
From: Simple_Not <44047940+moonbaseDelta@users.noreply.github.com>
Date: Thu, 20 Jul 2023 01:28:34 +1000
Subject: [PATCH 61/80] we can send now?
---
app.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/app.py b/app.py
index c73ea13..3e1577b 100644
--- a/app.py
+++ b/app.py
@@ -5,7 +5,7 @@ from todo import todos
from threads import threads_lists
from threads_with_posts import open_threads
from arango import ArangoClient
-from minio import minioClient
+from minio import Minio
import socket, os
@@ -182,6 +182,10 @@ def post_to_post(post_key):
def upload_file():
if request.method == "POST":
uploaded_file = request.files["file"]
+
+ minioClient = Minio(
+ "static.guaranteedstruggle.host",
+ )
if uploaded_file:
bucket_name = "thread-pics"
size = os.fstat(uploaded_file.fileno()).st_size
From 2f630ddde0e801246fa10748991a848a33ef3f6d Mon Sep 17 00:00:00 2001
From: Simple_Not <44047940+moonbaseDelta@users.noreply.github.com>
Date: Thu, 20 Jul 2023 01:32:57 +1000
Subject: [PATCH 62/80] we can send now?
---
app.py | 16 +-
static/src/_hyperscript.js | 7620 ++++++++++++++++++++++++++++++
templates/interactive-posts.html | 15 +-
3 files changed, 7631 insertions(+), 20 deletions(-)
create mode 100644 static/src/_hyperscript.js
diff --git a/app.py b/app.py
index 3e1577b..a47abe2 100644
--- a/app.py
+++ b/app.py
@@ -194,21 +194,9 @@ def upload_file():
bucket_name, uploaded_file.filename, uploaded_file, size
)
- return """
-
- """
+ return " NE OK "
diff --git a/static/src/_hyperscript.js b/static/src/_hyperscript.js
new file mode 100644
index 0000000..a41b6be
--- /dev/null
+++ b/static/src/_hyperscript.js
@@ -0,0 +1,7620 @@
+/**
+ * @typedef {Object} Hyperscript
+ */
+
+(function (self, factory) {
+ const _hyperscript = factory(self)
+
+ if (typeof exports === 'object' && typeof exports['nodeName'] !== 'string') {
+ module.exports = _hyperscript
+ } else {
+ self['_hyperscript'] = _hyperscript
+ if ('document' in self) self['_hyperscript'].browserInit()
+ }
+})(typeof self !== 'undefined' ? self : this, (globalScope) => {
+
+ 'use strict';
+
+ /**
+ * @type {Object}
+ * @property {DynamicConverter[]} dynamicResolvers
+ *
+ * @callback DynamicConverter
+ * @param {String} str
+ * @param {*} value
+ * @returns {*}
+ */
+ const conversions = {
+ dynamicResolvers: [
+ function(str, value){
+ if (str === "Fixed") {
+ return Number(value).toFixed();
+ } else if (str.indexOf("Fixed:") === 0) {
+ let num = str.split(":")[1];
+ return Number(value).toFixed(parseInt(num));
+ }
+ }
+ ],
+ String: function (val) {
+ if (val.toString) {
+ return val.toString();
+ } else {
+ return "" + val;
+ }
+ },
+ Int: function (val) {
+ return parseInt(val);
+ },
+ Float: function (val) {
+ return parseFloat(val);
+ },
+ Number: function (val) {
+ return Number(val);
+ },
+ Date: function (val) {
+ return new Date(val);
+ },
+ Array: function (val) {
+ return Array.from(val);
+ },
+ JSON: function (val) {
+ return JSON.stringify(val);
+ },
+ Object: function (val) {
+ if (val instanceof String) {
+ val = val.toString();
+ }
+ if (typeof val === "string") {
+ return JSON.parse(val);
+ } else {
+ return Object.assign({}, val);
+ }
+ },
+ }
+
+ const config = {
+ attributes: "_, script, data-script",
+ defaultTransition: "all 500ms ease-in",
+ disableSelector: "[disable-scripting], [data-disable-scripting]",
+ hideShowStrategies: {},
+ conversions,
+ }
+
+ class Lexer {
+ static OP_TABLE = {
+ "+": "PLUS",
+ "-": "MINUS",
+ "*": "MULTIPLY",
+ "/": "DIVIDE",
+ ".": "PERIOD",
+ "..": "ELLIPSIS",
+ "\\": "BACKSLASH",
+ ":": "COLON",
+ "%": "PERCENT",
+ "|": "PIPE",
+ "!": "EXCLAMATION",
+ "?": "QUESTION",
+ "#": "POUND",
+ "&": "AMPERSAND",
+ $: "DOLLAR",
+ ";": "SEMI",
+ ",": "COMMA",
+ "(": "L_PAREN",
+ ")": "R_PAREN",
+ "<": "L_ANG",
+ ">": "R_ANG",
+ "<=": "LTE_ANG",
+ ">=": "GTE_ANG",
+ "==": "EQ",
+ "===": "EQQ",
+ "!=": "NEQ",
+ "!==": "NEQQ",
+ "{": "L_BRACE",
+ "}": "R_BRACE",
+ "[": "L_BRACKET",
+ "]": "R_BRACKET",
+ "=": "EQUALS",
+ };
+
+ /**
+ * isValidCSSClassChar returns `true` if the provided character is valid in a CSS class.
+ * @param {string} c
+ * @returns boolean
+ */
+ static isValidCSSClassChar(c) {
+ return Lexer.isAlpha(c) || Lexer.isNumeric(c) || c === "-" || c === "_" || c === ":";
+ }
+
+ /**
+ * isValidCSSIDChar returns `true` if the provided character is valid in a CSS ID
+ * @param {string} c
+ * @returns boolean
+ */
+ static isValidCSSIDChar(c) {
+ return Lexer.isAlpha(c) || Lexer.isNumeric(c) || c === "-" || c === "_" || c === ":";
+ }
+
+ /**
+ * isWhitespace returns `true` if the provided character is whitespace.
+ * @param {string} c
+ * @returns boolean
+ */
+ static isWhitespace(c) {
+ return c === " " || c === "\t" || Lexer.isNewline(c);
+ }
+
+ /**
+ * positionString returns a string representation of a Token's line and column details.
+ * @param {Token} token
+ * @returns string
+ */
+ static positionString(token) {
+ return "[Line: " + token.line + ", Column: " + token.column + "]";
+ }
+
+ /**
+ * isNewline returns `true` if the provided character is a carrage return or newline
+ * @param {string} c
+ * @returns boolean
+ */
+ static isNewline(c) {
+ return c === "\r" || c === "\n";
+ }
+
+ /**
+ * isNumeric returns `true` if the provided character is a number (0-9)
+ * @param {string} c
+ * @returns boolean
+ */
+ static isNumeric(c) {
+ return c >= "0" && c <= "9";
+ }
+
+ /**
+ * isAlpha returns `true` if the provided character is a letter in the alphabet
+ * @param {string} c
+ * @returns boolean
+ */
+ static isAlpha(c) {
+ return (c >= "a" && c <= "z") || (c >= "A" && c <= "Z");
+ }
+
+ /**
+ * @param {string} c
+ * @param {boolean} [dollarIsOp]
+ * @returns boolean
+ */
+ static isIdentifierChar(c, dollarIsOp) {
+ return c === "_" || c === "$";
+ }
+
+ /**
+ * @param {string} c
+ * @returns boolean
+ */
+ static isReservedChar(c) {
+ return c === "`" || c === "^";
+ }
+
+ /**
+ * @param {Token[]} tokens
+ * @returns {boolean}
+ */
+ static isValidSingleQuoteStringStart(tokens) {
+ if (tokens.length > 0) {
+ var previousToken = tokens[tokens.length - 1];
+ if (
+ previousToken.type === "IDENTIFIER" ||
+ previousToken.type === "CLASS_REF" ||
+ previousToken.type === "ID_REF"
+ ) {
+ return false;
+ }
+ if (previousToken.op && (previousToken.value === ">" || previousToken.value === ")")) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * @param {string} string
+ * @param {boolean} [template]
+ * @returns {Tokens}
+ */
+ static tokenize(string, template) {
+ var tokens = /** @type {Token[]}*/ [];
+ var source = string;
+ var position = 0;
+ var column = 0;
+ var line = 1;
+ var lastToken = "