author | Claus Gittinger <cg@exept.de> |
Wed, 05 Aug 2009 15:23:49 +0200 | |
changeset 2710 | 29d76b5bb816 |
parent 2588 | b833c2b7a356 |
child 2724 | 8e834e62dbbc |
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. |
|
2710 | 326 |
TypeToImageReaderClassMapping at:'image/png' put:PNGReader. |
1729 | 327 |
|
328 |
"/ setup suffix to image reader class mapping ... |
|
329 |
||
330 |
FileSuffixToImageReaderClassMapping at:'jpg' put:JPEGReader. |
|
331 |
FileSuffixToImageReaderClassMapping at:'gif' put:GIFReader. |
|
332 |
FileSuffixToImageReaderClassMapping at:'tif' put:TIFFReader. |
|
2710 | 333 |
FileSuffixToImageReaderClassMapping at:'png' put:PNGReader. |
2570 | 334 |
|
335 |
WindowsIconReader notNil ifTrue:[ |
|
336 |
TypeToImageReaderClassMapping at:'image/bmp' put:WindowsIconReader. |
|
337 |
FileSuffixToImageReaderClassMapping at:'bmp' put:WindowsIconReader. |
|
338 |
]. |
|
2298 | 339 |
! |
340 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
341 |
initializeParenthesisSpecMappings |
2298 | 342 |
|spec| |
343 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
344 |
TypeToParenthesisSpecMapping := Dictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
345 |
SuffixToParenthesisSpecMapping := Dictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
346 |
|
2298 | 347 |
"/ ST/X spec |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
348 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
349 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
350 |
spec at:#open put:#( $( $[ ${ ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
351 |
spec at:#close put:#( $) $] $} ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
352 |
spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
353 |
spec at:#eolComment put:'"/'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
354 |
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
|
355 |
|
2479 | 356 |
"/ XML & HTML |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
357 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
358 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
359 |
spec at:#open put:#( $< ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
360 |
spec at:#close put:#( $> ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
361 |
spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
362 |
#( '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
|
363 |
TypeToParenthesisSpecMapping at:eachXMLType put:spec |
2298 | 364 |
]. |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
365 |
|
2479 | 366 |
"/ ANSI-c, Java, C# |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
367 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
368 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
369 |
spec at:#open put:#( $( $[ ${ ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
370 |
spec at:#close put:#( $) $] $} ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
371 |
spec at:#ignore put:#( $' $" ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
372 |
spec at:#eolComment put:'//'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
373 |
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
|
374 |
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
|
375 |
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
|
376 |
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
|
377 |
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
|
378 |
|
2298 | 379 |
"/ Lisp |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
380 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
381 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
382 |
spec at:#open put:#( $( ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
383 |
spec at:#close put:#( $) ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
384 |
spec at:#ignore put:#( $" ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
385 |
spec at:#eolComment put:';'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
386 |
TypeToParenthesisSpecMapping at:'application/x-lisp-source' put:spec. |
2298 | 387 |
|
388 |
"Created: / 10-04-2007 / 15:16:37 / cg" |
|
1729 | 389 |
! ! |
390 |
||
391 |
!MIMETypes class methodsFor:'initialization-lists'! |
|
392 |
||
393 |
applicationCompressorsAndArchiveTypeList |
|
1604 | 394 |
^ #( |
1890 | 395 |
'tar' 'application/x-tar' |
396 |
'gtar' 'application/x-gtar' |
|
1891 | 397 |
('tgz' 'tar.gz') 'application/x-tar-gzip-compressed' "/ 'application/x-tar-compressed' |
398 |
('tar.bz2') 'application/x-tar-bzip2-compressed' |
|
1890 | 399 |
'zip' 'application/x-zip-compressed' |
400 |
'bz2' 'application/x-bzip2-compressed' |
|
401 |
('gz' 'z') 'application/x-gzip-compressed' |
|
402 |
'cpio' 'application/x-cpio' |
|
403 |
'shar' 'application/x-shar' |
|
404 |
'jar' 'application/java-archive' |
|
405 |
'sar' 'application/x-squeak-archive' |
|
406 |
'sit' 'application/x-stuffit' |
|
407 |
'hqx' 'application/mac-binhex40' |
|
408 |
'cpt' 'application/mac-compactpro' |
|
1604 | 409 |
) |
410 |
! |
|
645 | 411 |
|
1609 | 412 |
applicationMiscTypeList |
413 |
"misc applications" |
|
414 |
||
415 |
^ #( |
|
416 |
('a' 'o' 'obj' ) 'application/binary' |
|
417 |
'a' 'application/library' |
|
418 |
('dll' 'so') 'application/shared-library' |
|
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
419 |
|
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
420 |
('ets') 'application/x-expecco-testsuite' |
2489
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
421 |
('elf') 'application/x-expecco-logfile' |
1609 | 422 |
) |
423 |
! |
|
424 |
||
1604 | 425 |
applicationProgLangTypeList |
1606 | 426 |
"applications for programm languages" |
713 | 427 |
|
1604 | 428 |
^ #( |
1609 | 429 |
('st' 'cls' 'rc') 'application/x-smalltalk-source' |
1604 | 430 |
'sif' 'application/x-smalltalk-source-sif' |
1668 | 431 |
'pac' 'application/x-smalltalk-dolphin-package' |
1778 | 432 |
|
433 |
'sts' 'application/x-squeak-source' |
|
434 |
'pr' 'application/x-squeak-project' |
|
435 |
||
1604 | 436 |
'c' 'application/x-c-source' |
437 |
('cc' 'cpp') 'application/x-cpp-source' |
|
2479 | 438 |
'cs' 'application/x-csharp-source' |
1609 | 439 |
('h' 'hi') 'application/x-c-header' |
1604 | 440 |
('js' 'mocha') 'application/x-javascript' |
441 |
('java' 'jav') 'application/x-java-source' |
|
442 |
'sh' 'application/x-sh' |
|
443 |
'csh' 'application/x-csh' |
|
444 |
'tcl' 'application/x-tcl' |
|
445 |
'pl' 'application/x-perl' |
|
446 |
'mak' 'application/x-make' |
|
447 |
'bat' 'application/x-batch-script' |
|
2534 | 448 |
('asn1' 'x409' 'gdmo' 'gdm') 'application/x-asn1-source' |
449 |
('lisp' 'lsp' 'scm' 'ss' 'arc' 'cl') 'application/x-lisp-source' |
|
1604 | 450 |
) |
2298 | 451 |
|
452 |
"Modified: / 09-04-2007 / 09:46:04 / cg" |
|
1604 | 453 |
! |
1561 | 454 |
|
1604 | 455 |
applicationTextTypeList |
1606 | 456 |
"text applications" |
1604 | 457 |
|
458 |
^ #( |
|
459 |
('ps' 'eps') 'application/postscript' |
|
1778 | 460 |
"/ 'ai' 'application/postscript' |
1604 | 461 |
'pdf' 'application/pdf' |
462 |
'rtf' 'application/rtf' |
|
1778 | 463 |
"/ 'rtf' 'text/rtf' ???? |
464 |
"/ 'doc' 'application/winword' |
|
1779 | 465 |
'doc' 'application/ms-word-document' |
1778 | 466 |
'swf' 'application/x-shockwave-flash' |
467 |
('ppt' 'ppz' 'pot' 'pps') 'application/mspowerpoint' |
|
2028 | 468 |
'xls' 'application/x-excel' |
469 |
'slk' 'application/vnd.ms-excel' |
|
1604 | 470 |
) |
471 |
! |
|
472 |
||
473 |
applicationTypeList |
|
1606 | 474 |
"applications" |
1604 | 475 |
|
1729 | 476 |
|typeList| |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
477 |
|
1729 | 478 |
typeList := OrderedCollection new. |
479 |
typeList addAll:self applicationProgLangTypeList. |
|
480 |
typeList addAll:self applicationTextTypeList. |
|
481 |
typeList addAll:self applicationCompressorsAndArchiveTypeList. |
|
482 |
typeList addAll:self applicationMiscTypeList. |
|
1616 | 483 |
|
1729 | 484 |
^ typeList |
1604 | 485 |
! |
486 |
||
487 |
audioTypeList |
|
1606 | 488 |
"audio formats ..." |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
489 |
|
1604 | 490 |
^ #( |
1720 | 491 |
('au' 'snd') 'audio/basic' |
1778 | 492 |
('ra') 'audio/x-realaudio' |
493 |
('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
|
494 |
"/ cg: see unixSpecific / windowsSpecific |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
495 |
"/ 'rpm' 'audio/x-pn-realaudio-plugin' |
1720 | 496 |
('mpa' 'mpega') 'audio/mpeg' |
1778 | 497 |
"/ 'mp3' 'audio/x-mp3' |
498 |
('mp3' 'mp2') 'audio/mpeg' |
|
1604 | 499 |
'wav' 'audio/x-wav' |
500 |
('aif' 'aiff' 'aifc') 'audio/x-aiff' |
|
1778 | 501 |
('midi' 'mid') 'audio/midi' |
1604 | 502 |
) |
503 |
! |
|
504 |
||
505 |
imageTypeList |
|
506 |
||
507 |
^ #( |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
508 |
"/ image formats ... |
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
509 |
|
1216 | 510 |
('jpg' 'jpeg') 'image/jpeg' |
1188 | 511 |
'gif' 'image/gif' |
512 |
('tif' 'tiff') 'image/tiff' |
|
513 |
'xbm' 'image/x-xbitmap' |
|
514 |
'xpm' 'image/x-xpixmap' |
|
1720 | 515 |
'png' 'image/png' |
1188 | 516 |
'pcd' 'image/x-photo-cd' |
517 |
'bmp' 'image/x-MS-bmp' |
|
518 |
'rgb' 'image/x-rgb' |
|
519 |
'ppm' 'image/x-portable-pixmap' |
|
520 |
'pgm' 'image/x-portable-graymap' |
|
521 |
'pbm' 'image/x-portable-bitmap' |
|
522 |
'pnm' 'image/x-portable-anymap' |
|
523 |
'xwd' 'image/x-xwindowdump' |
|
524 |
'ras' 'image/x-cmu-raster' |
|
1216 | 525 |
'tga' 'image/x-targa' |
2020 | 526 |
'ico' 'image/x-ico' |
1604 | 527 |
) |
528 |
! |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
529 |
|
1609 | 530 |
miscFilenameList |
531 |
"other formats (not by suffix, but by fileName isnstead) ..." |
|
532 |
||
533 |
^ #( |
|
2113 | 534 |
('makefile' 'make.proto' 'make.spec' 'nt.mak') 'application/x-make' |
535 |
('exe' 'bin') 'application/octet-stream' |
|
536 |
('class') 'application/octet-stream' |
|
2375 | 537 |
('top') 'application/x-waltop-digital-notepad' |
1609 | 538 |
) |
539 |
! |
|
540 |
||
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
541 |
osSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
542 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
543 |
^ self windowsSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
544 |
]. |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
545 |
^ self unixSpecificTypeList |
2023 | 546 |
|
547 |
" |
|
548 |
self osSpecificTypeList |
|
549 |
" |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
550 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
551 |
|
1604 | 552 |
textTypeList |
553 |
"/ misc text ... |
|
554 |
||
555 |
^ #( |
|
1887 | 556 |
('html' 'htm' 'shtml') 'text/html' |
1604 | 557 |
('txt' 'text') 'text/plain' |
1680 | 558 |
'xml' 'text/xml' |
1777 | 559 |
'css' 'text/css' |
2432 | 560 |
'csv' 'text/csv' |
1604 | 561 |
) |
562 |
! |
|
563 |
||
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
564 |
unixSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
565 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
566 |
^ #( |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
567 |
"/ 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
|
568 |
"/ 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
|
569 |
'rpm' 'application/x-rpm' |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
570 |
) |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
571 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
572 |
|
1604 | 573 |
videoTypeList |
574 |
"/ video formats ... |
|
575 |
||
576 |
^ #( |
|
1720 | 577 |
('qt' 'mov' 'moov') 'video/quicktime' |
578 |
('mpv' 'mpegv' 'mpg' 'mpeg' 'mpe') 'video/mpeg' |
|
1604 | 579 |
'movie' 'video/x-sgi-movie' |
1820 | 580 |
('avi' 'wmv' 'asf') 'video/x-msvideo' |
1604 | 581 |
('mpv2' 'mp2v' 'mp2' 'mpeg2') 'video/x-mpeg2' |
1680 | 582 |
'rm' 'application/vnd.rn-realmedia' |
583 |
'rv' 'video/x-pn-realvideo' |
|
1778 | 584 |
) |
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
585 |
! |
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 |
windowsSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
588 |
^ #( |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
589 |
"/ 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
|
590 |
"/ 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
|
591 |
'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
|
592 |
) |
643 | 593 |
! ! |
594 |
||
1729 | 595 |
!MIMETypes class methodsFor:'obsolete'! |
1489 | 596 |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
597 |
defaultCommandForMimeType:mimeType |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
598 |
<resource: #obsolete> |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
599 |
self obsoleteMethodWarning:'use #defaultCommandTemplateToOpenMimeType:'. |
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 |
^ self defaultCommandTemplateToOpenMimeType:mimeType |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
602 |
|
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 |
MIMETypes defaultCommandForMimeType:'application/pdf' |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
605 |
" |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
606 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
607 |
"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
|
608 |
"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
|
609 |
! |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
610 |
|
1729 | 611 |
fontForCharset:aCharSetName |
612 |
"return the font-encoding for an iso-charset" |
|
1489 | 613 |
|
1981 | 614 |
<resource:#obsolete> |
1729 | 615 |
self obsoleteMethodWarning:'use FontDescription >> fontNamePatternForCharset:'. |
616 |
^ FontDescription fontNamePatternForCharset:aCharSetName. |
|
1489 | 617 |
|
618 |
" |
|
1729 | 619 |
MIMETypes fontForCharset:'iso2022-jp' |
620 |
MIMETypes fontForCharset:'euc-jp' |
|
1472 | 621 |
" |
622 |
||
1729 | 623 |
"Modified: / 1.8.1998 / 17:00:57 / cg" |
624 |
! ! |
|
1472 | 625 |
|
1729 | 626 |
!MIMETypes class methodsFor:'queries'! |
1472 | 627 |
|
647 | 628 |
defineImageType:mimeType suffix:aSuffix reader:aReaderClass |
629 |
"register an image reader." |
|
630 |
||
631 |
aSuffix notNil ifTrue:[ |
|
632 |
self imageReaderForSuffix:aSuffix put:aReaderClass. |
|
633 |
]. |
|
634 |
||
635 |
mimeType notNil ifTrue:[ |
|
636 |
self imageReaderForType:mimeType put:aReaderClass |
|
637 |
]. |
|
638 |
||
639 |
(aSuffix notNil and:[mimeType notNil]) ifTrue:[ |
|
640 |
self mimeTypeForSuffix:aSuffix put:mimeType |
|
641 |
]. |
|
642 |
! |
|
643 |
||
643 | 644 |
fileSuffixToImageReaderMapping |
1021 | 645 |
"return the suffix-to-imageReader mapping" |
646 |
||
643 | 647 |
^ FileSuffixToImageReaderClassMapping ? #() |
648 |
||
1021 | 649 |
"Modified: / 1.8.1998 / 17:00:11 / cg" |
643 | 650 |
! |
651 |
||
652 |
imageFileSuffixes |
|
1021 | 653 |
"return a collection with known file suffixes" |
654 |
||
643 | 655 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[^ #()]. |
656 |
^ FileSuffixToImageReaderClassMapping keys |
|
657 |
||
1021 | 658 |
"Created: / 30.6.1997 / 22:04:48 / cg" |
659 |
"Modified: / 1.8.1998 / 17:01:26 / cg" |
|
643 | 660 |
! |
661 |
||
1473 | 662 |
mimeTypeForFilename:filenameArg |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
663 |
"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
|
664 |
|
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
665 |
|type filename lcFilename suff suff2| |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
666 |
|
1473 | 667 |
filename := filenameArg asFilename. |
1474 | 668 |
|
669 |
lcFilename := filename baseName asLowercase. |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
670 |
type := FilenameToTypeMapping at:lcFilename ifAbsent:nil. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
671 |
type isNil ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
672 |
"/ allow for fallback ... |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
673 |
type := OperatingSystem mimeTypeForFilename:lcFilename. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
674 |
"/ 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
|
675 |
"/ 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
|
676 |
"/ the OS. |
1275 | 677 |
"/ type isNil ifTrue:[ |
678 |
"/ FilenameToTypeMapping at:lcFilename put:#unknown |
|
679 |
"/ ]. |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
680 |
]. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
681 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
682 |
type == #unknown ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
683 |
type := nil. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
684 |
]. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
685 |
|
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
686 |
type isNil ifTrue:[ |
1473 | 687 |
suff := filename suffix. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
688 |
suff size ~~ 0 ifTrue:[ |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
689 |
"/ sigh - special code for multiple-suffices... |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
690 |
"/ .tar.gz -> tgz |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
691 |
suff2 := filename withoutSuffix suffix. |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
692 |
suff2 size > 0 ifTrue:[ |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
693 |
type := self mimeTypeForSuffix:(suff2 , '.' , suff). |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
694 |
]. |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
695 |
type isNil ifTrue:[ |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
696 |
type := self mimeTypeForSuffix:suff |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
697 |
]. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
698 |
] |
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
699 |
]. |
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
700 |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
701 |
^ type |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
702 |
|
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
703 |
" |
1841 | 704 |
self mimeTypeForFilename:'typeinst.dvi' |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
705 |
self mimeTypeForFilename:'foo.tar' |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
706 |
self mimeTypeForFilename:'foo.tgz' |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
707 |
self mimeTypeForFilename:'foo.tar.gz' |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
708 |
" |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
709 |
! |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
710 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
711 |
mimeTypeForFilename:filename put:mimeType |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
712 |
"register a mime type for a filename" |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
713 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
714 |
FilenameToTypeMapping isNil ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
715 |
FilenameToTypeMapping := Dictionary new |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
716 |
]. |
1612 | 717 |
FilenameToTypeMapping at:filename put:(MIMEType fromString:mimeType asLowercase) |
1611 | 718 |
! |
719 |
||
643 | 720 |
mimeTypeForSuffix:suffix |
1021 | 721 |
"given a file suffix, return the mime-type" |
722 |
||
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
723 |
|type lcSuffix| |
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
724 |
|
1837 | 725 |
suffix = LastSuffix ifTrue:[ |
726 |
^ LastType |
|
727 |
]. |
|
728 |
||
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
729 |
lcSuffix := suffix asLowercase. |
1837 | 730 |
type := FileSuffixToTypeMapping at:lcSuffix ifAbsent:nil. |
731 |
type isNil ifTrue:[ |
|
732 |
"/ allow for fallback ... |
|
733 |
type := OperatingSystem mimeTypeForSuffix:lcSuffix. |
|
734 |
"/ the special value #unknown is returned as nil; |
|
735 |
"/ this avoids constant retry if a mimeType is not known in the OS. |
|
736 |
||
737 |
type := type ? #unknown. |
|
738 |
FileSuffixToTypeMapping at:lcSuffix put:type. |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
739 |
]. |
1837 | 740 |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
741 |
type == #unknown ifTrue:[ |
1837 | 742 |
type := nil. |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
743 |
]. |
1840 | 744 |
type notNil ifTrue:[ |
745 |
LastSuffix := suffix. |
|
746 |
LastType := MIMEType fromString:type. |
|
747 |
^ LastType |
|
748 |
]. |
|
1841 | 749 |
^ type |
643 | 750 |
|
1666 | 751 |
" |
1840 | 752 |
self mimeTypeForSuffix:'gif' |
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
753 |
self mimeTypeForSuffix:'rpm' |
1666 | 754 |
" |
755 |
||
1021 | 756 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
1300 | 757 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
643 | 758 |
! |
759 |
||
760 |
mimeTypeForSuffix:suffix put:mimeType |
|
1021 | 761 |
"register a mime type for a file suffix" |
762 |
||
643 | 763 |
FileSuffixToTypeMapping isNil ifTrue:[ |
764 |
FileSuffixToTypeMapping := Dictionary new |
|
765 |
]. |
|
766 |
FileSuffixToTypeMapping at:suffix put:mimeType asLowercase |
|
767 |
||
1021 | 768 |
"Created: / 30.6.1997 / 21:56:20 / cg" |
769 |
"Modified: / 1.8.1998 / 17:03:18 / cg" |
|
1593 | 770 |
! |
771 |
||
772 |
mimeTypeForSuffixMapping |
|
773 |
||
774 |
^ FileSuffixToTypeMapping |
|
1611 | 775 |
! |
776 |
||
2023 | 777 |
mimeTypeFromString:mimeTypeString |
778 |
"given a mime-type for a string" |
|
779 |
||
780 |
^ MIMEType fromString:mimeTypeString |
|
781 |
||
782 |
" |
|
783 |
self mimeTypeFromString:'image/gif' |
|
2487
eaa224da42fa
mimeType: x-expecco-testsuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2486
diff
changeset
|
784 |
self mimeTypeFromString:'application/x-expecco-testsuite' |
2023 | 785 |
" |
786 |
! |
|
787 |
||
1611 | 788 |
mimeTypeOfContents:filename |
789 |
"given a filename, scan the contents, return the mime-type or nil, if unknown" |
|
790 |
||
1612 | 791 |
|typeString| |
792 |
||
793 |
typeString := filename mimeTypeOfContents. |
|
794 |
typeString isNil ifTrue:[^ nil]. |
|
795 |
^ MIMEType fromString:typeString. |
|
1887 | 796 |
! |
797 |
||
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
798 |
mimeTypeOfData:someData |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
799 |
"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
|
800 |
Returns nil, if unknown. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
801 |
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
|
802 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
803 |
|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
|
804 |
|
2583 | 805 |
someData isEmptyOrNil ifTrue:[^ nil]. |
806 |
||
807 |
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
|
808 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
809 |
"/ read some data from the file ... |
2583 | 810 |
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
|
811 |
lcBuffer := buffer asLowercase. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
812 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
813 |
(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
|
814 |
idx := idx + 'mimetype:' size. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
815 |
idx := lcBuffer indexOfNonSeparatorStartingAt:idx. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
816 |
idx2 := lcBuffer indexOfSeparatorStartingAt:idx. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
817 |
idx2 > idx ifTrue:[ |
2583 | 818 |
^ 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
|
819 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
820 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
821 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
822 |
#( |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
823 |
( #[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
|
824 |
#'application/x-ms-shortcut' ) |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
825 |
( 'WALTOP' |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
826 |
#'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
|
827 |
) pairsDo:[:pattern :what | |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
828 |
|patternString| |
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 |
patternString := pattern asString. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
831 |
(buffer startsWith:patternString) ifTrue:[ |
2583 | 832 |
^ MIMEType fromString:what |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
833 |
] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
834 |
]. |
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 |
#( |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
837 |
('<body:' #'text/html') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
838 |
('%!!ps-adobe' #'application/postscript') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
839 |
('%PDF-' #'application/pdf') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
840 |
('#!! /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
|
841 |
('#!!/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
|
842 |
"/ ('#!! /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
|
843 |
"/ ('#!!/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
|
844 |
('<?xml version=' #'text/xml') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
845 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
846 |
('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
|
847 |
('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
|
848 |
('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
|
849 |
('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
|
850 |
('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
|
851 |
('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
|
852 |
('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
|
853 |
('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
|
854 |
('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
|
855 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
856 |
) pairsDo:[:pattern :what | |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
857 |
(lcBuffer findString:pattern) ~~ 0 ifTrue:[ |
2583 | 858 |
^ MIMEType fromString:what |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
859 |
] |
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 |
(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
|
863 |
((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
|
864 |
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
|
865 |
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
|
866 |
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
|
867 |
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
|
868 |
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
|
869 |
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
|
870 |
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
|
871 |
ifTrue:[ |
2583 | 872 |
^ 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
|
873 |
] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
874 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
875 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
876 |
[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
|
877 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
878 |
size == 0 ifTrue:[ |
2583 | 879 |
^ 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
|
880 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
881 |
^ nil |
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 |
|
1887 | 884 |
suffixForMimeType:mimeType |
885 |
"given a file suffix, return the mime-type" |
|
886 |
||
887 |
^ TypeToFileSuffixMapping at:mimeType ifAbsent:nil |
|
888 |
||
889 |
" |
|
890 |
self suffixForMimeType:(MIMEType fromString:'image/gif') |
|
891 |
" |
|
892 |
||
893 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
|
894 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
|
895 |
! |
|
896 |
||
897 |
suffixForMimeTypeString:mimeTypeString |
|
898 |
"given a file suffix, return the mime-type" |
|
899 |
||
900 |
^ self suffixForMimeType:(MIMEType fromString:mimeTypeString) |
|
901 |
||
902 |
" |
|
903 |
self suffixForMimeTypeString:'image/gif' |
|
904 |
" |
|
905 |
||
906 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
|
907 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
|
1612 | 908 |
! ! |
909 |
||
2116 | 910 |
!MIMETypes class methodsFor:'queries-applications'! |
911 |
||
2117 | 912 |
defaultCommandPerMIME |
913 |
"returns the collection which is used to map MIME-type to command-templates." |
|
914 |
||
915 |
"TODO: move this to OS/UserPreferences" |
|
916 |
||
917 |
DefaultCommandPerMIMEPerOS isNil ifTrue:[ |
|
918 |
self initializeDefaultCommands |
|
919 |
]. |
|
920 |
OperatingSystem isUNIXlike ifTrue:[ |
|
921 |
^ DefaultCommandPerMIMEPerOS at:#unix |
|
922 |
]. |
|
923 |
^ DefaultCommandPerMIMEPerOS at:#win32 |
|
924 |
! |
|
925 |
||
2116 | 926 |
defaultCommandTemplateToOpenMimeType:mimeType |
927 |
|cmd| |
|
928 |
||
929 |
cmd := self defaultCommandPerMIME at:mimeType ifAbsent:nil. |
|
930 |
cmd isNil ifTrue:[ |
|
931 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
932 |
cmd := Win32OperatingSystem::RegistryEntry commandTemplateToOpenMimeType:mimeType |
|
933 |
]. |
|
934 |
]. |
|
935 |
^ cmd |
|
936 |
||
937 |
" |
|
938 |
MIMETypes defaultCommandTemplateToOpenMimeType:'application/pdf' |
|
2118 | 939 |
MIMETypes defaultCommandTemplateToOpenMimeType:'text/html' |
2116 | 940 |
" |
941 |
||
942 |
"Created: / 12-05-2004 / 11:09:22 / cg" |
|
943 |
"Modified: / 12-05-2004 / 11:16:53 / cg" |
|
944 |
! |
|
945 |
||
946 |
defaultCommandTemplateToPrintMimeType:mimeType |
|
947 |
|cmd| |
|
948 |
||
949 |
cmd := self defaultPrintCommandPerMIME at:mimeType ifAbsent:nil. |
|
950 |
cmd isNil ifTrue:[ |
|
951 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
952 |
cmd := Win32OperatingSystem::RegistryEntry commandTemplateToPrintMimeType:mimeType |
|
953 |
]. |
|
954 |
]. |
|
955 |
^ cmd |
|
956 |
||
957 |
" |
|
958 |
MIMETypes defaultCommandTemplateToPrintMimeType:'application/pdf' |
|
959 |
" |
|
2117 | 960 |
! |
961 |
||
962 |
defaultPrintCommandPerMIME |
|
963 |
"returns the collection which is used to map MIME-type to printing command-templates." |
|
964 |
||
965 |
"TODO: move this to OS/UserPreferences" |
|
966 |
||
967 |
DefaultPrintCommandPerMIMEPerOS isNil ifTrue:[ |
|
968 |
self initializeDefaultCommands |
|
969 |
]. |
|
970 |
OperatingSystem isUNIXlike ifTrue:[ |
|
971 |
^ DefaultPrintCommandPerMIMEPerOS at:#unix |
|
972 |
]. |
|
973 |
^ DefaultPrintCommandPerMIMEPerOS at:#win32 |
|
2116 | 974 |
! ! |
975 |
||
1729 | 976 |
!MIMETypes class methodsFor:'queries-image formats'! |
977 |
||
978 |
imageReaderClasses |
|
979 |
"return a collection of registered image reader classes" |
|
980 |
||
981 |
|setOfClasses| |
|
982 |
||
983 |
setOfClasses := IdentitySet new. |
|
984 |
FileSuffixToImageReaderClassMapping notNil ifTrue:[ |
|
985 |
FileSuffixToImageReaderClassMapping keysAndValuesDo:[:suff :cls | |
|
986 |
setOfClasses add:cls |
|
987 |
]. |
|
988 |
]. |
|
989 |
TypeToImageReaderClassMapping notNil ifTrue:[ |
|
990 |
TypeToImageReaderClassMapping keysAndValuesDo:[:suff :cls | |
|
991 |
setOfClasses add:cls |
|
992 |
]. |
|
993 |
]. |
|
994 |
^ setOfClasses |
|
995 |
||
996 |
"Created: / 30.6.1997 / 22:03:42 / cg" |
|
997 |
"Modified: / 1.8.1998 / 16:59:52 / cg" |
|
998 |
! |
|
999 |
||
1000 |
imageReaderForSuffix:aSuffix |
|
1001 |
"given a file suffix, return an approriate image reader class" |
|
1002 |
||
1003 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[^ nil]. |
|
1004 |
^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil |
|
1005 |
||
1006 |
"Created: / 30.6.1997 / 21:59:11 / cg" |
|
1007 |
"Modified: / 1.8.1998 / 17:01:58 / cg" |
|
1008 |
! |
|
1009 |
||
1010 |
imageReaderForSuffix:aSuffix put:aReaderClass |
|
1011 |
"register an image reader for a file suffix" |
|
1012 |
||
1013 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
|
1014 |
FileSuffixToImageReaderClassMapping := Dictionary new. |
|
1015 |
]. |
|
1016 |
FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass |
|
1017 |
||
1018 |
"Created: / 30.6.1997 / 21:59:43 / cg" |
|
1019 |
"Modified: / 1.8.1998 / 17:02:14 / cg" |
|
1020 |
! |
|
1021 |
||
1022 |
imageReaderForType:mimeTypeString |
|
1023 |
"given a mime-type, return an approriate image reader class" |
|
1024 |
||
1025 |
TypeToImageReaderClassMapping isNil ifTrue:[^ nil]. |
|
1026 |
^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil |
|
1027 |
||
1028 |
"Created: / 30.6.1997 / 21:56:01 / cg" |
|
1029 |
"Modified: / 1.8.1998 / 17:02:28 / cg" |
|
1030 |
! |
|
1031 |
||
1032 |
imageReaderForType:mimeTypeString put:aReaderClass |
|
1033 |
"register an image reader for a mime-type" |
|
1034 |
||
1035 |
TypeToImageReaderClassMapping isNil ifTrue:[ |
|
1036 |
TypeToImageReaderClassMapping := Dictionary new. |
|
1037 |
]. |
|
1038 |
TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass |
|
1039 |
||
1040 |
"Created: / 30.6.1997 / 21:56:11 / cg" |
|
1041 |
"Modified: / 1.8.1998 / 17:02:40 / cg" |
|
1042 |
! ! |
|
1043 |
||
1044 |
!MIMETypes class methodsFor:'queries-language syntax'! |
|
1045 |
||
1046 |
commentStringsForFilename:aFilename |
|
1047 |
"return a useful comment definition; heuristics for now. |
|
1048 |
The returned value is an array of 2 elements; |
|
1049 |
the first is the end-of-line comment string (or nil); |
|
1050 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1051 |
||
1052 |
|mime| |
|
1053 |
||
1054 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
1055 |
^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) |
|
1056 |
||
1057 |
" |
|
1058 |
MIMETypes commentStringsForFilename:'Makefile'. |
|
1059 |
MIMETypes commentStringsForFilename:'Object.st'. |
|
1060 |
MIMETypes commentStringsForFilename:'Foo.java'. |
|
1925 | 1061 |
MIMETypes commentStringsForFilename:'Foo.html'. |
1729 | 1062 |
" |
1063 |
! |
|
1064 |
||
1065 |
commentStringsForFilename:aFilename ifUnknown:alternativeBlockReturningCommentString |
|
1066 |
"return a useful comment definition; heuristics for now. |
|
1067 |
The returned value is an array of 2 elements; |
|
1068 |
the first is the end-of-line comment string (or nil); |
|
1069 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1070 |
||
1071 |
|mime| |
|
1072 |
||
1073 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
1074 |
^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternativeBlockReturningCommentString |
|
1075 |
||
1076 |
" |
|
1077 |
MIMETypes commentStringsForFilename:'Makefile'. |
|
1078 |
MIMETypes commentStringsForFilename:'Object.st'. |
|
1079 |
MIMETypes commentStringsForFilename:'Foo.java'. |
|
1080 |
" |
|
1081 |
! |
|
1082 |
||
1083 |
commentStringsForMimeType:mime suffix:suff |
|
1084 |
"return a useful comment definition; heuristics for now. |
|
1085 |
The returned value is an array of 2 elements; |
|
1086 |
the first is the end-of-line comment string (or nil); |
|
1087 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1088 |
||
1089 |
^ self |
|
1090 |
commentStringsForMimeType:mime suffix:suff |
|
1091 |
ifUnknown: #(';' (nil nil)) |
|
1092 |
||
1093 |
" |
|
1094 |
|mime| |
|
1095 |
||
1096 |
mime := MIMETypes mimeTypeForFilename:'Makefile'. |
|
1097 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1098 |
" |
|
1099 |
||
1100 |
" |
|
1101 |
|mime| |
|
1102 |
||
1103 |
mime := MIMETypes mimeTypeForFilename:'Object.st'. |
|
1104 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1105 |
" |
|
1106 |
! |
|
1107 |
||
1108 |
commentStringsForMimeType:mime suffix:suff ifUnknown:alternativeBlockReturningCommentString |
|
1109 |
"return a useful comment definition; heuristics for now. |
|
1110 |
The returned value is an array of 2 elements; |
|
1111 |
the first is the end-of-line comment string (or nil); |
|
1112 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1113 |
||
1114 |
|commentSpec| |
|
1115 |
||
1116 |
commentSpec := TypeToCommentStringMapping at:mime ifAbsent:nil. |
|
1117 |
commentSpec notNil ifTrue:[ |
|
1118 |
^ commentSpec |
|
1119 |
]. |
|
1120 |
||
1121 |
commentSpec := SuffixToCommentStringMapping at:suff ifAbsent:nil. |
|
1122 |
commentSpec notNil ifTrue:[ |
|
1123 |
^ commentSpec |
|
1124 |
]. |
|
1125 |
||
1126 |
^ alternativeBlockReturningCommentString value |
|
1127 |
||
1128 |
" |
|
1129 |
|mime| |
|
1130 |
||
1131 |
mime := MIMETypes mimeTypeForFilename:'Makefile'. |
|
1132 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1133 |
" |
|
1134 |
||
1135 |
" |
|
1136 |
|mime| |
|
1137 |
||
1138 |
mime := MIMETypes mimeTypeForFilename:'Object.st'. |
|
1139 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1140 |
" |
|
2298 | 1141 |
! |
1142 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1143 |
parenthesisSpecForFilename:aFilename |
2298 | 1144 |
"return a useful parentesis spec; heuristics for now. |
1145 |
The returned value is a dictionary to be used as parentesis spec in an editor" |
|
1146 |
||
1147 |
|mime| |
|
1148 |
||
1149 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1150 |
^ self parenthesisSpecForMimeType:mime suffix:(aFilename asFilename suffix) |
2298 | 1151 |
|
1152 |
" |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1153 |
MIMETypes parenthesisSpecForFilename:'Object.st'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1154 |
MIMETypes parenthesisSpecForFilename:'Foo.java'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1155 |
MIMETypes parenthesisSpecForFilename:'Foo.html'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1156 |
MIMETypes parenthesisSpecForFilename:'Foo.lsp'. |
2298 | 1157 |
" |
1158 |
||
1159 |
"Created: / 10-04-2007 / 15:18:41 / cg" |
|
1160 |
! |
|
1161 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1162 |
parenthesisSpecForFilename:aFilename ifUnknown:alternative |
2298 | 1163 |
|mime| |
1164 |
||
1165 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1166 |
^ self parenthesisSpecForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternative |
2298 | 1167 |
|
1168 |
"Created: / 10-04-2007 / 15:26:20 / cg" |
|
1169 |
! |
|
1170 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1171 |
parenthesisSpecForMimeType:mime suffix:suff |
2298 | 1172 |
^ self |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1173 |
parenthesisSpecForMimeType:mime suffix:suff |
2298 | 1174 |
ifUnknown: nil |
1175 |
||
1176 |
"Created: / 10-04-2007 / 15:19:39 / cg" |
|
1177 |
! |
|
1178 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1179 |
parenthesisSpecForMimeType:mime suffix:suff ifUnknown:alternativeValue |
2298 | 1180 |
|spec| |
1181 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1182 |
spec := TypeToParenthesisSpecMapping at:mime ifAbsent:nil. |
2298 | 1183 |
spec notNil ifTrue:[ |
1184 |
^ spec |
|
1185 |
]. |
|
1186 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1187 |
spec := SuffixToParenthesisSpecMapping at:suff ifAbsent:nil. |
2298 | 1188 |
spec notNil ifTrue:[ |
1189 |
^ spec |
|
1190 |
]. |
|
1191 |
||
1192 |
^ alternativeValue value |
|
1193 |
||
1194 |
"Created: / 10-04-2007 / 15:20:38 / cg" |
|
1729 | 1195 |
! ! |
1196 |
||
1612 | 1197 |
!MIMETypes::MIMEType class methodsFor:'documentation'! |
1198 |
||
1199 |
documentation |
|
1200 |
" |
|
1864 | 1201 |
like a string, but knows that it represents a mimeType. |
1612 | 1202 |
" |
1203 |
! ! |
|
1204 |
||
1205 |
!MIMETypes::MIMEType class methodsFor:'initialization'! |
|
1206 |
||
1207 |
initialize |
|
1208 |
CachedTypes := CacheDictionary new:30. |
|
1209 |
||
1210 |
" |
|
1211 |
self initialize |
|
1212 |
" |
|
1213 |
! ! |
|
1214 |
||
1215 |
!MIMETypes::MIMEType class methodsFor:'instance creation'! |
|
1216 |
||
1217 |
fromString:aString |
|
1218 |
|cachedType newType| |
|
1219 |
||
1220 |
aString class == self ifTrue:[^ aString]. |
|
1221 |
||
1222 |
cachedType := CachedTypes at:aString ifAbsent:nil. |
|
1223 |
cachedType notNil ifTrue:[^ cachedType]. |
|
1224 |
newType := aString copy changeClassTo:self. |
|
1225 |
CachedTypes at:aString put:newType. |
|
1226 |
^ newType |
|
1227 |
||
1228 |
" |
|
1229 |
self fromString:'text/html' |
|
1230 |
" |
|
1231 |
! ! |
|
1232 |
||
1233 |
!MIMETypes::MIMEType methodsFor:'queries'! |
|
1234 |
||
1693 | 1235 |
isArchive |
1864 | 1236 |
"return true, if I represent an archive type (such as zip or tar)" |
1237 |
||
1612 | 1238 |
|archivTypes| |
1239 |
||
1729 | 1240 |
archivTypes := MIMETypes applicationCompressorsAndArchiveTypeList. |
1612 | 1241 |
archivTypes pairWiseDo:[: ext : type | |
1242 |
self = type ifTrue:[ ^ true]. |
|
1243 |
]. |
|
1244 |
^ false |
|
1245 |
! |
|
1246 |
||
2024 | 1247 |
isBinary |
1248 |
"return true, if I represent a binary (non-text) type" |
|
1249 |
||
1250 |
^ self isTextType not |
|
1251 |
! |
|
1252 |
||
1612 | 1253 |
isHtml |
1864 | 1254 |
"return true, if I represent the html text type" |
1612 | 1255 |
|
1256 |
^ (self = 'text/html') |
|
1257 |
! |
|
1258 |
||
1259 |
isImage |
|
1864 | 1260 |
"return true, if I represent an image type (such as gif or jpg)" |
1612 | 1261 |
|
1693 | 1262 |
^ (self startsWith:'image/') |
1612 | 1263 |
! |
1264 |
||
1265 |
isPdf |
|
1864 | 1266 |
"return true, if I represent the pdf type" |
1267 |
||
1612 | 1268 |
^ (self = 'application/pdf') |
1269 |
! |
|
1270 |
||
1271 |
isSmalltalkSource |
|
1864 | 1272 |
"return true, if I represent the smalltalk sourcecode type" |
1273 |
||
1612 | 1274 |
^ (self = 'application/x-smalltalk-source') |
1783 | 1275 |
! |
1276 |
||
2024 | 1277 |
isTextType |
1278 |
"return true, if I represent some text type" |
|
1279 |
||
1280 |
^ self startsWith:'text/' |
|
1281 |
! |
|
1282 |
||
1783 | 1283 |
isXml |
1864 | 1284 |
"return true, if I represent the xml text type" |
1285 |
||
1783 | 1286 |
^ (self = 'text/xml') |
2490 | 1287 |
! |
1288 |
||
1289 |
suffix |
|
1290 |
^ MIMETypes suffixForMimeType:self |
|
1291 |
||
1292 |
" |
|
1293 |
(MIMETypes mimeTypeFromString:'application/x-expecco-testsuite') suffix |
|
1294 |
" |
|
643 | 1295 |
! ! |
1296 |
||
1297 |
!MIMETypes class methodsFor:'documentation'! |
|
1298 |
||
1299 |
version |
|
2710 | 1300 |
^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.103 2009-08-05 13:23:49 cg Exp $' |
643 | 1301 |
! ! |
1666 | 1302 |
|
643 | 1303 |
MIMETypes initialize! |
1666 | 1304 |
MIMETypes::MIMEType initialize! |