--web共有で.css、.js、.html/htmファイルのヘッダを強制的に「text/css」「text/javascript」「text/html」として送り出すスクリプト。 --web共有の「アクション」に「拡張子で開く」で登録して使う。 --MIME設定からはcss、js、html、htmを削除しておく必要がある。 --ver1.01 2005/12/15 html/htmもサポート。どちらも「text/html」として出力する。これはiCab対策。 --ver1.0 2005/10/5 最初のバージョン property crlf : (ASCII character 13) & (ASCII character 10) property head200css : "HTTP/1.1 200 OK" & crlf & "Content-Type: text/css" & crlf & crlf property head200js : "HTTP/1.0 200 OK" & crlf & "Content-Type: text/javascript" & crlf & crlf property head200html : "HTTP/1.0 200 OK" & crlf & "Content-Type: text/html" & crlf & crlf property rootDir : "" on run --- 起動時に、rootDir に Web のルートのパスを収める set rootDir to (":" as alias) as string end run on handle CGI request myPathArg executing by myPath -- リクエストされたcss(myPath)をファイルのパス(myCss)に変換 set myCss to my barasu(myPath, "/", 1) --/で分解 set myCss to my barasu(myCss, ":", 0) --:でつなぐ(置換する) set cssPath to rootDir & myCss --このままだと例えば HD_name:web_page::aaa.css などとなって::が重なってしまう。 set cssPath to my barasu(cssPath, "::", 1) --::で分解 set cssPath to my barasu(cssPath, ":", 0) --:でつなぐ(置換する) try --- ファイルを読み込む set myData to my readFile(cssPath) set suffix to my barasu(cssPath, ".", 1) --.で分解 if item -1 of suffix = "css" then --最期の項目がcssなら return head200css & myData else if item -1 of suffix = "js" then --最期の項目がjsなら return head200js & myData else --html/htmのはず return head200html & myData end if end if on error --たぶんファイルがなかった。なにもせずにサーバの処理に任せる return "" end try end handle CGI request on barasu(myText, newDel, bORt) --1は分解それ以外はつなぐ set oldDel to AppleScript's text item delimiters --デリミタを保存しておく set AppleScript's text item delimiters to newDel --渡されたデリミタにする if bORt = 1 then set myText to every text item of myText --1なら分解 else set myText to myText as string --それ以外はつなぐ end if set AppleScript's text item delimiters to oldDel --デリミタを元に戻す return myText end barasu --ファイルを読み込む on readFile(filePath) --該当ファイルを読み込む set filePath to filePath as string open for access file filePath --with write permission --ファイルを開く set txtData to read file filePath --ファイルを読む close access file filePath --ファイルを閉じる return txtData end readFile