It should be the Import Publication script hook. How do you add the citation?

Christiaan

> On 26 Oct 2019, at 22:53, Danushka Bollegala <danushka.bolleg...@gmail.com> 
> wrote:
> 
> Thank you Christian for the script.
> 
> In order to run this script when I copy a bibtex entry from the aclanthology 
> to bibdesk, to which script hook should I assign it?
> I tried assigning it to “Import publication” hook but that does not seem to 
> get invoked.
> If you could kindly clarify how to get the script associated and running that 
> would be great.
> 
> Thanks in advance
> 
> Danushka
> 
> 
>> On 26 Oct 2019, at 14:54, Christiaan Hofman <cmhof...@gmail.com 
>> <mailto:cmhof...@gmail.com>> wrote:
>> 
>> Here’s an example of such a script hook:
>> 
>> 
>> 
>>> On 26 Oct 2019, at 15:28, Christiaan Hofman <cmhof...@gmail.com 
>>> <mailto:cmhof...@gmail.com>> wrote:
>>> 
>>> 
>>> 
>>>> On 25 Oct 2019, at 23:44, Christiaan Hofman <cmhof...@gmail.com 
>>>> <mailto:cmhof...@gmail.com>> wrote:
>>>> 
>>>> 
>>>> 
>>>>> On 25 Oct 2019, at 23:14, Danushka Bollegala 
>>>>> <danushka.bolleg...@gmail.com <mailto:danushka.bolleg...@gmail.com>> 
>>>>> wrote:
>>>>> 
>>>>> Thank you for developing BibDesk which is an essential component of my 
>>>>> research workflow!
>>>>> 
>>>>> I use acl anthology for importing papers into bibdesk. The Url field in 
>>>>> the BibText in acl anthology does not contain .pdf extension.
>>>>> For example, see https://www.aclweb.org/anthology/N18-2115/ 
>>>>> <https://www.aclweb.org/anthology/N18-2115/>
>>>>> for which the bibtex entry contains
>>>>>     url = "https://www.aclweb.org/anthology/N18-2115 
>>>>> <https://www.aclweb.org/anthology/N18-2115>”
>>>>> Unfortunately, this gets mapped to the Url field in Bibdesk and I cannot 
>>>>> download the pdf but the top page by “Download Urls” menu.
>>>>> Is there a way (for example a script hook etc.) that would let me 
>>>>> automatically append .pdf to the url field when a bibtex entry is copied 
>>>>> to BibDesk?
>>>>> Thank you
>>>>> Danushka
>>>>> ______________________________
>>>>> Prof. Danushka Bollegala
>>>>> Head of Data Mining and Machine Learning
>>>>> Department of Computer Science
>>>>> University of Liverpool
>>>>> 224 Ashton Building
>>>>> Ashton Street
>>>>> Liverpool    L69 3BX
>>>>>  
>>>>> T  +44 151 795 4283
>>>>> F  +44 151 795 4235
>>>>> W  danushka.net <http://danushka.net/>
>>>>> E  m...@danushka.net <mailto:m...@danushka.net>
>>>>> T  @Bollegala
>>>>> 
>>>> 
>>>> 
>>>> Perhaps the Import Publications script hook could do that. How do you 
>>>> import the bibtex entries? And what is setting this URL field?
>>>> 
>>>> Christiaan
>>> 
>>> 
>>> Be aware that the Import Publications script hook comes after the 
>>> conversion of the Url field to a linked URL, so you probably also want to 
>>> repoace the linked URL from the script hook. Also if you want to 
>>> automatically downoad the URL, this would not be done in this case, so you 
>>> should also do that from the script hook.
>>> 
>>> Christiaan
>>> 
>> 
>> 
>> Here’s an example of such a script hook:
>> 
>> property theURLPrefixes : {"https://www.aclweb.org/anthology/ 
>> <https://www.aclweb.org/anthology/>"}
>> property thePDFExtension : ".pdf"
>> 
>> on hasAnyPrefix(theString, thePrefixes)
>>      repeat with thePrefix in thePrefixes
>>              if theString starts with thePrefix then return true
>>      end repeat
>>      return false
>> end hasAnyPrefix
>> 
>> on fixURL(theURL)
>>      if (my hasAnyPrefix(theURL, theURLPrefixes) and theURL does not end 
>> with thePDFExtension) then
>>              if theURL ends with "/" then set theURL to text 1 thru -2 of 
>> theURL
>>              set theURL to theURL & thePDFExtension
>>      end if
>>      return theURL
>> end fixURL
>> 
>> using terms from application "BibDesk"
>>      on perform BibDesk action with publications thePubs for script hook 
>> theScriptHook
>>              tell application "BibDesk"
>>                      repeat with thePub in thePubs
>>                              tell contents of thePub
>>                                      set theURL to value of field "Url"
>>                                      set theFixedURL to my fixedURL(theURL)
>>                                      if (theURL is not theFixedURL) then
>>                                              set value of field "Url" to 
>> theURL & theExt
>>                                      end if
>>                                      if (count of linked URLs) > 0 then
>>                                              set theURL to linked URL 1
>>                                              set theFixedURL to my 
>> fixedURL(theURL)
>>                                              if (theURL is not theFixedURL) 
>> then
>>                                                      remove theURL
>>                                                      add theURL to beginning 
>> of linked URLs
>>                                                      --download linked URL 1 
>> --with replace
>>                                              end if
>>                                      end if
>>                              end tell
>>                      end repeat
>>              end tell
>>      end perform BibDesk action with publications
>> end using terms from
>> 
>> hth,
>> Christiaan

_______________________________________________
Bibdesk-users mailing list
Bibdesk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-users

Reply via email to