Open EmilyVam opened 8 years ago
I made some changes to the code (mainly brainspell.php
) -> print out all the article titles at the beginning of the search result page (it is very messy, sorry!) with any query. Then I was trying to save the article titles into a CSV file, but it gives me a warning message (below), I pushed all the changes to Emily branch for reference.
Warning: fopen(list_of_articles.csv): failed to open stream: Permission denied in /home/oski/brainspell/site/php/brainspell.php on line 607
Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/oski/brainspell/site/php/brainspell.php on line 608
Warning: fclose() expects parameter 1 to be resource, boolean given in /home/oski/brainspell/site/php/brainspell.php on line 609
Why would the it got denied? How am I suppose to fix it? @davclark @jbpoline @r03ert0
Have you check the permissions ? if you are writting as root, do you have permission to write where you are trying to save the csv ?
May be Roberto will be able to help tomorrow ?
cheers JB
On Tue, Oct 27, 2015 at 7:49 PM, Emily Zhang notifications@github.com wrote:
I made some changes to the code (mainly brainspell.php) -> print out all the article titles at the beginning of the search result page (it is very messy, sorry!) with any query. Then I was trying to save the article titles into a CSV file, but it gives me a warning message (below), I pushed all the changes to Emily branch for reference.
Warning: fopen(list_of_articles.csv): failed to open stream: Permission denied in /home/oski/brainspell/site/php/brainspell.php on line 607
Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/oski/brainspell/site/php/brainspell.php on line 608
Warning: fclose() expects parameter 1 to be resource, boolean given in /home/oski/brainspell/site/php/brainspell.php on line 609
Why would the it got denied? How am I suppose to fix it? @davclark https://github.com/davclark @jbpoline https://github.com/jbpoline @r03ert0 https://github.com/r03ert0
— Reply to this email directly or view it on GitHub https://github.com/BIDS-collaborative/brainspell/issues/12#issuecomment-151706169 .
I modified the brainspell.php file in the php folder, and I saved the csv file in the same folder. Maybe we can talk about it tomorrow.
Thanks, Emily
On Tue, Oct 27, 2015 at 7:57 PM, Jean-Baptiste Poline < notifications@github.com> wrote:
Have you check the permissions ? if you are writting as root, do you have permission to write where you are trying to save the csv ?
May be Roberto will be able to help tomorrow ?
cheers JB
On Tue, Oct 27, 2015 at 7:49 PM, Emily Zhang notifications@github.com wrote:
I made some changes to the code (mainly brainspell.php) -> print out all the article titles at the beginning of the search result page (it is very messy, sorry!) with any query. Then I was trying to save the article titles into a CSV file, but it gives me a warning message (below), I pushed all the changes to Emily branch for reference.
Warning: fopen(list_of_articles.csv): failed to open stream: Permission denied in /home/oski/brainspell/site/php/brainspell.php on line 607
Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/oski/brainspell/site/php/brainspell.php on line 608
Warning: fclose() expects parameter 1 to be resource, boolean given in /home/oski/brainspell/site/php/brainspell.php on line 609
Why would the it got denied? How am I suppose to fix it? @davclark https://github.com/davclark @jbpoline https://github.com/jbpoline @r03ert0 https://github.com/r03ert0
— Reply to this email directly or view it on GitHub < https://github.com/BIDS-collaborative/brainspell/issues/12#issuecomment-151706169
.
— Reply to this email directly or view it on GitHub https://github.com/BIDS-collaborative/brainspell/issues/12#issuecomment-151706957 .
Emily Zhang B.A. of Statistics and Economics University of California, Berkeley
Ideally, you should do that in the client, not in the server. When you launch a search there's already an array that is sent with all the titles. The code is in brainspell-search.js. You should just add a button to the title of the query result (when brainspell tells how many papers responded to the query), and add a function to that button to download the csv file when clicked. Brainspell uses jQuery, and is very easy to append click functions to anything. If you have a button defined like
you append a function in the code like $("#download_csv").click(function() { /* my download csv function here */ });
For the download function, have a look at this function I use to save SVG paths in another app:
function savePaths() { var filename=prompt("File name",filename); var tmpRegions=JSON.parse(JSON.stringify(Regions)); for(var i=0;i<Regions.length;i++) tmpRegions[i].path=Regions[i].path.exportJSON(); var json = JSON.stringify(tmpRegions); var jsonData = 'data:text/json;charset=utf-8,'+encodeURIComponent(json); var a = document.createElement('a'); a.href = jsonData; a.download = filename+'.json'; document.body.appendChild(a); a.click(); }
cheers, roberto
On Wed, Oct 28, 2015 at 3:50 AM, Emily Zhang notifications@github.com wrote:
I made some changes to the code (mainly brainspell.php) -> print out all the article titles at the beginning of the search result page (it is very messy, sorry!) with any query. Then I was trying to save the article titles into a CSV file, but it gives me a warning message (below), I pushed all the changes to Emily branch for reference.
Warning: fopen(list_of_articles.csv): failed to open stream: Permission denied in /home/oski/brainspell/site/php/brainspell.php on line 607
Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/oski/brainspell/site/php/brainspell.php on line 608
Warning: fclose() expects parameter 1 to be resource, boolean given in /home/oski/brainspell/site/php/brainspell.php on line 609
Why would the it got denied? How am I suppose to fix it? @davclark https://github.com/davclark @jbpoline https://github.com/jbpoline @r03ert0 https://github.com/r03ert0
— Reply to this email directly or view it on GitHub https://github.com/BIDS-collaborative/brainspell/issues/12#issuecomment-151706169 .
Meeting Updates & Next Steps:
<!-- Bla Bla Bla -->
symbol, more detail explanations in the Documentation.md file.
@EmilyVam has implemented some sample downloader button (where?) and @anokhikastia has wired something up to the actual app (again, where?)!
I have pushed all my changes on Emily branch. But here is the code I added in the base.html:
$('#give-me-something').click(function () {
var filename="Test";
var csvfile=["Articles", "\narticle1", "\narticle2", "\narticle3"]
var csvData = 'data:text/json;charset=utf-8,'+ encodeURIComponent(csvfile);
var a = document.createElement('a');
a.href = csvData;
a.download = filename+'.csv';
document.body.appendChild(a);
a.click();
});
@anokhikastia You can just copy this for the button you created on the brainspell.dev.
Help! @davclark @jbpoline @r03ert0
Can anyone enlighten me how to pass a php variable to js file? It is kind of frustrated after I tried multiple ways (I learned from Google), but none of them worked.
Two of the methods I tried are:
var data = <?php echo $articles; ?>;
var data = <?php echo json_encode($articles); ?>;
When I printed out the $articles
variable in PHP, it listed all the article names I need, but when I print out the data
variable in JS using document.print(data)
, it doesn't print out anything.
Hi Emily,
brainspell.php passes data to the javascript code through the html page it generates. More in detail: when a user searches a query term, lets say 'vision', this gets transformed into a query for the following web page:
http://brainspell.org/search?query=vision
this web page does not exist before hand -- it is generated by the server (the php code). To generate the search result page, brainspell.php uses Lucene to query the DB that indexes all the papers. The result of this query is an array, similar to $articles in your example. However, instead of adding all the article data to the web page, brainspell.php generates a formated html list of papers, which is the list of papers you can see when you do a search (the 132 papers that correspond to 'vision'). This is the way in which brainspell.php is already passing the list of articles to the client. I don't think it's necessary to do it again.
what you can do now in the client is to recover the article data from the html page using jquery. All the papers in the list have the class "paper-stuff'. Inside the 'paper-stuff' div, the href attribute of the link elements contains the PMID of the papers, that we want to save to the CSV file. The text of the link contains the paper title, authors, journal, etc, that we may also want to save to the CSV file. You can get a javascript array with all the papers by typing:
$(".paper-stuff")
(this works even from the web browser console! give it a try!)
The jquery function each() may come handy for iterate through the results, you can use find() to find the elements that you need, attr() to get the value of specific attributes (such as href), and text() to get the text content of an element.
Hope this helps,
roberto
On Thu, Nov 12, 2015 at 2:38 AM, Emily Zhang notifications@github.com wrote:
Help! @davclark https://github.com/davclark @jbpoline https://github.com/jbpoline @r03ert0 https://github.com/r03ert0
Can anyone enlighten me how to pass a php variable to js file? It is kind of frustrated after I tried multiple ways (I learned from Google), but none of them worked.
Two of the methods I tried are:
var data = <?php echo $articles; ?>; var data = <?php echo json_encode($articles); ?>;
When I printed out the $articles variable in PHP, it listed all the article names I need, but when I print out the data variable in JS using document.print(data), it doesn't print out anything.
— Reply to this email directly or view it on GitHub https://github.com/BIDS-collaborative/brainspell/issues/12#issuecomment-155969692 .
Last week:
This week:
Next step:
Create a downloadable file (csv/json/other formats) at the bottom of the searching result page that store articles' info with given searching query. More discussion at #11