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