summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/app.js4
-rw-r--r--src/client/main.js5
-rw-r--r--src/client/rz_config.js1
-rw-r--r--src/server/rz_feedback.py29
-rw-r--r--src/server/rz_server.py7
5 files changed, 42 insertions, 4 deletions
diff --git a/src/client/app.js b/src/client/app.js
index 4bb762d5..b0485090 100644
--- a/src/client/app.js
+++ b/src/client/app.js
@@ -12,7 +12,9 @@
FileSaver: lib_path + 'FileSaver',
jquery: lib_path + 'jquery',
'jquery-ui': lib_path + 'jquery-ui',
- socketio: lib_path + '/socket.io/socket.io.min_0.9.10',
+ socketio: lib_path + 'socket.io/socket.io.min_0.9.10',
+ html2canvas: lib_path + 'html2canvas',
+ feedback: lib_path + 'feedback',
}
}
diff --git a/src/client/main.js b/src/client/main.js
index 5c837b75..4d83fbde 100644
--- a/src/client/main.js
+++ b/src/client/main.js
@@ -1,5 +1,5 @@
-define(['textanalysis.ui', 'textanalysis', 'buttons', 'history', 'drag_n_drop', 'robot', 'model/core', 'rz_config', 'rz_core', 'view/selection', 'util', 'view/search'],
-function(textanalysis_ui, textanalysis, buttons, history, drag_n_drop, robot, model_core, rz_config, rz_core, selection, util, search) {
+define(['textanalysis.ui', 'textanalysis', 'buttons', 'history', 'drag_n_drop', 'robot', 'model/core', 'rz_config', 'rz_core', 'view/selection', 'util', 'view/search', 'feedback'],
+function(textanalysis_ui, textanalysis, buttons, history, drag_n_drop, robot, model_core, rz_config, rz_core, selection, util, search, feedback) {
function expand(obj){
if (!obj.savesize) {
@@ -74,6 +74,7 @@ function(textanalysis_ui, textanalysis, buttons, history, drag_n_drop,
model_core.init(rz_config);
textanalysis.init(rz_core.main_graph);
search.init();
+ $.feedback({ajaxURL: rz_config.feedback_url});
}
return {
diff --git a/src/client/rz_config.js b/src/client/rz_config.js
index 2258a77a..858fbf18 100644
--- a/src/client/rz_config.js
+++ b/src/client/rz_config.js
@@ -6,5 +6,6 @@ define(function() {
'rz_server_port': '8080',
'backend_enabled': true,
'backend__maintain_ws_connection': false,
+ 'feedback_url': '/feedback',
};
});
diff --git a/src/server/rz_feedback.py b/src/server/rz_feedback.py
new file mode 100644
index 00000000..74fe2c7f
--- /dev/null
+++ b/src/server/rz_feedback.py
@@ -0,0 +1,29 @@
+import logging
+
+from flask import request
+from flask import json
+
+
+log = logging.getLogger('rhizi')
+
+def feedback():
+ """
+ Email all parts as attachments to configured feedback email
+ """
+
+ def sanitize_input(req):
+ d = request.form.to_dict()
+ feedback = d['feedback']
+ req_json = json.loads(feedback)
+ url = req_json['url']
+ note = req_json['note']
+ img = req_json['img'] # FIXME base64 encoded data URI
+ html = req_json['html']
+ return url, note, img, html
+
+ try:
+ url, note, img, html = sanitize_input(request)
+ except:
+ log.warn('failed to sanitize inputs. request: %s' % request)
+
+ return "success"
diff --git a/src/server/rz_server.py b/src/server/rz_server.py
index 118cfa16..52db213e 100644
--- a/src/server/rz_server.py
+++ b/src/server/rz_server.py
@@ -29,6 +29,7 @@ from rz_mesh import init_ws_interface
from rz_kernel import RZ_Kernel
import rz_api
import rz_api_rest
+import rz_feedback
class Config(object):
"""
@@ -194,12 +195,16 @@ def init_rest_interface(cfg, flask_webapp):
rest_entry('/logout', rz_api.logout, {'methods': ['GET', 'POST']}),
rest_entry('/match/node-set', rz_api.match_node_set_by_attr_filter_map),
rest_entry('/monitor/server-info', rz_api.monitor__server_info),
+ rest_entry('/feedback', rz_feedback.feedback),
]
+ # FIXME: but should be rate limited (everything should be, regardless of login)
+ no_login_paths = set(['/login', '/feedback'])
+
for re_entry in rest_entry_set:
rest_path, f, flask_args = re_entry
- if cfg.access_control and '/login' != rest_path:
+ if cfg.access_control and rest_path not in no_login_paths:
# currently require login on all but /login paths
f = login_decorator(f)