
【ATS-FontValidator】JSONに出力する、同時にHTMLも出力する
【Safari・FireFox用Script Editorで開く】 |
| ソース | |
|---|---|
| 001 | #!/usr/bin/env osascript |
| 002 | #coding: utf-8 |
| 003 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7-- |
| 004 | (* |
| 005 | |
| 006 | /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Support/FontValidator |
| 007 | [-help -version -local -quiet -ios_only -pedantic |
| 008 | [-report -report_output OUTPUT_FILE_PATH -relative_path] |
| 009 | [FONT_FILE_OR_DIR_PATH]] |
| 010 | |
| 011 | Validates font files are adequate to use with the OS. |
| 012 | If a directory is specified, it recursively examines font files found |
| 013 | |
| 014 | -local Performs all validation in-process. Default validation is performed by a separate process |
| 015 | -quiet Suppress progress information and errors |
| 016 | -ios_only Fonts not supported by iOS are treated as errors |
| 017 | -duplicates check for duplicates |
| 018 | -dynamic perform dynamic validation (runtime checks against ATS/CT APIs) |
| 019 | -only_fonts Any file that isn't a font file will be reported as an error |
| 020 | -pedantic Reports non-font files as errors |
| 021 | -showSuccesses Report shows names of successful tests |
| 022 | -showWarnings Report shows warnings |
| 023 | -warningAsError Warning presence indicates validation failure. (-showWarnings implied) |
| 024 | -report_output Specify a file to hold the report. If not specified stdout will be used |
| 025 | -relative_path File paths in report are relative to the base path passed in. |
| 026 | Warning: this may yield similar paths if 2 input directorys contain similar directory structures |
| 027 | |
| 028 | |
| 029 | |
| 030 | com.cocolog-nifty.quicktimer.icefloe *) |
| 031 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7-- |
| 032 | use AppleScript version "2.8" |
| 033 | use framework "Foundation" |
| 034 | use framework "AppKit" |
| 035 | use framework "UniformTypeIdentifiers" |
| 036 | use scripting additions |
| 037 | |
| 038 | property refMe : a reference to current application |
| 039 | |
| 040 | ############################# |
| 041 | # |
| 042 | set strBinPath to ("/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Support/FontValidator") as text |
| 043 | ############################# |
| 044 | #ダイアログ |
| 045 | |
| 046 | set aliasDefaultLocation to (path to fonts folder from user domain) as alias |
| 047 | # |
| 048 | set listUTI to {"public.font"} as list |
| 049 | set strMes to ("フォントを選択してください") as text |
| 050 | set strPrompt to ("フォントを選択してください") as text |
| 051 | try |
| 052 | tell application "SystemUIServer" |
| 053 | activate |
| 054 | set listAliasFilePath to (choose file strMes with prompt strPrompt default location aliasDefaultLocation of type listUTI with invisibles, showing package contents and multiple selections allowed) as list |
| 055 | end tell |
| 056 | on error strErrMes number numErrNo |
| 057 | log strErrMes & numErrNo |
| 058 | return false |
| 059 | end try |
| 060 | if listAliasFilePath is {} then |
| 061 | return false |
| 062 | end if |
| 063 | |
| 064 | ############################# |
| 065 | #パスArrayにする |
| 066 | set strPathList to ("") as text |
| 067 | # |
| 068 | repeat with itemAliasFilePath in listAliasFilePath |
| 069 | set aliasFilePath to itemAliasFilePath as alias |
| 070 | set strFilePath to (POSIX path of aliasFilePath) as text |
| 071 | set strFilePath to doPathEscape(strFilePath) |
| 072 | set strPathList to ("" & strPathList & " \\\"" & strFilePath & "\\\"") as text |
| 073 | end repeat |
| 074 | #ソート |
| 075 | |
| 076 | |
| 077 | ############################# |
| 078 | # |
| 079 | set aliasDefaultLocation to (path to desktop folder from user domain) as alias |
| 080 | |
| 081 | set strFileExtension to ("json") as text |
| 082 | set strSaveFileName to ("FontValidator." & strFileExtension & "") as text |
| 083 | # |
| 084 | set strMsg to ("保存先を指定してください") as text |
| 085 | set strPrompt to ("保存先を指定してください") as text |
| 086 | try |
| 087 | tell application "SystemUIServer" |
| 088 | activate |
| 089 | set aliasSaveFilePath to (choose file name strMsg default location aliasDefaultLocation default name strSaveFileName with prompt strPrompt) as «class furl» |
| 090 | end tell |
| 091 | on error strErrMes number numErrNo |
| 092 | return strErrMes & numErrNo |
| 093 | end try |
| 094 | set strSaveFilePath to (POSIX path of aliasSaveFilePath) as text |
| 095 | set ocidSaveFilePath to refMe's NSString's stringWithString:(strSaveFilePath) |
| 096 | set ocidSaveFilePathURL to refMe's NSURL's fileURLWithPath:(ocidSaveFilePath) |
| 097 | set strFileExtensionName to ocidSaveFilePathURL's pathExtension() as text |
| 098 | #ダイアログで拡張子を取っちゃった時対策 |
| 099 | if strFileExtensionName is not strFileExtension then |
| 100 | set ocidSaveFilePathURL to ocidSaveFilePathURL's URLByAppendingPathExtension:(strFileExtension) |
| 101 | end if |
| 102 | set ocidSaveFilePath to ocidSaveFilePathURL's |path|() |
| 103 | |
| 104 | ############################# |
| 105 | #エスケープ |
| 106 | set strBinPath to doPathEscape(strBinPath) |
| 107 | set ocidSaveFilePath to doPathEscape(ocidSaveFilePath) |
| 108 | #コマンド整形 |
| 109 | set strCmd to ("\\\"" & strBinPath & "\\\" -dynamic -local -showSuccesses -showWarnings " & strPathList & " -report_output \\\"" & ocidSaveFilePath & "\\\"") as text |
| 110 | log (return & strCmd & return) |
| 111 | set strExec to ("/bin/zsh -c \"" & strCmd & "\"") as text |
| 112 | try |
| 113 | set strResponse to (do shell script strExec) as text |
| 114 | on error |
| 115 | log "osascript でエラーしました" |
| 116 | return false |
| 117 | end try |
| 118 | ############################# |
| 119 | # |
| 120 | set ocidJsonFileName to ocidSaveFilePathURL's lastPathComponent() |
| 121 | set ocidJsonFileName to ocidJsonFileName's decomposedStringWithCanonicalMapping() |
| 122 | set ocidJsonBaseFileName to ocidJsonFileName's stringByDeletingPathExtension() |
| 123 | set strPlistFileName to (ocidJsonBaseFileName's stringByAppendingPathExtension:("plist")) as text |
| 124 | set ocidSaveDirPathURL to ocidSaveFilePathURL's URLByDeletingLastPathComponent() |
| 125 | set ocidPlistFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strPlistFileName) isDirectory:(false) |
| 126 | |
| 127 | ############################# |
| 128 | # |
| 129 | set ocidOption to (refMe's NSDataReadingMappedIfSafe) |
| 130 | set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidSaveFilePathURL) options:(ocidOption) |error|:(reference) |
| 131 | if (item 2 of listResponse) = (missing value) then |
| 132 | log "A" |
| 133 | set ocidReadData to (item 1 of listResponse) |
| 134 | else if (item 2 of listResponse) ≠ (missing value) then |
| 135 | set strErrorNO to (item 2 of listResponse)'s code() as text |
| 136 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
| 137 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
| 138 | return "initWithContentsOfURL エラーしました" & strErrorNO & strErrorMes |
| 139 | end if |
| 140 | #JSON ルートがDICT |
| 141 | set ocidOption to (refMe's NSJSONReadingJSON5Allowed) |
| 142 | set listResponse to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidReadData) options:(ocidOption) |error|:(reference)) |
| 143 | if (item 2 of listResponse) = (missing value) then |
| 144 | log "B" |
| 145 | set ocidJsonDict to (item 1 of listResponse) |
| 146 | else if (item 2 of listResponse) ≠ (missing value) then |
| 147 | set strErrorNO to (item 2 of listResponse)'s code() as text |
| 148 | set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text |
| 149 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
| 150 | return "JSONObjectWithData エラーしました" & strErrorNO & strErrorMes |
| 151 | end if |
| 152 | #PLIST2NSDATA(MutableContainersAndLeaves) |
| 153 | set ocidFormat to (refMe's NSPropertyListXMLFormat_v1_0) |
| 154 | set listResponse to refMe's NSPropertyListSerialization's dataWithPropertyList:(ocidJsonDict) format:(ocidFormat) options:0 |error|:(reference) |
| 155 | if (first item of listResponse) is not false then |
| 156 | log "dataWithPropertyList 正常処理" |
| 157 | set ocidPlistData to (first item of listResponse) |
| 158 | else if (second item of listResponse) ≠ (missing value) then |
| 159 | set strErrorNO to (second item of listResponse)'s code() as text |
| 160 | set strErrorMes to (second item of listResponse)'s localizedDescription() as text |
| 161 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
| 162 | return "dataWithPropertyList エラーしました" & strErrorNO & strErrorMes |
| 163 | end if |
| 164 | #NSDATA |
| 165 | set ocidOption to (refMe's NSDataWritingAtomic) |
| 166 | set listDone to ocidPlistData's writeToURL:(ocidPlistFilePathURL) options:(ocidOption) |error|:(reference) |
| 167 | if (item 1 of listDone) is true then |
| 168 | log "writeToURL 正常処理" |
| 169 | else if (second item of listDone) ≠ (missing value) then |
| 170 | set strErrorNO to (second item of listDone)'s code() as text |
| 171 | set strErrorMes to (second item of listDone)'s localizedDescription() as text |
| 172 | refMe's NSLog("■:" & strErrorNO & strErrorMes) |
| 173 | return "writeToURL エラーしました" & strErrorNO & strErrorMes |
| 174 | end if |
| 175 | |
| 176 | ####################################### |
| 177 | ##【1】 HTML 本体ROOT |
| 178 | #XML初期化 |
| 179 | set ocidXMLDoc to refMe's NSXMLDocument's alloc()'s init() |
| 180 | ocidXMLDoc's setDocumentContentKind:(refMe's NSXMLDocumentHTMLKind) |
| 181 | set ocidDTD to refMe's NSXMLDTD's alloc()'s init() |
| 182 | ocidDTD's setName:("html") |
| 183 | ocidXMLDoc's setDTD:(ocidDTD) |
| 184 | set ocidRootElement to refMe's NSXMLElement's elementWithName:("html") |
| 185 | set ocidAddNode to refMe's NSXMLNode's attributeWithName:("lang") stringValue:("ja") |
| 186 | ocidRootElement's addAttribute:(ocidAddNode) |
| 187 | ####################################### |
| 188 | ##【2】head meta部分 |
| 189 | set ocidHeadElement to refMe's NSXMLElement's elementWithName:("head") |
| 190 | # |
| 191 | set ocidAddElement to refMe's NSXMLElement's elementWithName:("title") |
| 192 | ocidAddElement's setStringValue:("FontValidator出力結果") |
| 193 | ocidHeadElement's addChild:(ocidAddElement) |
| 194 | # http-equiv |
| 195 | set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta") |
| 196 | set ocidAddNode to refMe's NSXMLNode's attributeWithName:("http-equiv") stringValue:("Content-Type") |
| 197 | ocidAddElement's addAttribute:(ocidAddNode) |
| 198 | set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("text/html; charset=UTF-8") |
| 199 | ocidAddElement's addAttribute:(ocidAddNode) |
| 200 | ocidHeadElement's addChild:(ocidAddElement) |
| 201 | # |
| 202 | set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta") |
| 203 | set ocidAddNode to refMe's NSXMLNode's attributeWithName:("name") stringValue:("viewport") |
| 204 | ocidAddElement's addAttribute:(ocidAddNode) |
| 205 | set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("width=720") |
| 206 | ocidAddElement's addAttribute:(ocidAddNode) |
| 207 | ocidHeadElement's addChild:(ocidAddElement) |
| 208 | # |
| 209 | set ocidAddElement to refMe's NSXMLElement's elementWithName:("style") |
| 210 | ocidAddElement's setStringValue:("body { margin: 10px; background-color: #FFFFFF; } table { border-spacing: 0; caption-side: top; font-family: system-ui; } thead th { border: solid 1px #666666; padding: .5ch 1ch; border-block-width: 1px 0; border-inline-width: 1px 0; &:first-of-type { border-start-start-radius: .5em } &:last-of-type { border-start-end-radius: .5em; border-inline-end-width: 1px } } tbody td { word-wrap: break-word;max-width: 360px;border-spacing: 0; border: solid 1px #666666; padding: .5ch 1ch; border-block-width: 1px 0; border-inline-width: 1px 0; &:last-of-type { border-inline-end-width: 1px } } tbody th { border-spacing: 0; border: solid 1px #666666; padding: .5ch 1ch; border-block-width: 1px 0; border-inline-width: 1px 0; } tbody tr:nth-of-type(odd) { background: #F2F2F2; } .kind_string { font-size: 0.75em; } .date_string { font-size: 0.5em; } tfoot th { border: solid 1px #666666; padding: .5ch 1ch; &:first-of-type { border-end-start-radius: .5em } &:last-of-type { border-end-end-radius: .5em; border-inline-end-width: 1px } }img{max-width: 96px; max-height: 96px; min-width: 96px; min-height: 96px;}") |
| 211 | # |
| 212 | ocidHeadElement's addChild:(ocidAddElement) |
| 213 | ocidRootElement's addChild:(ocidHeadElement) |
| 214 | ######################################## |
| 215 | ##【3】ボディ body |
| 216 | set ocidBodyElement to refMe's NSXMLElement's elementWithName:("body") |
| 217 | ######################################## |
| 218 | ##【4】ヘッダー header |
| 219 | set ocidHeaderElement to refMe's NSXMLElement's elementWithName:("header") |
| 220 | set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("header") |
| 221 | ocidHeaderElement's addAttribute:(ocidAddNode) |
| 222 | set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_header") |
| 223 | ocidHeaderElement's addAttribute:(ocidAddNode) |
| 224 | # |
| 225 | set ocidH3Element to refMe's NSXMLElement's elementWithName:("h3") |
| 226 | set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("header_h3") |
| 227 | ocidH3Element's addAttribute:(ocidAddNode) |
| 228 | (ocidH3Element's setStringValue:("FontValidator検査結果")) |
| 229 | ocidHeaderElement's addChild:(ocidH3Element) |
| 230 | # |
| 231 | set ocidHrElement to refMe's NSXMLElement's elementWithName:("hr") |
| 232 | ocidHeaderElement's addChild:(ocidHrElement) |
| 233 | ####################################### |
| 234 | ##【5】メインコンテンツ部 article |
| 235 | set ocidArticleElement to refMe's NSXMLElement's elementWithName:("article") |
| 236 | set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("article") |
| 237 | ocidArticleElement's addAttribute:(ocidAddNode) |
| 238 | set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_article") |
| 239 | ocidArticleElement's addAttribute:(ocidAddNode) |
| 240 | ####################################### |
| 241 | ##テーブル生成 |
| 242 | |
| 243 | |
| 244 | #テーブル部生成開始 |
| 245 | set ocidTableElement to refMe's NSXMLElement's elementWithName:("table") |
| 246 | ######【caption】 |
| 247 | set ocidCaptionElement to refMe's NSXMLElement's elementWithName:("caption") |
| 248 | ocidCaptionElement's setStringValue:("システムアイコン一覧") |
| 249 | ocidTableElement's addChild:(ocidCaptionElement) |
| 250 | ######【thead】 |
| 251 | set ocidTheadElement to refMe's NSXMLElement's elementWithName:("thead") |
| 252 | #TR |
| 253 | set ocidTrElement to refMe's NSXMLElement's elementWithName:("tr") |
| 254 | #TH |
| 255 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 256 | ocidAddElement's setStringValue:("NO") |
| 257 | ocidTrElement's addChild:(ocidAddElement) |
| 258 | #TH |
| 259 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 260 | ocidAddElement's setStringValue:("FileName") |
| 261 | ocidTrElement's addChild:(ocidAddElement) |
| 262 | #TH |
| 263 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 264 | ocidAddElement's setStringValue:("FontName") |
| 265 | ocidTrElement's addChild:(ocidAddElement) |
| 266 | #TH |
| 267 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 268 | ocidAddElement's setStringValue:("cmap") |
| 269 | ocidTrElement's addChild:(ocidAddElement) |
| 270 | #TH |
| 271 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 272 | ocidAddElement's setStringValue:("hmtx") |
| 273 | ocidTrElement's addChild:(ocidAddElement) |
| 274 | #TH |
| 275 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 276 | ocidAddElement's setStringValue:("loca") |
| 277 | ocidTrElement's addChild:(ocidAddElement) |
| 278 | #TH |
| 279 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 280 | ocidAddElement's setStringValue:("name-U") |
| 281 | ocidTrElement's addChild:(ocidAddElement) |
| 282 | #TH |
| 283 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 284 | ocidAddElement's setStringValue:("post") |
| 285 | ocidTrElement's addChild:(ocidAddElement) |
| 286 | |
| 287 | #TH |
| 288 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 289 | ocidAddElement's setStringValue:("sfnt") |
| 290 | ocidTrElement's addChild:(ocidAddElement) |
| 291 | #TH |
| 292 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 293 | ocidAddElement's setStringValue:("head") |
| 294 | ocidTrElement's addChild:(ocidAddElement) |
| 295 | #TH |
| 296 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 297 | ocidAddElement's setStringValue:("hhea") |
| 298 | ocidTrElement's addChild:(ocidAddElement) |
| 299 | #TH |
| 300 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 301 | ocidAddElement's setStringValue:("maxp") |
| 302 | ocidTrElement's addChild:(ocidAddElement) |
| 303 | #TH |
| 304 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 305 | ocidAddElement's setStringValue:("name") |
| 306 | ocidTrElement's addChild:(ocidAddElement) |
| 307 | #TH |
| 308 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 309 | ocidAddElement's setStringValue:("glyf") |
| 310 | ocidTrElement's addChild:(ocidAddElement) |
| 311 | #TH |
| 312 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 313 | ocidAddElement's setStringValue:("glyf-I") |
| 314 | ocidTrElement's addChild:(ocidAddElement) |
| 315 | #TH |
| 316 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 317 | ocidAddElement's setStringValue:("kern") |
| 318 | ocidTrElement's addChild:(ocidAddElement) |
| 319 | #TH |
| 320 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 321 | ocidAddElement's setStringValue:("vmtx") |
| 322 | ocidTrElement's addChild:(ocidAddElement) |
| 323 | #TH |
| 324 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 325 | ocidAddElement's setStringValue:("fpgm") |
| 326 | ocidTrElement's addChild:(ocidAddElement) |
| 327 | #TH |
| 328 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 329 | ocidAddElement's setStringValue:("prep") |
| 330 | ocidTrElement's addChild:(ocidAddElement) |
| 331 | |
| 332 | |
| 333 | #TH |
| 334 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 335 | ocidAddElement's setStringValue:("重複") |
| 336 | ocidTrElement's addChild:(ocidAddElement) |
| 337 | #TH |
| 338 | set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 339 | ocidAddElement's setStringValue:("検証") |
| 340 | ocidTrElement's addChild:(ocidAddElement) |
| 341 | #TRをTHEADにセット |
| 342 | ocidTheadElement's addChild:(ocidTrElement) |
| 343 | #THEADをテーブルにセット |
| 344 | ocidTableElement's addChild:(ocidTheadElement) |
| 345 | ######【tbody】 |
| 346 | set ocidTbodyElement to refMe's NSXMLElement's elementWithName:("tbody") |
| 347 | ########################################## |
| 348 | set ocidDetailsArray to ocidJsonDict's objectForKey:("Details") |
| 349 | set numCntLineNo to 0 as integer |
| 350 | repeat with itemDetail in ocidDetailsArray |
| 351 | set numCntLineNo to (numCntLineNo + 1) as integer |
| 352 | set strCntLoneNo to ("000" & numCntLineNo & "") as text |
| 353 | set strCntLoneNo to (text -2 through -1 of strCntLoneNo) as text |
| 354 | ######TR |
| 355 | set ocidTrElement to (refMe's NSXMLElement's elementWithName:("tr")) |
| 356 | # |
| 357 | set ocidValidationDict to (itemDetail's objectForKey:("validation")) |
| 358 | set ocidFontsArray to (ocidValidationDict's objectForKey:("fonts")) |
| 359 | set numCntFonts to ocidFontsArray's |count|() as integer |
| 360 | set strCntFonts to numCntFonts as text |
| 361 | #1:NO |
| 362 | set ocidThElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 363 | set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("rowspan") stringValue:(strCntFonts)) |
| 364 | (ocidThElement's addAttribute:(ocidAddNode)) |
| 365 | (ocidThElement's setStringValue:(strCntLoneNo)) |
| 366 | (ocidTrElement's addChild:(ocidThElement)) |
| 367 | #2:FileName |
| 368 | set ocidFilePathStr to (itemDetail's objectForKey:("path")) |
| 369 | set ocidFilePathStr to ocidFilePathStr's precomposedStringWithCanonicalMapping() |
| 370 | set ocidFilePath to ocidFilePathStr's stringByStandardizingPath() |
| 371 | set ocidFilePath to ocidFilePath's stringByExpandingTildeInPath() |
| 372 | set ocidFilePathURL to (refMe's NSURL's fileURLWithPath:(ocidFilePath) isDirectory:(false)) |
| 373 | set strFilePath to ocidFilePathURL's absoluteString() as text |
| 374 | set ocidFileName to ocidFilePathURL's lastPathComponent() |
| 375 | # |
| 376 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 377 | set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("rowspan") stringValue:(strCntFonts)) |
| 378 | (ocidTdElement's addAttribute:(ocidAddNode)) |
| 379 | set ocidAElement to (refMe's NSXMLElement's elementWithName:("a")) |
| 380 | set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("href") stringValue:(strFilePath)) |
| 381 | (ocidAElement's addAttribute:(ocidAddNode)) |
| 382 | set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("target") stringValue:("_blank")) |
| 383 | (ocidAElement's addAttribute:(ocidAddNode)) |
| 384 | (ocidAElement's setStringValue:(ocidFileName)) |
| 385 | (ocidTdElement's addChild:(ocidAElement)) |
| 386 | (ocidTrElement's addChild:(ocidTdElement)) |
| 387 | ###################### |
| 388 | set numCntRowspan to 0 as integer |
| 389 | repeat with itemFont in ocidFontsArray |
| 390 | set numCntRowspan to numCntRowspan + 1 as integer |
| 391 | if numCntFonts ≥ 2 then |
| 392 | if numCntRowspan ≥ 2 then |
| 393 | set ocidTrElement to (refMe's NSXMLElement's elementWithName:("tr")) |
| 394 | end if |
| 395 | end if |
| 396 | #3:FontName |
| 397 | set ocidFontName to (itemFont's objectForKey:("fontname")) |
| 398 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 399 | (ocidTdElement's setStringValue:(ocidFontName)) |
| 400 | (ocidTrElement's addChild:(ocidTdElement)) |
| 401 | # |
| 402 | set ocidSuccessesArray to (itemFont's objectForKey:("successes")) |
| 403 | set ocidWarningsArray to (itemFont's objectForKey:("warnings")) |
| 404 | set ocidFailuresArray to (itemFont's objectForKey:("failures")) |
| 405 | #4:CMAP |
| 406 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "cmap") |
| 407 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 408 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 409 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 410 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 411 | if numCntSuccesses = 1 then |
| 412 | (ocidTdElement's setStringValue:("✅")) |
| 413 | else if numCntWarnings = 1 then |
| 414 | (ocidTdElement's setStringValue:("⚠️")) |
| 415 | else if numCntFailures = 1 then |
| 416 | (ocidTdElement's setStringValue:("❌")) |
| 417 | end if |
| 418 | (ocidTrElement's addChild:(ocidTdElement)) |
| 419 | #5:hmtx |
| 420 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "hmtx") |
| 421 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 422 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 423 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 424 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 425 | if numCntSuccesses = 1 then |
| 426 | (ocidTdElement's setStringValue:("✅")) |
| 427 | else if numCntWarnings = 1 then |
| 428 | (ocidTdElement's setStringValue:("⚠️")) |
| 429 | else if numCntFailures = 1 then |
| 430 | (ocidTdElement's setStringValue:("❌")) |
| 431 | end if |
| 432 | (ocidTrElement's addChild:(ocidTdElement)) |
| 433 | |
| 434 | #5:loca |
| 435 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "loca") |
| 436 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 437 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 438 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 439 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 440 | if numCntSuccesses = 1 then |
| 441 | (ocidTdElement's setStringValue:("✅")) |
| 442 | else if numCntWarnings = 1 then |
| 443 | (ocidTdElement's setStringValue:("⚠️")) |
| 444 | else if numCntFailures = 1 then |
| 445 | (ocidTdElement's setStringValue:("❌")) |
| 446 | end if |
| 447 | (ocidTrElement's addChild:(ocidTdElement)) |
| 448 | |
| 449 | #6:name |
| 450 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@ AND SELF CONTAINS %@", "name", "使用") |
| 451 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 452 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 453 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 454 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 455 | if numCntSuccesses = 1 then |
| 456 | (ocidTdElement's setStringValue:("✅")) |
| 457 | else if numCntWarnings = 1 then |
| 458 | (ocidTdElement's setStringValue:("⚠️")) |
| 459 | else if numCntFailures = 1 then |
| 460 | (ocidTdElement's setStringValue:("❌")) |
| 461 | end if |
| 462 | (ocidTrElement's addChild:(ocidTdElement)) |
| 463 | |
| 464 | #7:post |
| 465 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "post") |
| 466 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 467 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 468 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 469 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 470 | if numCntSuccesses = 1 then |
| 471 | (ocidTdElement's setStringValue:("✅")) |
| 472 | else if numCntWarnings = 1 then |
| 473 | (ocidTdElement's setStringValue:("⚠️")) |
| 474 | else if numCntFailures = 1 then |
| 475 | (ocidTdElement's setStringValue:("❌")) |
| 476 | end if |
| 477 | (ocidTrElement's addChild:(ocidTdElement)) |
| 478 | |
| 479 | |
| 480 | #8:sfnt |
| 481 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "sfnt") |
| 482 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 483 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 484 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 485 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 486 | if numCntSuccesses = 1 then |
| 487 | (ocidTdElement's setStringValue:("✅")) |
| 488 | else if numCntWarnings = 1 then |
| 489 | (ocidTdElement's setStringValue:("⚠️")) |
| 490 | else if numCntFailures = 1 then |
| 491 | (ocidTdElement's setStringValue:("❌")) |
| 492 | end if |
| 493 | (ocidTrElement's addChild:(ocidTdElement)) |
| 494 | |
| 495 | |
| 496 | |
| 497 | #9:head |
| 498 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "head") |
| 499 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 500 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 501 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 502 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 503 | if numCntSuccesses = 1 then |
| 504 | (ocidTdElement's setStringValue:("✅")) |
| 505 | else if numCntWarnings = 1 then |
| 506 | (ocidTdElement's setStringValue:("⚠️")) |
| 507 | else if numCntFailures = 1 then |
| 508 | (ocidTdElement's setStringValue:("❌")) |
| 509 | end if |
| 510 | (ocidTrElement's addChild:(ocidTdElement)) |
| 511 | |
| 512 | #10:hhea |
| 513 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "hhea") |
| 514 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 515 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 516 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 517 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 518 | if numCntSuccesses = 1 then |
| 519 | (ocidTdElement's setStringValue:("✅")) |
| 520 | else if numCntWarnings = 1 then |
| 521 | (ocidTdElement's setStringValue:("⚠️")) |
| 522 | else if numCntFailures = 1 then |
| 523 | (ocidTdElement's setStringValue:("❌")) |
| 524 | end if |
| 525 | (ocidTrElement's addChild:(ocidTdElement)) |
| 526 | |
| 527 | #11:maxp |
| 528 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "maxp") |
| 529 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 530 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 531 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 532 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 533 | if numCntSuccesses = 1 then |
| 534 | (ocidTdElement's setStringValue:("✅")) |
| 535 | else if numCntWarnings = 1 then |
| 536 | (ocidTdElement's setStringValue:("⚠️")) |
| 537 | else if numCntFailures = 1 then |
| 538 | (ocidTdElement's setStringValue:("❌")) |
| 539 | end if |
| 540 | (ocidTrElement's addChild:(ocidTdElement)) |
| 541 | |
| 542 | |
| 543 | #12:name |
| 544 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@ AND SELF CONTAINS %@", "name", "構造") |
| 545 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 546 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 547 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 548 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 549 | if numCntSuccesses = 1 then |
| 550 | (ocidTdElement's setStringValue:("✅")) |
| 551 | else if numCntWarnings = 1 then |
| 552 | (ocidTdElement's setStringValue:("⚠️")) |
| 553 | else if numCntFailures = 1 then |
| 554 | (ocidTdElement's setStringValue:("❌")) |
| 555 | end if |
| 556 | (ocidTrElement's addChild:(ocidTdElement)) |
| 557 | |
| 558 | |
| 559 | #13:glyf |
| 560 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@ AND SELF CONTAINS %@", "glyf", "構造") |
| 561 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 562 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 563 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 564 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 565 | if numCntSuccesses = 1 then |
| 566 | (ocidTdElement's setStringValue:("✅")) |
| 567 | else if numCntWarnings = 1 then |
| 568 | (ocidTdElement's setStringValue:("⚠️")) |
| 569 | else if numCntFailures = 1 then |
| 570 | (ocidTdElement's setStringValue:("❌")) |
| 571 | end if |
| 572 | (ocidTrElement's addChild:(ocidTdElement)) |
| 573 | |
| 574 | #14:glyf |
| 575 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@ AND SELF CONTAINS %@", "glyf", "イン") |
| 576 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 577 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 578 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 579 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 580 | if numCntSuccesses = 1 then |
| 581 | (ocidTdElement's setStringValue:("✅")) |
| 582 | else if numCntWarnings = 1 then |
| 583 | (ocidTdElement's setStringValue:("⚠️")) |
| 584 | else if numCntFailures = 1 then |
| 585 | (ocidTdElement's setStringValue:("❌")) |
| 586 | end if |
| 587 | (ocidTrElement's addChild:(ocidTdElement)) |
| 588 | |
| 589 | |
| 590 | |
| 591 | #15:kern |
| 592 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "kern") |
| 593 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 594 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 595 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 596 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 597 | if numCntSuccesses = 1 then |
| 598 | (ocidTdElement's setStringValue:("✅")) |
| 599 | else if numCntWarnings = 1 then |
| 600 | (ocidTdElement's setStringValue:("⚠️")) |
| 601 | else if numCntFailures = 1 then |
| 602 | (ocidTdElement's setStringValue:("❌")) |
| 603 | end if |
| 604 | (ocidTrElement's addChild:(ocidTdElement)) |
| 605 | |
| 606 | #16:kern |
| 607 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "vmtx") |
| 608 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 609 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 610 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 611 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 612 | if numCntSuccesses = 1 then |
| 613 | (ocidTdElement's setStringValue:("✅")) |
| 614 | else if numCntWarnings = 1 then |
| 615 | (ocidTdElement's setStringValue:("⚠️")) |
| 616 | else if numCntFailures = 1 then |
| 617 | (ocidTdElement's setStringValue:("❌")) |
| 618 | end if |
| 619 | (ocidTrElement's addChild:(ocidTdElement)) |
| 620 | |
| 621 | #17:fpgm |
| 622 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "fpgm") |
| 623 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 624 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 625 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 626 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 627 | if numCntSuccesses = 1 then |
| 628 | (ocidTdElement's setStringValue:("✅")) |
| 629 | else if numCntWarnings = 1 then |
| 630 | (ocidTdElement's setStringValue:("⚠️")) |
| 631 | else if numCntFailures = 1 then |
| 632 | (ocidTdElement's setStringValue:("❌")) |
| 633 | end if |
| 634 | (ocidTrElement's addChild:(ocidTdElement)) |
| 635 | |
| 636 | |
| 637 | #18:kern |
| 638 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "prep") |
| 639 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 640 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 641 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 642 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 643 | if numCntSuccesses = 1 then |
| 644 | (ocidTdElement's setStringValue:("✅")) |
| 645 | else if numCntWarnings = 1 then |
| 646 | (ocidTdElement's setStringValue:("⚠️")) |
| 647 | else if numCntFailures = 1 then |
| 648 | (ocidTdElement's setStringValue:("❌")) |
| 649 | end if |
| 650 | (ocidTrElement's addChild:(ocidTdElement)) |
| 651 | |
| 652 | |
| 653 | #19:重複 |
| 654 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "重複") |
| 655 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 656 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 657 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 658 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 659 | if numCntSuccesses = 1 then |
| 660 | (ocidTdElement's setStringValue:("✅")) |
| 661 | else if numCntWarnings = 1 then |
| 662 | (ocidTdElement's setStringValue:("⚠️")) |
| 663 | else if numCntFailures = 1 then |
| 664 | (ocidTdElement's setStringValue:("❌")) |
| 665 | end if |
| 666 | (ocidTrElement's addChild:(ocidTdElement)) |
| 667 | |
| 668 | |
| 669 | |
| 670 | #20:検証 |
| 671 | set appPredicate to refMe's NSPredicate's predicateWithFormat_("SELF CONTAINS %@", "検証") |
| 672 | set numCntSuccesses to (ocidSuccessesArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 673 | set numCntWarnings to (ocidWarningsArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 674 | set numCntFailures to (ocidFailuresArray's filteredArrayUsingPredicate:(appPredicate))'s |count|() |
| 675 | set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td")) |
| 676 | if numCntSuccesses = 1 then |
| 677 | (ocidTdElement's setStringValue:("✅")) |
| 678 | else if numCntWarnings = 1 then |
| 679 | (ocidTdElement's setStringValue:("⚠️")) |
| 680 | else if numCntFailures = 1 then |
| 681 | (ocidTdElement's setStringValue:("❌")) |
| 682 | end if |
| 683 | (ocidTrElement's addChild:(ocidTdElement)) |
| 684 | |
| 685 | |
| 686 | (ocidTbodyElement's addChild:(ocidTrElement)) |
| 687 | |
| 688 | |
| 689 | end repeat |
| 690 | |
| 691 | if numCntRowspan = 1 then |
| 692 | # (ocidTbodyElement's addChild:(ocidTrElement)) |
| 693 | end if |
| 694 | ###################### |
| 695 | |
| 696 | end repeat |
| 697 | |
| 698 | ########################################## |
| 699 | #TBODYをテーブルにセット |
| 700 | ocidTableElement's addChild:(ocidTbodyElement) |
| 701 | ######【tfoot】 TRで |
| 702 | set ocidTfootElement to refMe's NSXMLElement's elementWithName:("tfoot") |
| 703 | set ocidTrElement to refMe's NSXMLElement's elementWithName:("tr") |
| 704 | #colspan指定して1行でセット |
| 705 | set ocidThElement to (refMe's NSXMLElement's elementWithName:("th")) |
| 706 | set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("colspan") stringValue:("21")) |
| 707 | (ocidThElement's addAttribute:(ocidAddNode)) |
| 708 | (ocidThElement's setStringValue:("name-U: テーブルの使用性, glyf-I: テーブルのインストラクション")) |
| 709 | #THをTRにセットして |
| 710 | ocidTrElement's addChild:(ocidThElement) |
| 711 | #TRをTFOOTにセット |
| 712 | ocidTfootElement's addChild:(ocidTrElement) |
| 713 | #TFOOTをテーブルにセット |
| 714 | ocidTableElement's addChild:(ocidTfootElement) |
| 715 | #テーブルをアーティクルにセット |
| 716 | ocidArticleElement's addChild:(ocidTableElement) |
| 717 | ######################################## |
| 718 | ##【6】フッター footer |
| 719 | set ocidFooterElement to refMe's NSXMLElement's elementWithName:("footer") |
| 720 | set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("footer") |
| 721 | ocidFooterElement's addAttribute:(ocidAddNode) |
| 722 | set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_footer") |
| 723 | ocidFooterElement's addAttribute:(ocidAddNode) |
| 724 | # |
| 725 | set ocidPElement to refMe's NSXMLElement's elementWithName:("p") |
| 726 | set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("header_p") |
| 727 | ocidPElement's addAttribute:(ocidAddNode) |
| 728 | # |
| 729 | set ocidAElement to refMe's NSXMLElement's elementWithName:("a") |
| 730 | set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("href") stringValue:("https://note.com/search?context=note&q=from%3A%40quicktimer%20&sort=new")) |
| 731 | (ocidAElement's addAttribute:(ocidAddNode)) |
| 732 | set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("target") stringValue:("_blank")) |
| 733 | (ocidAElement's addAttribute:(ocidAddNode)) |
| 734 | set strContents to ("AppleScriptで生成しました") as text |
| 735 | (ocidAElement's setStringValue:(strContents)) |
| 736 | ocidPElement's addChild:(ocidAElement) |
| 737 | ocidFooterElement's addChild:(ocidPElement) |
| 738 | |
| 739 | ######################################## |
| 740 | ##【7】header article footerをbodyに追加 |
| 741 | ocidBodyElement's addChild:(ocidHeaderElement) |
| 742 | ocidBodyElement's addChild:(ocidArticleElement) |
| 743 | ocidBodyElement's addChild:(ocidFooterElement) |
| 744 | |
| 745 | ######################################## |
| 746 | ##【8】body をROOTに追加 |
| 747 | ocidRootElement's addChild:(ocidBodyElement) |
| 748 | |
| 749 | ######################################## |
| 750 | ##【9】ROOTをXMLセットしてXMLとしては完成 |
| 751 | ocidXMLDoc's setRootElement:(ocidRootElement) |
| 752 | |
| 753 | ######################################## |
| 754 | ##【10】保存 |
| 755 | set strHTMLFileName to (ocidJsonBaseFileName's stringByAppendingPathExtension:("html")) as text |
| 756 | set ocidHTMLFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strHTMLFileName) isDirectory:(false) |
| 757 | |
| 758 | #読み取りやすい表示 |
| 759 | set ocidXMLdata to ocidXMLDoc's XMLDataWithOptions:(refMe's NSXMLNodePrettyPrint) |
| 760 | set listDone to ocidXMLdata's writeToURL:(ocidHTMLFilePathURL) options:(refMe's NSDataWritingAtomic) |error|:(reference) |
| 761 | if (item 2 of listDone) = (missing value) then |
| 762 | log "保存しました" |
| 763 | else if (item 1 of listDone) is false then |
| 764 | log (item 2 of listDone)'s localizedFailureReason() as text |
| 765 | return "保存に失敗しました" |
| 766 | end if |
| 767 | |
| 768 | |
| 769 | |
| 770 | |
| 771 | return strResponse |
| 772 | |
| 773 | |
| 774 | |
| 775 | ######################## |
| 776 | #パスのエスケープ |
| 777 | to doPathEscape(strFilePath) |
| 778 | set strFilePath to strFilePath as text |
| 779 | set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath) |
| 780 | set ocidFilePath to ocidFilePathStr's stringByStandardizingPath() |
| 781 | set ocidFilePathURL to refMe's NSURL's fileURLWithPath:(ocidFilePath) isDirectory:(false) |
| 782 | set listEscChar to {"\\", "\"", "$", "`"} as list |
| 783 | repeat with itemEscChar in listEscChar |
| 784 | set ocidFilePath to (ocidFilePath's stringByReplacingOccurrencesOfString:(itemEscChar) withString:("\\\\\\" & itemEscChar & "")) |
| 785 | end repeat |
| 786 | set ocidFilePath to (ocidFilePath's stringByReplacingOccurrencesOfString:("!") withString:("\\\"'!'\\\"")) |
| 787 | |
| 788 | return ocidFilePath |
| 789 | end doPathEscape |
| 790 | |
| 791 | |
| AppleScriptで生成しました | |
