<commit_before># Python module to use when working with the tulip module in a Jupyter / IPython notebook
# It enables to inline Tulip WebGL graph visualizations in the notebook

# That code is freely inspired from the great mpld3 project
# (see https://github.com/mpld3/mpld3/tree/master/mpld3)

import sys
import base64
import jinja2
import random
import os.path
import tempfile
import shutil
import IPython
from IPython.core.getipython import get_ipython
from IPython.core.display import display as ipythondisplay
from tulip import *

TULIPJS_HTML = jinja2.Template("""
<style type="text/css">
.tulip_viz {
  height: 400px;
  border: 1px solid black;
}
.interactor_button {
  position: absolute;
  left: 5px !important;
  z-index: 10;
}
.center_button {
  position: absolute;
  right: 0px !important;
  top: 0px !important;
  z-index: 10;
}
</style>

<link rel="stylesheet" href="{{ jquerytoolbarcss_url }}" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"/>

<div id="toolbar-options{{ vizid }}" class="hidden">
   <a class="interactor-znp" href="#"><i class="fa fa-hand-paper-o" aria-hidden="true"></i></a>
   <a class="interactor-zoom" href="#"><i class="fa fa-search-plus"></i></a>
   <a class="interactor-fisheye" href="#"><i class="fa fa-eye"></i></a>
</div>

<div id="{{ vizid }}" class="tulip_viz">

<div id="toolbar{{ vizid }}" class="btn-toolbar btn-toolbar-dark interactor_button hidden">
    <i class="fa fa-hand-paper-o" aria-hidden="true"></i>
</div>

<div id="center{{ vizid }}" class="btn-toolbar btn-toolbar-dark center_button hidden">
    <i class="fa fa-arrows" aria-hidden="true"></i>
</div>

</div>

<script type="text/javascript">

  require.config({paths: {tulip: "{{ tulipjs_url[:-3] }}",
                          base64utils: "{{ base64utils_url[:-3] }}",
                          jquerytoolbar: "{{ jquerytoolbarjs_url[:-3] }}"}});
  require(["tulip", "base64utils", "jquerytoolbar"], function(tulip, base64utils) {

    var tulipView;

    function initTulipGraphVisualization() {
      if (!tulip.isLoaded()) {
        setTimeout(initTulipGraphVisualization, 1000);
      } else {
        var tlpbgzGraphBase64 = "{{ tlpbgz_graph_base64 }}";
        var tlpbgzGraphBinary = base64utils.base64DecToArr(tlpbgzGraphBase64);
        var container = document.getElementById("{{ vizid }}");
        tulipView = tulip.View(container);
        $("#toolbar{{ vizid }}").removeClass('hidden');
        $("#center{{ vizid }}").removeClass('hidden');
        tulipView.loadGraphFromData("graph.tlpb.gz", tlpbgzGraphBinary);
        tulipView.centerScene();
        tulipView.draw();
      }
    };

    $("#toolbar-options{{ vizid }}").find(".interactor-znp").on('click', function() {
      tulipView.activateInteractor('ZoomAndPan');
    });

    $("#toolbar-options{{ vizid }}").find(".interactor-zoom").on('click', function() {
      tulipView.activateInteractor('RectangleZoom');
    });

    $("#center{{ vizid }}").on('click', function() {
      tulipView.centerScene();
    });

    $("#toolbar-options{{ vizid }}").find(".interactor-fisheye").on('click', function() {
      tulipView.activateInteractor('Fisheye');
    });

    $("#toolbar-options{{ vizid }}").find('a').on('click', function() {
      $this = $(this);<commit_msg>add fullscreen support for embedded graph visualizations<commit_after># Python module to use when working with the tulip module in a Jupyter / IPython notebook
# It enables to inline Tulip WebGL graph visualizations in the notebook

# That code is freely inspired from the great mpld3 project
# (see https://github.com/mpld3/mpld3/tree/master/mpld3)

import sys
import base64
import jinja2
import random
import os.path
import tempfile
import shutil
import IPython
from IPython.core.getipython import get_ipython
from IPython.core.display import display as ipythondisplay
from tulip import *

TULIPJS_HTML = jinja2.Template("""
<style type="text/css">
.tulip_viz {
  height: 400px;
  border: 1px solid black;
}
.interactor_button {
  position: absolute;
  left: 5px !important;
  z-index: 10;
}
.center_button {
  position: absolute;
  right: 0px !important;
  top: 0px !important;
  z-index: 10;
}
.fullscreen_button {
  position: absolute;
  right: 0px !important;
  top: 45px !important;
  z-index: 10;
}
</style>

<link rel="stylesheet" href="{{ jquerytoolbarcss_url }}" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"/>

<div id="toolbar-options{{ vizid }}" class="hidden">
   <a class="interactor-znp" href="#"><i class="fa fa-hand-paper-o" aria-hidden="true"></i></a>
   <a class="interactor-zoom" href="#"><i class="fa fa-search-plus"></i></a>
   <a class="interactor-fisheye" href="#"><i class="fa fa-eye"></i></a>
</div>

<div id="{{ vizid }}" class="tulip_viz">

<div id="toolbar{{ vizid }}" class="btn-toolbar btn-toolbar-dark interactor_button hidden">
    <i class="fa fa-hand-paper-o" aria-hidden="true"></i>
</div>

<div id="center{{ vizid }}" class="btn-toolbar btn-toolbar-dark center_button hidden">
    <i class="fa fa-arrows" aria-hidden="true"></i>
</div>

<div id="fullscreen{{ vizid }}" class="btn-toolbar btn-toolbar-dark fullscreen_button hidden">
    <i class="fa fa-arrows-alt" aria-hidden="true"></i>
</div>

</div>

<script type="text/javascript">

  require.config({paths: {tulip: "{{ tulipjs_url[:-3] }}",
                          base64utils: "{{ base64utils_url[:-3] }}",
                          jquerytoolbar: "{{ jquerytoolbarjs_url[:-3] }}"}});
  require(["tulip", "base64utils", "jquerytoolbar"], function(tulip, base64utils) {

    var tulipView;

    function initTulipGraphVisualization() {
      if (!tulip.isLoaded()) {
        setTimeout(initTulipGraphVisualization, 1000);
      } else {
        var tlpbgzGraphBase64 = "{{ tlpbgz_graph_base64 }}";
        var tlpbgzGraphBinary = base64utils.base64DecToArr(tlpbgzGraphBase64);
        var container = document.getElementById("{{ vizid }}");
        tulipView = tulip.View(container);
        $("#toolbar{{ vizid }}").removeClass('hidden');
        $("#center{{ vizid }}").removeClass('hidden');
        $("#fullscreen{{ vizid }}").removeClass('hidden');
        tulipView.loadGraphFromData("graph.tlpb.gz", tlpbgzGraphBinary);
        tulipView.centerScene();
        tulipView.draw();
      }
    };

    $("#toolbar-options{{ vizid }}").find(".interactor-znp").on('click', function() {
      tulipView.activateInteractor('ZoomAndPan');
    });

    $("#toolbar-options{{ vizid }}").find(".interactor-zoom").on('click', function() {
      tulipView.activateInteractor('RectangleZoom');
    });

    $("#center{{ vizid }}").on('click', function() {
      tulipView.centerScene();
    });

    $("#fullscreen{{ vizid }}").on('click', function() {
      tulipView.fullScreen();
    });

    $("#toolbar-options{{ vizid }}").find(".interactor-fisheye").on('click', function() {
      tulipView.activateInteractor('Fisheye');
    });

    $("#toolbar-options{{ vizid }}").find('a').on('click', function() {
      $this = $(this);
{'fraction_non_alphanumeric': 0.18149816952970993, 'fraction_numerical': 0.013939735285834975, 'mean_word_length': 3.9532775453277544, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 65, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '192194', 'n_tokens_mistral': 2480, 'n_tokens_neox': 2382, 'n_words': 490}