From baebdbe399ac9cfe93f435de8df1bc535f68c33a Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Fri, 9 Oct 2020 14:43:23 +0200
Subject: [PATCH 1/3] Add new config variables (defaults are what you want if
you don't have http to https redirect enabled)
---
.env.tpl | 16 ++++++++++++----
web/config.py | 27 ++++++++++++++++-----------
2 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/.env.tpl b/.env.tpl
index ba4732d2..eea32232 100644
--- a/.env.tpl
+++ b/.env.tpl
@@ -100,15 +100,23 @@ NOPAQUE_CONTACT_EMAIL_ADRESS=
# Choose one: http, https
# NOPAQUE_PROTOCOL=
-# DEFAULT: 5
-# NOPAQUE_RESSOURCES_PER_PAGE=
+# DEFAULT: True
+# Choose one: False, True
+# NOPAQUE_REMEMBER_COOKIE_HTTPONLY=
+
+# DEFAULT: False
+# Choose one: False, True
+# HINT: Set to true if you redirect http to https
+# NOPAQUE_REMEMBER_COOKIE_SECURE=
# DEFAULT: hard to guess string
# HINT: Use this bash command `python -c "import uuid; print(uuid.uuid4().hex)"`
# NOPAQUE_SECRET_KEY=
-# DEFAULT: 10
-# NOPAQUE_USERS_PER_PAGE=
+# DEFAULT: False
+# Choose one: False, True
+# HINT: Set to true if you redirect http to https
+# NOPAQUE_SESSION_COOKIE_SECURE=
################################################################################
diff --git a/web/config.py b/web/config.py
index 2b2ffb69..066592a0 100644
--- a/web/config.py
+++ b/web/config.py
@@ -19,9 +19,10 @@ DEFAULT_SMTP_USE_SSL = 'False'
DEFAULT_SMTP_USE_TLS = 'False'
DEFAULT_NUM_PROXIES = '0'
DEFAULT_PROTOCOL = 'http'
-DEFAULT_RESSOURCES_PER_PAGE = '5'
-DEFAULT_USERS_PER_PAGE = '10'
+DEFAULT_REMEMBER_COOKIE_HTTPONLY = 'True'
+DEFAULT_REMEMBER_COOKIE_SECURE = 'False'
DEFAULT_SECRET_KEY = 'hard to guess string'
+DEFAULT_SESSION_COOKIE_SECURE = 'False'
class Config:
@@ -55,15 +56,19 @@ class Config:
NUM_PROXIES = int(os.environ.get('NOPAQUE_NUM_PROXIES',
DEFAULT_NUM_PROXIES))
PROTOCOL = os.environ.get('NOPAQUE_PROTOCOL', DEFAULT_PROTOCOL)
- RESSOURCES_PER_PAGE = int(os.environ.get('NOPAQUE_RESSOURCES_PER_PAGE',
- DEFAULT_RESSOURCES_PER_PAGE))
- SECRET_KEY = os.environ.get('NOPAQUE_SECRET_KEY', DEFAULT_SECRET_KEY)
- USERS_PER_PAGE = int(os.environ.get('NOPAQUE_USERS_PER_PAGE',
- DEFAULT_USERS_PER_PAGE))
- if PROTOCOL == 'https':
- REMEMBER_COOKIE_HTTPONLY = True
- REMEMBER_COOKIE_SECURE = True
- SESSION_COOKIE_SECURE = True
+ REMEMBER_COOKIE_HTTPONLY = os.environ.get(
+ 'NOPAQUE_REMEMBER_COOKIE_HTTPONLY',
+ DEFAULT_REMEMBER_COOKIE_HTTPONLY
+ ).lower() == 'true'
+ REMEMBER_COOKIE_SECURE = os.environ.get(
+ 'NOPAQUE_REMEMBER_COOKIE_SECURE',
+ DEFAULT_REMEMBER_COOKIE_SECURE
+ ).lower() == 'true'
+ SECRET_KEY = os.environ.get('RECIPY_SECRET_KEY', DEFAULT_SECRET_KEY)
+ SESSION_COOKIE_SECURE = os.environ.get(
+ 'NOPAQUE_SESSION_COOKIE_SECURE',
+ DEFAULT_SESSION_COOKIE_SECURE
+ ).lower() == 'true'
''' ### Logging ### '''
LOG_DATE_FORMAT = os.environ.get('NOPAQUE_LOG_DATE_FORMAT',
From b44a5e1113c9b331df9ffa3fe6bec726b391f4cf Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Fri, 9 Oct 2020 15:32:09 +0200
Subject: [PATCH 2/3] fix indent
---
web/app/corpora/events.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/web/app/corpora/events.py b/web/app/corpora/events.py
index 23f11521..a0ae9322 100644
--- a/web/app/corpora/events.py
+++ b/web/app/corpora/events.py
@@ -126,8 +126,8 @@ def corpus_analysis_query(query):
context = 50
progress = 0
# for attr in corpus.structural_attributes.list():
- # if attr.attrs['name'] == 'text':
- # text_attr = attr
+ # if attr.attrs['name'] == 'text':
+ # text_attr = attr
# logging.warning(results.fdist_1(15, results.attrs['fields']['match'], text_attr))
client.status = 'running'
while chunk_start <= results.attrs['size']:
From 4ec3ce01fa94c6dc32445dcea2c8dcf6a0ecd45c Mon Sep 17 00:00:00 2001
From: Stephan Porada
Date: Fri, 9 Oct 2020 16:15:47 +0200
Subject: [PATCH 3/3] Show right match_count per text, not per last incoming
chunk
---
.../corpus_analysis/client/callbacks.js | 19 +++++++++++++++++--
.../modules/corpus_analysis/model/Results.js | 2 ++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/web/app/static/js/modules/corpus_analysis/client/callbacks.js b/web/app/static/js/modules/corpus_analysis/client/callbacks.js
index 66fe3c8f..7a50726d 100644
--- a/web/app/static/js/modules/corpus_analysis/client/callbacks.js
+++ b/web/app/static/js/modules/corpus_analysis/client/callbacks.js
@@ -33,13 +33,24 @@ function prepareQueryData() {
*/
function saveQueryData() {
let [payload, client, results, rest] = arguments;
+ // Get data matches length before new chunk data is being inserted
let dataLength = results.data.matches.length;
if (client.dynamicMode) {
- // get data matches length before new chunk data is being inserted
- // incorporating new chunk data into full results
+ // Incorporating new chunk data into full results
results.data.matches.push(...payload.chunk.matches);
results.data.addData(payload.chunk.cpos_lookup, 'cpos_lookup');
results.data.addData(payload.chunk.text_lookup, 'text_lookup');
+ console.log(payload.chunk.text_lookup);
+ /**
+ * Increment match_counts per text in a global results varaible because
+ * they are coming in chunkwise.
+ */
+ for (let [text_key, value] of Object.entries(payload.chunk.text_lookup)) {
+ if (!(text_key in results.tmp_match_counts)) {
+ results.tmp_match_counts[text_key] = {match_count: 0};
+ }
+ results.tmp_match_counts[text_key].match_count += payload.chunk.text_lookup[text_key].match_count;
+ }
results.data.cpos_ranges = payload.chunk.cpos_ranges;
let queryFormElement = document.querySelector('#query-form');
results.data.getQueryStr(queryFormElement);
@@ -51,6 +62,10 @@ function saveQueryData() {
console.info('Query data chunk saved', results.data);
if (client.requestQueryProgress === 100) {
client.isBusy = false;
+ // Update text_lookup with tmp_match_counts.
+ for (let [text_key, value] of Object.entries(results.tmp_match_counts)) {
+ results.data.text_lookup[text_key].match_count = results.tmp_match_counts[text_key].match_count;
+ }
client.notifyView('query-data-recieved');
}
} else {
diff --git a/web/app/static/js/modules/corpus_analysis/model/Results.js b/web/app/static/js/modules/corpus_analysis/model/Results.js
index 2d1ab7df..e2abd66e 100644
--- a/web/app/static/js/modules/corpus_analysis/model/Results.js
+++ b/web/app/static/js/modules/corpus_analysis/model/Results.js
@@ -22,6 +22,8 @@ class Results {
this.fullResultsData.init();
this.subResultsData.init();
this.inspectResultsData.init();
+ // Temporarly save match counts per text
+ this.tmp_match_counts = {};
}
}