Automatizzare Timeline 3D con Applescript
Usare Applescript per integrate Timeline nel tuo flusso di lavoro.
Le tecnologie Applescript possono essere usate per integrare Timeline 3D con altri prodotti e sorgenti di dati per creare linee temporali automaticamente.
La struttura di un documento Timeline
Capire l'anatomia basilare di un documento Timeline ti aiuterà a scrivere il tuo script:
Documento: Oggetto di livello superiore che può essere aperto, chiuso e salvato su disco. Contiene inoltre l'aspetto dello sfondo e la modalità di visualizzazione.
Riga: Contenuto in un oggetto documento e timeline può avere uno o più righe di eventi. Le righe possono avere etichette e diverse impostazioni di visualizzazione. Sei pregato di notare che l'interfaccia di Timeline mantiene le stesse impostazioni di visualizzazione per tutte le righe in un documento singolo, ma lo script ti permetterà di impostare differenti valori per ogni riga.
Evento: Contenuto da un oggetto riga. Gli oggetti eventi contengono i dati per ogni evento così come le impostazioni della progettazione visiva quali i colori.
Esempio di script per creare una linea temporale basata sui messaggi di posta elettronica recenti
Questo script mostra come può essere utilizzato Applescript per creare un grafico temporale con qualsiasi applicazione che supporti lo scripting.
tell application "Timeline 3D"
activate
set newDoc to make new document
tell newDoc
-- hide the intro panel
set showing panel to false
-- bulk edit view is much faster for large timelines
set view mode to bulk edit view
set name of first row to "MOST RECENT E-MAILS" -- set the row label
-- create a new event for each message
repeat with messageNumber from 1 to 20
tell application "Mail"
set myMessage to message messageNumber of inbox
set mySubject to (subject of myMessage) as string
set myDate to date received of myMessage
set mySender to sender of myMessage
end tell -- end tell application "Mail"
tell first row to make new event with properties {¬
name:mySubject,¬
notes:mySender,¬
starting date:myDate,¬
URL:"http://www.beedocs.com",¬
image:"/Applications/Mail.app/Contents/Resources/app.icns",¬
image size:50,¬
colorR:1.0, colorG:0, colorB:0.5, colorA:1.0}
-- If there was a media file to associate with each event,
-- it would be added to the properties in this format:
-- media:"/Users/myaccount/Music/audio.mp3",
end repeat
set view mode to screen view -- back to screen view after the changes
end tell -- end tell newDoc
end tell -- end tell application "Timeline 3D"
Esempio di script per convertire una linea temporale in HTML
Nel seguente script il documento timeline è convertito in un semplice HTML, un evento alla volta.
tell application "Timeline 3D"
set header to "<head><style>h1, h2, p { font-family: helvetica; font-size: 9pt; margin:0} h1 { font-size: 12pt; margin-top: 25px; } h2 { font-weight: normal; font-style: italic; margin-bottom: 10px; } p { color:#555; }</style></head>" & return & "<body style='width:400px'>" & return
set eventContents to ""
tell first row of front document
repeat with myEvent in events
set eventLabel to my encode_text(name of myEvent)
set eventDate to my encode_text(displayed range of myEvent)
set eventNotes to my encode_text(notes of myEvent)
set eventContents to eventContents & tab & "<h1>" & eventLabel & "</h1><h2>" & eventDate & "</h2>" & return
if the length of eventNotes is greater than 0 then
set eventContents to eventContents & "<p>" & eventNotes & "</p>" & return
end if
set eventImage to my encode_text(image of myEvent)
if the length of eventImage is greater than 0 then
set eventContents to eventContents & "<img src=\"" & eventImage & "\">" & return
end if
end repeat
end tell
set footer to "</body>"
set output to header & eventContents & footer
end tell
on encode_text(this_text) -- required to prep text for html
set the encoded_text to ""
repeat with this_char in this_text
if this_char as string is equal to "<" then
set the encoded_text to (the encoded_text & "<") as string
else if this_char as string is equal to "&" then
set the encoded_text to (the encoded_text & "&") as string
else if this_char as string is equal to (ASCII character 10) as string then
set the encoded_text to (the encoded_text & "<br />") as string
else
set the encoded_text to (the encoded_text & this_char) as string
end if
end repeat
return the encoded_text
end encode_text