Skip to content

Commit

Permalink
HTML2 reporter: use local copy of all JS and CSS files
Browse files Browse the repository at this point in the history
Make the report folders self-contained
  • Loading branch information
Johannes Bechberger committed Aug 19, 2020
1 parent a3bf632 commit 1dafa11
Show file tree
Hide file tree
Showing 14 changed files with 185 additions and 13 deletions.
28 changes: 15 additions & 13 deletions temci/report/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,12 @@ def report(self):
shutil.rmtree(self.misc["out"])
else:
return
resources_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "report_resources"))
shutil.copytree(resources_path, self.misc["out"])
os.chmod(self.misc["out"], 0o755)
chown(self.misc["out"])
os.makedirs(self.misc["out"])
for folder in ["js", "css"]:
resources_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "report_resources/" + folder))
shutil.copytree(resources_path, self.misc["out"] + "/" + folder)
os.chmod(self.misc["out"] + "/" + folder, 0o755)
chown(self.misc["out"] + "/" + folder)
runs = self.stats_helper.valid_runs()
self._percent_format = self.misc["percent_format"]
self._float_format = self.misc["float_format"]
Expand All @@ -357,15 +359,14 @@ def report(self):
<head>
<title>Benchmarking report</title>
<meta charset="UTF-8"/>
<link rel="stylesheet" src="jquery.ui.all.css">
<link rel="stylesheet" src="jquery.tocify.css">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="jquery-ui-1.9.1.custom.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_SVG"></script>
<script src="script.js"></script>
<link rel="stylesheet" src="css/jquery.ui.all.css">
<link rel="stylesheet" src="css/jquery.tocify.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-ui-1.9.1.custom.min.js"></script>
<script src="js/script.js"></script>
</head>
<body style="font-family: sans-serif;">
<a href="" id="hidden_link" style="display: none;"></a>
Expand All @@ -388,6 +389,7 @@ def report(self):
</div>
</div>
{self._app_html}
<script src="js/custom-mathjax.min.js"></script>
<script>
$(function () {{
$('[data-toggle="popover"]').popover({{"content": function(){{
Expand Down
6 changes: 6 additions & 0 deletions temci/report/report_resources/css/bootstrap.min.css

Large diffs are not rendered by default.

File renamed without changes.
47 changes: 47 additions & 0 deletions temci/report/report_resources/custom-mathjax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Source: http://docs.mathjax.org/en/latest/web/webpack.html
//
// Initialize the MathJax startup code
//
require('mathjax-full/components/src/startup/lib/startup.js');

//
// Get the loader module and indicate the modules that
// will be loaded by hand below
//
const {Loader} = require('mathjax-full/js/components/loader.js');
Loader.preLoad(
'loader', 'startup',
'core',
'input/tex-base',
'[tex]/ams',
'output/svg', 'output/svg/fonts/tex.js',
);

//
// Load the components that we want to combine into one component
// (the ones listed in the preLoad() call above)
//
require('mathjax-full/components/src/core/core.js');

require('mathjax-full/components/src/input/tex-base/tex-base.js');
require('mathjax-full/components/src/input/tex/extensions/ams/ams.js');

require('mathjax-full/components/src/output/svg/svg.js');
require('mathjax-full/components/src/output/svg/fonts/tex/tex.js');


//
// Update the configuration to include any updated values
//
const {insert} = require('mathjax-full/js/util/Options.js');
insert(MathJax.config, {
tex: {
packages: {'[+]': ['ams']}
}
});

//
// Loading this component will cause all the normal startup
// operations to be performed
//
require('mathjax-full/components/src/startup/startup.js');
16 changes: 16 additions & 0 deletions temci/report/report_resources/custom-mathjax.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*************************************************************
*
* Copyright (c) 2017 The MathJax Consortium
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
62 changes: 62 additions & 0 deletions temci/report/report_resources/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#! /bin/sh

# Downloads all JS and CSS files
# requires npm to be installed

set -e
target_dir=$(dirname $(readlink -f $0))
cd $target_dir

# build mathjax

collect_dir="$target_dir/tmp"
custom_folder="$collect_dir/custom-mathjax"
mkdir -p $collect_dir
mkdir -p $custom_folder
cp webpack.config.js $custom_folder
cp custom-mathjax.js $custom_folder
cd $collect_dir

npm install mathjax-full@3
npm uninstall webpack --save-dev || echo 1
npm install webpack --save-dev
npm install webpack-cli
npm install uglifyjs-webpack-plugin
npm install @babel/core
npm install @babel/preset-env
npm install babel-core
npm install babel-preset-env
npm install babel-loader

cd $custom_folder
npm install @babel/core
npm install @babel/preset-env
../node_modules/mathjax-full/components/bin/makeAll
echo "/*************************************************************
*
* Copyright (c) 2017 The MathJax Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an \"AS IS\" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/" > $target_dir/js/custom-mathjax.min.js
cat custom-mathjax.min.js >> $target_dir/js/custom-mathjax.min.js

cd $target_dir


rm -r $collect_dir
cd css
wget https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css -O bootstrap.min.css
cd ../js
wget https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js -O jquery.min.js
wget https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js -O bootstrap.min.js

7 changes: 7 additions & 0 deletions temci/report/report_resources/js/bootstrap.min.js

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions temci/report/report_resources/js/custom-mathjax.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions temci/report/report_resources/js/jquery.min.js

Large diffs are not rendered by default.

File renamed without changes.
11 changes: 11 additions & 0 deletions temci/report/report_resources/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Source: http://docs.mathjax.org/en/latest/web/webpack.html

const PACKAGE = require('mathjax-full/components/webpack.common.js');

module.exports = PACKAGE(
'custom-mathjax', // the name of the package to build
'../node_modules/mathjax-full/js', // location of the mathjax library
[], // packages to link to
__dirname, // our directory
'.' // where to put the packaged component
);

0 comments on commit 1dafa11

Please sign in to comment.