diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..76bb828 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "jsroot"] + path = jsroot + url = git@github.com:linev/jsroot.git diff --git a/README.md b/README.md index a9f6650..7e91a74 100644 --- a/README.md +++ b/README.md @@ -15,15 +15,21 @@ It is tailored to people working in High Energy Physics that use ROOT (http://ro cd -1. Clone this repository +1. Clone this repository (and its submodule jsroot) - git clone https://github.com/musella/php-plots.git . + git clone --recursive https://github.com/simonepigazzini/php-plots.git 1. Copy the example/htaccess file into .htaccess and edit its content to suit your needs. cp -p example/htaccess .htaccess $EDITOR .htacces +1. Copy res/ jsroot/ and index.php into your web page top directory. + + cp -r res/ /path/to/www/ + cp -r jsroot/ /path/to/www/ + cp index.php /path/to/www/ + 1. Open the web folder into your browser. 1. Enjoy. @@ -41,6 +47,7 @@ It is tailored to people working in High Energy Physics that use ROOT (http://ro 1. Overlay content of .txt version on mouse hover. -# Example +1. Display root files using [JSROOT](https://root.cern.ch/js/) + +1. Display html interactive plots generated with [plotly](https://plotly.com/) -https://musella.web.cern.ch/musella/php-plots diff --git a/example/htaccess b/example/htaccess index e39b9d0..30d5f52 100644 --- a/example/htaccess +++ b/example/htaccess @@ -1,23 +1,56 @@ -## CERN Signle sign-on -## Uncomment if you want to restrict the access to your files +# *** This htaccess file has been modified automatically on November 16, 2020 *** +# Due to the end-of-life of SLC6 and Apache 2.2, web sites get migrated to a new infrastructure running +# CC7 and Apache 2.4. There are incompatible differences in web site configuration between these two versions. +# Because this htaccess file contained such incompatibilities, it has been modified in a way that works on both +# old and new infrastructures during the transition period (October-November 2020). +# See https://cern.service-now.com/service-portal/?id=outage&n=OTG0059516 # -# ShibRequireAll On -# ShibRequireSession On -# ShibExportAssertion On -# SSLRequireSSL -# AuthType Shibboleth -# -# SSLVerifyClient optional -# SSLVerifyDepth 5 -# SSLOptions +StrictRequire -# -# # Authorized group -# Require adfs-group "cms-private" - -## END CERN SSO +# *** If you need to modify this file during the transition period, make sure to apply your changes to both sections +# below. The site owner received an email with instructions to validate the web site configuration in the new +# infrastructure. *** + += 2.3> +# This section contains the Apache configuration directives used in the new webeos infrastructure running +# Apache 2.4 on CC7 + +Options +Indexes + +AuthType openid-connect +Require claim cern_roles:view-site-root + +## Tell Apache this is the web index +## +DirectoryIndex index.php index.html index.htm /spigazzi/index.php + + + + + +# This section contains the Apache configuration directives used in the legacy webeos infrastructure running +# Apache 2.2 on SLC6 +# It can be removed after December 2020 when https://cern.service-now.com/service-portal/?id=outage&n=OTG0059516 is complete. + +Options +Indexes + + + +ShibRequireAll On + +ShibRequireSession On + +ShibExportAssertion On + +SSLRequireSSL # The modules only work using HTTPS + +AuthType Shibboleth + + + +Require adfs-group "cms-physics" ## Tell Apache this is the web index ## -# Put below the path to your index.php (starting from the server root) -# eg /musella/higgs/index.php -DirectoryIndex index.php index.html index.htm ///index.php +DirectoryIndex index.php index.html index.htm /spigazzi/index.php + + + diff --git a/index.php b/index.php index f7965f3..1be82bf 100644 --- a/index.php +++ b/index.php @@ -1,24 +1,81 @@ - + ",$closetag="") +{ + $ret = ""; + if ( $opentag != "" ) $ret .= $opentag; + $encurl = $url; + $ret .= "[$name]"; + if ( $closetag != "" ) $ret .= $closetag; + return $ret; +} + +function resource($url,$name) +{ + return bookmark($url, $name, "_blank", "", ""); +} + + +/** + * Reads a list of links from a file and renders them. + * + * The expected file format is + * url && linkname + */ +function get_bookmarks($filename,$target="_blank",$rowlen=12,$opentable="",$closetable="
",$openrow="",$closerow="",$opencell="",$closecell="") +{ + $file = file_get_contents($filename); + $bookmarks=split("\n",$file); + + $ret = $opentable; + $n = 1; + foreach( $bookmarks as $bm ) { + if( $bm == "" ) { continue; } + list($url,$name) = split("[ ]*&&[ ]*",$bm); + if( ! empty($url) ) { + if( $rowlen > 0 && $n % $rowlen == 1 ) { $ret .= $openrow; } + $ret .= bookmark( $url, $name, $target, $opencell, $closecell ); + if( $rowlen > 0 && $n % $rowlen == 0 ) { $ret .= $closerow; } + $n++; + } + } + if( $rowlen > 0 && $n % $rowlen != 1 ) { $ret .= $closerow; } + $ret .= $closetable; + return $ret; +} + +$jsroot_instance = "/jsroot/index.htm"; +$pruned_uri = strtok($_SERVER['REQUEST_URI'], '?'); +$folder = str_replace($_SERVER['DOCUMENT_ROOT'], "", str_replace("index.php","",$pruned_uri)); +$target_folder = substr_replace($pruned_uri, $_SERVER['CONTEXT_DOCUMENT_ROOT'], 0, strlen($_SERVER['CONTEXT_PREFIX'])); +$script_path = substr_replace(dirname($_SERVER["SCRIPT_FILENAME"]), $_SERVER['CONTEXT_PREFIX'], 0, strlen($_SERVER['CONTEXT_DOCUMENT_ROOT'])); +chdir( $target_folder ) + ?> " /> @@ -61,15 +118,9 @@ function matchall($match,$name) { return true; } [parent] "; ?> 0; if ($has_subs) { print "
\n"; @@ -80,6 +131,7 @@ function matchall($match,$name) { return true; } print " (hide plots in subfolders)\n"; } print "\n"; + rsort($folders); foreach ($folders as $filename) { print " [$filename]"; } @@ -91,12 +143,27 @@ function matchall($match,$name) { return true; } print "
\n"; readfile($readme); print "
"; } } + +$bookm=""; +foreach (array("bookmarks.txt") as $bm) { + if (file_exists($bm)) { + if( $bookm == "" ) { + $bookm .= '

Bookmarks

'; + } + $bookm .= get_bookmarks($bm,"",10,"","","","
","",""); + } +} +if( $bookm != "" ) { + print "
\n"; + print $bookm; + print "
"; +} + ?>

Plots

-

Filter: - +

Filter: +

@@ -104,26 +171,20 @@ function matchall($match,$name) { return true; }

1 ) { + if( isset($_GET['depth']) && intval($_GET['depth'])>1 ) { $wildc="*"; for( $de=2; $de<=intval($_GET['depth']); $de++ ){ $wildc = $wildc."/*"; @@ -138,8 +199,7 @@ function matchall($match,$name) { return true; } } sort($filenames); foreach ($filenames as $filename) { - if( ! $matchf($match,$filename) ) { continue; } - /// if (isset($_GET['match']) && !fnmatch('*'.$_GET['match'].'*', $filename)) continue; + if( ! matchall($match, $filename) ) { continue; } $path_parts = pathinfo($filename); if (PHP_VERSION_ID < 50200) { $path_parts['filename'] = str_replace('.'.$path_parts['extension'],"",$path_parts['basename']); @@ -160,7 +220,7 @@ function matchall($match,$name) { return true; } if( $skip ) { continue; } array_push($displayed, $filename); $others = array(); - $max=46; + $max=25; $asym=2; $len=strlen($filename); if ($len >= $max) { @@ -179,16 +239,21 @@ function matchall($match,$name) { return true; } // print ""; print ""; // print ""; - foreach ($other_exts as $ex) { - $other_filename = $path_parts['filename'].$ex; - if (file_exists($other_filename)) { - if ($ex != '.txt') { - array_push($others, "[" . $ex . "]"); - array_push($displayed, $other_filename); - } else { + foreach ($other_exts as $ex) { + $other_filename = $path_parts['filename'].$ex; + if (file_exists($other_filename)) { + switch ($ex) { + case '.txt': $text = file_get_contents($other_filename); - array_push($others, "[" . $ex . "]". $text .""); - + array_push($others, "[" . $ex . "]". $text .""); + break; + case '.root': + array_push($others, "[" . $ex . "]"); + array_push($displayed, $other_filename); + break; + default : + array_push($others, "[" . $ex . "]"); + array_push($displayed, $other_filename); } } } @@ -198,31 +263,34 @@ function matchall($match,$name) { return true; } } } ?> -
+

Other files

+

-Like this page? Get it here.
+Like this page? Get it here.
Credits: Giovanni Petrucciani.

diff --git a/jsroot b/jsroot new file mode 160000 index 0000000..cde67e9 --- /dev/null +++ b/jsroot @@ -0,0 +1 @@ +Subproject commit cde67e98f870a194697c057b158e55e0f9dc9441