[texworks] JabRef Bibtex and php MySql insert \cite[]{}
Paul A Norman
paul.a.norman at gmail.com
Sat Jul 17 06:26:18 CEST 2010
>> If you use JabRef ( http://jabref.sourceforge.net/ ) to maintain your
>> biblios, and have MySql and php (CLI) then here is a system I
>> personally use.
Ok, this lets the user choose how to order the available citations, by
"cite_key", "title", "author", "year", or "journal"
And then shows each citation along with its document title in the drop
down list according to the order just chosen.
Remember to use \usepackage{natbib} in the preamble if you use this.
I've attached it as a zip to unzup into your Tw Script folder (allow
use folder names during decompression). Reload your scripts list from
ther Tw Menu Scripts/Scripting TeXworks.
Paul
>> If you use JabRef ( http://jabref.sourceforge.net/ ) to maintain your
>> biblios, and have MySql and php (CLI) then here is a system I
>> personally use.
>>
>> JabRef lets me set up an MySql database very simply.
If you need php and MySql (and Apache), then get an installation like
Xampp http://www.apachefriends.org/en/index.html
>>
>> (i) Just use your MySql management tool of choice, and make a
>> database called jabref (no tables neeeded)
>> (ii) In Jab Ref open your biblio
>> (iii) File/Connect to External SQL database
>> (iv) File/Export to External Database
>>
>> (I use this with then a latter JabRef File/ Import From External
>> Database to mainatain my references through other interfaces as well.)
>>
If you add new entries in JabRef, then also when saving your work,
also connect / and export again.
>> With that done, you can use these twoi scripts, one a Qt TwScript,
>> the other a php script stored in the same directory under your Tw
>> Scripts folder.
>>
>> And the normal sort of thing (don't forget to run BibTex in Tw after
>> your first pdflatex and then two more pdflatex(s)
>>
>> \bibliographystyle{unsrt}
>> \bibliography{../../bibliographies/myBiblio}
>>
>> Hope it helps/inspires someone,
>>
>> Paul
On 16 July 2010 23:25, Paul A Norman <paul.a.norman at gmail.com> wrote:
> Here is a more robust - insertCitation.js
>
> // TeXworksScript
> // Title: \cite from JabRef -> MySql
> // Description: Make other Scripts
> // Author: Paul A. Norman
> // Version: 0.3
> // Date: 2010-07-16
> // Script-Type: standalone
> // Context: TeXDocument
> // Shortcut: Alt+B, Alt+C
>
>
> var citationType = ["[1. page 2-3]", "Goossens et al.
> (1993)","(Goossens et al., 1993)","Goossens, Mittlebach, and Samarin
> (1993)","(Goossens, Mittlebach, and Samarin, 1993)", "Jones et
> al.","Jones, Baker, and Williams","1990","(1990)"];
>
> var insertCite = [ "cite", "citet", "citep", "citet*", "citep*",
> "citeauthor", "citeauthor*", "citeyear", "citeyearpar"];
>
> var phpScript = __FILE__.substr(0,__FILE__.lastIndexOf("/") +1) +
> 'getCiteKeys.php';
>
> // Non-windows OSes won't need the cmd /c
> var citeKeys = TW.app.system('cmd /c php ' + phpScript).split("\n");
>
> var chosenCitation = TW.getItem( null, "Insert Citation", "Please
> Choose A Citation Key: ", citeKeys , 0, true ) ;
>
> if (chosenCitation != undefined)
> {
>
> var pageRange = TW.getText( null, "Page Range", "Please
> enter A Page Range etc.\n\nE.g.> 123-127", "");
> if (pageRange == undefined)
> {
> pageRange = "";
> }
> else
> {
> pageRange = '[P.~'+ pageRange + ']';
> }
>
> var citeTypeChosen = TW.getItem( null, "Citation Style",
> "(In Preamble, Place: \\usepackage{natbib})\n\n\nChoose A Citation
> Type: ",
> citationType , 0, true ) ;
>
> if (citeTypeChosen != undefined)
> {
> for (find =0; find < citationType.length; find++)
> {
> if (citationType[find] == citeTypeChosen)
> {
> citeType = insertCite[find];
> break;
> }
> }
>
> TW.target.insertText('\\'+citeType+pageRange+'{'+chosenCitation+'}');
> }// /End. IF citeType != undefined
> } // /End. IF chosenCitation != undefined
> null;
>
> // Thanks to http://www.andy-roberts.net/misc/latex/latextutorial3.html
> // Thanks to
> http://www.ctan.org/tex-archive/macros/latex/contrib/natbib/natbib.pdf
>
>
>
> On 16 July 2010 18:50, Paul A Norman <paul.a.norman at gmail.com> wrote:
>> Hi all,
>>
>> Here is a thing of interest, that others might adapt and use.
>>
>> If you use JabRef ( http://jabref.sourceforge.net/ ) to maintain your
>> biblios, and have MySql and php (CLI) then here is a system I
>> personally use.
>>
>> JabRef lets me set up an MySql database very simply.
>>
>> (i) Just use your MySql management tool of choice, and make a
>> database called jabref (no tables neeeded)
>> (ii) In Jab Ref open your biblio
>> (iii) File/Connect to External SQL database
>> (iv) File/Export to External Database
>>
>> (I use this with then a latter JabRef File/ Import From External
>> Database to mainatain my references through other interfaces as well.)
>>
>> With that done, you can use these twoi scripts, one a Qt TwScript,
>> the other a php script stored in the same directory under your Tw
>> Scripts folder.
>>
>> And the normal sort of thing (don't forget to run BibTex in Tw after
>> your first pdflatex and then two more pdflatex(s)
>>
>> \bibliographystyle{unsrt}
>> \bibliography{../../bibliographies/myBiblio}
>>
>> Hope it helps/inspires someone,
>>
>> Paul
>>
>> Script One - php called - getCiteKeys.php
>>
>> <?php
>> // Connecting, selecting database
>> $link = mysql_connect('localhost', 'root', '')
>> or die('Could not connect: ' . mysql_error());
>> // echo 'Connected successfully';
>> mysql_select_db('jabref') or die('Could not select database');
>>
>> // Performing SQL query
>> $query = 'SELECT cite_key FROM entries';
>> $result = mysql_query($query) or die('Query failed: ' . mysql_error());
>>
>> $build = "";
>>
>> while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
>>
>> foreach ($line as $col_value) {
>> $build .= $col_value . "\n";
>> }
>> }
>>
>> // Free resultset
>> mysql_free_result($result);
>> // Closing connection
>> mysql_close($link);
>>
>> echo $build;
>> ?>
>>
>> And now a Qt TwScript I use as - insertCitation.js
>>
>> //TeXworksScript
>> //Title: \cite from JabRef -> MySql
>> //Description: Make other Scripts
>> //Author: Paul A. Norman
>> //Version: 0.3
>> //Date: 2010-16-07
>> //Script-Type: standalone
>> //Context: TeXDocument
>> //Shortcut: Alt+B, Alt+C
>>
>> var phpScript = __FILE__.substr(0,__FILE__.lastIndexOf("/") +1) +
>> 'getCiteKeys.php';
>>
>> // Non-windows OS-es won't need the cmd /c
>> var citeKeys = TW.app.system('cmd /c php ' + phpScript).split("\n");
>>
>> var chosenCitation = TW.getItem( null, "Insert Citation", "Please
>> Choose A Citation Key: ", citeKeys , 0, true ) ;
>>
>> if (chosenCitation != undefined)
>> {
>>
>> var pageRange = TW.getText( null, "Page Range", "Please enter A
>> Page Range etc.\n\nE.g.> 123-127", "");
>> if (pageRange == undefined)
>> {
>> pageRange = "";
>> }
>> else
>> {
>> pageRange = '[P.~'+ pageRange + ']';
>> }
>>
>> TW.target.insertText('\\cite'+pageRange+'{'+chosenCitation+'}');
>>
>> } // /End. IF chosenCitation != undefined
>> null;
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bibliography.zip
Type: application/zip
Size: 3621 bytes
Desc: not available
URL: <http://tug.org/pipermail/texworks/attachments/20100717/293ed270/attachment.zip>
More information about the texworks
mailing list