text
stringlengths
0
15.7k
source
stringlengths
6
112
property mainTemplate : ""
MarsEdit-MakeLink.scpt
property beforeTemplate : ""
MarsEdit-MakeLink.scpt
property afterTemplate : ""
MarsEdit-MakeLink.scpt
property imageWidth : 130
MarsEdit-MakeLink.scpt
property imageHeight : 130
MarsEdit-MakeLink.scpt
property dateFormat : "'+%Y/%m/%d'"
MarsEdit-MakeLink.scpt
property pubDateFormat : "'+%Y/%m/%d'"
MarsEdit-MakeLink.scpt
to switchTemplateType(templateType)
MarsEdit-MakeLink.scpt
if templateType is equal to "Simple" then
MarsEdit-MakeLink.scpt
set mainTemplate to "<a href=\"%{sourceURL}\" target=\"_blank\">%{escapeTitle}</a><br />
MarsEdit-MakeLink.scpt
set beforeTemplate to "
MarsEdit-MakeLink.scpt
set afterTemplate to ""
MarsEdit-MakeLink.scpt
if templateType is equal to "List" then
MarsEdit-MakeLink.scpt
set mainTemplate to "
MarsEdit-MakeLink.scpt
<li><a href=\"%{sourceURL}\" target=\"_blank\">%{escapeTitle}</a></li>"
MarsEdit-MakeLink.scpt
<figure>
MarsEdit-MakeLink.scpt
<figcaption>
MarsEdit-MakeLink.scpt
参考記事
MarsEdit-MakeLink.scpt
</figcaption>
MarsEdit-MakeLink.scpt
<ul>
MarsEdit-MakeLink.scpt
set afterTemplate to "
MarsEdit-MakeLink.scpt
</ul>
MarsEdit-MakeLink.scpt
</figure>
MarsEdit-MakeLink.scpt
if templateType is equal to "List with Thumbnail" then
MarsEdit-MakeLink.scpt
<li>
MarsEdit-MakeLink.scpt
<a href=\"%{sourceURL}\" target=\"_blank\"><img title=\"%{sourceTitle}\" src=\"%{imageURL}\" width=\"%{imageWidth}\" height=\"%{imageHeight}\" alt=\"%{sourceURL}\"/></a>
MarsEdit-MakeLink.scpt
<a href=\"%{sourceURL}\" target=\"_blank\">%{escapeTitle}</a>
MarsEdit-MakeLink.scpt
</li>"
MarsEdit-MakeLink.scpt
set imageWidth to 120
MarsEdit-MakeLink.scpt
set imageHeight to 120
MarsEdit-MakeLink.scpt
if templateType is equal to "Simple with Thumbnail" then
MarsEdit-MakeLink.scpt
<a href=\"%{sourceURL}\" target=\"_blank\">%{escapeTitle}</a><br />
MarsEdit-MakeLink.scpt
set beforeTemplate to ""
MarsEdit-MakeLink.scpt
if templateType is equal to "Blockquote" then
MarsEdit-MakeLink.scpt
<blockquote>
MarsEdit-MakeLink.scpt
<p>
MarsEdit-MakeLink.scpt
%{escapeSelection}
MarsEdit-MakeLink.scpt
</p>
MarsEdit-MakeLink.scpt
</blockquote>
MarsEdit-MakeLink.scpt
set imageWidth to 80
MarsEdit-MakeLink.scpt
set imageHeight to 80
MarsEdit-MakeLink.scpt
if templateType is equal to "Blockquote with Thumbnail" then
MarsEdit-MakeLink.scpt
<cite><a href=\"%{sourceURL}\" target=\"_blank\">%{escapeTitle}</a></cite>
MarsEdit-MakeLink.scpt
end switchTemplateType
MarsEdit-MakeLink.scpt
to formattedText(objs)
MarsEdit-MakeLink.scpt
set templateTypes to {"Simple", "Simple with Thumbnail", "List", "List with Thumbnail", "Blockquote", "Blockquote with Thumbnail"}
MarsEdit-MakeLink.scpt
set resultText to ""
MarsEdit-MakeLink.scpt
set selectedType to choose from list templateTypes with prompt "どのテンプレートを使用しますか?" default items (item 1 of templateTypes)
MarsEdit-MakeLink.scpt
if selectedType = false then return
MarsEdit-MakeLink.scpt
switchTemplateType(item 1 of selectedType)
MarsEdit-MakeLink.scpt
repeat with i from 1 to (count of objs)
MarsEdit-MakeLink.scpt
set obj to item i of objs
MarsEdit-MakeLink.scpt
set tmpResult to mainTemplate
MarsEdit-MakeLink.scpt
if wwwTitle of obj is not equal to "" then
MarsEdit-MakeLink.scpt
set tmpResult to replaceStringAction(tmpResult, "%{sourceTitle}", wwwTitle of obj)
MarsEdit-MakeLink.scpt
set tmpResult to replaceStringAction(tmpResult, "%{escapeTitle}", replaceHtmlEntity(wwwTitle of obj))
MarsEdit-MakeLink.scpt
if wwwURL of obj is not equal to "" then
MarsEdit-MakeLink.scpt
set tmpResult to replaceStringAction(tmpResult, "%{sourceURL}", wwwURL of obj)
MarsEdit-MakeLink.scpt
set tmpResult to replaceStringAction(tmpResult, "%{escapeURL}", replaceHtmlEntity(wwwURL of obj))
MarsEdit-MakeLink.scpt
set tmpImageURL to "http://capture.heartrails.com/" & imageWidth & "×" & imageHeight & "?" & (wwwURL of obj)
MarsEdit-MakeLink.scpt
set tmpResult to replaceStringAction(tmpResult, "%{imageURL}", tmpImageURL)
MarsEdit-MakeLink.scpt
set tmpResult to replaceStringAction(tmpResult, "%{selection}", wwwSelection of obj)
MarsEdit-MakeLink.scpt
set tmpResult to replaceStringAction(tmpResult, "%{escapeSelection}", replaceHtmlEntity(wwwSelection of obj))
MarsEdit-MakeLink.scpt
set tmpPubDate to (do shell script "date -jf '%Y/%m/%e %H:%M:%S' '" & wwwPubDate of obj & "' " & dateFormat)
MarsEdit-MakeLink.scpt
set tmpResult to replaceStringAction(tmpResult, "%{publishDate}", tmpPubDate)
MarsEdit-MakeLink.scpt
set tmpResult to replaceStringAction(tmpResult, "%{imageWidth}", imageWidth as string)
MarsEdit-MakeLink.scpt
set tmpResult to replaceStringAction(tmpResult, "%{imageHeight}", imageHeight as string)
MarsEdit-MakeLink.scpt
set resultText to (resultText & tmpResult)
MarsEdit-MakeLink.scpt
set resultText to beforeTemplate & resultText & afterTemplate
MarsEdit-MakeLink.scpt
set resultText to replaceStringAction(resultText, "%{count}", (count of objs) as string)
MarsEdit-MakeLink.scpt
set dateText to (do shell script "date " & dateFormat)
MarsEdit-MakeLink.scpt
set resultText to replaceStringAction(resultText, "%{date}", dateText)
MarsEdit-MakeLink.scpt
if resultText is equal to "" then
MarsEdit-MakeLink.scpt
return resultText
MarsEdit-MakeLink.scpt
end formattedText
MarsEdit-MakeLink.scpt
set marseditProcessA to processBundleID("com.red-sweater.marsedit.macappstore")
MarsEdit-MakeLink.scpt
set marseditProcessB to processBundleID("com.red-sweater.marsedit")
MarsEdit-MakeLink.scpt
if marseditProcessA is equal to false and marseditProcessB is equal to false then
MarsEdit-MakeLink.scpt
set targetApplications to {"Safari", "GoogleChrome", "MarsEdit"}
MarsEdit-MakeLink.scpt
set selectedApplication to choose from list targetApplications with prompt "どのアプリケーションからリンクを作成しますか?" default items (item 1 of targetApplications)
MarsEdit-MakeLink.scpt
if selectedApplication = false then return
MarsEdit-MakeLink.scpt
if item 1 of selectedApplication is equal to "Safari" then
MarsEdit-MakeLink.scpt
set targetProcess to processBundleID("com.apple.Safari")
MarsEdit-MakeLink.scpt
else if item 1 of selectedApplication is equal to "GoogleChrome" then
MarsEdit-MakeLink.scpt
set targetProcess to processBundleID("com.google.Chrome")
MarsEdit-MakeLink.scpt
else if item 1 of selectedApplication is equal to "MarsEdit" then
MarsEdit-MakeLink.scpt
if marseditProcessA is not equal to false then
MarsEdit-MakeLink.scpt
set targetProcess to marseditProcessA
MarsEdit-MakeLink.scpt
else if marseditProcessB is not equal to false then
MarsEdit-MakeLink.scpt
set targetProcess to marseditProcessB
MarsEdit-MakeLink.scpt
if targetProcess is equal to false then
MarsEdit-MakeLink.scpt
if (count of document) is equal to 0 then
MarsEdit-MakeLink.scpt
set siteRecords to {}
MarsEdit-MakeLink.scpt
repeat with i from 1 to count of tabs
MarsEdit-MakeLink.scpt
set tabDocument to item i of tabs
MarsEdit-MakeLink.scpt
set siteTitle to name of tabDocument
MarsEdit-MakeLink.scpt
set selectionCommand to "window.unescape(escape(window.getSelection()));"
MarsEdit-MakeLink.scpt
set selectionText to (do JavaScript selectionCommand in tabDocument) as string
MarsEdit-MakeLink.scpt
set siteRecord to {wwwTitle:siteTitle, wwwURL:URL of tabDocument, wwwSelection:selectionText, listTitle:(i & ": " & siteTitle) as string}
MarsEdit-MakeLink.scpt
set the end of siteRecords to siteRecord
MarsEdit-MakeLink.scpt