author | Claus Gittinger <cg@exept.de> |
Sat, 13 Dec 2008 11:39:21 +0100 | |
changeset 2583 | c33208757c6f |
parent 2582 | 298203fdb64d |
child 2588 | b833c2b7a356 |
permissions | -rw-r--r-- |
643 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
1612 | 3 |
All Rights Reserved |
643 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1410 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
643 | 14 |
Object subclass:#MIMETypes |
1612 | 15 |
instanceVariableNames:'' |
1729 | 16 |
classVariableNames:'TypeToImageReaderClassMapping TypeToCommentStringMapping |
1979
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
17 |
TypeToFileSuffixMapping TypeToViewerApplicationMapping |
1729 | 18 |
SuffixToCommentStringMapping FileSuffixToTypeMapping |
1979
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
19 |
FilenameToTypeMapping FileSuffixToImageReaderClassMapping |
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
20 |
CharSetToFontMapping LastSuffix LastType |
2298 | 21 |
DefaultCommandPerMIMEPerOS DefaultPrintCommandPerMIMEPerOS |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
22 |
TypeToParenthesisSpecMapping SuffixToParenthesisSpecMapping' |
1612 | 23 |
poolDictionaries:'' |
1800 | 24 |
category:'Net-Communication-Support' |
1612 | 25 |
! |
26 |
||
27 |
String variableByteSubclass:#MIMEType |
|
28 |
instanceVariableNames:'' |
|
29 |
classVariableNames:'CachedTypes' |
|
30 |
poolDictionaries:'' |
|
31 |
privateIn:MIMETypes |
|
643 | 32 |
! |
33 |
||
34 |
!MIMETypes class methodsFor:'documentation'! |
|
35 |
||
36 |
copyright |
|
37 |
" |
|
38 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
1612 | 39 |
All Rights Reserved |
643 | 40 |
|
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
||
48 |
||
49 |
" |
|
50 |
! |
|
51 |
||
52 |
documentation |
|
53 |
" |
|
54 |
just a place to keep MIME information |
|
55 |
(avoid spreading things at many places) |
|
56 |
||
1021 | 57 |
MIMETypes is abstract and functional. |
58 |
Actually, in some OperatingSystems, this information may |
|
59 |
be found in some config files (or registries). |
|
60 |
Therefore, this class may have to be extended to support this |
|
61 |
and fetch the information from there eventually. |
|
62 |
||
643 | 63 |
[author:] |
64 |
Claus Gittinger |
|
65 |
" |
|
1311 | 66 |
! |
67 |
||
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
68 |
examples |
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
69 |
" |
2487
eaa224da42fa
mimeType: x-expecco-testsuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2486
diff
changeset
|
70 |
MIMETypes mimeTypeFromString:'application/x-expecco-testsuite' |
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
71 |
|
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
72 |
MIMETypes mimeTypeForSuffix:'gif' |
2487
eaa224da42fa
mimeType: x-expecco-testsuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2486
diff
changeset
|
73 |
MIMETypes mimeTypeForSuffix:'ets' |
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
74 |
" |
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
75 |
! |
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
76 |
|
1311 | 77 |
knownTypes |
78 |
" |
|
79 |
simply a reminder for me ... |
|
80 |
||
81 |
application mime file extentsions |
|
82 |
||
83 |
powerpoint application/ms-powerpoint .pot, .ppz, .ppt, .pps, |
|
84 |
application/mspowerpoint |
|
85 |
application/vnd.ms-powerpoint |
|
86 |
application/x-mspowerpoint |
|
87 |
||
1312 | 88 |
shockwave application/x-shockwave-flash .swf |
1311 | 89 |
|
1312 | 90 |
futuresplash application/futuresplash .spl |
1311 | 91 |
" |
643 | 92 |
! ! |
93 |
||
94 |
!MIMETypes class methodsFor:'initialization'! |
|
95 |
||
1729 | 96 |
initialize |
97 |
"initialize wellKnown facts" |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
98 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
99 |
MIMEType initialize. "must be initialized first" |
1729 | 100 |
LastSuffix := LastType := nil. |
101 |
self initializeFileNameToMimeTypeMapping. |
|
102 |
self initializeImageReaderMappings. |
|
103 |
self initializeCommentStringMappings. |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
104 |
self initializeParenthesisSpecMappings. |
1729 | 105 |
|
106 |
" |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
107 |
self initialize" |
2298 | 108 |
"Modified: / 10-04-2007 / 15:16:44 / cg" |
1729 | 109 |
! |
110 |
||
111 |
initializeCommentStringMappings |
|
112 |
TypeToCommentStringMapping := Dictionary new. |
|
113 |
SuffixToCommentStringMapping := Dictionary new. |
|
114 |
||
115 |
TypeToCommentStringMapping |
|
116 |
at:'application/x-make' |
|
117 |
put:#('#' (nil nil)). "/ '#' for EOL comments only |
|
118 |
||
119 |
TypeToCommentStringMapping |
|
120 |
at:'application/x-sh' |
|
121 |
put:#('#' (nil nil)). "/ '#' for EOL comments only |
|
122 |
||
2489
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
123 |
#('text/html' 'text/xml' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
124 |
'application/xml' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
125 |
'application/x-expecco-testsuite' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
126 |
'application/x-expecco-logfile' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
127 |
) |
1729 | 128 |
do:[:eachXMLType | |
129 |
TypeToCommentStringMapping |
|
130 |
at:eachXMLType |
|
131 |
put:#(nil ('<!!-- ' ' -->')). "/ '<!!-- ... -->' delimited comments only |
|
132 |
]. |
|
133 |
||
134 |
TypeToCommentStringMapping |
|
2055 | 135 |
at:'text/css' |
136 |
put:#('//' ('/*' '*/')). |
|
137 |
||
138 |
TypeToCommentStringMapping |
|
1729 | 139 |
at:'application/x-batch-script' |
140 |
put:#('rem ' (nil nil)). "/ 'rem ' for EOL comments only |
|
141 |
||
142 |
"/ the following is ST/X specific |
|
143 |
TypeToCommentStringMapping |
|
144 |
at:'application/x-smalltalk-source' |
|
145 |
put:#('"/' ('"' '"')). "/ '"/ ' for EOL; ".." for delimited comments |
|
146 |
||
2055 | 147 |
|
1729 | 148 |
"/ this is for standard smalltalk |
149 |
"/ TypeToCommentStringMapping |
|
150 |
"/ at:'application/x-smalltalk-source' |
|
151 |
"/ put:#(nil ('"' '"')). "/ ".." for delimited comments only |
|
152 |
||
153 |
||
154 |
TypeToCommentStringMapping |
|
155 |
at:'application/x-pascal-source' |
|
156 |
put:#(nil ('{' '}')). "/ '{'..'}' for delimited comments |
|
157 |
||
2055 | 158 |
|
2048
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
159 |
"/ "/ the following is k&r |
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
160 |
"/ TypeToCommentStringMapping |
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
161 |
"/ at:'application/x-c-source' |
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
162 |
"/ put:#(nil ('/*' '*/')). "/ '/*'..'*/' for delimited comments |
1729 | 163 |
"/ this is ANSI-c |
164 |
TypeToCommentStringMapping |
|
165 |
at:'application/x-c-source' |
|
166 |
put:#('//' ('/*' '*/')). |
|
167 |
||
168 |
TypeToCommentStringMapping |
|
169 |
at:'application/x-cpp-source' |
|
170 |
put:#('//' ('/*' '*/')). |
|
171 |
||
172 |
TypeToCommentStringMapping |
|
2479 | 173 |
at:'application/x-csharp-source' |
174 |
put:#('//' ('/*' '*/')). |
|
175 |
||
176 |
TypeToCommentStringMapping |
|
1729 | 177 |
at:'application/x-java-source' |
178 |
put:#('//' ('/*' '*/')). |
|
179 |
||
180 |
TypeToCommentStringMapping |
|
2048
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
181 |
at:'application/x-javascript' |
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
182 |
put:#('//' ('/*' '*/')). |
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
183 |
|
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
184 |
TypeToCommentStringMapping |
2298 | 185 |
at:'application/x-lisp-source' |
186 |
put:#(';' (nil nil)). "/ '#' for EOL comments only |
|
187 |
||
188 |
TypeToCommentStringMapping |
|
1729 | 189 |
at:'application/x-asn1-source' |
190 |
put:#('--' ('--' '--')). |
|
191 |
||
192 |
||
193 |
"/ st/x support files |
|
194 |
SuffixToCommentStringMapping |
|
195 |
at:'style' |
|
196 |
put:#(';' (nil nil)). |
|
1604 | 197 |
|
1729 | 198 |
SuffixToCommentStringMapping |
199 |
at:'rs' |
|
2298 | 200 |
put:#(';' (nil nil)). |
201 |
||
202 |
"Modified: / 07-04-2007 / 16:12:05 / cg" |
|
1729 | 203 |
! |
204 |
||
205 |
initializeDefaultCommands |
|
206 |
"TODO: move this to OS" |
|
207 |
||
2116 | 208 |
|unixCommands win32Commands unixPrintCommands win32PrintCommands| |
1729 | 209 |
|
210 |
DefaultCommandPerMIMEPerOS := Dictionary new. |
|
211 |
DefaultCommandPerMIMEPerOS at:#unix put:(unixCommands := Dictionary new). |
|
212 |
DefaultCommandPerMIMEPerOS at:#win32 put:(win32Commands := Dictionary new). |
|
213 |
||
214 |
unixCommands at:'application/x-tar-compressed' put:'gunzip < %1 | tar tvf -'. |
|
215 |
unixCommands at:'application/pdf' put:'acroread -display %2 %1'. |
|
216 |
||
2141 | 217 |
OperatingSystem isMSWINDOWSlike ifFalse:[ |cmd| |
2142 | 218 |
cmd := #( firefox konqueror mozilla netscape opera ) |
2141 | 219 |
detect:[:aCmd| (OperatingSystem pathOfCommand:aCmd) notEmptyOrNil ] |
220 |
ifNone:nil. |
|
221 |
||
222 |
cmd notNil ifTrue:[ |
|
2142 | 223 |
unixCommands at:'text/html' put:(cmd, ' "%1"') |
2141 | 224 |
]. |
225 |
]. |
|
226 |
||
227 |
||
2116 | 228 |
DefaultPrintCommandPerMIMEPerOS := Dictionary new. |
229 |
DefaultPrintCommandPerMIMEPerOS at:#unix put:(unixPrintCommands := Dictionary new). |
|
230 |
DefaultPrintCommandPerMIMEPerOS at:#win32 put:(win32PrintCommands := Dictionary new). |
|
231 |
||
232 |
"/ if you have a good (intelligent) spooler ;-) |
|
233 |
unixPrintCommands at:'application/pdf' put:'lpr %1'. |
|
234 |
"/ if not, you may need more... |
|
235 |
"/ unixPrintCommands at:'application/pdf' put:'pdfToPS %1 | lpr'. |
|
236 |
||
237 |
"/ WIN32 setup is now obsolete - now read through the registry |
|
2096 | 238 |
"/ OperatingSystem isMSWINDOWSlike ifTrue:[ |
239 |
"/ #( |
|
240 |
"/ "suffix" "default" "mime" |
|
241 |
"/ ( 'pdf' 'acrord32 %1' 'application/pdf' ) |
|
242 |
"/ ) triplesDo:[:suffix :default :mime| |
|
243 |
"/ |cmd| |
|
244 |
"/ |
|
245 |
"/ cmd := Win32OperatingSystem::RegistryEntry executableForSuffix:suffix. |
|
246 |
"/ cmd isNil ifTrue:[ |
|
247 |
"/ "assume its in the path" |
|
248 |
"/ cmd := default. |
|
249 |
"/ ]. |
|
250 |
"/ win32Commands at:mime put:cmd. |
|
251 |
"/ ]. |
|
252 |
"/ ]. |
|
1979
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
253 |
|
1729 | 254 |
" |
255 |
self initializeDefaultCommands |
|
256 |
" |
|
1979
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
257 |
|
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
258 |
"Modified: / 12-05-2004 / 11:43:23 / cg" |
1729 | 259 |
! |
260 |
||
261 |
initializeFileNameToMimeTypeMapping |
|
262 |
"initialize wellKnown facts" |
|
263 |
||
264 |
|types| |
|
265 |
||
266 |
FileSuffixToTypeMapping isNil ifTrue:[ |
|
267 |
FileSuffixToTypeMapping := Dictionary new |
|
268 |
]. |
|
1887 | 269 |
TypeToFileSuffixMapping isNil ifTrue:[ |
270 |
TypeToFileSuffixMapping := Dictionary new |
|
271 |
]. |
|
1729 | 272 |
FilenameToTypeMapping isNil ifTrue:[ |
273 |
FilenameToTypeMapping := Dictionary new. |
|
274 |
]. |
|
275 |
||
276 |
types := OrderedCollection new. |
|
277 |
types addAll:self textTypeList. |
|
278 |
types addAll:self imageTypeList. |
|
279 |
types addAll:self videoTypeList. |
|
280 |
types addAll:self audioTypeList. |
|
281 |
types addAll:self applicationTypeList. |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
282 |
types addAll:self osSpecificTypeList. |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
283 |
|
1729 | 284 |
types pairWiseDo:[:suff :typeString| |
285 |
|type| |
|
286 |
||
287 |
type := MIMEType fromString:typeString. |
|
288 |
suff isArray ifTrue:[ |
|
1887 | 289 |
suff do:[:s | FileSuffixToTypeMapping at:s put:type]. |
290 |
TypeToFileSuffixMapping at:type put:suff first. |
|
1729 | 291 |
] ifFalse:[ |
1887 | 292 |
FileSuffixToTypeMapping at:suff put:type. |
293 |
TypeToFileSuffixMapping at:type put:suff. |
|
294 |
]. |
|
1729 | 295 |
]. |
296 |
||
297 |
self miscFilenameList pairWiseDo:[:nm :typeString| |
|
298 |
|type| |
|
299 |
||
300 |
type := MIMEType fromString:typeString. |
|
301 |
nm isArray ifTrue:[ |
|
302 |
nm do:[:s | FilenameToTypeMapping at:s put:type] |
|
303 |
] ifFalse:[ |
|
304 |
FilenameToTypeMapping at:nm put:type |
|
305 |
] |
|
306 |
]. |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
307 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
308 |
" |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
309 |
self initializeFileNameToMimeTypeMapping |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
310 |
" |
1729 | 311 |
! |
312 |
||
313 |
initializeImageReaderMappings |
|
314 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
|
315 |
FileSuffixToImageReaderClassMapping := Dictionary new |
|
316 |
]. |
|
317 |
"MIME" TypeToImageReaderClassMapping isNil ifTrue:[ |
|
318 |
TypeToImageReaderClassMapping := Dictionary new |
|
319 |
]. |
|
320 |
||
321 |
"/ setup mimeType to image reader class mapping ... |
|
322 |
||
323 |
TypeToImageReaderClassMapping at:'image/jpeg' put:JPEGReader. |
|
324 |
TypeToImageReaderClassMapping at:'image/gif' put:GIFReader. |
|
325 |
TypeToImageReaderClassMapping at:'image/tiff' put:TIFFReader. |
|
326 |
||
327 |
"/ setup suffix to image reader class mapping ... |
|
328 |
||
329 |
FileSuffixToImageReaderClassMapping at:'jpg' put:JPEGReader. |
|
330 |
FileSuffixToImageReaderClassMapping at:'gif' put:GIFReader. |
|
331 |
FileSuffixToImageReaderClassMapping at:'tif' put:TIFFReader. |
|
2570 | 332 |
|
333 |
WindowsIconReader notNil ifTrue:[ |
|
334 |
TypeToImageReaderClassMapping at:'image/bmp' put:WindowsIconReader. |
|
335 |
FileSuffixToImageReaderClassMapping at:'bmp' put:WindowsIconReader. |
|
336 |
]. |
|
2298 | 337 |
! |
338 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
339 |
initializeParenthesisSpecMappings |
2298 | 340 |
|spec| |
341 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
342 |
TypeToParenthesisSpecMapping := Dictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
343 |
SuffixToParenthesisSpecMapping := Dictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
344 |
|
2298 | 345 |
"/ ST/X spec |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
346 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
347 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
348 |
spec at:#open put:#( $( $[ ${ ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
349 |
spec at:#close put:#( $) $] $} ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
350 |
spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
351 |
spec at:#eolComment put:'"/'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
352 |
TypeToParenthesisSpecMapping at:'application/x-smalltalk-source' put:spec. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
353 |
|
2479 | 354 |
"/ XML & HTML |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
355 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
356 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
357 |
spec at:#open put:#( $< ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
358 |
spec at:#close put:#( $> ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
359 |
spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
360 |
#( 'text/html' 'text/xml' 'application/xml' ) do:[:eachXMLType | |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
361 |
TypeToParenthesisSpecMapping at:eachXMLType put:spec |
2298 | 362 |
]. |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
363 |
|
2479 | 364 |
"/ ANSI-c, Java, C# |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
365 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
366 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
367 |
spec at:#open put:#( $( $[ ${ ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
368 |
spec at:#close put:#( $) $] $} ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
369 |
spec at:#ignore put:#( $' $" ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
370 |
spec at:#eolComment put:'//'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
371 |
TypeToParenthesisSpecMapping at:'application/x-c-source' put:spec. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
372 |
TypeToParenthesisSpecMapping at:'application/x-cpp-source' put:spec. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
373 |
TypeToParenthesisSpecMapping at:'application/x-csharp-source' put:spec. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
374 |
TypeToParenthesisSpecMapping at:'application/x-java-source' put:spec. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
375 |
TypeToParenthesisSpecMapping at:'application/x-javascript' put:spec. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
376 |
|
2298 | 377 |
"/ Lisp |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
378 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
379 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
380 |
spec at:#open put:#( $( ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
381 |
spec at:#close put:#( $) ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
382 |
spec at:#ignore put:#( $" ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
383 |
spec at:#eolComment put:';'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
384 |
TypeToParenthesisSpecMapping at:'application/x-lisp-source' put:spec. |
2298 | 385 |
|
386 |
"Created: / 10-04-2007 / 15:16:37 / cg" |
|
1729 | 387 |
! ! |
388 |
||
389 |
!MIMETypes class methodsFor:'initialization-lists'! |
|
390 |
||
391 |
applicationCompressorsAndArchiveTypeList |
|
1604 | 392 |
^ #( |
1890 | 393 |
'tar' 'application/x-tar' |
394 |
'gtar' 'application/x-gtar' |
|
1891 | 395 |
('tgz' 'tar.gz') 'application/x-tar-gzip-compressed' "/ 'application/x-tar-compressed' |
396 |
('tar.bz2') 'application/x-tar-bzip2-compressed' |
|
1890 | 397 |
'zip' 'application/x-zip-compressed' |
398 |
'bz2' 'application/x-bzip2-compressed' |
|
399 |
('gz' 'z') 'application/x-gzip-compressed' |
|
400 |
'cpio' 'application/x-cpio' |
|
401 |
'shar' 'application/x-shar' |
|
402 |
'jar' 'application/java-archive' |
|
403 |
'sar' 'application/x-squeak-archive' |
|
404 |
'sit' 'application/x-stuffit' |
|
405 |
'hqx' 'application/mac-binhex40' |
|
406 |
'cpt' 'application/mac-compactpro' |
|
1604 | 407 |
) |
408 |
! |
|
645 | 409 |
|
1609 | 410 |
applicationMiscTypeList |
411 |
"misc applications" |
|
412 |
||
413 |
^ #( |
|
414 |
('a' 'o' 'obj' ) 'application/binary' |
|
415 |
'a' 'application/library' |
|
416 |
('dll' 'so') 'application/shared-library' |
|
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
417 |
|
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
418 |
('ets') 'application/x-expecco-testsuite' |
2489
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
419 |
('elf') 'application/x-expecco-logfile' |
1609 | 420 |
) |
421 |
! |
|
422 |
||
1604 | 423 |
applicationProgLangTypeList |
1606 | 424 |
"applications for programm languages" |
713 | 425 |
|
1604 | 426 |
^ #( |
1609 | 427 |
('st' 'cls' 'rc') 'application/x-smalltalk-source' |
1604 | 428 |
'sif' 'application/x-smalltalk-source-sif' |
1668 | 429 |
'pac' 'application/x-smalltalk-dolphin-package' |
1778 | 430 |
|
431 |
'sts' 'application/x-squeak-source' |
|
432 |
'pr' 'application/x-squeak-project' |
|
433 |
||
1604 | 434 |
'c' 'application/x-c-source' |
435 |
('cc' 'cpp') 'application/x-cpp-source' |
|
2479 | 436 |
'cs' 'application/x-csharp-source' |
1609 | 437 |
('h' 'hi') 'application/x-c-header' |
1604 | 438 |
('js' 'mocha') 'application/x-javascript' |
439 |
('java' 'jav') 'application/x-java-source' |
|
440 |
'sh' 'application/x-sh' |
|
441 |
'csh' 'application/x-csh' |
|
442 |
'tcl' 'application/x-tcl' |
|
443 |
'pl' 'application/x-perl' |
|
444 |
'mak' 'application/x-make' |
|
445 |
'bat' 'application/x-batch-script' |
|
2534 | 446 |
('asn1' 'x409' 'gdmo' 'gdm') 'application/x-asn1-source' |
447 |
('lisp' 'lsp' 'scm' 'ss' 'arc' 'cl') 'application/x-lisp-source' |
|
1604 | 448 |
) |
2298 | 449 |
|
450 |
"Modified: / 09-04-2007 / 09:46:04 / cg" |
|
1604 | 451 |
! |
1561 | 452 |
|
1604 | 453 |
applicationTextTypeList |
1606 | 454 |
"text applications" |
1604 | 455 |
|
456 |
^ #( |
|
457 |
('ps' 'eps') 'application/postscript' |
|
1778 | 458 |
"/ 'ai' 'application/postscript' |
1604 | 459 |
'pdf' 'application/pdf' |
460 |
'rtf' 'application/rtf' |
|
1778 | 461 |
"/ 'rtf' 'text/rtf' ???? |
462 |
"/ 'doc' 'application/winword' |
|
1779 | 463 |
'doc' 'application/ms-word-document' |
1778 | 464 |
'swf' 'application/x-shockwave-flash' |
465 |
('ppt' 'ppz' 'pot' 'pps') 'application/mspowerpoint' |
|
2028 | 466 |
'xls' 'application/x-excel' |
467 |
'slk' 'application/vnd.ms-excel' |
|
1604 | 468 |
) |
469 |
! |
|
470 |
||
471 |
applicationTypeList |
|
1606 | 472 |
"applications" |
1604 | 473 |
|
1729 | 474 |
|typeList| |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
475 |
|
1729 | 476 |
typeList := OrderedCollection new. |
477 |
typeList addAll:self applicationProgLangTypeList. |
|
478 |
typeList addAll:self applicationTextTypeList. |
|
479 |
typeList addAll:self applicationCompressorsAndArchiveTypeList. |
|
480 |
typeList addAll:self applicationMiscTypeList. |
|
1616 | 481 |
|
1729 | 482 |
^ typeList |
1604 | 483 |
! |
484 |
||
485 |
audioTypeList |
|
1606 | 486 |
"audio formats ..." |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
487 |
|
1604 | 488 |
^ #( |
1720 | 489 |
('au' 'snd') 'audio/basic' |
1778 | 490 |
('ra') 'audio/x-realaudio' |
491 |
('ram' 'rm') 'audio/x-pn-realaudio' |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
492 |
"/ cg: see unixSpecific / windowsSpecific |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
493 |
"/ 'rpm' 'audio/x-pn-realaudio-plugin' |
1720 | 494 |
('mpa' 'mpega') 'audio/mpeg' |
1778 | 495 |
"/ 'mp3' 'audio/x-mp3' |
496 |
('mp3' 'mp2') 'audio/mpeg' |
|
1604 | 497 |
'wav' 'audio/x-wav' |
498 |
('aif' 'aiff' 'aifc') 'audio/x-aiff' |
|
1778 | 499 |
('midi' 'mid') 'audio/midi' |
1604 | 500 |
) |
501 |
! |
|
502 |
||
503 |
imageTypeList |
|
504 |
||
505 |
^ #( |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
506 |
"/ image formats ... |
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
507 |
|
1216 | 508 |
('jpg' 'jpeg') 'image/jpeg' |
1188 | 509 |
'gif' 'image/gif' |
510 |
('tif' 'tiff') 'image/tiff' |
|
511 |
'xbm' 'image/x-xbitmap' |
|
512 |
'xpm' 'image/x-xpixmap' |
|
1720 | 513 |
'png' 'image/png' |
1188 | 514 |
'pcd' 'image/x-photo-cd' |
515 |
'bmp' 'image/x-MS-bmp' |
|
516 |
'rgb' 'image/x-rgb' |
|
517 |
'ppm' 'image/x-portable-pixmap' |
|
518 |
'pgm' 'image/x-portable-graymap' |
|
519 |
'pbm' 'image/x-portable-bitmap' |
|
520 |
'pnm' 'image/x-portable-anymap' |
|
521 |
'xwd' 'image/x-xwindowdump' |
|
522 |
'ras' 'image/x-cmu-raster' |
|
1216 | 523 |
'tga' 'image/x-targa' |
2020 | 524 |
'ico' 'image/x-ico' |
1604 | 525 |
) |
526 |
! |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
527 |
|
1609 | 528 |
miscFilenameList |
529 |
"other formats (not by suffix, but by fileName isnstead) ..." |
|
530 |
||
531 |
^ #( |
|
2113 | 532 |
('makefile' 'make.proto' 'make.spec' 'nt.mak') 'application/x-make' |
533 |
('exe' 'bin') 'application/octet-stream' |
|
534 |
('class') 'application/octet-stream' |
|
2375 | 535 |
('top') 'application/x-waltop-digital-notepad' |
1609 | 536 |
) |
537 |
! |
|
538 |
||
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
539 |
osSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
540 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
541 |
^ self windowsSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
542 |
]. |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
543 |
^ self unixSpecificTypeList |
2023 | 544 |
|
545 |
" |
|
546 |
self osSpecificTypeList |
|
547 |
" |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
548 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
549 |
|
1604 | 550 |
textTypeList |
551 |
"/ misc text ... |
|
552 |
||
553 |
^ #( |
|
1887 | 554 |
('html' 'htm' 'shtml') 'text/html' |
1604 | 555 |
('txt' 'text') 'text/plain' |
1680 | 556 |
'xml' 'text/xml' |
1777 | 557 |
'css' 'text/css' |
2432 | 558 |
'csv' 'text/csv' |
1604 | 559 |
) |
560 |
! |
|
561 |
||
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
562 |
unixSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
563 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
564 |
^ #( |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
565 |
"/ cg: RPM is 'audio/x-pn-realaudio-plugin' for WIN32 |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
566 |
"/ and 'application/x-rpm' for Unix |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
567 |
'rpm' 'application/x-rpm' |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
568 |
) |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
569 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
570 |
|
1604 | 571 |
videoTypeList |
572 |
"/ video formats ... |
|
573 |
||
574 |
^ #( |
|
1720 | 575 |
('qt' 'mov' 'moov') 'video/quicktime' |
576 |
('mpv' 'mpegv' 'mpg' 'mpeg' 'mpe') 'video/mpeg' |
|
1604 | 577 |
'movie' 'video/x-sgi-movie' |
1820 | 578 |
('avi' 'wmv' 'asf') 'video/x-msvideo' |
1604 | 579 |
('mpv2' 'mp2v' 'mp2' 'mpeg2') 'video/x-mpeg2' |
1680 | 580 |
'rm' 'application/vnd.rn-realmedia' |
581 |
'rv' 'video/x-pn-realvideo' |
|
1778 | 582 |
) |
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
583 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
584 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
585 |
windowsSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
586 |
^ #( |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
587 |
"/ cg: RPM is 'audio/x-pn-realaudio-plugin' for WIN32 |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
588 |
"/ and 'application/x-rpm' for Unix |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
589 |
'rpm' 'audio/x-pn-realaudio-plugin' |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
590 |
) |
643 | 591 |
! ! |
592 |
||
1729 | 593 |
!MIMETypes class methodsFor:'obsolete'! |
1489 | 594 |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
595 |
defaultCommandForMimeType:mimeType |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
596 |
<resource: #obsolete> |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
597 |
self obsoleteMethodWarning:'use #defaultCommandTemplateToOpenMimeType:'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
598 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
599 |
^ self defaultCommandTemplateToOpenMimeType:mimeType |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
600 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
601 |
" |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
602 |
MIMETypes defaultCommandForMimeType:'application/pdf' |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
603 |
" |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
604 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
605 |
"Created: / 12-05-2004 / 11:09:22 / cg" |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
606 |
"Modified: / 12-05-2004 / 11:16:53 / cg" |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
607 |
! |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
608 |
|
1729 | 609 |
fontForCharset:aCharSetName |
610 |
"return the font-encoding for an iso-charset" |
|
1489 | 611 |
|
1981 | 612 |
<resource:#obsolete> |
1729 | 613 |
self obsoleteMethodWarning:'use FontDescription >> fontNamePatternForCharset:'. |
614 |
^ FontDescription fontNamePatternForCharset:aCharSetName. |
|
1489 | 615 |
|
616 |
" |
|
1729 | 617 |
MIMETypes fontForCharset:'iso2022-jp' |
618 |
MIMETypes fontForCharset:'euc-jp' |
|
1472 | 619 |
" |
620 |
||
1729 | 621 |
"Modified: / 1.8.1998 / 17:00:57 / cg" |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
622 |
! |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
623 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
624 |
parentesisSpecForFilename:aFilename |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
625 |
<resource: #obsolete> |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
626 |
^ self parenthesisSpecForFilename:aFilename |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
627 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
628 |
"Created: / 10-04-2007 / 15:18:41 / cg" |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
629 |
! |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
630 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
631 |
parentesisSpecForFilename:aFilename ifUnknown:alternative |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
632 |
<resource: #obsolete> |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
633 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
634 |
^ self parenthesisSpecForFilename:aFilename ifUnknown:alternative |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
635 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
636 |
"Created: / 10-04-2007 / 15:26:20 / cg" |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
637 |
! |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
638 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
639 |
parentesisSpecForMimeType:mime suffix:suff |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
640 |
<resource: #obsolete> |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
641 |
^ self parenthesisSpecForMimeType:mime suffix:suff |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
642 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
643 |
"Created: / 10-04-2007 / 15:19:39 / cg" |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
644 |
! |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
645 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
646 |
parentesisSpecForMimeType:mime suffix:suff ifUnknown:alternativeValue |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
647 |
<resource: #obsolete> |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
648 |
^ self parenthesisSpecForMimeType:mime suffix:suff ifUnknown:alternativeValue |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
649 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
650 |
"Created: / 10-04-2007 / 15:20:38 / cg" |
1729 | 651 |
! ! |
1472 | 652 |
|
1729 | 653 |
!MIMETypes class methodsFor:'queries'! |
1472 | 654 |
|
647 | 655 |
defineImageType:mimeType suffix:aSuffix reader:aReaderClass |
656 |
"register an image reader." |
|
657 |
||
658 |
aSuffix notNil ifTrue:[ |
|
659 |
self imageReaderForSuffix:aSuffix put:aReaderClass. |
|
660 |
]. |
|
661 |
||
662 |
mimeType notNil ifTrue:[ |
|
663 |
self imageReaderForType:mimeType put:aReaderClass |
|
664 |
]. |
|
665 |
||
666 |
(aSuffix notNil and:[mimeType notNil]) ifTrue:[ |
|
667 |
self mimeTypeForSuffix:aSuffix put:mimeType |
|
668 |
]. |
|
669 |
! |
|
670 |
||
643 | 671 |
fileSuffixToImageReaderMapping |
1021 | 672 |
"return the suffix-to-imageReader mapping" |
673 |
||
643 | 674 |
^ FileSuffixToImageReaderClassMapping ? #() |
675 |
||
1021 | 676 |
"Modified: / 1.8.1998 / 17:00:11 / cg" |
643 | 677 |
! |
678 |
||
679 |
imageFileSuffixes |
|
1021 | 680 |
"return a collection with known file suffixes" |
681 |
||
643 | 682 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[^ #()]. |
683 |
^ FileSuffixToImageReaderClassMapping keys |
|
684 |
||
1021 | 685 |
"Created: / 30.6.1997 / 22:04:48 / cg" |
686 |
"Modified: / 1.8.1998 / 17:01:26 / cg" |
|
643 | 687 |
! |
688 |
||
1473 | 689 |
mimeTypeForFilename:filenameArg |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
690 |
"given a filename, return the mime-type or nil, if unknown" |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
691 |
|
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
692 |
|type filename lcFilename suff suff2| |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
693 |
|
1473 | 694 |
filename := filenameArg asFilename. |
1474 | 695 |
|
696 |
lcFilename := filename baseName asLowercase. |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
697 |
type := FilenameToTypeMapping at:lcFilename ifAbsent:nil. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
698 |
type isNil ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
699 |
"/ allow for fallback ... |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
700 |
type := OperatingSystem mimeTypeForFilename:lcFilename. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
701 |
"/ the special value #unknown is returned as nil; |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
702 |
"/ this avoids constant retry if a mimeType is not known in |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
703 |
"/ the OS. |
1275 | 704 |
"/ type isNil ifTrue:[ |
705 |
"/ FilenameToTypeMapping at:lcFilename put:#unknown |
|
706 |
"/ ]. |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
707 |
]. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
708 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
709 |
type == #unknown ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
710 |
type := nil. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
711 |
]. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
712 |
|
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
713 |
type isNil ifTrue:[ |
1473 | 714 |
suff := filename suffix. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
715 |
suff size ~~ 0 ifTrue:[ |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
716 |
"/ sigh - special code for multiple-suffices... |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
717 |
"/ .tar.gz -> tgz |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
718 |
suff2 := filename withoutSuffix suffix. |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
719 |
suff2 size > 0 ifTrue:[ |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
720 |
type := self mimeTypeForSuffix:(suff2 , '.' , suff). |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
721 |
]. |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
722 |
type isNil ifTrue:[ |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
723 |
type := self mimeTypeForSuffix:suff |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
724 |
]. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
725 |
] |
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
726 |
]. |
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
727 |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
728 |
^ type |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
729 |
|
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
730 |
" |
1841 | 731 |
self mimeTypeForFilename:'typeinst.dvi' |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
732 |
self mimeTypeForFilename:'foo.tar' |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
733 |
self mimeTypeForFilename:'foo.tgz' |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
734 |
self mimeTypeForFilename:'foo.tar.gz' |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
735 |
" |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
736 |
! |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
737 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
738 |
mimeTypeForFilename:filename put:mimeType |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
739 |
"register a mime type for a filename" |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
740 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
741 |
FilenameToTypeMapping isNil ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
742 |
FilenameToTypeMapping := Dictionary new |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
743 |
]. |
1612 | 744 |
FilenameToTypeMapping at:filename put:(MIMEType fromString:mimeType asLowercase) |
1611 | 745 |
! |
746 |
||
643 | 747 |
mimeTypeForSuffix:suffix |
1021 | 748 |
"given a file suffix, return the mime-type" |
749 |
||
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
750 |
|type lcSuffix| |
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
751 |
|
1837 | 752 |
suffix = LastSuffix ifTrue:[ |
753 |
^ LastType |
|
754 |
]. |
|
755 |
||
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
756 |
lcSuffix := suffix asLowercase. |
1837 | 757 |
type := FileSuffixToTypeMapping at:lcSuffix ifAbsent:nil. |
758 |
type isNil ifTrue:[ |
|
759 |
"/ allow for fallback ... |
|
760 |
type := OperatingSystem mimeTypeForSuffix:lcSuffix. |
|
761 |
"/ the special value #unknown is returned as nil; |
|
762 |
"/ this avoids constant retry if a mimeType is not known in the OS. |
|
763 |
||
764 |
type := type ? #unknown. |
|
765 |
FileSuffixToTypeMapping at:lcSuffix put:type. |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
766 |
]. |
1837 | 767 |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
768 |
type == #unknown ifTrue:[ |
1837 | 769 |
type := nil. |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
770 |
]. |
1840 | 771 |
type notNil ifTrue:[ |
772 |
LastSuffix := suffix. |
|
773 |
LastType := MIMEType fromString:type. |
|
774 |
^ LastType |
|
775 |
]. |
|
1841 | 776 |
^ type |
643 | 777 |
|
1666 | 778 |
" |
1840 | 779 |
self mimeTypeForSuffix:'gif' |
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
780 |
self mimeTypeForSuffix:'rpm' |
1666 | 781 |
" |
782 |
||
1021 | 783 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
1300 | 784 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
643 | 785 |
! |
786 |
||
787 |
mimeTypeForSuffix:suffix put:mimeType |
|
1021 | 788 |
"register a mime type for a file suffix" |
789 |
||
643 | 790 |
FileSuffixToTypeMapping isNil ifTrue:[ |
791 |
FileSuffixToTypeMapping := Dictionary new |
|
792 |
]. |
|
793 |
FileSuffixToTypeMapping at:suffix put:mimeType asLowercase |
|
794 |
||
1021 | 795 |
"Created: / 30.6.1997 / 21:56:20 / cg" |
796 |
"Modified: / 1.8.1998 / 17:03:18 / cg" |
|
1593 | 797 |
! |
798 |
||
799 |
mimeTypeForSuffixMapping |
|
800 |
||
801 |
^ FileSuffixToTypeMapping |
|
1611 | 802 |
! |
803 |
||
2023 | 804 |
mimeTypeFromString:mimeTypeString |
805 |
"given a mime-type for a string" |
|
806 |
||
807 |
^ MIMEType fromString:mimeTypeString |
|
808 |
||
809 |
" |
|
810 |
self mimeTypeFromString:'image/gif' |
|
2487
eaa224da42fa
mimeType: x-expecco-testsuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2486
diff
changeset
|
811 |
self mimeTypeFromString:'application/x-expecco-testsuite' |
2023 | 812 |
" |
813 |
! |
|
814 |
||
1611 | 815 |
mimeTypeOfContents:filename |
816 |
"given a filename, scan the contents, return the mime-type or nil, if unknown" |
|
817 |
||
1612 | 818 |
|typeString| |
819 |
||
820 |
typeString := filename mimeTypeOfContents. |
|
821 |
typeString isNil ifTrue:[^ nil]. |
|
822 |
^ MIMEType fromString:typeString. |
|
1887 | 823 |
! |
824 |
||
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
825 |
mimeTypeOfData:someData |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
826 |
"this tries to guess the mime type of contents of someData. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
827 |
Returns nil, if unknown. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
828 |
This is done using some heuristics, and may need some improvement" |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
829 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
830 |
|buffer lcBuffer size idx idx2| |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
831 |
|
2583 | 832 |
someData isEmptyOrNil ifTrue:[^ nil]. |
833 |
||
834 |
size := 2048 min:someData size. |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
835 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
836 |
"/ read some data from the file ... |
2583 | 837 |
buffer := (someData copyTo:size) asString. |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
838 |
lcBuffer := buffer asLowercase. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
839 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
840 |
(idx := lcBuffer findString:'mimetype:') ~~ 0 ifTrue:[ |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
841 |
idx := idx + 'mimetype:' size. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
842 |
idx := lcBuffer indexOfNonSeparatorStartingAt:idx. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
843 |
idx2 := lcBuffer indexOfSeparatorStartingAt:idx. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
844 |
idx2 > idx ifTrue:[ |
2583 | 845 |
^ MIMEType fromString:(lcBuffer copyFrom:idx to:idx2-1) |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
846 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
847 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
848 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
849 |
#( |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
850 |
( #[16r4C 16r00 16r00 16r00 16r01 16r14 16r02 16r00 16r00 16r00 16r00 16r00 16rC0 16r00 16r00 16r00 16r00 16r00 16r00 16r46] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
851 |
#'application/x-ms-shortcut' ) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
852 |
( 'WALTOP' |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
853 |
#'application/x-waltop-digital-notepad' ) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
854 |
) pairsDo:[:pattern :what | |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
855 |
|patternString| |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
856 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
857 |
patternString := pattern asString. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
858 |
(buffer startsWith:patternString) ifTrue:[ |
2583 | 859 |
^ MIMEType fromString:what |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
860 |
] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
861 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
862 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
863 |
#( |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
864 |
('<body:' #'text/html') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
865 |
('%!!ps-adobe' #'application/postscript') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
866 |
('%PDF-' #'application/pdf') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
867 |
('#!! /bin/sh' #'application/x-sh') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
868 |
('#!!/bin/sh' #'application/x-sh') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
869 |
"/ ('#!! /bin/bash' 'application/x-bash') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
870 |
"/ ('#!!/bin/bash' 'application/x-bash') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
871 |
('<?xml version=' #'text/xml') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
872 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
873 |
('from dolphin' #'application/x-smalltalk-source') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
874 |
('from visualworks' #'application/x-smalltalk-source') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
875 |
('categoriesforclass' #'application/x-smalltalk-source') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
876 |
('methodsfor!!' #'application/x-smalltalk-source') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
877 |
('subclass:' #'application/x-smalltalk-source') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
878 |
('methodsfor:' #'application/x-smalltalk-source') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
879 |
('interchangeversion:' #'application/x-smalltalk-source-sif') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
880 |
('subclass:' #'application/x-smalltalk-source') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
881 |
('methodsfor:' #'application/x-smalltalk-source') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
882 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
883 |
) pairsDo:[:pattern :what | |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
884 |
(lcBuffer findString:pattern) ~~ 0 ifTrue:[ |
2583 | 885 |
^ MIMEType fromString:what |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
886 |
] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
887 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
888 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
889 |
(idx := lcBuffer findString:'<h') ~~ 0 ifTrue:[ |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
890 |
((lcBuffer continuesWith:'<head' startingAt:idx) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
891 |
or:[(lcBuffer continuesWith:'<html' startingAt:idx) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
892 |
or:[(lcBuffer continuesWith:'<h1' startingAt:idx) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
893 |
or:[(lcBuffer continuesWith:'<h2' startingAt:idx) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
894 |
or:[(lcBuffer continuesWith:'<h3' startingAt:idx) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
895 |
or:[(lcBuffer continuesWith:'<h4' startingAt:idx) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
896 |
or:[(lcBuffer continuesWith:'<h5' startingAt:idx) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
897 |
or:[(lcBuffer continuesWith:'<h6' startingAt:idx)]]]]]]]) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
898 |
ifTrue:[ |
2583 | 899 |
^ MIMEType fromString:'text/html' |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
900 |
] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
901 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
902 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
903 |
[size ~~ 0 and:[(buffer at:size) isPrintable]] whileTrue:[size := size - 1]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
904 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
905 |
size == 0 ifTrue:[ |
2583 | 906 |
^ MIMEType fromString:'text/plain' |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
907 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
908 |
^ nil |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
909 |
! |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
910 |
|
1887 | 911 |
suffixForMimeType:mimeType |
912 |
"given a file suffix, return the mime-type" |
|
913 |
||
914 |
^ TypeToFileSuffixMapping at:mimeType ifAbsent:nil |
|
915 |
||
916 |
" |
|
917 |
self suffixForMimeType:(MIMEType fromString:'image/gif') |
|
918 |
" |
|
919 |
||
920 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
|
921 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
|
922 |
! |
|
923 |
||
924 |
suffixForMimeTypeString:mimeTypeString |
|
925 |
"given a file suffix, return the mime-type" |
|
926 |
||
927 |
^ self suffixForMimeType:(MIMEType fromString:mimeTypeString) |
|
928 |
||
929 |
" |
|
930 |
self suffixForMimeTypeString:'image/gif' |
|
931 |
" |
|
932 |
||
933 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
|
934 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
|
1612 | 935 |
! ! |
936 |
||
2116 | 937 |
!MIMETypes class methodsFor:'queries-applications'! |
938 |
||
2117 | 939 |
defaultCommandPerMIME |
940 |
"returns the collection which is used to map MIME-type to command-templates." |
|
941 |
||
942 |
"TODO: move this to OS/UserPreferences" |
|
943 |
||
944 |
DefaultCommandPerMIMEPerOS isNil ifTrue:[ |
|
945 |
self initializeDefaultCommands |
|
946 |
]. |
|
947 |
OperatingSystem isUNIXlike ifTrue:[ |
|
948 |
^ DefaultCommandPerMIMEPerOS at:#unix |
|
949 |
]. |
|
950 |
^ DefaultCommandPerMIMEPerOS at:#win32 |
|
951 |
! |
|
952 |
||
2116 | 953 |
defaultCommandTemplateToOpenMimeType:mimeType |
954 |
|cmd| |
|
955 |
||
956 |
cmd := self defaultCommandPerMIME at:mimeType ifAbsent:nil. |
|
957 |
cmd isNil ifTrue:[ |
|
958 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
959 |
cmd := Win32OperatingSystem::RegistryEntry commandTemplateToOpenMimeType:mimeType |
|
960 |
]. |
|
961 |
]. |
|
962 |
^ cmd |
|
963 |
||
964 |
" |
|
965 |
MIMETypes defaultCommandTemplateToOpenMimeType:'application/pdf' |
|
2118 | 966 |
MIMETypes defaultCommandTemplateToOpenMimeType:'text/html' |
2116 | 967 |
" |
968 |
||
969 |
"Created: / 12-05-2004 / 11:09:22 / cg" |
|
970 |
"Modified: / 12-05-2004 / 11:16:53 / cg" |
|
971 |
! |
|
972 |
||
973 |
defaultCommandTemplateToPrintMimeType:mimeType |
|
974 |
|cmd| |
|
975 |
||
976 |
cmd := self defaultPrintCommandPerMIME at:mimeType ifAbsent:nil. |
|
977 |
cmd isNil ifTrue:[ |
|
978 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
979 |
cmd := Win32OperatingSystem::RegistryEntry commandTemplateToPrintMimeType:mimeType |
|
980 |
]. |
|
981 |
]. |
|
982 |
^ cmd |
|
983 |
||
984 |
" |
|
985 |
MIMETypes defaultCommandTemplateToPrintMimeType:'application/pdf' |
|
986 |
" |
|
2117 | 987 |
! |
988 |
||
989 |
defaultPrintCommandPerMIME |
|
990 |
"returns the collection which is used to map MIME-type to printing command-templates." |
|
991 |
||
992 |
"TODO: move this to OS/UserPreferences" |
|
993 |
||
994 |
DefaultPrintCommandPerMIMEPerOS isNil ifTrue:[ |
|
995 |
self initializeDefaultCommands |
|
996 |
]. |
|
997 |
OperatingSystem isUNIXlike ifTrue:[ |
|
998 |
^ DefaultPrintCommandPerMIMEPerOS at:#unix |
|
999 |
]. |
|
1000 |
^ DefaultPrintCommandPerMIMEPerOS at:#win32 |
|
2116 | 1001 |
! ! |
1002 |
||
1729 | 1003 |
!MIMETypes class methodsFor:'queries-image formats'! |
1004 |
||
1005 |
imageReaderClasses |
|
1006 |
"return a collection of registered image reader classes" |
|
1007 |
||
1008 |
|setOfClasses| |
|
1009 |
||
1010 |
setOfClasses := IdentitySet new. |
|
1011 |
FileSuffixToImageReaderClassMapping notNil ifTrue:[ |
|
1012 |
FileSuffixToImageReaderClassMapping keysAndValuesDo:[:suff :cls | |
|
1013 |
setOfClasses add:cls |
|
1014 |
]. |
|
1015 |
]. |
|
1016 |
TypeToImageReaderClassMapping notNil ifTrue:[ |
|
1017 |
TypeToImageReaderClassMapping keysAndValuesDo:[:suff :cls | |
|
1018 |
setOfClasses add:cls |
|
1019 |
]. |
|
1020 |
]. |
|
1021 |
^ setOfClasses |
|
1022 |
||
1023 |
"Created: / 30.6.1997 / 22:03:42 / cg" |
|
1024 |
"Modified: / 1.8.1998 / 16:59:52 / cg" |
|
1025 |
! |
|
1026 |
||
1027 |
imageReaderForSuffix:aSuffix |
|
1028 |
"given a file suffix, return an approriate image reader class" |
|
1029 |
||
1030 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[^ nil]. |
|
1031 |
^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil |
|
1032 |
||
1033 |
"Created: / 30.6.1997 / 21:59:11 / cg" |
|
1034 |
"Modified: / 1.8.1998 / 17:01:58 / cg" |
|
1035 |
! |
|
1036 |
||
1037 |
imageReaderForSuffix:aSuffix put:aReaderClass |
|
1038 |
"register an image reader for a file suffix" |
|
1039 |
||
1040 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
|
1041 |
FileSuffixToImageReaderClassMapping := Dictionary new. |
|
1042 |
]. |
|
1043 |
FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass |
|
1044 |
||
1045 |
"Created: / 30.6.1997 / 21:59:43 / cg" |
|
1046 |
"Modified: / 1.8.1998 / 17:02:14 / cg" |
|
1047 |
! |
|
1048 |
||
1049 |
imageReaderForType:mimeTypeString |
|
1050 |
"given a mime-type, return an approriate image reader class" |
|
1051 |
||
1052 |
TypeToImageReaderClassMapping isNil ifTrue:[^ nil]. |
|
1053 |
^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil |
|
1054 |
||
1055 |
"Created: / 30.6.1997 / 21:56:01 / cg" |
|
1056 |
"Modified: / 1.8.1998 / 17:02:28 / cg" |
|
1057 |
! |
|
1058 |
||
1059 |
imageReaderForType:mimeTypeString put:aReaderClass |
|
1060 |
"register an image reader for a mime-type" |
|
1061 |
||
1062 |
TypeToImageReaderClassMapping isNil ifTrue:[ |
|
1063 |
TypeToImageReaderClassMapping := Dictionary new. |
|
1064 |
]. |
|
1065 |
TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass |
|
1066 |
||
1067 |
"Created: / 30.6.1997 / 21:56:11 / cg" |
|
1068 |
"Modified: / 1.8.1998 / 17:02:40 / cg" |
|
1069 |
! ! |
|
1070 |
||
1071 |
!MIMETypes class methodsFor:'queries-language syntax'! |
|
1072 |
||
1073 |
commentStringsForFilename:aFilename |
|
1074 |
"return a useful comment definition; heuristics for now. |
|
1075 |
The returned value is an array of 2 elements; |
|
1076 |
the first is the end-of-line comment string (or nil); |
|
1077 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1078 |
||
1079 |
|mime| |
|
1080 |
||
1081 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
1082 |
^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) |
|
1083 |
||
1084 |
" |
|
1085 |
MIMETypes commentStringsForFilename:'Makefile'. |
|
1086 |
MIMETypes commentStringsForFilename:'Object.st'. |
|
1087 |
MIMETypes commentStringsForFilename:'Foo.java'. |
|
1925 | 1088 |
MIMETypes commentStringsForFilename:'Foo.html'. |
1729 | 1089 |
" |
1090 |
! |
|
1091 |
||
1092 |
commentStringsForFilename:aFilename ifUnknown:alternativeBlockReturningCommentString |
|
1093 |
"return a useful comment definition; heuristics for now. |
|
1094 |
The returned value is an array of 2 elements; |
|
1095 |
the first is the end-of-line comment string (or nil); |
|
1096 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1097 |
||
1098 |
|mime| |
|
1099 |
||
1100 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
1101 |
^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternativeBlockReturningCommentString |
|
1102 |
||
1103 |
" |
|
1104 |
MIMETypes commentStringsForFilename:'Makefile'. |
|
1105 |
MIMETypes commentStringsForFilename:'Object.st'. |
|
1106 |
MIMETypes commentStringsForFilename:'Foo.java'. |
|
1107 |
" |
|
1108 |
! |
|
1109 |
||
1110 |
commentStringsForMimeType:mime suffix:suff |
|
1111 |
"return a useful comment definition; heuristics for now. |
|
1112 |
The returned value is an array of 2 elements; |
|
1113 |
the first is the end-of-line comment string (or nil); |
|
1114 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1115 |
||
1116 |
^ self |
|
1117 |
commentStringsForMimeType:mime suffix:suff |
|
1118 |
ifUnknown: #(';' (nil nil)) |
|
1119 |
||
1120 |
" |
|
1121 |
|mime| |
|
1122 |
||
1123 |
mime := MIMETypes mimeTypeForFilename:'Makefile'. |
|
1124 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1125 |
" |
|
1126 |
||
1127 |
" |
|
1128 |
|mime| |
|
1129 |
||
1130 |
mime := MIMETypes mimeTypeForFilename:'Object.st'. |
|
1131 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1132 |
" |
|
1133 |
! |
|
1134 |
||
1135 |
commentStringsForMimeType:mime suffix:suff ifUnknown:alternativeBlockReturningCommentString |
|
1136 |
"return a useful comment definition; heuristics for now. |
|
1137 |
The returned value is an array of 2 elements; |
|
1138 |
the first is the end-of-line comment string (or nil); |
|
1139 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1140 |
||
1141 |
|commentSpec| |
|
1142 |
||
1143 |
commentSpec := TypeToCommentStringMapping at:mime ifAbsent:nil. |
|
1144 |
commentSpec notNil ifTrue:[ |
|
1145 |
^ commentSpec |
|
1146 |
]. |
|
1147 |
||
1148 |
commentSpec := SuffixToCommentStringMapping at:suff ifAbsent:nil. |
|
1149 |
commentSpec notNil ifTrue:[ |
|
1150 |
^ commentSpec |
|
1151 |
]. |
|
1152 |
||
1153 |
^ alternativeBlockReturningCommentString value |
|
1154 |
||
1155 |
" |
|
1156 |
|mime| |
|
1157 |
||
1158 |
mime := MIMETypes mimeTypeForFilename:'Makefile'. |
|
1159 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1160 |
" |
|
1161 |
||
1162 |
" |
|
1163 |
|mime| |
|
1164 |
||
1165 |
mime := MIMETypes mimeTypeForFilename:'Object.st'. |
|
1166 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1167 |
" |
|
2298 | 1168 |
! |
1169 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1170 |
parenthesisSpecForFilename:aFilename |
2298 | 1171 |
"return a useful parentesis spec; heuristics for now. |
1172 |
The returned value is a dictionary to be used as parentesis spec in an editor" |
|
1173 |
||
1174 |
|mime| |
|
1175 |
||
1176 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1177 |
^ self parenthesisSpecForMimeType:mime suffix:(aFilename asFilename suffix) |
2298 | 1178 |
|
1179 |
" |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1180 |
MIMETypes parenthesisSpecForFilename:'Object.st'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1181 |
MIMETypes parenthesisSpecForFilename:'Foo.java'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1182 |
MIMETypes parenthesisSpecForFilename:'Foo.html'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1183 |
MIMETypes parenthesisSpecForFilename:'Foo.lsp'. |
2298 | 1184 |
" |
1185 |
||
1186 |
"Created: / 10-04-2007 / 15:18:41 / cg" |
|
1187 |
! |
|
1188 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1189 |
parenthesisSpecForFilename:aFilename ifUnknown:alternative |
2298 | 1190 |
|mime| |
1191 |
||
1192 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1193 |
^ self parenthesisSpecForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternative |
2298 | 1194 |
|
1195 |
"Created: / 10-04-2007 / 15:26:20 / cg" |
|
1196 |
! |
|
1197 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1198 |
parenthesisSpecForMimeType:mime suffix:suff |
2298 | 1199 |
^ self |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1200 |
parenthesisSpecForMimeType:mime suffix:suff |
2298 | 1201 |
ifUnknown: nil |
1202 |
||
1203 |
"Created: / 10-04-2007 / 15:19:39 / cg" |
|
1204 |
! |
|
1205 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1206 |
parenthesisSpecForMimeType:mime suffix:suff ifUnknown:alternativeValue |
2298 | 1207 |
|spec| |
1208 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1209 |
spec := TypeToParenthesisSpecMapping at:mime ifAbsent:nil. |
2298 | 1210 |
spec notNil ifTrue:[ |
1211 |
^ spec |
|
1212 |
]. |
|
1213 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1214 |
spec := SuffixToParenthesisSpecMapping at:suff ifAbsent:nil. |
2298 | 1215 |
spec notNil ifTrue:[ |
1216 |
^ spec |
|
1217 |
]. |
|
1218 |
||
1219 |
^ alternativeValue value |
|
1220 |
||
1221 |
"Created: / 10-04-2007 / 15:20:38 / cg" |
|
1729 | 1222 |
! ! |
1223 |
||
1612 | 1224 |
!MIMETypes::MIMEType class methodsFor:'documentation'! |
1225 |
||
1226 |
documentation |
|
1227 |
" |
|
1864 | 1228 |
like a string, but knows that it represents a mimeType. |
1612 | 1229 |
" |
1230 |
! ! |
|
1231 |
||
1232 |
!MIMETypes::MIMEType class methodsFor:'initialization'! |
|
1233 |
||
1234 |
initialize |
|
1235 |
CachedTypes := CacheDictionary new:30. |
|
1236 |
||
1237 |
" |
|
1238 |
self initialize |
|
1239 |
" |
|
1240 |
! ! |
|
1241 |
||
1242 |
!MIMETypes::MIMEType class methodsFor:'instance creation'! |
|
1243 |
||
1244 |
fromString:aString |
|
1245 |
|cachedType newType| |
|
1246 |
||
1247 |
aString class == self ifTrue:[^ aString]. |
|
1248 |
||
1249 |
cachedType := CachedTypes at:aString ifAbsent:nil. |
|
1250 |
cachedType notNil ifTrue:[^ cachedType]. |
|
1251 |
newType := aString copy changeClassTo:self. |
|
1252 |
CachedTypes at:aString put:newType. |
|
1253 |
^ newType |
|
1254 |
||
1255 |
" |
|
1256 |
self fromString:'text/html' |
|
1257 |
" |
|
1258 |
! ! |
|
1259 |
||
1260 |
!MIMETypes::MIMEType methodsFor:'queries'! |
|
1261 |
||
1693 | 1262 |
isArchive |
1864 | 1263 |
"return true, if I represent an archive type (such as zip or tar)" |
1264 |
||
1612 | 1265 |
|archivTypes| |
1266 |
||
1729 | 1267 |
archivTypes := MIMETypes applicationCompressorsAndArchiveTypeList. |
1612 | 1268 |
archivTypes pairWiseDo:[: ext : type | |
1269 |
self = type ifTrue:[ ^ true]. |
|
1270 |
]. |
|
1271 |
^ false |
|
1272 |
! |
|
1273 |
||
2024 | 1274 |
isBinary |
1275 |
"return true, if I represent a binary (non-text) type" |
|
1276 |
||
1277 |
^ self isTextType not |
|
1278 |
! |
|
1279 |
||
1612 | 1280 |
isHtml |
1864 | 1281 |
"return true, if I represent the html text type" |
1612 | 1282 |
|
1283 |
^ (self = 'text/html') |
|
1284 |
! |
|
1285 |
||
1286 |
isImage |
|
1864 | 1287 |
"return true, if I represent an image type (such as gif or jpg)" |
1612 | 1288 |
|
1693 | 1289 |
^ (self startsWith:'image/') |
1612 | 1290 |
! |
1291 |
||
1292 |
isPdf |
|
1864 | 1293 |
"return true, if I represent the pdf type" |
1294 |
||
1612 | 1295 |
^ (self = 'application/pdf') |
1296 |
! |
|
1297 |
||
1298 |
isSmalltalkSource |
|
1864 | 1299 |
"return true, if I represent the smalltalk sourcecode type" |
1300 |
||
1612 | 1301 |
^ (self = 'application/x-smalltalk-source') |
1783 | 1302 |
! |
1303 |
||
2024 | 1304 |
isTextType |
1305 |
"return true, if I represent some text type" |
|
1306 |
||
1307 |
^ self startsWith:'text/' |
|
1308 |
! |
|
1309 |
||
1783 | 1310 |
isXml |
1864 | 1311 |
"return true, if I represent the xml text type" |
1312 |
||
1783 | 1313 |
^ (self = 'text/xml') |
2490 | 1314 |
! |
1315 |
||
1316 |
suffix |
|
1317 |
^ MIMETypes suffixForMimeType:self |
|
1318 |
||
1319 |
" |
|
1320 |
(MIMETypes mimeTypeFromString:'application/x-expecco-testsuite') suffix |
|
1321 |
" |
|
643 | 1322 |
! ! |
1323 |
||
1324 |
!MIMETypes class methodsFor:'documentation'! |
|
1325 |
||
1326 |
version |
|
2583 | 1327 |
^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.101 2008-12-13 10:39:21 cg Exp $' |
643 | 1328 |
! ! |
1666 | 1329 |
|
643 | 1330 |
MIMETypes initialize! |
1666 | 1331 |
MIMETypes::MIMEType initialize! |