|
From: creedon <icr...@us...> - 2006-02-10 03:20:23
|
Update of /cvsroot/frontierkernel/odbs/mainResponderRoot/mainResponder/discuss In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1264 Modified Files: postAttachedFile Log Message: add file name to attachment url store attachments in site name folder Index: postAttachedFile =================================================================== RCS file: /cvsroot/frontierkernel/odbs/mainResponderRoot/mainResponder/discuss/postAttachedFile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** postAttachedFile 9 Feb 2006 02:52:18 -0000 1.2 --- postAttachedFile 10 Feb 2006 03:20:14 -0000 1.3 *************** *** 1,3 **** FrontierVcsFile:1:scpt:mainResponder.discuss.postAttachedFile ! on postAttachedFile (adrFileArgs, msgNum, memberGroup) { ÇChanges Ç1/15/06; 1:36:47 PM by TAC Çcategorize images and attachements in alsoListedIn Çstore information about the file in an attachement table, we don't care what kind of file it is Ç7/26/03; 4:04:15 PM by TAC Çadded PNG support Ç03/15/00; 5:26:21 PM by PBS ÇWhen computing the path to the attachments folder for this message, it now calls mainResponder.discuss.getMessageAttachmentsFolder -- a new bottleneck script. Ç1999 Ç10/20/99; 12:16:56 PM by PBS ÇIf an image is attached, store it in the dg in an image subtable. ÇOnly do so if flDiscussStoreImages is true, otherwise write even images to disk. Ç10/15/99; 1:13:09 AM by PBS ÇAdded support for addresses, and strings that can be coerced to addresses, in discuss.root. Ç5/20/99; 8:39:55 AM by AR ÇFirst implementation. Based on screenshotsSite.postCatcher in screenshots.root. ÇStore an attached file, either on disk or inside the discussion group. bundle { //error checking if not defined (adrFileArgs^.filename) { return (false)}; if not defined (adrFileArgs^.data) { return (false)}; if string.length (adrFileArgs^.filename) == 0 { return (false)}; if string.length (adrFileArgs^.data) == 0 { return (false)}}; local (pta = html.getPageTableAddress ()); local (adrMsg = mainResponder.discuss.getMessageTable (msgNum)); local (adrAttachment = @adrMsg^.attachment); local (flStoredInDg = false, f, newAlsoListedIn, oldAlsoListedIn = ""); if defined (adrAttachment^.mimeType) { // old also listed in case string.lower (adrAttachment^.mimeType) { // is it a GIF, JPEG, or PNG? "image/gif"; "image/jpeg"; "image/pjpeg"; "image/png" { oldAlsoListedIn = "images"}} else { oldAlsoListedIn = "attachments"}}; bundle { // set up attachment storage if not defined (adrAttachment^) { new (tableType, adrAttachment)}; try { adrAttachment^.mimeType = adrFileArgs^.["Content-type"]}; adrAttachment^.originalFileName = adrFileArgs^.filename; adrAttachment^.sizeBytes = sizeOf (adrFileArgs^.data)}; if defined (pta^.responderAttributes.flDiscussStoreImages) { // possibly store an image attachment in the dg, not to disk if pta^.responderAttributes.flDiscussStoreImages { if defined (adrAttachment^.mimeType) { local (mimeType = adrAttachment^.mimeType); local (flGif = false, flJpeg = false, flPng = false); case string.lower (mimeType) { // is it a GIF, JPEG, or PNG? "image/gif" { flGif = true}; "image/jpeg"; "image/pjpeg" { flJpeg = true}; "image/png" { flPng = true}}; if flGif or flJpeg or flPng { // store GIFs, JPEGs, or PNGs in the dg local (hwList); adrAttachment^.data = binary (adrFileArgs^.data); if flGif { hwList = html.getGifHeightWidth (@adrAttachment^.data); setBinaryType (@adrAttachment^.data, 'GIFf')}; if flJpeg { hwList = html.getJpegHeightWidth (@adrAttachment^.data); setBinaryType (@adrAttachment^.data, 'JPEG')}; if flPng { hwList = html.getPngHeightWidth (@adrAttachment^.data); setBinaryType (@adrAttachment^.data, 'PNGf')}; adrAttachment^.height = hwList [1]; adrAttachment^.width = hwList [2]; newAlsoListedIn = "images"; flStoredInDg = true}}}}; if not flStoredInDg { //write to disk local (folderPath, s = adrFileArgs^.filename, i, ch); local (pc = file.getPathChar ()); bundle { //compute folderPath folderPath = mainResponder.discuss.getMessageAttachmentsFolder (adrMsg, @adrAttachment^.url); ÇPBS 03/15/00: old code, now factored out Çlocal (adrDiscuss = mainResponder.discuss.openRoot ()) Çlocal (dgName = nameOf (adrDiscuss^)) Çtry //PBS 10/15/99: get the real name of the dg (it might be an address in discuss.root) Çlocal (adr = @[system.temp.mainResponder.discussRootFile]) Çif defined (adr^.[pta^.discussionRoot]) ÇdgName = nameOf (adr^.[pta^.discussionRoot]) Çlocal (discussionFolderName = nameOf (adrDiscuss^)) //PBS 10/15/99 Çif discussionFolderName beginsWith "#" ÇdiscussionFolderName = string.popLeading (discussionFolderName, '#') Çon add (s) //append sub-folders to folderpath ÇfolderPath = folderPath + s + pc ÇfolderPath = adrDiscuss^.prefs.binaryServerFolder Çadd (memberGroup) Çadd (adrMsg^.member) Çadd (dgName) Çadd (msgNum)};}; for i = sizeOf (s) downTo 1 { //pop off everything but the file name ch = s [i]; if not (string.isAlpha (ch) or string.isNumeric (ch) or (ch == ".") or (ch == " ")) { s = string.delete (s, 1, i); break}}; adrAttachment^.fileName = s; f = folderPath + adrAttachment^.fileName; adrAttachment^.f = f; file.sureFilePath (f); file.writeWholeFile (f, adrFileArgs^.data); newAlsoListedIn = "attachments"}; bundle { // also listed in if not (defined (adrMsg^.alsoListedIn)) { adrMsg^.alsoListedIn = {}}; adrMsg^.alsoListedIn = adrMsg^.alsoListedIn - {oldAlsoListedIn}; adrMsg^.alsoListedIn = adrMsg^.alsoListedIn + {newAlsoListedIn}}; return (f)} \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:mainResponder.discuss.postAttachedFile ! on postAttachedFile (adrFileArgs, msgNum, memberGroup) { ÇChanges Ç2/9/06; 5:56:03 PM by TAC Çadd file name to attachment url Çstore attachments in site name folder Ç1/15/06; 1:36:47 PM by TAC Çcategorize images and attachements in alsoListedIn Çstore information about the file in an attachement table, we don't care what kind of file it is Ç7/26/03; 4:04:15 PM by TAC Çadded PNG support Ç03/15/00; 5:26:21 PM by PBS ÇWhen computing the path to the attachments folder for this message, it now calls mainResponder.discuss.getMessageAttachmentsFolder -- a new bottleneck script. Ç1999 Ç10/20/99; 12:16:56 PM by PBS ÇIf an image is attached, store it in the dg in an image subtable. ÇOnly do so if flDiscussStoreImages is true, otherwise write even images to disk. Ç10/15/99; 1:13:09 AM by PBS ÇAdded support for addresses, and strings that can be coerced to addresses, in discuss.root. Ç5/20/99; 8:39:55 AM by AR ÇFirst implementation. Based on screenshotsSite.postCatcher in screenshots.root. ÇStore an attached file, either on disk or inside the discussion group. bundle { //error checking if not defined (adrFileArgs^.filename) { return (false)}; if not defined (adrFileArgs^.data) { return (false)}; if string.length (adrFileArgs^.filename) == 0 { return (false)}; if string.length (adrFileArgs^.data) == 0 { return (false)}}; local (pta = html.getPageTableAddress ()); local (adrMsg = mainResponder.discuss.getMessageTable (msgNum)); local (adrAttachment = @adrMsg^.attachment); local (flStoredInDg = false, f, newAlsoListedIn, oldAlsoListedIn = ""); if defined (adrAttachment^.mimeType) { // old also listed in case string.lower (adrAttachment^.mimeType) { // is it a GIF, JPEG, or PNG? "image/gif"; "image/jpeg"; "image/pjpeg"; "image/png" { oldAlsoListedIn = "images"}} else { oldAlsoListedIn = "attachments"}}; bundle { // set up attachment storage if not defined (adrAttachment^) { new (tableType, adrAttachment)}; try { adrAttachment^.mimeType = adrFileArgs^.["Content-type"]}; adrAttachment^.originalFileName = adrFileArgs^.filename; adrAttachment^.sizeBytes = sizeOf (adrFileArgs^.data)}; if defined (pta^.responderAttributes.flDiscussStoreImages) { // possibly store an image attachment in the dg, not to disk if pta^.responderAttributes.flDiscussStoreImages { if defined (adrAttachment^.mimeType) { local (mimeType = adrAttachment^.mimeType); local (flGif = false, flJpeg = false, flPng = false); case string.lower (mimeType) { // is it a GIF, JPEG, or PNG? "image/gif" { flGif = true}; "image/jpeg"; "image/pjpeg" { flJpeg = true}; "image/png" { flPng = true}}; if flGif or flJpeg or flPng { // store GIFs, JPEGs, or PNGs in the dg local (hwList); adrAttachment^.data = binary (adrFileArgs^.data); if flGif { hwList = html.getGifHeightWidth (@adrAttachment^.data); setBinaryType (@adrAttachment^.data, 'GIFf')}; if flJpeg { hwList = html.getJpegHeightWidth (@adrAttachment^.data); setBinaryType (@adrAttachment^.data, 'JPEG')}; if flPng { hwList = html.getPngHeightWidth (@adrAttachment^.data); setBinaryType (@adrAttachment^.data, 'PNGf')}; adrAttachment^.height = hwList [1]; adrAttachment^.width = hwList [2]; newAlsoListedIn = "images"; flStoredInDg = true}}}}; if not flStoredInDg { //write to disk local (folderPath, s = adrFileArgs^.filename, i, ch); local (pc = file.getPathChar ()); bundle { //compute folderPath folderPath = mainResponder.discuss.getMessageAttachmentsFolder (adrMsg, @adrAttachment^.url, pta, true); }; ÇPBS 03/15/00: old code, now factored out Çlocal (adrDiscuss = mainResponder.discuss.openRoot ()) Çlocal (dgName = nameOf (adrDiscuss^)) Çtry //PBS 10/15/99: get the real name of the dg (it might be an address in discuss.root) Çlocal (adr = @[system.temp.mainResponder.discussRootFile]) Çif defined (adr^.[pta^.discussionRoot]) ÇdgName = nameOf (adr^.[pta^.discussionRoot]) Çlocal (discussionFolderName = nameOf (adrDiscuss^)) //PBS 10/15/99 Çif discussionFolderName beginsWith "#" ÇdiscussionFolderName = string.popLeading (discussionFolderName, '#') Çon add (s) //append sub-folders to folderpath ÇfolderPath = folderPath + s + pc ÇfolderPath = adrDiscuss^.prefs.binaryServerFolder Çadd (memberGroup) Çadd (adrMsg^.member) Çadd (dgName) Çadd (msgNum)}; for i = sizeOf (s) downTo 1 { //pop off everything but the file name ch = s [i]; if not (string.isAlpha (ch) or string.isNumeric (ch) or (ch == ".") or (ch == " ")) { s = string.delete (s, 1, i); break}}; adrAttachment^.fileName = s; f = folderPath + s; adrAttachment^.f = f; file.sureFilePath (f); file.writeWholeFile (f, adrFileArgs^.data); newAlsoListedIn = "attachments"; adrAttachment^.url = adrAttachment^.url + s}; bundle { // also listed in if not (defined (adrMsg^.alsoListedIn)) { adrMsg^.alsoListedIn = {}}; adrMsg^.alsoListedIn = adrMsg^.alsoListedIn - {oldAlsoListedIn}; adrMsg^.alsoListedIn = adrMsg^.alsoListedIn + {newAlsoListedIn}}; return (f)} \ No newline at end of file |