text
stringlengths 0
15.7k
| source
stringlengths 6
112
|
---|---|
set theChoice to choose from list theChoices with prompt "Select:"
|
crossref-lookup.applescript
|
if theChoice is false then return
|
crossref-lookup.applescript
|
repeat with a from 1 to length of theChoices
|
crossref-lookup.applescript
|
set currentItem to item a of theChoices
|
crossref-lookup.applescript
|
if currentItem as string is equal to theChoice as string then
|
crossref-lookup.applescript
|
set chosenItem to item a of theItems
|
crossref-lookup.applescript
|
set dateString to my extractDate(chosenItem)
|
crossref-lookup.applescript
|
set dateStruct to my appleDate(dateString)
|
crossref-lookup.applescript
|
set recordPath to path of theRecord
|
crossref-lookup.applescript
|
set the date of theRecord to dateStruct
|
crossref-lookup.applescript
|
set typeTag to |type| of chosenItem
|
crossref-lookup.applescript
|
if typeTag is not in tags of theRecord then
|
crossref-lookup.applescript
|
set tagList to tags of theRecord
|
crossref-lookup.applescript
|
set end of tagList to typeTag
|
crossref-lookup.applescript
|
set tags of theRecord to tagList
|
crossref-lookup.applescript
|
set uri to |URL| of chosenItem
|
crossref-lookup.applescript
|
set the URL of theRecord to uri
|
crossref-lookup.applescript
|
set citation to my lookupCitation(uri)
|
crossref-lookup.applescript
|
set the comment of theRecord to citation
|
crossref-lookup.applescript
|
set recordTitle to item 1 of title of chosenItem
|
crossref-lookup.applescript
|
my setPDFMetadata("Title", recordTitle, recordPath)
|
crossref-lookup.applescript
|
set authorString to my extractAuthor(chosenItem)
|
crossref-lookup.applescript
|
my setPDFMetadata("Author", authorString, recordPath)
|
crossref-lookup.applescript
|
on crossrefLookup(query)
|
crossref-lookup.applescript
|
set apiURL to "https://api.crossref.org/works"
|
crossref-lookup.applescript
|
set shellScript to ("curl -A \"" & my UAString & "\" -G " & apiURL ¬
|
crossref-lookup.applescript
|
& " --data-urlencode query.bibliographic=" & quoted form of query ¬
|
crossref-lookup.applescript
|
& " -d rows=5 -d select=author,title,type,publisher,issued,subject,URL")
|
crossref-lookup.applescript
|
set apiResult to (do shell script shellScript)
|
crossref-lookup.applescript
|
set jsonResponse to read JSON from apiResult
|
crossref-lookup.applescript
|
if not status of jsonResponse is equal to "OK" then
|
crossref-lookup.applescript
|
error "API response not OK: " & message of jsonResponse
|
crossref-lookup.applescript
|
return jsonResponse
|
crossref-lookup.applescript
|
end crossrefLookup
|
crossref-lookup.applescript
|
on extractDate(record_item)
|
crossref-lookup.applescript
|
set [iyear, imonth, iday] to item 1 of |date-parts| of issued of record_item
|
crossref-lookup.applescript
|
set dateString to ((iday as string) & "-" & imonth as string) & "-" & iyear as string
|
crossref-lookup.applescript
|
set [iyear, imonth] to item 1 of |date-parts| of issued of record_item
|
crossref-lookup.applescript
|
set dateString to "01-" & (imonth as string) & "-" & iyear as string
|
crossref-lookup.applescript
|
set iyear to item 1 of |date-parts| of issued of record_item
|
crossref-lookup.applescript
|
set dateString to "01-01-" & iyear as string
|
crossref-lookup.applescript
|
set dateString to ""
|
crossref-lookup.applescript
|
return dateString
|
crossref-lookup.applescript
|
end extractDate
|
crossref-lookup.applescript
|
on appleDate(date_string)
|
crossref-lookup.applescript
|
return date (date_string)
|
crossref-lookup.applescript
|
end appleDate
|
crossref-lookup.applescript
|
on extractAuthor(record_item)
|
crossref-lookup.applescript
|
set firstAuthor to ""
|
crossref-lookup.applescript
|
set author_entries to author of record_item
|
crossref-lookup.applescript
|
repeat with a from 1 to length of author_entries
|
crossref-lookup.applescript
|
set this_entry to item a of author_entries
|
crossref-lookup.applescript
|
if sequence of this_entry is equal to "first" then
|
crossref-lookup.applescript
|
set firstAuthor to this_entry
|
crossref-lookup.applescript
|
if firstAuthor is equal to "" then
|
crossref-lookup.applescript
|
set authorString to |given| of firstAuthor & " " & family of firstAuthor
|
crossref-lookup.applescript
|
set authorString to family of firstAuthor
|
crossref-lookup.applescript
|
set authorString to |name| of firstAuthor
|
crossref-lookup.applescript
|
return authorString
|
crossref-lookup.applescript
|
end extractAuthor
|
crossref-lookup.applescript
|
on setPDFMetadata(mdKey, mdValue, recordPath)
|
crossref-lookup.applescript
|
set shellCommand to "/opt/homebrew/bin/exiftool -overwrite_original -" & mdKey & "=" & quoted form of mdValue & " " & quoted form of recordPath
|
crossref-lookup.applescript
|
set exifresult to do shell script shellCommand
|
crossref-lookup.applescript
|
end setPDFMetadata
|
crossref-lookup.applescript
|
on lookupCitation(uri)
|
crossref-lookup.applescript
|
set shellScript to ("curl -A \"" & my UAString & "\" " & ¬
|
crossref-lookup.applescript
|
"-LH \"Accept: text/bibliography; style=" & my CitationName & "\" " & uri)
|
crossref-lookup.applescript
|
return apiResult
|
crossref-lookup.applescript
|
end lookupCitation
|
crossref-lookup.applescript
|
on sansExt(theFileName)
|
keynote_export.applescript
|
do shell script "file=" & theFileName & ";" & "echo ${file%.*}"
|
keynote_export.applescript
|
end sansExt
|
keynote_export.applescript
|
on getExt(theFileName)
|
keynote_export.applescript
|
do shell script "file=" & theFileName & ";" & "echo ${file##*.}"
|
keynote_export.applescript
|
end getExt
|
keynote_export.applescript
|
set keynote_path to (item 1 of argv)
|
keynote_export.applescript
|
set out_path to (item 2 of argv)
|
keynote_export.applescript
|
set extension to getExt(out_path)
|
keynote_export.applescript
|
set basename to sansExt(out_path)
|
keynote_export.applescript
|
set keynote_file to open (keynote_path as POSIX file)
|
keynote_export.applescript
|
if extension is equal to "pdf" then
|
keynote_export.applescript
|
export keynote_file to (out_path as POSIX file) as PDF
|
keynote_export.applescript
|
else if extension is equal to "jpeg" then
|
keynote_export.applescript
|
export keynote_file to (basename as POSIX file) as slide images with properties { compression factor: 1.0, image format: JPEG }
|
keynote_export.applescript
|
do shell script "echo Output format " & extension & " not supported."
|
keynote_export.applescript
|
close keynote_file saving no
|
keynote_export.applescript
|
display dialog (count of paragraphs of selection)
|
remove space and tab in front of paragraphs.applescript
|
repeat with i from 1 to count of paragraphs of selection
|
remove space and tab in front of paragraphs.applescript
|
if first character of paragraph i of selection is " " or first character of paragraph i of selection is " " then
|
remove space and tab in front of paragraphs.applescript
|
set first character of paragraph i of selection to ""
|
remove space and tab in front of paragraphs.applescript
|
tell dock preferences
|
dock-properties.applescript
|
set properties to {minimize effect:scale, magnification size:0.5, dock size:0.2, autohide:true, animate:true, magnification:false, screen edge:bottom}
|
dock-properties.applescript
|
openDirectory()
|
Open Max for Live User Directory.applescript
|
on openDirectory()
|
Open Max for Live User Directory.applescript
|
set theFilePath to ((path to home folder) as string) & "Documents:Max 8:Max for Live Devices:"
|
Open Max for Live User Directory.applescript
|
set thePOSIXPath to the POSIX path of theFilePath
|
Open Max for Live User Directory.applescript
|
set theCommand to "open " & quoted form of thePOSIXPath
|
Open Max for Live User Directory.applescript
|
do shell script theCommand
|
Open Max for Live User Directory.applescript
|
end openDirectory
|
Open Max for Live User Directory.applescript
|
do shell script "networksetup -setairportpower en0 off"
|
Turn WiFi Off.applescript
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.