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