mirror of https://github.com/CIRCL/lookyloo
chg: Use d3v5, cleanup.
parent
28d078aec4
commit
72759850ac
|
@ -48,7 +48,7 @@ sudo docker run -p 8050:8050 -p 5023:5023 scrapinghub/splash --disable-ui --disa
|
||||||
```bash
|
```bash
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
pip install -e .
|
pip install -e .
|
||||||
wget https://d3js.org/d3.v4.min.js -O lookyloo/static/d3.v4.min.js
|
wget https://d3js.org/d3.v5.min.js -O lookyloo/static/d3.v5.min.js
|
||||||
wget https://cdn.rawgit.com/eligrey/FileSaver.js/5733e40e5af936eb3f48554cf6a8a7075d71d18a/FileSaver.js -O lookyloo/static/FileSaver.js
|
wget https://cdn.rawgit.com/eligrey/FileSaver.js/5733e40e5af936eb3f48554cf6a8a7075d71d18a/FileSaver.js -O lookyloo/static/FileSaver.js
|
||||||
```
|
```
|
||||||
# Run the app locally
|
# Run the app locally
|
||||||
|
|
|
@ -38,12 +38,6 @@ SPLASH = 'http://127.0.0.1:8050'
|
||||||
HAR_DIR.mkdir(parents=True, exist_ok=True)
|
HAR_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
@app.before_request
|
|
||||||
def session_management():
|
|
||||||
# make the session last indefinitely until it is cleared
|
|
||||||
session.permanent = True
|
|
||||||
|
|
||||||
|
|
||||||
def cleanup_old_tmpfiles():
|
def cleanup_old_tmpfiles():
|
||||||
for tmpfile in pathlib.Path(tempfile.gettempdir()).glob('lookyloo*'):
|
for tmpfile in pathlib.Path(tempfile.gettempdir()).glob('lookyloo*'):
|
||||||
if time.time() - tmpfile.stat().st_atime > 36000:
|
if time.time() - tmpfile.stat().st_atime > 36000:
|
||||||
|
@ -145,6 +139,7 @@ def tree(tree_id):
|
||||||
@app.route('/', methods=['GET'])
|
@app.route('/', methods=['GET'])
|
||||||
def index():
|
def index():
|
||||||
cleanup_old_tmpfiles()
|
cleanup_old_tmpfiles()
|
||||||
|
session.clear()
|
||||||
i = 0
|
i = 0
|
||||||
titles = []
|
titles = []
|
||||||
if not HAR_DIR.exists():
|
if not HAR_DIR.exists():
|
||||||
|
|
|
@ -88,17 +88,9 @@ function str2bytes (str) {
|
||||||
|
|
||||||
function urlnode_click(d) {
|
function urlnode_click(d) {
|
||||||
var url = "url/" + d.data.uuid;
|
var url = "url/" + d.data.uuid;
|
||||||
var xhr = new XMLHttpRequest();
|
d3.blob(url, {credentials: 'same-origin'}).then(function(data) {
|
||||||
xhr.open('GET', url, true);
|
saveAs(data, 'file.zip');
|
||||||
xhr.responseType = "blob";
|
});
|
||||||
xhr.withCredentials = true;
|
|
||||||
xhr.onreadystatechange = function (){
|
|
||||||
if (xhr.readyState === 4) {
|
|
||||||
var blob = xhr.response;
|
|
||||||
saveAs(blob, 'file.zip');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
xhr.send();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
d3.selection.prototype.moveToFront = function() {
|
d3.selection.prototype.moveToFront = function() {
|
||||||
|
@ -154,9 +146,8 @@ function hostnode_click(d) {
|
||||||
|
|
||||||
// Modal display
|
// Modal display
|
||||||
var url = "/tree/hostname/" + d.data.uuid;
|
var url = "/tree/hostname/" + d.data.uuid;
|
||||||
d3.json(url, function(error, urls) {
|
d3.json(url, {credentials: 'same-origin'}).then(function(urls) {
|
||||||
var interval_entries = 40;
|
var interval_entries = 40;
|
||||||
if (error) throw error;
|
|
||||||
urls.forEach(function(url, index, array) {
|
urls.forEach(function(url, index, array) {
|
||||||
var jdata = JSON.parse(url)
|
var jdata = JSON.parse(url)
|
||||||
overlay_hostname.datum({'data': jdata});
|
overlay_hostname.datum({'data': jdata});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
<script src='{{ url_for('static', filename='FileSaver.js') }}'></script>
|
<script src='{{ url_for('static', filename='FileSaver.js') }}'></script>
|
||||||
<script src='{{ url_for('static', filename='d3.v4.min.js') }}'></script>
|
<script src='{{ url_for('static', filename='d3.v5.min.js') }}'></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
|
|
Loading…
Reference in New Issue