text
stringlengths
0
15.7k
source
stringlengths
6
112
set error_count to error_count + 1
Import%20Poacket.scpt
set this_offlinefolder_path to offline_path & uid & "/"
Import%20Poacket.scpt
set this_tempfolder_path to tempfolder_path & uid & "/"
Import%20Poacket.scpt
set has_local_file to true
Import%20Poacket.scpt
do shell script "ditto " & (quoted form of this_offlinefolder_path) & " " & this_tempfolder_path
Import%20Poacket.scpt
set has_local_file to false
Import%20Poacket.scpt
set result_record to null
Import%20Poacket.scpt
set location_target to incoming group of current database
Import%20Poacket.scpt
if mime = "application/pdf" or url_orig ends with ".pdf" then -- doesn't catch those pdfs w/o mime and url without "pdf" in it
Import%20Poacket.scpt
set local_url to "file://" & this_tempfolder_path & "web.pdf"
Import%20Poacket.scpt
" & local_url
Import%20Poacket.scpt
set result_record to create PDF document from local_url in location_target
Import%20Poacket.scpt
else if offline_text = "1" then
Import%20Poacket.scpt
set local_url to "file://" & (POSIX path of this_tempfolder_path) & "text.html"
Import%20Poacket.scpt
set result_record to create formatted note from local_url in location_target
Import%20Poacket.scpt
else if offline_web = "1" then
Import%20Poacket.scpt
set local_url to "file://" & this_tempfolder_path & "web.html"
Import%20Poacket.scpt
set local_path to this_tempfolder_path & "web.html"
Import%20Poacket.scpt
set rec1 to import local_path to location_target
Import%20Poacket.scpt
set rec2 to convert record rec1 to rich -- DT doesn't allow to set URL (or rather: it doesn't show up in the address line
Import%20Poacket.scpt
delete record rec1
Import%20Poacket.scpt
set result_record to rec2
Import%20Poacket.scpt
else if not has_local_file then
Import%20Poacket.scpt
set result_record to create record with {URL:url_orig, type:bookmark} in location_target
Import%20Poacket.scpt
set result_record to create record with {name:"error", plain text:itemlog, type:text} in location_target
Import%20Poacket.scpt
set record_created to true
Import%20Poacket.scpt
name of result_record -- raises an error if class type is missing value
Import%20Poacket.scpt
set record_created to false
Import%20Poacket.scpt
if record_created then
Import%20Poacket.scpt
set this_record to result_record
Import%20Poacket.scpt
tell this_record
Import%20Poacket.scpt
set name to (title)
Import%20Poacket.scpt
set the creation date to time_added
Import%20Poacket.scpt
set URL to url_orig
Import%20Poacket.scpt
set comment to "unique_id::" & uid & "
Import%20Poacket.scpt
item_id::" & item_id & "
Import%20Poacket.scpt
loop_count::" & loop_count
Import%20Poacket.scpt
if errors_raised then writelog(itemlog, timestamp)
Import%20Poacket.scpt
else if (loop_count > loop_max) then
Import%20Poacket.scpt
writelog(("
Import%20Poacket.scpt
" & error_count & " error(s) occured. (" & (current date) & "). Loop_count: " & loop_count), timestamp)
Import%20Poacket.scpt
set logfile to (path to desktop as string) & "Pocket2Devonthink_Log_" & timestamp & ".txt"
Import%20Poacket.scpt
set y to POSIX path of logfile
Import%20Poacket.scpt
do shell script "open " & y
Import%20Poacket.scpt
on get_articles(sql_where)
Import%20Poacket.scpt
log ">>>> GetPocketReferences"
Import%20Poacket.scpt
set sCommand to sqlite_path & " -separator ';; ' " & quoted_db_path_p & " 'select unique_id, item_id, url, title, time_added, word_count, mime, offline_text, offline_web,\"<EOR>
Import%20Poacket.scpt
\"
Import%20Poacket.scpt
from items" & sql_where & ";'"
Import%20Poacket.scpt
set sResult to (do shell script sCommand)
Import%20Poacket.scpt
return sResult
Import%20Poacket.scpt
end get_articles
Import%20Poacket.scpt
on textToTwoDArray(theText, mainDelimiter, secondaryDelimiter)
Import%20Poacket.scpt
set {tids, text item delimiters} to {text item delimiters, mainDelimiter}
Import%20Poacket.scpt
set firstArray to text items of theText
Import%20Poacket.scpt
set text item delimiters to secondaryDelimiter
Import%20Poacket.scpt
set twoDArray to {}
Import%20Poacket.scpt
repeat with anItem in firstArray
Import%20Poacket.scpt
set end of twoDArray to text items of anItem
Import%20Poacket.scpt
return twoDArray
Import%20Poacket.scpt
end textToTwoDArray
Import%20Poacket.scpt
on timestamp2appledate(timestamp)
Import%20Poacket.scpt
end timestamp2appledate
Import%20Poacket.scpt
on remove_http(url1)
Import%20Poacket.scpt
set n to count of url1
Import%20Poacket.scpt
if characters 1 through 6 of url1 as string = "https:" then
Import%20Poacket.scpt
set url2 to characters 9 thru n of url1 as string
Import%20Poacket.scpt
else if characters 1 through 5 of url1 as string = "http:" then
Import%20Poacket.scpt
set url2 to characters 8 thru n of url1 as string
Import%20Poacket.scpt
log "url1: " & url1
Import%20Poacket.scpt
log characters 1 through 4 of url1 as string
Import%20Poacket.scpt
log url2
Import%20Poacket.scpt
return url2
Import%20Poacket.scpt
end remove_http
Import%20Poacket.scpt
on writelog(this_message, timestamp)
Import%20Poacket.scpt
set the log_file to ((path to desktop) as text) & "Pocket2Devonthink_Log_" & timestamp & ".txt"
Import%20Poacket.scpt
open for access file the log_file with write permission
Import%20Poacket.scpt
write (this_message & return) to file the log_file starting at eof
Import%20Poacket.scpt
close access file the log_file
Import%20Poacket.scpt
end writelog
Import%20Poacket.scpt
on setGeneratedInfo(theDate as date)
StephensLib.applescript
set theNewHtmlText to missing value
StephensLib.applescript
if theDate is missing value then
StephensLib.applescript
theDate is (current date)
StephensLib.applescript
set theHTML to "<sup>Generated by " & getMyName() & " on " & theDate & "</sup></p>"
StephensLib.applescript
end setGeneratedInfo
StephensLib.applescript
on getMyName()
StephensLib.applescript
local myName, tidSaved
StephensLib.applescript
set myAlias to path to me
StephensLib.applescript
set myName to name of myAlias
StephensLib.applescript
if name extension of myAlias is not "" then
StephensLib.applescript
set {tidSaved, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {""}}
StephensLib.applescript
set myName to items 1 through -(2 + (length of (get name extension of myAlias))) of myName as text
StephensLib.applescript
set AppleScript's text item delimiters to tidSaved
StephensLib.applescript
return myName
StephensLib.applescript
end getMyName
StephensLib.applescript
on toLowerCase(theString)
StephensLib.applescript
return (current application's NSString's stringWithString:theString)'s lowercaseString() as text
StephensLib.applescript
end toLowerCase
StephensLib.applescript
property NSTimer : class "NSTimer" of current application
Controller copy 2.applescript