diff --git a/var/www/Flask_server.py b/var/www/Flask_server.py
index c94b5285..3989043f 100755
--- a/var/www/Flask_server.py
+++ b/var/www/Flask_server.py
@@ -27,20 +27,49 @@ cfg = Flask_config.cfg
Flask_config.app = Flask(__name__, static_url_path='/static/')
app = Flask_config.app
-# dynamically import routes and functions from modules
+# Dynamically import routes and functions from modules
+# Also, prepare header.html
+to_add_to_header_dico = {}
for root, dirs, files in os.walk('modules/'):
- for directory in dirs:
- #if directory == 'templates':
- # continue
- sys.path.append(join(root, directory))
- for name in files:
- if name.startswith('Flask_') and name.endswith('.py'):
- if name == 'Flask_config.py':
- continue
- name = name.strip('.py')
- print('importing {}'.format(name))
- importlib.import_module(name)
+ sys.path.append(join(root))
+ for name in files:
+ module_name = root.split('/')[-2]
+ if name.startswith('Flask_') and name.endswith('.py'):
+ if name == 'Flask_config.py':
+ continue
+ name = name.strip('.py')
+ #print('importing {}'.format(name))
+ importlib.import_module(name)
+ elif name == 'header_{}.html'.format(module_name):
+ with open(join(root, name), 'r') as f:
+ to_add_to_header_dico[module_name] = f.read()
+#create header.html
+complete_header = ""
+with open('templates/header_base.html', 'r') as f:
+ complete_header = f.read()
+modified_header = complete_header
+
+#Add the header in the supplied order
+for module_name, txt in to_add_to_header_dico.items():
+ to_replace = ''.format(module_name)
+ if to_replace in complete_header:
+ modified_header = modified_header.replace(to_replace, txt)
+ del to_add_to_header_dico[module_name]
+
+#Add the header for no-supplied order
+to_add_to_header = []
+for module_name, txt in to_add_to_header_dico.items():
+ to_add_to_header.append(txt)
+
+modified_header = modified_header.replace('', '\n'.join(to_add_to_header))
+
+#Write the header.html file
+with open('templates/header.html', 'w') as f:
+ f.write(modified_header)
+
+
+# ========= JINJA2 FUNCTIONS ========
def list_len(s):
return len(s)
app.jinja_env.filters['list_len'] = list_len
@@ -57,6 +86,12 @@ def add_header(response):
response.headers['Cache-Control'] = 'public, max-age=0'
return response
+# ========== ROUTES ============
+@app.route('/searchbox/')
+def searchbox():
+ return render_template("searchbox.html")
+
+
# ============ MAIN ============
if __name__ == "__main__":
diff --git a/var/www/modules/browsepastes/Flask_browsepastes.py b/var/www/modules/browsepastes/Flask_browsepastes.py
new file mode 100644
index 00000000..d3b1bb4d
--- /dev/null
+++ b/var/www/modules/browsepastes/Flask_browsepastes.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python2
+# -*-coding:UTF-8 -*
+
+'''
+ Flask functions and routes for the trending modules page
+'''
+import redis
+import json
+import flask
+from flask import Flask, render_template, jsonify, request, Blueprint
+
+import Paste
+
+# ============ VARIABLES ============
+import Flask_config
+
+app = Flask_config.app
+cfg = Flask_config.cfg
+max_preview_char = Flask_config.max_preview_char
+max_preview_modal = Flask_config.max_preview_modal
+r_serv_db = Flask_config.r_serv_db
+
+browsepastes = Blueprint('browsepastes', __name__, template_folder='templates')
+
+# ============ FUNCTIONS ============
+
+def getPastebyType(server, module_name):
+ all_path = []
+ for path in server.smembers('WARNING_'+module_name):
+ all_path.append(path)
+ return all_path
+
+
+def event_stream_getImportantPasteByModule(module_name):
+ index = 0
+ all_pastes_list = getPastebyType(r_serv_db, module_name)
+ for path in all_pastes_list:
+ index += 1
+ paste = Paste.Paste(path)
+ content = paste.get_p_content().decode('utf8', 'ignore')
+ content_range = max_preview_char if len(content)>max_preview_char else len(content)-1
+ curr_date = str(paste._get_p_date())
+ curr_date = curr_date[0:4]+'/'+curr_date[4:6]+'/'+curr_date[6:]
+ data = {}
+ data["module"] = module_name
+ data["index"] = index
+ data["path"] = path
+ data["content"] = content[0:content_range]
+ data["linenum"] = paste.get_lines_info()[0]
+ data["date"] = curr_date
+ data["char_to_display"] = max_preview_modal
+ data["finished"] = True if index == len(all_pastes_list) else False
+ yield 'retry: 100000\ndata: %s\n\n' % json.dumps(data) #retry to avoid reconnection of the browser
+
+# ============ ROUTES ============
+
+@browsepastes.route("/browseImportantPaste/", methods=['GET'])
+def browseImportantPaste():
+ module_name = request.args.get('moduleName')
+ return render_template("browse_important_paste.html")
+
+
+@browsepastes.route("/importantPasteByModule/", methods=['GET'])
+def importantPasteByModule():
+ module_name = request.args.get('moduleName')
+
+ all_content = []
+ paste_date = []
+ paste_linenum = []
+ all_path = []
+ allPastes = getPastebyType(r_serv_db, module_name)
+
+ for path in allPastes[0:10]:
+ all_path.append(path)
+ paste = Paste.Paste(path)
+ content = paste.get_p_content().decode('utf8', 'ignore')
+ content_range = max_preview_char if len(content)>max_preview_char else len(content)-1
+ all_content.append(content[0:content_range].replace("\"", "\'").replace("\r", " ").replace("\n", " "))
+ curr_date = str(paste._get_p_date())
+ curr_date = curr_date[0:4]+'/'+curr_date[4:6]+'/'+curr_date[6:]
+ paste_date.append(curr_date)
+ paste_linenum.append(paste.get_lines_info()[0])
+
+ if len(allPastes) > 10:
+ finished = False
+ else:
+ finished = True
+
+ return render_template("important_paste_by_module.html",
+ moduleName=module_name,
+ all_path=all_path,
+ content=all_content,
+ paste_date=paste_date,
+ paste_linenum=paste_linenum,
+ char_to_display=max_preview_modal,
+ finished=finished)
+
+@browsepastes.route("/_getImportantPasteByModule")
+def getImportantPasteByModule():
+ module_name = request.args.get('moduleName')
+ return flask.Response(event_stream_getImportantPasteByModule(module_name), mimetype="text/event-stream")
+
+
+# ========= REGISTRATION =========
+app.register_blueprint(browsepastes)
diff --git a/var/www/modules/browsepastes/templates/browse_important_paste.html b/var/www/modules/browsepastes/templates/browse_important_paste.html
index 09a21a70..ee3503fd 100644
--- a/var/www/modules/browsepastes/templates/browse_important_paste.html
+++ b/var/www/modules/browsepastes/templates/browse_important_paste.html
@@ -35,24 +35,7 @@
-
-
+ {% include 'navbar.html' %}
diff --git a/var/www/modules/browsepastes/templates/header_browsepastes.html b/var/www/modules/browsepastes/templates/header_browsepastes.html
new file mode 100644
index 00000000..fbbc77bc
--- /dev/null
+++ b/var/www/modules/browsepastes/templates/header_browsepastes.html
@@ -0,0 +1 @@
+
Browse important pastes
diff --git a/var/www/modules/dashboard/templates/header_dashboard.html b/var/www/modules/dashboard/templates/header_dashboard.html
new file mode 100644
index 00000000..ea48e917
--- /dev/null
+++ b/var/www/modules/dashboard/templates/header_dashboard.html
@@ -0,0 +1 @@
+
Dashboard
diff --git a/var/www/modules/search/templates/search.html b/var/www/modules/search/templates/search.html
index 03022361..43895a9f 100644
--- a/var/www/modules/search/templates/search.html
+++ b/var/www/modules/search/templates/search.html
@@ -37,23 +37,7 @@
-
-
-
+ {% include 'navbar.html' %}
diff --git a/var/www/modules/sentiment/templates/header_sentiment.html b/var/www/modules/sentiment/templates/header_sentiment.html
new file mode 100644
index 00000000..650a7717
--- /dev/null
+++ b/var/www/modules/sentiment/templates/header_sentiment.html
@@ -0,0 +1,7 @@
+
Sentiment Analysis
+
+
+
diff --git a/var/www/modules/sentiment/templates/sentiment_analysis_plot_tool.html b/var/www/modules/sentiment/templates/sentiment_analysis_plot_tool.html
index 55b0b866..5d79addc 100644
--- a/var/www/modules/sentiment/templates/sentiment_analysis_plot_tool.html
+++ b/var/www/modules/sentiment/templates/sentiment_analysis_plot_tool.html
@@ -31,25 +31,7 @@
-
-
-
+ {% include 'navbar.html' %}
diff --git a/var/www/modules/sentiment/templates/sentiment_analysis_trending.html b/var/www/modules/sentiment/templates/sentiment_analysis_trending.html
index b0ac487d..4895bba1 100644
--- a/var/www/modules/sentiment/templates/sentiment_analysis_trending.html
+++ b/var/www/modules/sentiment/templates/sentiment_analysis_trending.html
@@ -84,25 +84,7 @@
-
-
-
+ {% include 'navbar.html' %}
diff --git a/var/www/modules/skeleton/Flask_skeleton.py b/var/www/modules/skeleton/Flask_skeleton.py
new file mode 100644
index 00000000..4b110f64
--- /dev/null
+++ b/var/www/modules/skeleton/Flask_skeleton.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python2
+# -*-coding:UTF-8 -*
+
+'''
+ Flask functions and routes for the trending modules page
+'''
+import redis
+from flask import Flask, render_template, jsonify, request, Blueprint
+
+# ============ VARIABLES ============
+import Flask_config
+
+app = Flask_config.app
+cfg = Flask_config.cfg
+
+skeleton = Blueprint('skeleton', __name__, template_folder='templates')
+
+# ============ FUNCTIONS ============
+def one():
+ return 1
+
+# ============= ROUTES ==============
+
+@skeleton.route("/skeleton/", methods=['GET'])
+def skeleton_page():
+ return render_template("skeleton.html")
+
+
+# ========= REGISTRATION =========
+app.register_blueprint(skeleton)
diff --git a/var/www/modules/skeleton/templates/header_skeleton.html b/var/www/modules/skeleton/templates/header_skeleton.html
new file mode 100644
index 00000000..e333c2d4
--- /dev/null
+++ b/var/www/modules/skeleton/templates/header_skeleton.html
@@ -0,0 +1 @@
+
Skeleton page
diff --git a/var/www/modules/skeleton/templates/skeleton.html b/var/www/modules/skeleton/templates/skeleton.html
new file mode 100644
index 00000000..81180040
--- /dev/null
+++ b/var/www/modules/skeleton/templates/skeleton.html
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
Analysis Information Leak framework Dashboard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% include 'navbar.html' %}
+
+
+
+
+
+
+
+
+
diff --git a/var/www/modules/terms/templates/header_terms.html b/var/www/modules/terms/templates/header_terms.html
new file mode 100644
index 00000000..d834bb31
--- /dev/null
+++ b/var/www/modules/terms/templates/header_terms.html
@@ -0,0 +1,8 @@
+
Terms frequency
+
+
+
diff --git a/var/www/modules/terms/templates/terms_management.html b/var/www/modules/terms/templates/terms_management.html
index 9bfa4259..a59a42a3 100644
--- a/var/www/modules/terms/templates/terms_management.html
+++ b/var/www/modules/terms/templates/terms_management.html
@@ -57,25 +57,7 @@
-
-
-
+ {% include 'navbar.html' %}
diff --git a/var/www/modules/terms/templates/terms_plot_tool.html b/var/www/modules/terms/templates/terms_plot_tool.html
index 340f9244..6337acce 100644
--- a/var/www/modules/terms/templates/terms_plot_tool.html
+++ b/var/www/modules/terms/templates/terms_plot_tool.html
@@ -32,25 +32,7 @@
-
-
-
+ {% include 'navbar.html' %}
diff --git a/var/www/modules/terms/templates/terms_plot_top.html b/var/www/modules/terms/templates/terms_plot_top.html
index 1f237cf7..bf5add76 100644
--- a/var/www/modules/terms/templates/terms_plot_top.html
+++ b/var/www/modules/terms/templates/terms_plot_top.html
@@ -33,25 +33,7 @@
-
-
-
+ {% include 'navbar.html' %}
diff --git a/var/www/modules/trendingcharts/templates/Trending.html b/var/www/modules/trendingcharts/templates/Trending.html
index 5cf914f9..4c7b5981 100644
--- a/var/www/modules/trendingcharts/templates/Trending.html
+++ b/var/www/modules/trendingcharts/templates/Trending.html
@@ -30,24 +30,8 @@
-
-
+ {% include 'navbar.html' %}
+
diff --git a/var/www/modules/trendingcharts/templates/header_trendingcharts.html b/var/www/modules/trendingcharts/templates/header_trendingcharts.html
new file mode 100644
index 00000000..605d4fa9
--- /dev/null
+++ b/var/www/modules/trendingcharts/templates/header_trendingcharts.html
@@ -0,0 +1 @@
+
Trending charts
diff --git a/var/www/modules/trendingmodules/templates/Moduletrending.html b/var/www/modules/trendingmodules/templates/Moduletrending.html
index 28fc3aa2..bfc0455f 100644
--- a/var/www/modules/trendingmodules/templates/Moduletrending.html
+++ b/var/www/modules/trendingmodules/templates/Moduletrending.html
@@ -22,24 +22,8 @@
-
-
+ {% include 'navbar.html' %}
+
{% include 'trending_graphs/Moduletrending.html' %}
diff --git a/var/www/modules/trendingmodules/templates/header_trendingmodules.html b/var/www/modules/trendingmodules/templates/header_trendingmodules.html
new file mode 100644
index 00000000..9a9c0596
--- /dev/null
+++ b/var/www/modules/trendingmodules/templates/header_trendingmodules.html
@@ -0,0 +1 @@
+
Modules statistics
diff --git a/var/www/templates/header.html b/var/www/templates/header.html
index ae394973..ad5508ce 100644
--- a/var/www/templates/header.html
+++ b/var/www/templates/header.html
@@ -1,23 +1,31 @@