Question
I want to use the searh template provided with the plugin to query some bib files. However, how can I choose the style used to render the results to the query? Something like
%BIBTEX{style="plain" form="on"}%
does not work. The style only affects the results displayed before the query is done.
I have tried to edit the template itself by adding the following input:
<input type="hidden" name="style" value="plain"/>
The output was indeed using the plain style, but I think the site was then using another style for my skin too
Thanks in advance
Environment
--
TWikiGuest - 24 Aug 2006
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
Just to confirm: If you load a topic with a %BIBTEX{style="plain" form="on"}% tag, you see output that matches bibtex rendering of the .bib file with the
plain style. But when you do a search, the output is no longer in
plain. (at least, this is close to what I saw on my own installation.)
It certainly seems reasonable to me that the output style should be governed by the
style setting in the BIBTEX declaration.
The output style appears to be forced to
bibtool in the
bin/bibsearch script (L115). Commenting this line out allows one to set the style in the search form.
To make this more general, and to set the output style in the BIBTEX macro, add the following patches:
lib/TWiki/Plugins/BibtexPlugin.pm
L672: $text =~ s/%BIBTEXRESULT%/$result/o;
++++: $text =~ s/%BIBSTYLE%/$theStyle/o;
L673: $result = $text;
and
data/TWiki/BibtexSearchTemplate.txt
L9: <input type="hidden" name="total" value="%BIBTOTAL%" />
+++: <input type="hidden" name="style" value="%BIBSTYLE%" />
L10: <table width="100%" cellspacing="0" cellpadding="0" ><tr><td>
I'll check these changes into SVN shortly.
--
ScottHoge - 25 Aug 2006
--
TWikiGuest - 28 Aug 2006
Thank you for your answer. However, adding the line
<input type="hidden" name="style" value="%BIBSTYLE%" />
changes the style of the skin used (I am using
NatSkin).
--
TWikiGuest - 28 Aug 2006
I'm not familiar with the NatSkin. Would changing the bibtex
style to
bibstyle solve this problem?
--
ScottHoge - 28 Aug 2006
what do you mean exactly?
--
FlorianSimatos - 28 Aug 2006
Well...
Changing the bibsearch form, in particular adding a line with a hidden parameter,
should have no effect on the skin you are using. NatSkin uses CSS pretty heavily, so my suspicion is that the
style declared in the bibsearch form is somehow causing confusion for the NatSkin css files.
So, if the line you add to the bibsearch form has
bibstyle inplace of
style, does the NatSkin rendering still change? Making such a change through the BibtexPlugin would be straightforward.
I'm not up for installing NatSkin anytime soon. So if switching
style to
bibstyle does not solve the skin-switching problem, then maybe attach a screen shot and/or HTML source files (created by twiki) to this topic and I'll take a look.
--
ScottHoge - 28 Aug 2006
I have added the following hidden form to the search template:
<input type="hidden" name="bibstyle" value="%BIBSTYLE%" />
I create the form with the following command in TWiki:
%BIBTEX{form="on" style="plain"}%
I have kept the line you told me to add:
$text =~ s/%BIBSTYLE%/$theStyle/o;
Then (I apologize for my lack of competence, I am really not familiar with scripts) I tried to modify the
BibtexPlugin.pm file by replacing
my $theStyle = &TWiki::Func::extractNameValuePair($theAttributes, "style")
on lines 369 and 399 by
my $theStyle = &TWiki::Func::extractNameValuePair($theAttributes, "bibstyle")
Then the skin is conserved, but the output does not use the plain style (both when the form is displayed before any query is made and to show the results to a query).
I have attached the source created by twiki for a page that answers to a given query, I hope this is what you were expecting.
--
TWikiGuest - 29 Aug 2006
No need to apologize. The style is set in multiple places...
To switch the parameter setting from
style to
bibstyle, the following lines need to be changed:
bin/bibsearch:
L99: my $theStyle = $query->param("bibstyle");
lib/TWiki/Plugins/BibtexPlugin.pm:
L375: my $theStyle = &TWiki::Func::extractNameValuePair($theAttributes, "bibstyle");
L402: my $theStyle = &TWiki::Func::extractNameValuePair($theAttributes, "bibstyle");
data/TWiki/BibtexSearchTemplate.txt:
L10: <input type="hidden" name="bibstyle" value="%BIBSTYLE%" />
In each case,
"style" has been replaced by
"bibstyle". If this doesn't work, we'll probably have to ask
Micha to look in to it.
--
ScottHoge - 29 Aug 2006
Everything seems to work fine now, thanks a lot!
--
FlorianSimatos - 29 Aug 2006
You're welcome. I'm glad we were able to track down the problem.
--
ScottHoge - 29 Aug 2006