Commit 482d0e27 authored by Romain Loth's avatar Romain Loth

Merge branch 'politoscope_programmes' into port_to_sigma_v1.2

All these advances from politoscope prototype will be useful for the port and general refactoring:
  - removed legacy cortext localdb
  - new 'attrs to bins' logic (cf. scanClusters in parsing)
  - new 'attrs to colors' logic
  - new alt_colors rendering
  - new histogram variant: *daily* histograms
  - ! new simpler twitterAPI (directly with twitter's endpoints) !
  - useful debug logs for db.json loading and parseCustom
  - prepared parseCustom 'types' refactoring
  - getCurrentType function
parents 89bd5639 a7dbdeb2
<?php
header('Content-Type: application/json');
include("DirectoryScanner.php");
$projectFolderPat = dirname(dirname(getcwd())) . "/";
$instance = new scanTree($projectFolderPat);
$instance->getDirectoryTree("data");
//pr(var_dump($instance->folders));
$output = array();
$output["folders"] = $instance->folders;
$output["gexf_idfolder"] = $instance->gexf_folder;
echo json_encode($output);
// ** Debug Functions: **
function br() {
echo "----------<br>";
}
function pr($msg) {
echo $msg . "<br>";
}
?>
<?php
class scanTree {
public $root;
public $folders = array();
public $gexf_folder = array();
public function __construct($rootpath = "") {
$this->root = $rootpath;
}
public function getDirectoryTree($dir) {
$folder = array();
$dbs = array();
$gexfs = array();
$dataFolder = $this->root . $dir;
$files = scandir($dataFolder);
foreach ($files as $f) {
if ($f != "." and $f != ".." and $f[strlen($f) - 1] != "~") {
if (is_dir($dataFolder . "/" . $f)) {
//pr("Dir: ".$f);
$subfolder = $f;
$this->getDirectoryTree($dir . "/" . $subfolder);
} else {
//pr("File: ".$f);
if ((strpos($f, '.gexf')))
array_push($gexfs, $f);
if ((strpos($f, '.db')) or (strpos($f, '.sqlite')) or (strpos($f, '.sqlite3')))
array_push($dbs, $f);
if (!$folder[$dir]["gexf"] or !$folder[$dir]["dbs"])
$folder[$dir] = array();
$folder[$dir]["gexf"] = $gexfs;
$folder[$dir]["dbs"] = $dbs;
if ((strpos($f, '.gexf'))) {
$this->gexf_folder[$dir . "/" . $f] = "";
}
}
}
}
if ($folder[$dir]["gexf"]) {
foreach ($folder[$dir]["gexf"] as $g) {
$this->gexf_folder[$dir . "/" . $g] = count($this->folders);
}
}
array_push($this->folders, $folder);
}
}
?>
<?php
echo 'toto';
?>
\ No newline at end of file
<?php
// default informations
$thedb = $graphdb;
$gexf=$_GET["gexf"];
$max_item_displayed=6;
$type = $_GET["type"];
$TITLE="ISITITLE";
$query = str_replace( '__and__', '&', $_GET["query"] );
$elems = json_decode($query);
$table = "";
$column = "";
$id="";
$twjs=end( explode("/",getcwd()) )."/"; // LOCALDB folder.
if($type=="social"){
$table = "ISIAUTHOR";
$column = "data";
$id = "id";
$restriction='';
$factor=10;// factor for normalisation of stars
}
if($type=="semantic"){
$table = $_GET["index"];//"ISItermsfirstindexing";
$column = "data";
$id = "id";
$restriction='';
$factor=10;
}
$restriction='';
$factor=10;
$sql="";
//////////
if (count($elems)==1){// un seul mot est sélectionné, on compte les mots multiples
$sql = 'SELECT count(*),'.$id.'
FROM '.$table.' where (';
foreach($elems as $elem){
$sql.=' '.$column.'="'.$elem.'" OR ';
}
#$querynotparsed=$sql;#####
$sql = substr($sql, 0, -3);
$sql = str_replace( ' & ', '" OR '.$column.'="', $sql );
$sql.=' COLLATE NOCASE ) '.$restriction.'
GROUP BY '.$id.'
ORDER BY count('.$id.') DESC
LIMIT 1000';
}else{// on compte une seule fois un mot dans un article
$factor=ceil(count($elems)/5); //les scores sont moins haut
$sql='';
foreach($elems as $elem){
$sql.=' '.$column.'="'.$elem.'" OR ';
}
$sql=substr($sql, 0, -3);
$sql='SELECT count(*),id,data FROM (SELECT *
FROM '.$table.' where ('.$sql.' COLLATE NOCASE )'.$restriction.'
group by id,data) GROUP BY '.$id.'
ORDER BY count('.$id.') DESC
LIMIT 1000';
}
$wos_ids = array();
$sum=0;
// echo "<br>";
// echo "$sql";
//The final query!
// array of all relevant documents with score
foreach ($base->query($sql) as $row) {
// on pondère le score par le nombre de termes mentionnés par l'article
//$num_rows = $result->numRows();
$wos_ids[$row[$id]] = $row["count(*)"];
$sum = $row["count(*)"] +$sum;
}
// /// nombre de document associés $related
$total_count=0;
$count_max=500;
$number_doc=count($wos_ids);
$count=0;
$all_terms_from_selected_projects=array();// list of terms for the top 6 project selected
// to filter under some conditions
$to_display=true;
$count=0;
foreach ($wos_ids as $id => $score) {
if ($total_count<$count_max) {
// retrieve publication year
if ($to_display){
$total_count+=1;
if ($count<=$max_item_displayed){
$count+=1;
$sql = 'SELECT data FROM ISITITLE WHERE id='.$id.' group by data';
foreach ($base->query($sql) as $row) {
$external_link="<a href=http://google.com/webhp?#q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=15px src="libs/img2/google.png"></a>';
$output.="<li title='".$score."'>";
$output.=$external_link.imagestar($score,$factor,$twjs).' ';
$output.='<a href="JavaScript:newPopup(\''.$twjs.'default_doc_details.php?gexf='.urlencode($gexf).'&index='.$table.'&query='.urlencode($query).'&type='.urlencode($_GET["type"]).'&id='.$id.' \')">'.$row['data']." </a> ";
// echo '<a href="JavaScript:newPopup(\''.$twjs.'default_doc_details.php?gexf='.urlencode($gexf).'&index='.$table.'&query='.urlencode($query).'&type='.urlencode($_GET["type"]).'&id='.$id.' \')">'.$row['data']." </a> ";
}
// get the authors
$sql = 'SELECT data FROM ISIAUTHOR WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$output.=($row['data']).', ';
}
$output = rtrim($output, ", ");
$output.="</li><br>";
}
}
} else{
continue;
}
}
if ($total_count<$count_max){
$related .= $total_count;
}else{
$related .= ">".$count_max;
}
$output .= "</ul>"; #####
// // if (($project_folder=='nci')&&(count($elems)<$max_selection_size)){
// // // for NCI we compare the impact and novelty score making the difference if there are more than 4 terms selected
// // $news='';//new terms
// // $terms_from_selected_projects=array_unique($all_terms_from_selected_projects);
// // if(count($terms_from_selected_projects)>3){
// // $diff=array();
// // foreach ($terms_from_selected_projects as $key => $term) {
// // $sql= "select count(*),ISIterms.id, ISIterms.data from ISIterms join ISIpubdate on (ISIterms.id=ISIpubdate.id AND ISIpubdate.data=2011 AND ISIterms.data='".$term."') group by ISIterms.data";
// // $nov=0;
// // foreach ($corporadb->query($sql) as $row) {
// // $nov=$row['count(*)'];
// // }
// // $sql= "select count(*),ISIterms.id, ISIterms.data from ISIterms join ISIpubdate on (ISIterms.id=ISIpubdate.id AND ISIpubdate.data=2012 AND ISIterms.data='".$term."') group by ISIterms.data";
// // $imp=0;
// // foreach ($corporadb->query($sql) as $row) {
// // $imp=$row['count(*)'];
// // }
// // $diff[$term]=info($nov,$imp); //positive si c'est un term novelty, negatif si c'est un terme impact.
// // //echo $term.'-nov: '.$nov.'- imp:'.$imp.'<br/>';//'-info'.$diff[$term].
// // }
// // if (true){
// // arsort($diff);
// // $res=array_keys($diff);
// // //echo implode(', ', $res);
// // $nov_string='';
// // for ($i=0;$i<$top_displayed;$i++){
// // // on récupère les titres du document qui a le plus for impact
// // $sql="SELECT ISIterms.id,ISIC1_1.data,count(*) from ISIterms,ISIpubdate,ISIC1_1 where ISIterms.data='".$res[$i]."' AND ISIterms.id=ISIpubdate.id AND ISIterms.id=ISIC1_1.id AND ISIpubdate.data='2011' group by ISIterms.id ORDER BY RANDOM() limit 1";
// // //on récupère les id associés.
// // foreach ($corporadb->query($sql) as $row){
// // $sql2='SELECT ISIpubdate.id,ISIC1_1.data from ISIpubdate,ISIC1_1 where ISIC1_1.data="'.$row['data'].'" AND ISIpubdate.id=ISIC1_1.id AND ISIpubdate.data="2013" limit 1';
// // //echo $sql2;
// // foreach ($corporadb->query($sql2) as $row2){
// // $nov_string.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?db='.urlencode($graphdb).'&gexf='.urlencode($gexf).'&query='.urlencode('["'.$res[$i].'"]').'&type='.urlencode($_GET["type"]).'&id='.$row2['id'].' \')">'.$res[$i]."</a>, ";
// // }
// // }
// // }
// // $news.='<br/><b><font color="#FF0066">Top '.$top_displayed.' Novelty related terms </font></b>'.$nov_string.'<br/>';
// // asort($diff);
// // $res=array_keys($diff);
// // $res_string='';
// // for ($i=0;$i<$top_displayed;$i++){
// // // on récupère les titres du document qui a le plus for impact
// // $sql="SELECT ISIterms.id,ISIC1_1.data,count(*) from ISIterms,ISIpubdate,ISIC1_1 where ISIterms.data='".$res[$i]."' AND ISIterms.id=ISIpubdate.id AND ISIterms.id=ISIC1_1.id AND ISIpubdate.data='2012' group by ISIterms.id ORDER BY RANDOM()limit 1";
// // //on récupère les id associés.
// // foreach ($corporadb->query($sql) as $row){
// // $sql2='SELECT ISIpubdate.id,ISIC1_1.data from ISIpubdate,ISIC1_1 where ISIC1_1.data="'.$row['data'].'" AND ISIpubdate.id=ISIC1_1.id AND ISIpubdate.data="2013" limit 1';
// // //echo $sql2;
// // foreach ($corporadb->query($sql2) as $row2){
// // $res_string.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?db='.urlencode($graphdb).'&gexf='.urlencode($gexf).'&query='.urlencode('["'.$res[$i].'"]').'&type='.urlencode($_GET["type"]).'&id='.$row2['id'].' \')">'.$res[$i]."</a>, ";
// // }
// // }
// // }
// // $news.='<br/><b><font color="#CF5300">Top '.$top_displayed.' Impact related terms: </font></b>'.$res_string.'<br/>';
// // }
// // }
// // }
// // display the most occuring terms when only one is selected.
// //elseif (count($elems)==1) {// on affiche les voisins
// // $terms_array=array();
// // $id_sql='SELECT ISIterms.id FROM ISIterms where ISIterms.data="'.$elems[0].'" group by id';
// // foreach ($base->query($id_sql) as $row_id) {
// // $sql2='SELECT ISIterms.data FROM ISIterms where ISIterms.id='.$row_id['id'];
// // foreach ($base->query($sql2) as $row_terms) {
// // if ($terms_array[$row_terms['data']]>0){
// // $terms_array[$row_terms['data']]=$terms_array[$row_terms['data']]+1;
// // }else{
// // $terms_array[$row_terms['data']]=1;
// // }
// // }
// // }
// // natsort($terms_array);
// // $terms_list=array_keys(array_slice($terms_array,-11,-1));
// // foreach ($terms_list as $first_term) {
// // $related_terms.=$first_term.', ';
// // }
// // $news.='<br/><b><font color="#CF5300">Related terms: </font></b>'.$related_terms.'<br/>';
// //}
// calculate binomial coefficient
function binomial_coeff($n, $k) {
$j = $res = 1;
if($k < 0 || $k > $n)
return 0;
if(($n - $k) < $k)
$k = $n - $k;
while($j <= $k) {
$res *= $n--;
$res /= $j++;
}
return $res;
}
function imagestar($score,$factor,$twjs) {
// produit le html des images de score
$star_image = '';
if ($score > .5) {
$star_image = '';
for ($s = 0; $s < min(5,$score/$factor); $s++) {
$star_image.='<img src="libs/img2/star.gif" border="0" >';
}
} else {
$star_image.='<img src="libs/img2/stargrey.gif" border="0">';
}
return $star_image;
}
if($max_item_displayed>$related) $max_item_displayed=$related;
echo $news.'<br/><h4><font color="#0000FF"> Full text of top '.$max_item_displayed.'/'.$related.' related publications:</font></h4>'.$output;
//pt - 301 ; 15.30
?>
<?php
include('parameters_details.php');
$db = $gexf_db[$gexf];
$base = new PDO("sqlite:../" .$db);
$query = str_replace( '__and__', '&', $_GET["query"] );
$terms_of_query = json_decode($query);
// echo "mainpath: ".$mainpath."<br>";
// echo "thedb: ".$db."<br>";
// echo "thequery: ".var_dump($terms_of_query);
echo '
<html>
<head>
<meta charset="utf-8" />
<title>Document details</title>
<link rel="stylesheet" href="js/jquery-ui.css" />
<script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery-ui.js"></script>
<script>
$(function() {
$( "#tabs" ).tabs({
collapsible: true
});
});
</script>
</head>
<body>
<div id="tabs">
<ul>
<li><a href="#tabs-1">Selected Document</a></li>
<li><a href="full_doc_list.php?'.'gexf='.urlencode($gexf).'&query='.urlencode($_GET["query"]).'&index='.$_GET["index"].'&type='.urlencode($_GET["type"]).'">Full list</a></li>';
echo '</ul>';
echo '<div id="tabs-1">';
$id=$_GET["id"];
// //$elems = json_decode($query);
// $sql = 'SELECT data FROM ISIkeyword WHERE id='.$id;
// foreach ($base->query($sql) as $row) {
// $country=$CC[strtoupper($row['data'])];
// }
$sql = 'SELECT data FROM ISITITLE WHERE id='.$id.' group by data';
foreach ($base->query($sql) as $row) {
$output.='<h2>'.$row['data'].'</h2>';
$find.="<br/><a href=http://google.com/webhp?q=".urlencode('"'.$row['data'].'"')." target='blank'>[ Search on the web ] </a>";
}
// get the authors
$sql = 'SELECT data FROM ISIAUTHOR WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$output.='<i>'.($row['data']).'</i>, ';
}
$output = rtrim($output, ", ");
// // // get the company
// // $sql = 'SELECT data FROM ISIC1_1 WHERE id='.$id;
// // foreach ($base->query($sql) as $row) {
// //$output.=' - '.substr($row['data'],3,strlen( $row['data'])).' ';
// //}
// get the date
$sql = 'SELECT data FROM ISIpubdate WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$output.=' ('.$row['data'].') ';
}
// // get the country
// $sql = 'SELECT data FROM ISIkeyword WHERE id='.$id;
// foreach ($base->query($sql) as $row) {
// $country=$CC[strtoupper($row['data'])];
// $output.=strtoupper($country).'<br/> ';
// }
// // get the date
if(strpos($_GET["index"],'terms') ) $sql = 'SELECT data FROM '.$_GET["index"].' WHERE id='.$id;
else $sql = 'SELECT data FROM ISItermsListV1 WHERE id='.$id;
$output.='<br/><b>Keywords: </b>';
$terms=array();
foreach ($base->query($sql) as $row) {
$terms[]=$row['data'];
}
natsort($terms);
$terms=array_unique($terms); // liste des termes de l'article
$keywords='';
foreach ($terms as $key => $value) {
$keywords.=$value.', ';
}
foreach ($terms_of_query as $key => $value) {
$keywords=str_replace($value,'<font color="green"><b> '.$value.'</b></font>',$keywords);
}
foreach (array_diff($terms,$terms_of_query) as $key => $value) {
$keywords=str_ireplace($value,'<font color="#800000"> '.$value.'</font>',$keywords);
}
$output.='<p align="justify">'.$keywords.'</p>';
// // get the website
$sql = 'SELECT data FROM ISISO WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$output.='<b>Journal: </b>'.$row['data'].'<br/> ';
}
$sql = 'SELECT data FROM ISIABSTRACT WHERE id='.$id;
// echo $output."<br>";
$abs="";
foreach ($base->query($sql) as $row) {
$abs.=". ".$row['data'];
}
$abs=str_replace('ISSUES:' ,'<br/><br/><b>Issues:</b>',$abs);
$abs=str_replace('INTENDED IMPACT:' ,'<br/><br/><b>Intended impact:</b>',$abs);
$abs=str_replace('IMPACT:' ,'<br/><br/><b>Impact:</b>',$abs);
$abs=str_replace('NOVELTY:' ,'<br/><br/><b>Novelty:</b>',$abs);
$abs=str_replace('BOLD INNOVATION:' ,'<br/><br/><b>Bold innovation:</b>',$abs);
$abs=str_replace('SOCIAL PROBLEM:' ,'<br/><br/><b>Social problem:</b>',$abs);
// solving encoding pb
$abs=str_replace('―', ' ', $abs);
$abs=str_replace('‟‟', ' ', $abs);
$abs=str_replace('„‟', ' ', $abs);
$abs=str_replace('_x000D_', ' ', $abs);
$abs=str_replace('•', ' ', $abs);
$abs=str_replace('’', '\'', $abs);
foreach ($terms_of_query as $key => $value) {
$abs=str_ireplace($value,'<font color="green"><b> '.$value.'</b></font>',$abs);
}
foreach (array_diff($terms,$terms_of_query) as $key => $value) {
$abs=str_ireplace($value,'<font color="#800000"> '.$value.'</font>',$abs);
}
$output.='<br/><p align="justify"><b>Abstract : </b><i>'.$abs.' </i></p>';
$output.="<br>";
echo $output.$find;
echo '</div>';
//echo '<div id="tabs-2">
// <p><strong>Click this tab again to close the content pane.</strong></p>
// <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>
// </div>';
echo '</div>';
function pt($string){
// juste pour afficher avec retour à la ligne
echo $string."<br/>";
}
function pta($array){
print_r($array);
echo '<br/>';
}
?>
<?php
include('parameters_details.php');
$db = $gexf_db[$gexf];
$base = new PDO("sqlite:../" ."data/terrorism/data.db");
$query = str_replace( '__and__', '&', $_GET["query"] );
$terms_of_query = json_decode($query);
// echo "mainpath: ".$mainpath."<br>";
// echo "thedb: ".$db."<br>";
// echo "thequery: ".var_dump($terms_of_query);
echo '
<html>
<head>
<meta charset="utf-8" />
<title>Document details</title>
<link rel="stylesheet" href="js/jquery-ui.css" />
<script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery-ui.js"></script>
<script>
$(function() {
$( "#tabs" ).tabs({
collapsible: true
});
});
</script>
</head>
<body>
<div id="tabs">
<ul>
<li><a href="#tabs-1">Selected Document</a></li>
<li><a href="full_doc_list2.php?'.'gexf='.urlencode($gexf).'&query='.urlencode($_GET["query"]).'&type='.urlencode($_GET["type"]).'">Full list</a></li>';
echo '</ul>';
echo '<div id="tabs-1">';
$id=$_GET["id"];
// //$elems = json_decode($query);
// $sql = 'SELECT data FROM ISIkeyword WHERE id='.$id;
// foreach ($base->query($sql) as $row) {
// $country=$CC[strtoupper($row['data'])];
// }
$sql = 'SELECT data FROM ID WHERE id='.$id.' group by data';
foreach ($base->query($sql) as $row) {
$output.='<h2>Project Identification: '.$row['data'].'</h2>';
}
$sql = 'SELECT data FROM TI WHERE id='.$id.' group by data';
foreach ($base->query($sql) as $row) {
$output.='<h2>'.$row['data'].'</h2>';
$find.="<br/><a href=http://google.com/webhp?q=".urlencode('"'.$row['data'].'"')." target='blank'>[ Search on the web ] </a>";
}
// get the authors
$sql = 'SELECT data FROM PI WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$output.='<i>'.($row['data']).'</i>, ';
}
$output = rtrim($output, ", ");
// // // get the company
// // $sql = 'SELECT data FROM ISIC1_1 WHERE id='.$id;
// // foreach ($base->query($sql) as $row) {
// //$output.=' - '.substr($row['data'],3,strlen( $row['data'])).' ';
// //}
$output.=' (2014) ';
// // get the country
// $sql = 'SELECT data FROM ISIkeyword WHERE id='.$id;
// foreach ($base->query($sql) as $row) {
// $country=$CC[strtoupper($row['data'])];
// $output.=strtoupper($country).'<br/> ';
// }
// // get the date
// $sql = 'SELECT data FROM '."ISItermsBigWL".' WHERE id='.$id;
$sql = 'SELECT data FROM ISItermsfirstindexing WHERE id='.$id;
$output.='<br/><b>Keywords: </b>';
$terms=array();
foreach ($base->query($sql) as $row) {
$terms[]=$row['data'];
}
natsort($terms);
$terms=array_unique($terms); // liste des termes de l'article
$keywords='';
foreach ($terms as $key => $value) {
$keywords.=$value.', ';
}
foreach ($terms_of_query as $key => $value) {
$keywords=str_replace($value,'<font color="green"><b> '.$value.'</b></font>',$keywords);
}
foreach (array_diff($terms,$terms_of_query) as $key => $value) {
$keywords=str_ireplace($value,'<font color="#800000"> '.$value.'</font>',$keywords);
}
$output.='<p align="justify">'.$keywords.'</p>';
// // get the website
$sql = 'SELECT data FROM AG1 WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$output.='<b>Agency: </b>'.$row['data'].'<br/> ';
}
$sql = 'SELECT data FROM ABS WHERE id='.$id;
// echo $output."<br>";
$abs="";
foreach ($base->query($sql) as $row) {
$abs.=". ".$row['data'];
}
$abs=str_replace('ISSUES:' ,'<br/><br/><b>Issues:</b>',$abs);
$abs=str_replace('INTENDED IMPACT:' ,'<br/><br/><b>Intended impact:</b>',$abs);
$abs=str_replace('IMPACT:' ,'<br/><br/><b>Impact:</b>',$abs);
$abs=str_replace('NOVELTY:' ,'<br/><br/><b>Novelty:</b>',$abs);
$abs=str_replace('BOLD INNOVATION:' ,'<br/><br/><b>Bold innovation:</b>',$abs);
$abs=str_replace('SOCIAL PROBLEM:' ,'<br/><br/><b>Social problem:</b>',$abs);
// solving encoding pb
$abs=str_replace('―', ' ', $abs);
$abs=str_replace('‟‟', ' ', $abs);
$abs=str_replace('„‟', ' ', $abs);
$abs=str_replace('_x000D_', ' ', $abs);
$abs=str_replace('•', ' ', $abs);
$abs=str_replace('’', '\'', $abs);
foreach ($terms_of_query as $key => $value) {
$abs=str_ireplace($value,'<font color="green"><b> '.$value.'</b></font>',$abs);
}
foreach (array_diff($terms,$terms_of_query) as $key => $value) {
$abs=str_ireplace($value,'<font color="#800000"> '.$value.'</font>',$abs);
}
$output.='<br/><p align="justify"><b>Abstract : </b><i>'.$abs.' </i></p>';
$output.="<br>";
echo $output.$find;
echo '</div>';
//echo '<div id="tabs-2">
// <p><strong>Click this tab again to close the content pane.</strong></p>
// <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>
// </div>';
echo '</div>';
function pt($string){
// juste pour afficher avec retour à la ligne
echo $string."<br/>";
}
function pta($array){
print_r($array);
echo '<br/>';
}
?>
<?php
$db= $_GET["db"];//I receive the specific database as string!
$terms_of_query=json_decode($_GET["query"]);
include('parameters_details.php');
$base = new PDO("sqlite:" .$mainpath.$db);
$query=$_GET["query"];
$gexf=$_GET["gexf"];
$max_tag_could_size=15;
$output = "<ul>"; // string sent to the javascript for display
$type = $_GET["type"];
$sql='SELECT id from favorites';
$wos_ids=array(); // favorite list
$num_favorite=0;
$count=0;
foreach ($base->query($sql) as $row){
$wos_ids[$row['id']] = 1;
$num_favorite+=1;
}
$favorite_keywords=array();
foreach ($wos_ids as $id => $score) {
if ($count<1000){
// retrieve publication year
$sql = 'SELECT data FROM ISIpubdate WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$pubdate=$row['data'];
}
$count+=1;
$output.="<li >";
$sql = 'SELECT data FROM ISItermsListV1 WHERE id='.$id;
foreach ($base->query($sql) as $row) {
if (array_key_exists($row['data'], $favorite_keywords)){
$favorite_keywords[$row['data']]=$favorite_keywords[$row['data']]+1;
}else{
$favorite_keywords[$row['data']]=1;
}
}
$sql = 'SELECT data FROM ISITITLE WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$output.='<a href="default_doc_details.php?db='.urlencode($db).'&type='.urlencode($_GET["type"]).'&query='.urlencode($query).'&id='.$id.'">'.$row['data']." </a> ";
//this should be the command:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?db='.urlencode($datadb).'&id='.$id.' \')">'.$row['data']." </a> ";
//the old one:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?id='.$id.' \')">'.$row['data']." </a> ";
$external_link="<a href=http://scholar.google.com/scholar?q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=20px src="img/gs.png"></a>';
//$output.='<a href="JavaScript:newPopup(''php/doc_details.php?id='.$id.''')"> Link</a>';
}
// get the authors
$sql = 'SELECT data FROM ISIAUTHOR WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$output.=strtoupper($row['data']).', ';
}
if($project_folder!='nci'){
$output.='('.$pubdate.') ';
}else {
$output.='(2013) ';
}
// get the country
$sql = 'SELECT data FROM ISIkeyword WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$country=$CC[strtoupper($row['data'])];
$output.=strtoupper($country).' ';
}
//<a href="JavaScript:newPopup('http://www.quackit.com/html/html_help.cfm');">Open a popup window</a>'
$output.=$external_link."</li><br>";
}else{
continue;
}
}
arsort($favorite_keywords);
$tag_coud_size=0;
$tag_could='';
foreach ($favorite_keywords as $key => $value) {
if ($tag_coud_size<$max_tag_could_size){
$tag_coud_size+=1;
$tag_could.='<font size="'.(3+log($value)).'">'.$key.', </font>';
}else{
continue;
} # code...
}
$output= '<h3>'.$num_favorite.' favorite items </h3>'.$tag_could.'<br/>'.$output;
echo $output;
function imagestar($score,$factor,$twjs) {
// produit le html des images de score
$star_image = '';
if ($score > .5) {
$star_image = '';
for ($s = 0; $s < min(5,$score/$factor); $s++) {
$star_image.='<img src="libs/img2/star.gif" border="0" >';
}
} else {
$star_image.='<img src="libs/img2/stargrey.gif" border="0">';
}
return $star_image;
}
?>
<?php
include('parameters_details.php');
$db = $gexf_db[$gexf];
$base = new PDO("sqlite:../" .$db);
$output = "<ul>"; // string sent to the javascript for display
#http://localhost/branch_ademe/php/test.php?type=social&query=[%22marwah,%20m%22]
$type = $_GET["type"];
$query = str_replace( '__and__', '&', $_GET["query"] );
$terms_of_query=json_decode($_GET["query"]);
$elems = json_decode($query);
// nombre d'item dans les tables
$sql='SELECT COUNT(*) FROM ISIABSTRACT';
foreach ($base->query($sql) as $row) {
$table_size=$row['COUNT(*)'];
}
$table = "";
$column = "";
$id="";
$twjs=end( explode("/",getcwd()) )."/"; // LOCALDB folder.
if($type=="social"){
$table = "ISIAUTHOR";
$column = "data";
$id = "id";
$restriction='';
$factor=10;// factor for normalisation of stars
}
if($type=="semantic"){
$table = $_GET["index"];
$column = "data";
$id = "id";
$restriction='';
$factor=10;
}
$sql = 'SELECT count(*),'.$id.'
FROM '.$table.' where (';
foreach($elems as $elem){
$sql.=' '.$column.'="'.$elem.'" OR ';
}
#$querynotparsed=$sql;#####
$sql = substr($sql, 0, -3);
$sql = str_replace( ' & ', '" OR '.$column.'="', $sql );
$sql.=')'.$restriction.'
GROUP BY '.$id.'
ORDER BY count('.$id.') DESC
LIMIT 1000';
#$queryparsed=$sql;#####
$wos_ids = array();
$sum=0;
//The final query!
// array of all relevant documents with score
foreach ($base->query($sql) as $row) {
// on pondère le score par le nombre de termes mentionnés par l'article
//$num_rows = $result->numRows();
$wos_ids[$row[$id]] = $row["count(*)"];
$sum = $row["count(*)"] +$sum;
}
//arsort($wos_ids);
$number_doc=ceil(count($wos_ids)/3);
$count=0;
foreach ($wos_ids as $id => $score) {
if ($count<1000){
// retrieve publication year
$sql = 'SELECT data FROM ISIpubdate WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$pubdate=$row['data'];
}
// to filter under some conditions
$to_display=true;
if ($to_display){
$count+=1;
$output.="<li title='".$score."'>";
$output.=imagestar($score,$factor,$twjs).' ';
$sql = 'SELECT data FROM ISITITLE WHERE id='.$id." group by data";
foreach ($base->query($sql) as $row) {
$output.='<a href="default_doc_details.php?gexf='.urlencode($gexf).'&type='.urlencode($_GET["type"]).'&query='.urlencode($query).'&id='.$id.'">'.$row['data']." </a> ";
//this should be the command:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?db='.urlencode($datadb).'&id='.$id.' \')">'.$row['data']." </a> ";
//the old one:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?id='.$id.' \')">'.$row['data']." </a> ";
$external_link="<a href=http://scholar.google.com/scholar?q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=20px src="libs/img2/gs.png"></a>';
//$output.='<a href="JavaScript:newPopup(''php/doc_details.php?id='.$id.''')"> Link</a>';
}
// get the authors
$sql = 'SELECT data FROM ISIAUTHOR WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$output.=strtoupper($row['data']).', ';
}
//<a href="JavaScript:newPopup('http://www.quackit.com/html/html_help.cfm');">Open a popup window</a>'
$output.=$external_link."</li><br>";
}
}else{
continue;
}
}
$output= '<h3>'.$count.' items related to: '.implode(' OR ', $elems).'</h3>'.$output;
echo $output;
function imagestar($score,$factor,$twjs) {
// produit le html des images de score
$star_image = '';
if ($score > .5) {
$star_image = '';
for ($s = 0; $s < min(5,$score/$factor); $s++) {
$star_image.='<img src="libs/img2/star.gif" border="0" >';
}
} else {
$star_image.='<img src="libs/img2/stargrey.gif" border="0">';
}
return $star_image;
}
?>
<?php
include('parameters_details.php');
$db = $gexf_db[$gexf];
$base = new PDO("sqlite:../" ."data/terrorism/data.db");
echo "sqlite:../" ."data/terrorism/data.db";
$output = "<ul>"; // string sent to the javascript for display
#http://localhost/branch_ademe/php/test.php?type=social&query=[%22marwah,%20m%22]
$type = $_GET["type"];
$query = str_replace( '__and__', '&', $_GET["query"] );
$terms_of_query=json_decode($_GET["query"]);
$elems = json_decode($query);
// nombre d'item dans les tables
$sql='SELECT COUNT(*) FROM ISIABSTRACT';
foreach ($base->query($sql) as $row) {
$table_size=$row['COUNT(*)'];
}
$table = "";
$column = "";
$id="";
$twjs="pasteurapi/"; // submod path of TinaWebJS
if($type=="social"){
$table = "ISIAUTHOR";
$column = "data";
$id = "id";
$restriction='';
$factor=10;// factor for normalisation of stars
}
if($type=="semantic"){
$table = "ISItermsListV1";
$column = "data";
$id = "id";
$restriction='';
$factor=10;
}
$sql = 'SELECT count(*),'.$id.'
FROM '.$table.' where (';
foreach($elems as $elem){
$sql.=' '.$column.'="'.$elem.'" OR ';
}
#$querynotparsed=$sql;#####
$sql = substr($sql, 0, -3);
$sql = str_replace( ' & ', '" OR '.$column.'="', $sql );
$sql.=')'.$restriction.'
GROUP BY '.$id.'
ORDER BY count('.$id.') DESC
LIMIT 1000';
#$queryparsed=$sql;#####
$wos_ids = array();
$sum=0;
//The final query!
// array of all relevant documents with score
foreach ($base->query($sql) as $row) {
// on pondère le score par le nombre de termes mentionnés par l'article
//$num_rows = $result->numRows();
$wos_ids[$row[$id]] = $row["count(*)"];
$sum = $row["count(*)"] +$sum;
}
//arsort($wos_ids);
$number_doc=ceil(count($wos_ids)/3);
$count=0;
foreach ($wos_ids as $id => $score) {
if ($count<1000){
// retrieve publication year
$sql = 'SELECT data FROM ISIpubdate WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$pubdate="2014";
}
// to filter under some conditions
$to_display=true;
if ($to_display){
$count+=1;
$output.="<li title='".$score."'>";
$output.=imagestar($score,$factor,$twjs).' ';
$sql = 'SELECT data FROM ISITITLE WHERE id='.$id." group by data";
foreach ($base->query($sql) as $row) {
$output.='<a href="default_doc_details2.php?gexf='.urlencode($gexf).'&type='.urlencode($_GET["type"]).'&query='.urlencode($query).'&id='.$id.'">'.$row['data']." </a> ";
//this should be the command:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?db='.urlencode($datadb).'&id='.$id.' \')">'.$row['data']." </a> ";
//the old one:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?id='.$id.' \')">'.$row['data']." </a> ";
$external_link="<a href=http://scholar.google.com/scholar?q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=20px src="libs/img2/gs.png"></a>';
//$output.='<a href="JavaScript:newPopup(''php/doc_details.php?id='.$id.''')"> Link</a>';
}
// get the authors
$sql = 'SELECT data FROM ISIAUTHOR WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$output.=strtoupper($row['data']).', ';
}
//<a href="JavaScript:newPopup('http://www.quackit.com/html/html_help.cfm');">Open a popup window</a>'
$output.=$external_link."</li><br>";
}
}else{
continue;
}
}
$output= '<h3>'.$count.' items related to: '.implode(' OR ', $elems).'</h3>'.$output;
echo $output;
function imagestar($score,$factor,$twjs) {
// produit le html des images de score
$star_image = '';
if ($score > .5) {
$star_image = '';
for ($s = 0; $s < min(5,$score/$factor); $s++) {
$star_image.='<img src="libs/img2/star.gif" border="0" >';
}
} else {
$star_image.='<img src="libs/img2/stargrey.gif" border="0">';
}
return $star_image;
}
?>
<?php
include('parameters_details.php');
$db= $_GET["db"];//I receive the specific database as string!
$query=$_GET["query"];
$gexf=$_GET["gexf"];
$base = new PDO("sqlite:" .$mainpath.$db);
$temp=explode('/',$db);
$project_folder=$temp[1];
$corpora=$temp[count($temp)-2];
$corporadb = new PDO("sqlite:" .$mainpath.'data/'.$corpora.'/'.$corpora.'.sqlite'); //data base with complementary data
$output = "<ul>"; // string sent to the javascript for display
#http://localhost/branch_ademe/php/test.php?type=social&query=[%22marwah,%20m%22]
$type = $_GET["type"];
$query = str_replace( '__and__', '&', $_GET["query"] );
$elems = json_decode($query);
// nombre d'item dans les tables
$sql='SELECT COUNT(*) FROM ISIABSTRACT';
foreach ($base->query($sql) as $row) {
$table_size=$row['COUNT(*)'];
}
///// Specific to rock //////////
// Other restrictions
// extracting the project folder and the year
if (strpos($gexf,'2013')>0){
$year='2013';
$year_filter=true;
}elseif (strpos($gexf,'2012')>0){
$year='2012';
$year_filter=true;
}else{
$year_filter=false;
}
// identification d'une année pour echoing
if($project_folder=='nci'){
$year_filter=true;
}
$table = "";
$column = "";
$id="";
$twjs="tinawebJS/"; // submod path of TinaWebJS
if($type=="social"){
$table = "ISIAUTHOR";
$column = "data";
$id = "id";
$restriction='';
$factor=10;// factor for normalisation of stars
}
if($type=="semantic"){
$table = "ISItermsListV1";
$column = "data";
$id = "id";
$restriction='';
$factor=10;
}
// identification d'une année pour echoing
if($project_folder=='nci'){
$restriction.=" AND ISIpubdate='2013'";
}
$sql = 'SELECT sum(tfidf),id
FROM tfidf where (';
foreach($elems as $elem){
$sql.=' term="'.$elem.'" OR ';
}
#$querynotparsed=$sql;#####
$sql = substr($sql, 0, -3);
$sql = str_replace( ' & ', '" OR term="', $sql );
$sql.=')'.//$restriction.
'GROUP BY '.$id.'
ORDER BY sum(tfidf) DESC
LIMIT 1000';
//echo $sql;
#$queryparsed=$sql;#####
$wos_ids = array();
$sum=0;
//echo $sql;//The final query!
// array of all relevant documents with score
$count=0;
foreach ($corporadb ->query($sql) as $row) {
//if ($count<4*$max_item_displayed){
$wos_ids[$row[$id]] = $row['sum(tfidf)'];//$row["count(*)"];
$sum = $row["count(*)"] +$sum;
//}else{
// continue;
//}
}
//arsort($wos_ids);
$number_doc=ceil(count($wos_ids)/3);
$count=0;
foreach ($wos_ids as $id => $score) {
if ($count<1000){
// retrieve publication year
$sql = 'SELECT data FROM ISIpubdate WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$pubdate=$row['data'];
}
// to filter under some conditions
$to_display=true;
if ($project_folder=='echoing'){
if ($year_filter){
if ($pubdate!=$year){
$to_display=false;
}
}
}elseif($project_folder=='nci'){
if ($year_filter){
if ($pubdate!='2013'){
$to_display=false;
}
}
}
if ($to_display){
$count+=1;
$output.="<li title='".$score."'>";
$output.=imagestar($score,$factor,$twjs).' ';
$sql = 'SELECT data FROM ISITITLE WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$output.='<a href="default_doc_details.php?db='.urlencode($db).'&type='.urlencode($_GET["type"]).'&query='.urlencode($query).'&id='.$id.'">'.$row['data']." </a> ";
//this should be the command:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?db='.urlencode($datadb).'&id='.$id.' \')">'.$row['data']." </a> ";
//the old one:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?id='.$id.' \')">'.$row['data']." </a> ";
$external_link="<a href=http://scholar.google.com/scholar?q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=20px src="libs/img2/gs.png"></a>';
//$output.='<a href="JavaScript:newPopup(''php/doc_details.php?id='.$id.''')"> Link</a>';
}
// get the authors
$sql = 'SELECT data FROM ISIAUTHOR WHERE id='.$id;
foreach ($base->query($sql) as $row) {
$output.=strtoupper($row['data']).', ';
}
if($project_folder!='nci'){
$output.='('.$pubdate.') ';
}else {
$output.='(2013) ';
}
//<a href="JavaScript:newPopup('http://www.quackit.com/html/html_help.cfm');">Open a popup window</a>'
$output.=$external_link."</li><br>";
}
}else{
continue;
}
}
$output= '<h3>'.$count.' items related to: '.implode(' OR ', $elems).'</h3>'.$output;
echo $output;
function imagestar($score,$factor,$twjs) {
// produit le html des images de score
$star_image = '';
if ($score > .5) {
$star_image = '';
for ($s = 0; $s < min(5,$score/$factor); $s++) {
$star_image.='<img src="libs/img2/star.gif" border="0" >';
}
} else {
$star_image.='<img src="libs/img2/stargrey.gif" border="0">';
}
return $star_image;
}
?>
<?php
// manage the dynamical additional information in the left panel.
// ini_set('display_errors',1);
// ini_set('display_startup_errors',1);
// error_reporting(-1);
include('parameters_details.php');
$max_item_displayed=6;
$base = new PDO("sqlite:../" .$graphdb);
include('default_div.php');
/*
* This function gets the first db name in the data folder
* IT'S NOT SCALABLE! (If you want to use several db's)
*/
function getDB ($directory) {
//$results = array();
$result = "";
$handler = opendir($directory);
while ($file = readdir($handler)) {
if ($file != "." && $file != ".."
&&
((strpos($file,'.db~'))==false && (strpos($file,'.db'))==true )
||
((strpos($file,'.sqlite~'))==false && (strpos($file,'.sqlite'))==true)
) {
//$results[] = $file;
$result = $file;
break;
}
}
closedir($handler);
//return $results;
return $result;
}
?>
<?php
// manage the dynamical additional information in the left panel.
// include('parameters_details.php');
$gexf= str_replace('"','',$_GET["gexf"]);
$max_item_displayed=6;
$type = $_GET["type"];
$TITLE="ISITITLE";
$query = str_replace( '__and__', '&', $_GET["query"] );
$elems = json_decode($query);
$table = "";
$column = "";
$id="";
$twjs="API_CNRS/"; // submod path of TinaWebJS
if($type=="semantic"){
$table = "ISItermsListV1";
$column = "data";
$id = "id";
$restriction='';
$factor=10;
}
$restriction='';
$factor=10;
$sql="";
if (count($elems)==1){// un seul mot est sélectionné, on compte les mots multiples
$sql = 'SELECT count(*),'.$id.'
FROM '.$table.' where (';
foreach($elems as $elem){
$sql.=' '.$column.'="'.$elem.'" OR ';
}
#$querynotparsed=$sql;#####
$sql = substr($sql, 0, -3);
$sql = str_replace( ' & ', '" OR '.$column.'="', $sql );
$sql.=')'.$restriction.'
GROUP BY '.$id.'
ORDER BY count('.$id.') DESC
LIMIT 1000';
}else{// on compte une seule fois un mot dans un article
$factor=ceil(count($elems)/5); //les scores sont moins haut
$sql='';
foreach($elems as $elem){
$sql.=' '.$column.'="'.$elem.'" OR ';
}
$sql=substr($sql, 0, -3);
$sql='SELECT count(*),id,data FROM (SELECT *
FROM '.$table.' where ('.$sql.')'.$restriction.'
group by id,data) GROUP BY '.$id.'
ORDER BY count('.$id.') DESC
LIMIT 1000 COLLATE NOCASE';
}
// echo $sql."<br>";
$base = new PDO("sqlite:../data/terrorism/data.db");
$wos_ids = array();
$sum=0;
//The final query!
// array of all relevant documents with score
foreach ($base->query($sql) as $row) {
// on pondère le score par le nombre de termes mentionnés par l'article
//$num_rows = $result->numRows();
$wos_ids[$row[$id]] = $row["count(*)"];
$sum = $row["count(*)"] +$sum;
}
// /// nombre de document associés $related
$total_count=0;
$count_max=500;
$number_doc=count($wos_ids);
$count=0;
$all_terms_from_selected_projects=array();// list of terms for the top 6 project selected
// to filter under some conditions
$to_display=true;
$count=0;
foreach ($wos_ids as $id => $score) {
if ($total_count<$count_max) {
// retrieve publication year
if ($to_display){
$total_count+=1;
if ($count<=$max_item_displayed){
$count+=1;
$sql = 'SELECT data FROM ISITITLE WHERE id='.$id.' group by data';
foreach ($base->query($sql) as $row) {
$external_link="<a href=http://google.com/webhp?#q=".urlencode('"'.utf8_decode($row['data']).'"')." target=blank>".' <img width=15px src="libs/img2/google.png"></a>';
$output.="<li title='".$score."'>";
$output.=$external_link.imagestar($score,$factor,$twjs).' ';
$output.='<a href="JavaScript:newPopup(\''.$twjs.'default_doc_details2.php?gexf='.urlencode($gexf).'&query='.urlencode($query).'&type='.urlencode($_GET["type"]).'&id='.$id.' \')">'.htmlentities($row['data'], ENT_QUOTES, "UTF-8")." </a> ";
// $output.='<a>'.htmlentities($row['data'], ENT_QUOTES, "UTF-8")." </a> ";
}
$sql = 'SELECT data FROM ISIDOI WHERE id='.$id.' group by data';
foreach ($base->query($sql) as $row) {
$output.=$external_link.imagestar($score,$factor,$twjs).' ';
$output.='<a href="JavaScript:newPopup(\''.$twjs.'default_doc_details2.php?gexf='.urlencode($gexf).'&query='.urlencode($query).'&type='.urlencode($_GET["type"]).'&id='.$id.' \')">'.htmlentities($row['data'], ENT_QUOTES, "UTF-8")." </a> ";
} // get the authors
$sql2 = 'SELECT data FROM ISIAUTHOR WHERE id='.$id. ' group by data';
foreach ($base->query($sql2) as $row2) {
$output.=(str_replace("\r", "", $row2['data'])).', ';
}
$output = rtrim($output, ", ");
$output.="</li><br>";
}
}
} else{
continue;
}
}
if ($total_count<$count_max){
$related .= $total_count;
}else{
$related .= ">".$count_max;
}
$output .= "</ul>"; #####
// echo $output."<br>";
if($max_item_displayed>$related) $max_item_displayed=$related;
echo $news.'<br/><h4><font color="#0000FF"> Full text of top '.$max_item_displayed.'/'.$related.' related grant proposals:</font></h4>'.$output;
//pt - 301 ; 15.30
/*
* This function gets the first db name in the data folder
* IT'S NOT SCALABLE! (If you want to use several db's)
*/
function getDB ($directory) {
//$results = array();
$result = "";
$handler = opendir($directory);
while ($file = readdir($handler)) {
if ($file != "." && $file != ".."
&&
((strpos($file,'.db~'))==false && (strpos($file,'.db'))==true )
||
((strpos($file,'.sqlite~'))==false && (strpos($file,'.sqlite'))==true)
) {
//$results[] = $file;
$result = $file;
break;
}
}
closedir($handler);
//return $results;
return $result;
}
function imagestar($score,$factor,$twjs) {
// produit le html des images de score
$star_image = '';
if ($score > .5) {
$star_image = '';
for ($s = 0; $s < min(5,$score/$factor); $s++) {
$star_image.='<img src="libs/img2/star.gif" border="0" >';
}
} else {
$star_image.='<img src="libs/img2/stargrey.gif" border="0">';
}
return $star_image;
}
?>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?php
header ("Content-Type:application/json");
//$string = getcwd();
//$string = str_replace("/php","",$string);
$string=dirname(dirname(getcwd())); // ProjectExplorer folder name: /var/www/ademe
//$files = getDirectoryList($string."/data");
include("DirectoryScanner.php");
$projectFolderPat = dirname(dirname(getcwd())) . "/";
$instance = new scanTree($projectFolderPat);
$instance->getDirectoryTree("data");
$gexfs=$instance->gexf_folder;
$files=array();
foreach($gexfs as $key => $value){
array_push($files,$key);
}
$filesSorted=array();
foreach($files as $file){
array_push($filesSorted,$file);
}
sort($filesSorted);
echo json_encode($filesSorted);
function getDirectoryList ($directory) {
$results = array();
$handler = opendir($directory);
while ($file = readdir($handler)) {
if ($file != "." && $file != ".." &&
(strpos($file,'.gexf~'))==false &&
(strpos($file,'.gexf'))==true) {
$results[] = $file;
}
}
closedir($handler);
return $results;
}
?>
<?php
$gexf_db = array();
# $gexf_db["data/terrorism/terrorism_bi.gexf"] = "data/terrorism/data.db";
# $gexf_db["data/ClimateChange/ClimateChangeV1.gexf"] = "data/ClimateChange/wosclimatechange-61715-1-wosclimatechange-db(2).db";
$gexf_db["data/ClimateChange/Maps_S_800.gexf"] = "data/ClimateChange/wos_climate-change_title_2014-2015.db";
$gexf_db["data/AXA/RiskV2PageRank1000.gexf"] = "data/AXA/data.db";
$gexf_db["data/AXA/RiskV2PageRank2500.gexf"] = "data/AXA/data.db";
$gexf_db["data/AXA/RiskV2PageRank5000.gexf"] = "data/AXA/data.db";
$gexf= str_replace('"','',$_GET["gexf"]);
$mainpath=dirname(getcwd())."/";
$graphdb = $gexf_db[$gexf];
?>
<?php
echo '<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>';
// compute the tfidf score for each terms for each document for cortext like databases and store them in a specific table
//include('parameters_details.php');
$db = new PDO("sqlite:graph.db");
$database_name='echoing.sqlite';
$project_base = new PDO("sqlite:" .$database_name);
// Table creation
// efface la base existante
$project_base->exec("DROP TABLE IF EXIST tfidf");
pt("creation of tfidf table");
//on crée un table pour les infos de clusters
$project_base->exec("CREATE TABLE tfidf (id NUMERIC,term TEXT,tfidf NUMERIC)");
//generating number of mention of terms in the corpora
$terms_freq=array();
pt('processing terms frequency');
$sql='SELECT count(*),data FROM ISItermsListV1 group by data';
foreach ($db->query($sql) as $term) {
$terms_freq[$term['data']]=$term['count(*)'];
}
pt('processing number of doc');
// nombre d'iterator_apply(iterator, function)em dans les tables
$sql='SELECT COUNT(*) FROM ISIABSTRACT';
foreach ($db->query($sql) as $row) {
$table_size=$row['COUNT(*)'];
}
pt($table_size.' documents in database');
// select all the doc
$sql='SELECT * FROM ISIABSTRACT';
foreach ($db->query($sql) as $doc) {
$id=$doc['id'];
pt($id);
//select all the terms of that document with their occurrences
$sql2="SELECT count(*),data FROM ISItermsListV1 where id='".$id."' group by data";
// for each term we compute the tfidf
foreach ($db->query($sql2) as $term_data) {
$term=$term_data['data'];
$term_occ_in_doc=$term_data['count(*)'];
$terms_tfidf=log(1+$term_occ_in_doc)*log($table_size/$terms_freq[$term]);
$query='INSERT INTO tfidf (id,term,tfidf) VALUES ('.$id.',"'.$term.'",'.$terms_tfidf.')';
$project_base->query($query);
}
}
function pt ($string) {
echo $string.'<br/>';
}
?>
{
"data/politoscope": {
"dbname":null,
"title":"Politoscope",
"date":"2017",
"abstract":"",
"first" : "ProgrammeDesCandidats.enrichi.gexf",
"gexfs": {
"ProgrammeDesCandidats.enrichi.gexf": {
"social": {},
"semantic": {}
},
"ProgrammeDesCandidats.gexf": {
"social": {},
"semantic": {}
}
}
},
"data/AXA": {
"dbname":"data.db",
"title":"ISITITLE",
"date":"ISIpubdate",
"abstract":"ISIABSTRACT",
"first" : "RiskV2PageRank1000.gexf",
"first" : "RiskV2PageRank1000.gexf",
"gexfs": {
"RiskV2PageRank1000.gexf": {
"social": { "table":"ISIAUTHOR" , "textCol":"data","forkeyCol":"id"},
......
......@@ -23,9 +23,14 @@
-->
<link href="https://fonts.googleapis.com/css?family=Ubuntu+Condensed" rel="stylesheet" type='text/css'>
<!-- Roboto
Good for tweets if Helvetica is not present
-->
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type='text/css'>
<!-- Crete Round
Original *and* informative :) -->
<!-- <link href='https://fonts.googleapis.com/css?family=Crete+Round:400,400italic&subset=latin-ext' rel='stylesheet' type='text/css'> -->
<link href='https://fonts.googleapis.com/css?family=Crete+Round:400,400italic&subset=latin-ext' rel='stylesheet' type='text/css'>
<!-- Lora
"book" (roman style) + nice heading -->
......@@ -53,6 +58,9 @@
<!-- NB bs2/3 not used for main grid (graph + bars) but inside the bars -->
<link rel="stylesheet" href="libs/css2/freshslider.css" media="screen">
<link type="text/css" href="twitterAPI2/twitterlibs/tweet.light.ltr.css" rel="stylesheet"/>
<link type="text/css" href="twitterAPI2/twitterlibs/custom.css" rel="stylesheet"/>
<!-- JS -->
<!-- <script src="script.js"></script> -->
</head>
......@@ -69,7 +77,8 @@
</li>
<li style="margin-left:10px;">
<a href="#" class="navbar-middle navbar-brand">
<span id="twbrand">Mapping Risk Research</span>
<!-- will be replaced by TW.branding -->
<span id="twbrand">TinaWebJS</span>
</a>
</li>
......@@ -144,15 +153,22 @@
</li>
-->
<li><a href="http://www.politoscope.org"
class="navbar-higher"
title="Politoscope">
<img src="libs/img2/politoscope_logo.jpg"
style="width:60px; position:absolute; top:-60px; left:-75px; z-index:5; overflow:visible; background-color:white">
</a></li>
<li>
<a>
<button type="button" id="changetype" class="btn btn-success btn-sm">Change Type</button>
<button type="button" id="changetype" class="btn btn-success btn-sm">Change<br>Type</button>
</a>
</li>
<li>
<a>
<button type="button" id="changelevel" class="btn btn-primary btn-sm" disabled>Change Level</button>
<button type="button" id="changelevel" class="btn btn-primary btn-sm" title="sélectionnez des sommets pour changer de niveau" disabled>Change<br>Level</button>
</a>
</li>
......@@ -276,24 +292,13 @@
<!-- say thanks for the suggestion, etc. -->
<li id="crowdsourcing_answer" class="nav crowdsourcingModule navbar-lower"></li>
<!-- checkbox -->
<li class="navbar-lower">
<input id="checkboxdiv" onclick="alertCheckBox(this);"
title="Add next search results to current selection"
class="nav btn btn-info"
type="checkbox">
<span style="position: relative; top: 4px;">Add to selection</span>
</li> <!-- /checkbox group -->
<li style="margin: 20px 0 0 10px;">
<div class="onoffswitch">
<input type="checkbox" name="edges-switch" class="onoffswitch-checkbox" id="edges-switch" checked>
<label class="onoffswitch-label" for="edges-switch">
<span id="edges-switch-inner-label" class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
</li>
</ul>
......@@ -365,6 +370,17 @@
<img src="libs/img2/edges.png" style="width:32px">
</a>
</li>
<li>
<div class="onoffswitch">
<input type="checkbox" name="edges-switch" class="onoffswitch-checkbox" id="edges-switch" checked>
<label class="onoffswitch-label" for="edges-switch">
<span id="edges-switch-inner-label" class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
</li>
</ul>
<!-- inline *after* sigma-contnr for better overlay positioning -->
......@@ -386,6 +402,12 @@
<!-- filled by query (user search value) to wos api -->
<div id="search_histogram" class="over-panels"></div>
</div><!-- /row -->
<!-- histogram of selected nodes, variant ; TODO unify -->
<div class="histogramDailyVariantModule">
<!-- filled by query (user search value) to wos api -->
<div id="search_histogram2" class="over-panels"></div>
</div><!-- /row -->
</div>
......@@ -436,11 +458,11 @@
</h4>
</div>
<div class="panel-collapse collapse" id="le_tutorial">
<!-- TODO: outcloud the video for better stream+player -->
<!-- TODO: outcloud the video for better stream+player -->
<!-- <div class="panel-collapse collapse" id="le_tutorial">
<video width="100%"
src="video/AXA2015.mp4" controls="" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></video>
</div>
</div> -->
</div>
<div class="panel panel-default" id="tips_panel">
......@@ -517,7 +539,7 @@
</div>
<div class="modal-body form-horizontal">
Which atributes do you want to keep?:
Which attributes do you want to keep?:
<div class="form-group">
<label class="col-lg-2 control-label"> </label>
<div class="col-lg-10">
......@@ -597,6 +619,10 @@
<script src="tinawebJS/sigma_v1.2/plugins/sigma.layout.forceAtlas2/worker.js"></script>
<script src="tinawebJS/sigma_v1.2/plugins/sigma.renderers.snapshot/sigma.renderers.snapshot.js"></script>
<!-- Tested as replacement for parseCustom -->
<!-- <script src="tinawebJS/sigma_v1.2/plugins/sigma.parsers.gexf/gexf-parser.js"></script> -->
<!-- <script src="tinawebJS/sigma_v1.2/plugins/sigma.parsers.gexf/sigma.parsers.gexf.js"></script> -->
<!-- testing sigma 1.5 imports from linkurious src -->
<!-- <script src="tinawebJS/sigma_v1.5/sigma.js" type="text/javascript" language="javascript"></script>
<script src="tinawebJS/sigma_v1.5/plugins.js" type="text/javascript" language="javascript"></script> -->
......@@ -617,6 +643,7 @@
<!-- <script src="tinawebJS/asyncFA2.js" type="text/javascript" language="javascript"></script> -->
<script src="tinawebJS/Tinaweb.js" type="text/javascript" language="javascript"></script>
<script src="tinawebJS/main.js" type="text/javascript" language="javascript"></script>
<script src="twitterAPI2/twitterlibs/widgets.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript">
// easytabs triggers errors when only one tab TODO fix
......
This diff is collapsed.
/* ---------------------------------------------------------------- */
/* --------------------- search histogram ----------------------- */
/* ---------------------------------------------------------------- */
// TODO be able to expose things from module like a histo.graph object
var hg
var $search_histogram = $("#search_histogram2")
//method for calling the ISC-API and get pubs-distribution of the suggested term
function search_proposed_terms_and_draw( the_queries ) {
console.log("search_proposed_terms_and_draw:\n"
+"i'm searching:\n"
+JSON.stringify(the_queries)) ;
$search_histogram.html("Searching for matching Twitter data...")
// the_queries is an array of str,
// but api.iscpif.fr/v2/pub/politic/france/twitter only takes single LUCENE query
var luc_q = the_queries.map(function (w) { return '('+w+')' }).join(" OR ")
var args = {
// luc_q is a str
"q": luc_q,
"interval": "day"
// no since and until: we want the entire period
}
var docs_days = [] ;
$search_histogram
.html('<p class="micromessage">Waiting for histogram data</p>')
$.ajax({
type: "GET",
url: 'https://api.iscpif.fr/v2/pub/politic/france/twitter/histogram',
data: args,
dataType: "json",
success : function(data, textStatus, jqXHR) {
// ES aggs response, for example
// data = {"took":91,"total":121673,"aggs":{"publicationCount":{"buckets":[{"key":1989,"doc_count":880},{"key":1990,"doc_count":1088},...,{"key":2012,"doc_count":9543},{"key":2013,"doc_count":8832}]}},"hits":{"total":121673,"max_score":0,"hits":[]}}
// console.log(">> incoming api data <<")
// console.log(data)
if(data.results.total==0) {
return false;
}
else {
var startRecordingFlag = false
for(var i in data.results.hits) {
var elem = data.results.hits[i]
var day = elem.key_as_string+""
var ndocs = elem.doc_count
if (! startRecordingFlag
&& ndocs > TW.histogramStartThreshold) {
startRecordingFlag = true
}
if (startRecordingFlag) {
docs_days.push( [ day , ndocs] )
}
}
// docs_days is now an array of couples [["2016-01-04T00:00:00.000Z",25],["2016-01-05T00:00:00.000Z",28],...]
// console.log("docs_days",docs_days)
// counts_by_year_array
draw_histogram(docs_days) ;
return true ;
}
},
error: function(exception) {
console.log("search_proposed_terms_and_draw:exception"
+ JSON.stringify(exception))
$search_histogram
.html('<p class="micromessage">'
+'<b>No histogram</b>: too many nodes selected</b>'
+'</p>')
}
})
}
// gotNodeSet event when Tinawab did main search behavior (select nodes)
$("#searchinput").on("tw:gotNodeSet", function(e) {
// console.warn("event 'nodes' --> the event's nodes: " + JSON.stringify(e.nodeIds)) ;
clean_histogram() ;
// now we may want to do other things (draw histogram, suggest term)
newnodesHistogramBehavior(e.nodeIds, e.q) ;
});
// eraseNodeSet event when Tinawab canceled the previous selections
$("#searchinput").on("tw:eraseNodeSet", function(e) {
// console.warn("event 'erase'") ;
clean_histogram() ;
$search_histogram.hide() ;
});
// emptyNodeSet event when Tinaweb search found nothing
$("#searchinput").on("tw:emptyNodeSet", function(e) {
// console.warn("event 'not found'") ;
clean_histogram() ;
$search_histogram.hide() ;
});
function newnodesHistogramBehavior(selectedNodeIds, unusedQuery) {
// console.log('FUN additionalSearchBehavior' + '\nselectedNodeIds:' +JSON.stringify(selectedNodeIds) ) ;
if( selectedNodeIds != null && selectedNodeIds.length > 0 ) {
// query : IF in the Map -> GO to ISC-API (search and draw it)
var selectedLabels = [] ;
for (i in selectedNodeIds) {
var thisId = selectedNodeIds[i]
if (TW.Nodes[thisId] != null) {
selectedLabels.push(TW.Nodes[thisId].label)
}
else {
console.log('ID error on TW.Nodes['+thisId+']')
}
}
// console.log('\n\n\n<---!--->\nselectedLabels' + JSON.stringify(selectedLabels))
search_proposed_terms_and_draw ( selectedLabels ) ;
}
}
// use dygraph lib to draw below the crowdsourcing div
function draw_histogram(counts_by_days_array) {
// 1) layout for the div#search_histogram
// /!\ this div *needs* padding:0 /!\;
$search_histogram.height("15em").show()
// 2) data preparation
// (cumulated sliding window over [J-7; J])
var cumulated_res = [] ;
for (i in counts_by_days_array) {
var isoDate = counts_by_days_array[i][0]
// 2016-01-04T00:00:00.000Z ~~> 2016/01/04
var theDate = new Date(isoDate)
var sum = 0
var nvalues = 0
for (var j=i; j >= Math.max(i-6, 0); j--) {
sum += counts_by_days_array[j][1]
nvalues++
}
cumulated_res.push([theDate, sum])
}
// console.log('=== GRAPH PREPARATION ===') ;
// console.log("counts_by_days_array", counts_by_days_array)
// console.log('cumulated_res', cumulated_res) ;
var emValue = parseFloat(getComputedStyle(document.body).fontSize)
// 3) call histogram lib
hg = new Dygraph($search_histogram[0],
cumulated_res,
{
labels: ['day', 'n'],
visibility: [true],
// ^^^
// n
drawPoints: true,
// pixels between labels <=> 1.5 em
axes: {
x: { pixelsPerLabel: 3 * emValue },
y: { pixelsPerLabel: 2 * emValue }
},
fillGraph: true,
animatedZoom: false,
// // legend => selected n (instead of %) thx highlightCallback
// highlightCallback: function(e, x, pts, row) {
// // n has i == 2 in counts_by_year_array tuples
// var this_n = hg.getValue(row, 2);
// var legendDiv = document.getElementsByClassName("dygraph-legend")[0]
// legendDiv.innerHTML = "<span style='font-weight: bold; background-color:#FFF; color:#070;'>n = " + this_n + "</span>";
// legendDiv.style.left = 0
// legendDiv.style.paddingLeft = "37%"
// legendDiv.style.paddingTop = "1%"
// legendDiv.style.display = "block"
// legendDiv.style.background = "none"
// }
});
}
function clean_histogram() {
$("#search_histogram").html("") ;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
body {
font-family: Helvetica Neue, Arial, Helvetica, sans-serif;
font-size: 90%;
}
*/
aside {
font-size: 90%;
}
#toc {
vertical-align: top;
width: 200px;
}
#gap {
style="width:0.5em;"
}
#rhs, #lhs {
vertical-align: top;
}
#subtitle a:visited {
color: blue;
}
#workarea {
border-style: solid;
border-color: #ddd;
padding: 4px;
}
#toc .entry {
background-color: #eee;
padding: .7em;
/* These two lines result in indenting wrapped lines forward a little bit. */
/* text-indent: -1em;
padding-left: 1em; */
}
#toc .entry:hover {
color: blue;
cursor: pointer;
}
#toc .entry .selected {
color: #090;
}
#code a:hover {
color: blue;
cursor: pointer;
}
#demotitle {
text-align: center;
font-size: 1.5em;
vertical-align: bottom;
}
.subdued:link,
.subdued:visited,
.subdued:active {
color: #000;
}
.subdued:hover {
color: blue;
}
/*
a {
text-decoration: none;
}
*/
/* CSS for drawing tool */
#workarea #drawing #tool_zoom {
background: url('images/tool-palette.png');
background-position: 0px 0px;
width: 32px;
height: 33px;
margin-left: 50px;
display: inline-block;
}
#workarea #drawing #tool_pencil {
background: url('images/tool-palette.png');
background-position: -32px 0px;
width: 32px;
height: 33px;
display: inline-block;
}
#workarea #drawing #tool_eraser {
background: url('images/tool-palette.png');
background-position: -64px 0px;
width: 33px;
height: 33px;
display: inline-block;
}
#workarea #drawing #toolbar {
display: inline-block;
}
/* CSS for independent series */
#workarea #independent-series .thinborder {
border-width: 1px;
border-spacing: 0px;
border-style: solid;
border-color: black;
border-collapse: collapse;
}
#workarea #independent-series .thinborder td,
#workarea #independent-series .thinborder th {
border-width: 1px;
padding: 5px;
border-style: solid;
border-color: black;
}
/* CSS for resize */
#workarea #resize #div_g {
/* The left and top are just guesses, this needs a proper run-through */
position: absolute;
left: 200px;
right: 10px;
top: 100px;
bottom: 10px;
}
/* CSS for styled-chart-label */
#workarea #styled-chart-labels .infotext {
}
#workarea #styled-chart-labels #div_g .dygraph-label {
/* This applies to the title, x-axis label and y-axis label */
font-family: Georgia, Verdana, serif;
/* can't set font-size because of inline values?? */
}
#workarea #styled-chart-labels #div_g .dygraph-title {
/* This rule only applies to the chart title */
font-size: 12px;
text-shadow: gray 1px 1px 1px; /* color, delta-x, delta-y, blur radius */
}
#workarea #styled-chart-labels #div_g .dygraph-ylabel {
/* This rule only applies to the y-axis label */
font-size: 6px;
text-shadow: gray -1px 1px 1px; /* (offsets are in a rotated frame) */
}
#workarea #styled-chart-labels .chart {
border: 1px dashed black;
margin: 2px 2px 2px 2px;
padding: 2px;
}
#workarea #temperature-sf-ny #bordered {
border: 1px solid red;
}
#workarea #highlighted-series .few .dygraph-legend > span.highlight { border: 1px solid grey; }
#workarea #highlighted-series .many .dygraph-legend > span { display: none; }
#workarea #highlighted-series .many .dygraph-legend > span.highlight { display: inline; }
#workarea #edge-padding fieldset { display: inline-block; vertical-align: top; }
.textarea {
position: absolute;
border: 1px solid black;
background-color: #dddddd;
z-index: 12;
}
.textarea .prompt {
padding-left: 2px;
}
.textarea .buttons {
position: absolute;
bottom: 5px;
right: 5px;
}
.textarea button {
color: #222222;
}
.textarea .editor {
font-family: Inconsolata, Courier New, Courier;
margin: 4px;
}
#modalBackground {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 11;
background-color:#333333;
display: none;
opacity: 0.40;
filter: alpha(opacity=40)
}
/* ------------- module dygraph charts pour histogramme WOS ----------------- */
/* graph div */
#search_histogram2 {
min-height: 12em ;
font-size: 75%;
background-color: #F9F9F9 ;
display: none;
position:relative;
padding: 0 15px;
max-width: 100%;
}
#search_histogram2 canvas {
margin-left: -2em;
}
// Histogram module
// =================
// Presents a histogram from WOS API
// Our module_name is simultaneously 3 things:
// - a DivsFlag for settings_explorerjs
// - our current dir for this module's files (and this init.js)
// - the class of module's html elements
module_name="histogramDailyVariantModule"
// ---- INIT main part -------- (listing all things to load)
// our histogram wrapper styles
loadCSS(module_name+"/histogram.css") ;
// our histogram controller
loadJS(module_name+"/dailyHistogram.js") ;
// dygraph library
// loadCSS(module_name+"/dygraph/gallery.css") ;
loadCSS(module_name+"/dygraph/textarea.css") ;
loadJS(module_name+"/dygraph/dygraph.combined.js") ;
console.log("OK LOADED " + module_name) ;
......@@ -8,6 +8,15 @@
-moz-box-shadow: 0px 2px 6px #000;
-webkit-box-shadow: 0px 2px 6px #000;
box-shadow: 0px 2px 6px #000;
/*non selectable*/
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome and Opera */
}
#unselectbutton {
......@@ -19,7 +28,7 @@
margin-right:1em
}
""
/* LEGEND PANEL */
.legend_for_clusters {
position:absolute;
......@@ -40,7 +49,7 @@
z-index: 5;
/* width: we set it equal or smaller than #lefttopbox width */
width:18%;
max-height: 40%;
max-height: 25%;
overflow-y:scroll;
bottom:5px;
left:5px;
......@@ -123,7 +132,7 @@
#ctlzoom {
position: fixed;
right: 260px;
right: 410px;
bottom: 0;
list-style: none;
padding: 0;
......@@ -140,9 +149,6 @@
}
#zoomSliderzone {
height: 100px;
top: -9px;
position: relative;
}
#edgesButton {
......@@ -234,11 +240,11 @@
}*/
#unfold {
width: 12px; height: 12px; background: rgb(250, 250, 252); padding: 2px 2px 2px 0; border-top-right-radius: 5px; border-bottom-right-radius: 5px; box-shadow: 1px 1px 2px #808090;
display:none; width: 12px; height: 12px; background: rgb(250, 250, 252); padding: 2px 2px 2px 0; border-top-right-radius: 5px; border-bottom-right-radius: 5px; box-shadow: 1px 1px 2px #808090;
}
#aUnfold {
display: block; width: 12px; height: 12px; background-image: url("../img2/fleches-horiz.png"); margin: 0 auto;
display: none; width: 12px; height: 12px; background-image: url("../img2/fleches-horiz.png"); margin: 0 auto;
}
/*
#saveAs {
......@@ -249,7 +255,7 @@
#zoomSlider {
background:#fff;
border:1px solid #aaa;
height: 120px; margin: 0 auto;
height: 90px; margin: 0 auto;
}
......@@ -281,3 +287,10 @@
#current-selection {
width: 100%; /* 100% within lefttopbox */
}
/* tweets inside topPapers */
.EmbeddedTweet-tweet {
width: 295px;
max-width: 295px;
}
......@@ -20,8 +20,14 @@ html, body {
top: 105px;
bottom: 0;
left: 0;
right: 250px;
right: 400px;
z-index: 1;
/* non selectable: we've got our own events here */
-webkit-user-select: none; /* Safari */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE/Edge */
user-select: none; /* Chrome and Opera, future + */
}
#sidebar {
......@@ -29,7 +35,7 @@ html, body {
top: 105px;
bottom: 0;
right: 0;
width: 250px;
width: 400px;
z-index: 2;
border-left: 1px #222 solid;
overflow-y: scroll;
......@@ -61,8 +67,8 @@ html, body {
#twbrand {
font-family: "Gurajada" ;
font-size: 28px;
font-family: "Gurajada", "Droid Sans", sans-serif ;
font-size: 24px;
width: 50px !important;
}
......@@ -115,6 +121,14 @@ html, body {
display: none; /*not shown at init*/
}
/*thick buttons needs lift*/
#changetype, #changelevel{
position: relative;
bottom: 2px;
font-size: 11px;
line-height: 12px;
}
/* override navbar toggle on right side when collapsed */
#toolbar-open {
float:left !important;
......@@ -122,6 +136,11 @@ html, body {
}
/* right info panel */
#accordion {
display:none
}
/* VARIAE */
#selectionsBox{
......@@ -255,6 +274,14 @@ p.micromessage{
font-size:80%;
}
.centered {
text-align: center;
}
.code {
font-family: "Fira Sans", "Courier", "Courier New", monospace;
color: '#222'
}
/* switch css -- generic (src: proto.io/freebies/onoff/)*/
......
......@@ -5,7 +5,7 @@ var TW = {}
TW.colorByAtt = false;
TW.twittertimeline = false;
TW.minimap=false;
TW.getAdditionalInfo=true;// True: Activate TopPapers feature.
TW.getAdditionalInfo = true;// True: Activate TopPapers feature.
//TW.mainfile = ["db.json"];
// // TW.mainfile = "api.json";
TW.mainfile = [
......@@ -21,7 +21,7 @@ var TW = {}
// // "data/example.json",
// // "data/Elisa__Omodei.gexf",
];
TW.APINAME = "LOCALDB/";
TW.APINAME = "http://127.0.0.1:5000/twitter_search";
TW.tagcloud_limit = 50;
TW.bridge={};
TW.bridge["forFilteredQuery"] = "php/bridgeClientServer_filter.php";
......@@ -43,8 +43,10 @@ var TW = {}
// flag name is div class to be removed if false
// *and* subdirectory to import if true
// see also ProcessDivsFlags()
TW.DivsFlags["histogramModule"] = true ;
TW.DivsFlags["crowdsourcingModule"] = true ; // £TODO fix topPapers
TW.DivsFlags["histogramModule"] = false ;
TW.DivsFlags["histogramDailyVariantModule"] = true ;
// TODO more generic module integrating the variants cf. experiments/histogramModule_STUB_GENERIQUE
TW.DivsFlags["crowdsourcingModule"] = true ;
TW.SystemStates = {}
TW.SystemStates.level = true;
......@@ -52,10 +54,7 @@ var TW = {}
TW.SystemStates.selections = [];
TW.SystemStates.opposites = [];
TW.catSoc = "Document";
TW.catSem = "NGram";
// to get ajax topPapers via info_div.php
TW.getAdditionalInfo = false;
TW.catSem = "terms";
TW.strSearchBar = "Select or suggest topics";
......@@ -70,8 +69,6 @@ var sizeMult = [];
sizeMult[TW.catSoc] = 0.0;
sizeMult[TW.catSem] = 0.0;
var inactiveColor = '#666';
var startingNodeId = "1";
var minLengthAutoComplete = 1;
var maxSearchResults = 10;
......@@ -83,6 +80,8 @@ var desirableTagCloudFont_MIN=12;
var desirableTagCloudFont_MAX=20;
var desirableNodeSizeMIN=1;
var desirableNodeSizeMAX=12;
// apparently not used ?
var desirableScholarSize=6; //Remember that all scholars have the same size!
/*
......@@ -101,7 +100,13 @@ var semanticConverged=false;
// ============ < / DEVELOPER OPTIONS > ============
var showLabelsIfZoom=1.0;
TW.branding = 'Politoscope: explorer les programmes'
TW.nodeClusAtt = "modularity_class"
TW.filterSliders = false
TW.histogramStartThreshold = 10 ;
TW.edgeDefaultOpacity = 0.5 // opacity when true_color
TW.edgeGreyColor = "rgba(150, 150, 150, 0.2)";
TW.nodesGreyBorderColor = "rgba(100, 100, 100, 0.5)";
......@@ -110,8 +115,17 @@ TW.selectedColor = "node" // "node" for a background like the node's color,
TW.overSampling = true // costly hi-def rendering (true => pixelRatio x 2)
TW.deselectOnclickStage = false // will a click on the background remove selection ? (except when dragging)
TW.deselectOnclickStage = true // will a click on the background remove selection ? (except when dragging)
var showLabelsIfZoom=1.0;
// for continuous attrvalues/colors (cf. clustersBy), how many levels in legend?
TW.legendsBins = 7 ;
// some specific attributes may have other number of levels
TW.customLegendsBins = {
'age': 8,
'growth_rate': 12
}
// ============ < / DEVELOPER OPTIONS > ============
......@@ -141,8 +155,9 @@ var sigmaJsDrawingProperties = {
twNodeRendBorderColor: "#222",
// twNodeRendBorderColor: "#eee",
font: "Droid Sans",
// font: "Crete Round",
font: "Ubuntu Condensed",
// font: "Ubuntu Condensed",
fontStyle: "bold",
};
var sigmaJsGraphProperties = {
......@@ -150,7 +165,7 @@ var sigmaJsGraphProperties = {
maxEdgeSize: 4
};
var sigmaJsMouseProperties = {
minRatio: 0.1,
minRatio: .03125, // 1/32 pour permettre zoom x32
maxRatio: 2
};
// ============ < / SIGMA.JS PROPERTIES > ============
......@@ -164,7 +179,7 @@ var twjs="tinawebJS/";
TW.categories = {};
TW.categoriesIndex = [];
var gexf;
var gexfFile;
//var zoom=0;
var checkBox=false;
......@@ -191,11 +206,11 @@ var lastFilter = []
TW.Filters = {}
var overviewWidth = 200;
var overviewHeight = 175;
var overviewScale = 0.25;
var overviewHover=false;
//
// var overviewWidth = 200;
// var overviewHeight = 175;
// var overviewScale = 0.25;
// var overviewHover=false;
var moveDelay = 80, zoomDelay = 2;
//var Vecindad;
TW.partialGraph;
......@@ -204,13 +219,31 @@ TW.Nodes = [];
TW.Edges = [];
TW.Clusters = [];
// new dev properties
TW.scanClusters = true // build TW.Clusters in an (attr+val => nodes) reverse index (aka facets)
TW.maxDiscreteValues = 40 // max discrete levels in facet legend (aka bins)
// new TW.Clusters structure
// --------------------------
// was: built in separate loop from read of all attr values
// TW.Clusters[nodeType][clusterType][possibleValue] = clst_idx_of_possible_value
// from now on:
// still built in ChangeGraphAppearanceByAtt
// POSS: build in parseCustom (when reading all nodes attributes anyway)
// if discrete attrvalues with <= 30 classes (colorsBy, clustersBy)
// => TW.Clusters[nodeType][clusterType].classes.[possibleValue] = list of ids with the value
// if continuous or many possible values (>30) (clustersBy, colorsRelByBins)
// => TW.Clusters[nodeType][clusterType].ranges.[interval] = list of ids in the interval
var nodeslength=0;
var labels = [];
var numberOfDocs=0;
var numberOfNGrams=0;
var numberOfDocs=0; // not used!
var numberOfNGrams=0; // not used, but cf TW.nNodes TW.nEdges
// FIXME should become TW.*
var selections = [];
var deselections={};
var opossites = {};
......
......@@ -155,6 +155,7 @@ function SelectionEngine() {
console.log("IN SelectionEngine.MultipleSelection2:")
console.log("nodes", nodes)
greyEverything();
var sameSideNeighbors = {}
......@@ -759,10 +760,10 @@ TinaWebJS = function ( sigmacanvas ) {
// new sigma.js current zoom ratio
value: partialGraph.camera.ratio,
min: 1 / sigmaJsMouseProperties.maxRatio,
max: 1 / sigmaJsMouseProperties.minRatio,
min: 1 / sigmaJsMouseProperties.maxRatio, // ex x.5
max: 1 / sigmaJsMouseProperties.minRatio, // ex x32
// range: true,
step: 1,
step: .2,
value: 1,
slide: function( event, ui ) {
partialGraph.camera.goTo({
......@@ -824,64 +825,70 @@ TinaWebJS = function ( sigmacanvas ) {
sigma_utils.toggleEdges()
});
NodeWeightFilter ( categories , "#slidercat0nodesweight" , categories[0], "type" ,"size");
EdgeWeightFilter("#slidercat0edgesweight", "label" , "nodes1", "weight");
if (TW.filterSliders) {
$("#category1").hide();
NodeWeightFilter ( categories , "#slidercat0nodesweight" , categories[0], "type" ,"size");
//finished
var labelSizeTimeout = null
$("#slidercat0nodessize").freshslider({
step:.5,
min:0,
max:5,
value: TW.partialGraph.settings('labelSizeRatio'),
bgcolor:"#27c470",
onchange:function(value){
if (labelSizeTimeout) {
clearTimeout(labelSizeTimeout)
}
labelSizeTimeout = setTimeout(function(){
if (TW.partialGraph.settings('labelSizeRatio') != value) {
var adaptedLabelThreshold = (5 - value) + 1
console.log("value", value, "thres", adaptedLabelThreshold)
TW.partialGraph.settings('labelSizeRatio', value)
TW.partialGraph.settings('labelThreshold', adaptedLabelThreshold)
TW.partialGraph.render()
EdgeWeightFilter("#slidercat0edgesweight", "label" , "nodes1", "weight");
}
$("#category1").hide();
//finished
var labelSizeTimeout = null
$("#slidercat0nodessize").freshslider({
step:.5,
min:0,
max:5,
value: TW.partialGraph.settings('labelSizeRatio'),
bgcolor:"#27c470",
onchange:function(value){
if (labelSizeTimeout) {
clearTimeout(labelSizeTimeout)
}
}, 200)
labelSizeTimeout = setTimeout(function(){
if (TW.partialGraph.settings('labelSizeRatio') != value) {
var adaptedLabelThreshold = 7 - value
// console.log("value", value, "thres", adaptedLabelThreshold)
}
});
TW.partialGraph.settings('labelSizeRatio', value)
TW.partialGraph.settings('labelThreshold', adaptedLabelThreshold)
TW.partialGraph.render()
}
}, 200)
// //finished
// $("#slidercat1nodessize").freshslider({
// step:1,
// min:-20,
// max:20,
// value:0,
// bgcolor:"#FFA500",
// onchange:function(value){
// setTimeout(function (){
// // new sigma.js loop on nodes POSS optimize
// nds = TW.partialGraph.graph.nodes()
// console.log("init: slider resize")
// for(j=0 ; j<TW.partialGraph.nNodes ; j++){
// if (nds[j]
// && nds[j].type == TW.catSem) {
// var n = nds[j]
// var newval = parseFloat(TW.Nodes[n.id].size) + parseFloat((value-1))*0.3
// n.size = (newval<1.0)?1:newval;
// sizeMult[TW.catSem] = parseFloat(value-1)*0.3;
// }
// }
// partialGraph.render()
// },
// 100);
// }
// });
}
});
// //finished
// $("#slidercat1nodessize").freshslider({
// step:1,
// min:-20,
// max:20,
// value:0,
// bgcolor:"#FFA500",
// onchange:function(value){
// setTimeout(function (){
// // new sigma.js loop on nodes POSS optimize
// nds = TW.partialGraph.graph.nodes()
// console.log("init: slider resize")
// for(j=0 ; j<TW.partialGraph.nNodes ; j++){
// if (nds[j]
// && nds[j].type == TW.catSem) {
// var n = nds[j]
// var newval = parseFloat(TW.Nodes[n.id].size) + parseFloat((value-1))*0.3
// n.size = (newval<1.0)?1:newval;
// sizeMult[TW.catSem] = parseFloat(value-1)*0.3;
// }
// }
// partialGraph.render()
// },
// 100);
// }
// });
//Cursor Size slider
var cursorSlider = $("#unranged-value").freshslider({
......@@ -920,6 +927,9 @@ TinaWebJS = function ( sigmacanvas ) {
winResizeTimeout = setTimeout(function() {
console.log('did refresh')
TW.partialGraph.refresh()
if (theHtml.classList) {
theHtml.classList.remove('waiting');
}
}, 3000)
}, true)
......
......@@ -3,6 +3,12 @@
// always useful
var theHtml = document.getElementsByTagName('html')[0]
TW.anynodegoes = true
// TW.anynodegoes = true
function writeBrand (brandString) {
document.getElementById('twbrand').innerHTML = brandString
}
//============================ < NEW BUTTONS > =============================//
......@@ -28,6 +34,7 @@ function changeType() {
// types eg [true] <=> '1'
// [true, true] <=> '1|1'
// [true, false] <=> '1|0'
// Complement of the received state ~[X\Y] )
var type_t1 = []
......@@ -449,6 +456,11 @@ function changeLevel() {
// NB new sigma js: dropEdge is quite slow so we add a waiting cursor
function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) {
console.log("EdgeWeightFilter")
console.log("sliderDivID", sliderDivID)
console.log("type_attrb", type_attrb)
console.log("type", type)
console.log("criteria", criteria)
// if ($(sliderDivID).html()!="") {
// console.log("\t\t\t\t\t\t[[ algorithm not applied "+sliderDivID+" ]]")
// return;
......@@ -480,10 +492,12 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) {
var filterparams = AlgorithmForSliders ( TW.Edges , type_attrb , type , criteria) //OK
// TODO make an index
// console.log("EdgeWeightFilter: "+type)
// console.log(filterparams)
console.log("EdgeWeightFilter: "+type)
console.log(filterparams)
var steps = filterparams["steps"]
var finalarray = filterparams["finalarray"]
// if(steps<3) {
// $(sliderDivID).freshslider({
......
......@@ -152,16 +152,19 @@ function getByID(elem) {
}
function hex2rga(sent_hex) {
// hex can be RGB (3 or 6 chars after #) or RGBA (4 or 8 chars)
function hex2rgba(sent_hex) {
if (!sent_hex) {
return [0,0,0,1]
}
result = []
hex = ( sent_hex.charAt(0) === "#" ? sent_hex.substr(1) : sent_hex );
// check if 6 letters are provided
if (hex.length === 6) {
if (hex.length == 6 || hex.length == 8) {
result = calculateFull(hex);
return result;
}
else if (hex.length === 3) {
else if (hex.length == 3 || hex.length == 3) {
result = calculatePartial(hex);
return result;
}
......@@ -171,7 +174,12 @@ function calculateFull(hex) {
var r = parseInt(hex.substring(0, 2), 16);
var g = parseInt(hex.substring(2, 4), 16);
var b = parseInt(hex.substring(4, 6), 16);
return [r,g,b];
var a = 0
if (hex.substring(6, 8)) {
a = parseInt(hex.substring(6, 8), 16) / 255;
}
return [r,g,b, a];
}
......@@ -180,7 +188,12 @@ function calculatePartial(hex) {
var r = parseInt(hex.substring(0, 1) + hex.substring(0, 1), 16);
var g = parseInt(hex.substring(1, 2) + hex.substring(1, 2), 16);
var b = parseInt(hex.substring(2, 3) + hex.substring(2, 3), 16);
return [r,g,b];
var a = 0
if (hex.substring(3, 4)) {
a = parseInt(hex.substring(3, 4), 16) / 255;
}
return [r,g,b, a];
}
function componentToHex(c) {
......
This diff is collapsed.
......@@ -17,26 +17,26 @@ function cancelSelection (fromTagCloud, settings) {
//Nodes colors go back to normal
overNodes=false;
//Edges colors go back to normal
if (TW.partialGraph.settings('drawEdges')) {
for(let i=0;i<TW.nEdges;i++){
let e = TW.partialGraph.graph.edges(TW.edgeIds[i])
// console.log("cancelSelection: edge", e)
if (e) {
e.color = e.customAttrs['grey'] ? e.customAttrs['true_color'] : e.color;
e.color = e.customAttrs['true_color'];
e.customAttrs.grey = 0;
e.customAttrs.activeEdge = 0;
}
}
}
//Nodes colors go back to normal
//Nodes colors go back to previous
for(let j=0;j<TW.nNodes;j++){
let n = TW.partialGraph.graph.nodes(TW.nodeIds[j])
// console.log("cancelSelection: node", n)
if (n) {
n.active = false;
// n.color = n.customAttrs['grey'] ? n.customAttrs['true_color'] : n.color;
n.color = n.customAttrs['true_color'];
n.color = TW.handpickedcolor ? n.customAttrs['alt_color'] : n.customAttrs['true_color'];
n.customAttrs.grey = 0
n.customAttrs.forceLabel = 0
}
......@@ -83,6 +83,27 @@ function cancelSelection (fromTagCloud, settings) {
}
}
function getCurrentType() {
// type grammar overly complicated: it's absurd to have to do 10 lines
// to retrieve the tina type when other times
// there's so many window-scoped vars !!!
// TODO expose current type more accessibly
let currentTypeName
let currentTypeIdx
let typeIdxs = Object.keys(TW.partialGraph.states.slice(-1)[0].type)
for (var m in typeIdxs) {
if (TW.partialGraph.states.slice(-1)[0].type[m]) {
currentTypeIdx = m
break
}
}
currentTypeName = window.categories[currentTypeIdx]
return currentTypeName
}
function highlightSelectedNodes(flag){
console.log("\t***methods.js:highlightSelectedNodes(flag)"+flag+" selEmpty:"+is_empty(selections))
if(!is_empty(selections)){
......@@ -201,7 +222,8 @@ function pushSWClick(arg){
swclickActual = arg;
}
// tag cloud div
// tag cloud div
// [but not used in monopart case]
function htmlfied_alternodes(elems) {
var oppositesNodes=[]
var js1='onclick="graphTagCloudElem(\'';
......@@ -580,13 +602,11 @@ function unHide(nodeId) {
TW.partialGraph.graph.nodes(nodeId).hidden=false
}
// edges greyish color for unselected, when we have a selection
// case default: we just change the flags
// - greyish color was precomputed in prepareNodesRenderingProperties
// as n.customAttrs.defgrey_color
// - renderer will see the flags and and handle the case accordingly
// cases when coloredBy (ex: centrality): color must be recomputed here
function greyEverything(notDefaultColors){
// NB: we just change the flags, not the colors
// renderer will see the flags and handle the case accordingly
function greyEverything(){
for(var j=0 ; j<TW.nNodes ; j++){
let n = TW.partialGraph.graph.nodes(TW.nodeIds[j])
......@@ -599,10 +619,6 @@ function greyEverything(notDefaultColors){
n.active = false
n.customAttrs.forceLabel = false;
n.customAttrs.highlight = false;
// special case after a coloredBy or clustersBy
if (notDefaultColors)
n.color = "rgba("+hex2rga(n.color)+",0.5)"
}
}
......@@ -612,39 +628,12 @@ function greyEverything(notDefaultColors){
if (e && !e.hidden && !e.customAttrs.grey) {
e.customAttrs.grey = 1
e.customAttrs.activeEdge = 0
// new specification: coloredBy does not affect edges
// (ie no special case for notDefaultColors)
}
}
}
}
// new sigma.js: TODO change logic (the reverse of greyEverything is done by redraw for the colors, and cancelSelection for the flags...)
// but this could be used for colorsBy menu
// function graphResetColor(){
// nds = TW.partialGraph.graph.nodes().filter(function(x) {
// return !x['hidden'];
// });
// eds = TW.partialGraph.graph.edges().filter(function(x) {
// return !x['hidden'];
// });
//
// for(var x in nds){
// n=nds[x];
// n.customAttrs["grey"] = 0;
// n.color = n.customAttrs["true_color"];
// }
//
// if (TW.partialGraph.settings('drawEdges')) {
// for(var x in eds){
// e=eds[x];
// e.customAttrs["grey"] = 0;
// e.color = e.customAttrs["true_color"];
// }
// }
// }
//
// function hideEverything(){
// console.log("\thiding all");
......@@ -683,11 +672,15 @@ function prepareNodesRenderingProperties(nodesDict) {
// new initial setup of properties
n.active = false
var rgba = hex2rgba(n.color)
var rgbStr = rgba.splice(0, 3).join(',');
n.customAttrs = {
grey: false,
highlight: false,
true_color : n.color,
defgrey_color : "rgba("+hex2rga(n.color)+",.4)"
defgrey_color : "rgba("+rgbStr+",.4)"
}
// POSS n.type: distinguish rendtype and twtype
......@@ -699,20 +692,20 @@ function prepareNodesRenderingProperties(nodesDict) {
// customFlags : {
// // our status flags
// grey: false,
// neighbor: false,
// highlight: false,
// // forceLabel: false,
// }
}
}
function prepareEdgesRenderingProperties(edgesDict) {
function prepareEdgesRenderingProperties(edgesDict, nodesDict) {
for (var eid in edgesDict) {
var e = edgesDict[eid]
e.weight = Math.round(e.weight*1000)/1000
// e.size = e.weight // REFA s/weight/size/ ?
var rgbStr = sigmaTools.edgeRGB(e.source, e.target)
var rgbStr = sigmaTools.edgeRGB(nodesDict[e.source].color, nodesDict[e.target].color)
e.color = "rgba("+rgbStr+","+TW.edgeDefaultOpacity+")"
e.customAttrs = {
......@@ -834,8 +827,10 @@ function saveGEXF(nodes,edges,atts){
gexf += ' <viz:position x="'+nodes[n].x+'" y="'+nodes[n].y+'" z="0" />\n';
if(atts["color"]) gexf += ' <viz:size value="'+nodes[n].size+'" />\n';
if(atts["color"]) {
col = hex2rga(nodes[n].color);
gexf += ' <viz:color r="'+col[0]+'" g="'+col[1]+'" b="'+col[2]+'" a="1"/>\n';
if (nodes[n].color && nodes[n].color.charAt(0) == '#') {
col = hex2rgba(nodes[n].color);
gexf += ' <viz:color r="'+col[0]+'" g="'+col[1]+'" b="'+col[2]+'" a='+col[3]+'/>\n';
}
}
gexf += ' <attvalues>\n';
gexf += ' <attvalue for="0" value="'+nodes[n].type+'"/>\n';
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
A simple relay server to the official Twitter search API
========================================================
## Credentials setup
Like any other Twitter REST API consumer, this app needs twitter authentication credentials.
To get them, go to https://apps.twitter.com/ and register a new app... The url param can be fake.
Once you have your keys and access tokens, create a `keys.json` file on the model of the attached `keys.json.template`, and save it in the same folder as the script.
Remember not to upload your `keys.json` on git !!
## Usage
Run it with the following command:
```
cd twitterAPI2
python3 topPapers_flask_server.py
```
Then you can query the app via `127.0.0.1:5000` like this:
- `http://127.0.0.1:5000/twitter_search?query=hamon`
- it returns the exact json from the twitter search
- tinawebJS will use it in topPapers if you fill "http://127.0.0.1:5000/twitter_search" in the variable TW.APINAME
- `http://127.0.0.1:5000/twitter_limits`
- this route informs you how many queries are left until the next 15 minutes renewal time
- more info on https://dev.twitter.com/rest/public/rate-limiting
#### In local tests
Use the `--cors` option to allow requests from all apps within the local LAN
```
python3 topPapers_flask_server.py --cors
```
#### On a real server
Use nohup or gunicorn to detach the process or make it into a full-fledged server.
## More info
```python3 topPapers_flask_server.py --help```
{
"consumer_key": "something_something",
"consumer_secret": "something_something_something",
"access_token_key": "something_else",
"access_token_secret": "something_else_something_else"
}
python-twitter
#flask-cors
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment