author | HG Automerge |
Thu, 19 Jan 2017 12:00:14 +0000 | |
branch | jv |
changeset 3854 | 4afd107bc911 |
parent 3756 | ca18095fa3c0 |
child 3862 | a5c6ef8ecf6a |
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 |
||
3451 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
643 | 16 |
Object subclass:#MIMETypes |
1612 | 17 |
instanceVariableNames:'' |
3691 | 18 |
classVariableNames:'CharSetToFontMapping DefaultCommandPerMIMEPerOS |
19 |
DefaultPrintCommandPerMIMEPerOS |
|
20 |
FileSuffixToImageReaderClassMapping FileSuffixToTypeMapping |
|
21 |
FilenameToTypeMapping LastSuffix LastType |
|
22 |
SuffixToCommentStringMapping SuffixToParenthesisSpecMapping |
|
23 |
TypeFromContentsDetectors TypeToCommentStringMapping |
|
24 |
TypeToFileSuffixMapping TypeToImageReaderClassMapping |
|
25 |
TypeToInfoMapping TypeToParenthesisSpecMapping |
|
26 |
TypeToViewerApplicationMapping' |
|
1612 | 27 |
poolDictionaries:'' |
1800 | 28 |
category:'Net-Communication-Support' |
1612 | 29 |
! |
30 |
||
3359 | 31 |
ImmutableString variableByteSubclass:#MIMEType |
1612 | 32 |
instanceVariableNames:'' |
33 |
classVariableNames:'CachedTypes' |
|
34 |
poolDictionaries:'' |
|
35 |
privateIn:MIMETypes |
|
643 | 36 |
! |
37 |
||
38 |
!MIMETypes class methodsFor:'documentation'! |
|
39 |
||
40 |
copyright |
|
41 |
" |
|
42 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
1612 | 43 |
All Rights Reserved |
643 | 44 |
|
45 |
This software is furnished under a license and may be used |
|
46 |
only in accordance with the terms of that license and with the |
|
47 |
inclusion of the above copyright notice. This software may not |
|
48 |
be provided or otherwise made available to, or used by, any |
|
49 |
other person. No title to or ownership of the software is |
|
50 |
hereby transferred. |
|
51 |
||
52 |
||
53 |
" |
|
54 |
! |
|
55 |
||
56 |
documentation |
|
57 |
" |
|
58 |
just a place to keep MIME information |
|
59 |
(avoid spreading things at many places) |
|
60 |
||
1021 | 61 |
MIMETypes is abstract and functional. |
62 |
Actually, in some OperatingSystems, this information may |
|
63 |
be found in some config files (or registries). |
|
64 |
Therefore, this class may have to be extended to support this |
|
65 |
and fetch the information from there eventually. |
|
66 |
||
643 | 67 |
[author:] |
68 |
Claus Gittinger |
|
69 |
" |
|
1311 | 70 |
! |
71 |
||
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
72 |
examples |
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
73 |
" |
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
74 |
[exBegin] |
3210 | 75 |
MIMETypes mimeTypeFromString:'text/plain' |
76 |
[exEnd] |
|
77 |
[exBegin] |
|
2487
eaa224da42fa
mimeType: x-expecco-testsuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2486
diff
changeset
|
78 |
MIMETypes mimeTypeFromString:'application/x-expecco-testsuite' |
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
79 |
[exEnd] |
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
80 |
|
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
81 |
[exBegin] |
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
82 |
MIMETypes mimeTypeForSuffix:'gif' |
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
83 |
MIMETypes mimeTypeForSuffix:'ets' |
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
84 |
MIMETypes mimeTypeForSuffix:'xlsx' |
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
85 |
[exEnd] |
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
86 |
" |
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
87 |
! |
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
88 |
|
1311 | 89 |
knownTypes |
90 |
" |
|
91 |
simply a reminder for me ... |
|
92 |
||
93 |
application mime file extentsions |
|
94 |
||
95 |
powerpoint application/ms-powerpoint .pot, .ppz, .ppt, .pps, |
|
96 |
application/mspowerpoint |
|
97 |
application/vnd.ms-powerpoint |
|
98 |
application/x-mspowerpoint |
|
99 |
||
1312 | 100 |
shockwave application/x-shockwave-flash .swf |
1311 | 101 |
|
1312 | 102 |
futuresplash application/futuresplash .spl |
1311 | 103 |
" |
643 | 104 |
! ! |
105 |
||
106 |
!MIMETypes class methodsFor:'initialization'! |
|
107 |
||
3691 | 108 |
addMimeTypeDetector:aMimeTypeFromContentsDetectorBlock |
109 |
"any class (especially: image readers) may add a block |
|
110 |
which detects the mime-type from a givel contents. |
|
111 |
The block is called with two arguments, some data (usually the first few kilobytes |
|
112 |
of a file) and the suffix of the file, or nil if unknown. |
|
113 |
The block should return the mimeType or nil." |
|
114 |
||
115 |
TypeFromContentsDetectors isNil ifTrue:[ TypeFromContentsDetectors := OrderedCollection new ]. |
|
116 |
TypeFromContentsDetectors add:aMimeTypeFromContentsDetectorBlock. |
|
117 |
! |
|
118 |
||
1729 | 119 |
initialize |
120 |
"initialize wellKnown facts" |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
121 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
122 |
MIMEType initialize. "must be initialized first" |
1729 | 123 |
LastSuffix := LastType := nil. |
124 |
self initializeFileNameToMimeTypeMapping. |
|
125 |
self initializeImageReaderMappings. |
|
126 |
self initializeCommentStringMappings. |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
127 |
self initializeParenthesisSpecMappings. |
3691 | 128 |
|
1729 | 129 |
" |
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
130 |
self initialize |
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
131 |
" |
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
132 |
|
2298 | 133 |
"Modified: / 10-04-2007 / 15:16:44 / cg" |
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
134 |
"Modified (comment): / 29-11-2011 / 19:11:51 / cg" |
1729 | 135 |
! |
136 |
||
137 |
initializeCommentStringMappings |
|
3359 | 138 |
"these are used by the editor's comment/uncomment functions" |
139 |
||
1729 | 140 |
TypeToCommentStringMapping := Dictionary new. |
141 |
SuffixToCommentStringMapping := Dictionary new. |
|
142 |
||
143 |
TypeToCommentStringMapping |
|
144 |
at:'application/x-make' |
|
3359 | 145 |
put:#('#' (nil nil)). "/ '#' EOL comments only |
1729 | 146 |
|
147 |
TypeToCommentStringMapping |
|
148 |
at:'application/x-sh' |
|
3359 | 149 |
put:#('#' (nil nil)). "/ '#' EOL comments only |
1729 | 150 |
|
2489
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
151 |
#('text/html' 'text/xml' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
152 |
'application/xml' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
153 |
'application/x-expecco-testsuite' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
154 |
'application/x-expecco-logfile' |
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
155 |
) |
1729 | 156 |
do:[:eachXMLType | |
157 |
TypeToCommentStringMapping |
|
158 |
at:eachXMLType |
|
159 |
put:#(nil ('<!!-- ' ' -->')). "/ '<!!-- ... -->' delimited comments only |
|
160 |
]. |
|
161 |
||
162 |
TypeToCommentStringMapping |
|
2055 | 163 |
at:'text/css' |
164 |
put:#('//' ('/*' '*/')). |
|
165 |
||
166 |
TypeToCommentStringMapping |
|
1729 | 167 |
at:'application/x-batch-script' |
2937
67ef44218dc0
changed: #initializeCommentStringMappings
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
168 |
put:#('@REM ' '@rem ' 'REM ' 'rem ' (nil nil)). "/ 'rem ' for EOL comments only |
1729 | 169 |
|
170 |
"/ the following is ST/X specific |
|
171 |
TypeToCommentStringMapping |
|
172 |
at:'application/x-smalltalk-source' |
|
173 |
put:#('"/' ('"' '"')). "/ '"/ ' for EOL; ".." for delimited comments |
|
174 |
||
175 |
"/ this is for standard smalltalk |
|
176 |
"/ TypeToCommentStringMapping |
|
177 |
"/ at:'application/x-smalltalk-source' |
|
178 |
"/ put:#(nil ('"' '"')). "/ ".." for delimited comments only |
|
179 |
||
180 |
||
181 |
TypeToCommentStringMapping |
|
182 |
at:'application/x-pascal-source' |
|
183 |
put:#(nil ('{' '}')). "/ '{'..'}' for delimited comments |
|
184 |
||
185 |
"/ this is ANSI-c |
|
186 |
TypeToCommentStringMapping |
|
187 |
at:'application/x-c-source' |
|
188 |
put:#('//' ('/*' '*/')). |
|
189 |
||
190 |
TypeToCommentStringMapping |
|
191 |
at:'application/x-cpp-source' |
|
192 |
put:#('//' ('/*' '*/')). |
|
193 |
||
194 |
TypeToCommentStringMapping |
|
2479 | 195 |
at:'application/x-csharp-source' |
196 |
put:#('//' ('/*' '*/')). |
|
197 |
||
198 |
TypeToCommentStringMapping |
|
1729 | 199 |
at:'application/x-java-source' |
200 |
put:#('//' ('/*' '*/')). |
|
201 |
||
202 |
TypeToCommentStringMapping |
|
2048
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
203 |
at:'application/x-javascript' |
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
204 |
put:#('//' ('/*' '*/')). |
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
205 |
|
dbb361dd9c5f
comment strings for javascript files
Claus Gittinger <cg@exept.de>
parents:
2028
diff
changeset
|
206 |
TypeToCommentStringMapping |
2298 | 207 |
at:'application/x-lisp-source' |
3482 | 208 |
put:#(';' (nil nil)). "/ ';' for EOL comments only |
209 |
||
210 |
TypeToCommentStringMapping |
|
211 |
at:'application/x-python-source' |
|
212 |
put:#('#' (nil nil)). "/ '#' for EOL comments only |
|
2298 | 213 |
|
214 |
TypeToCommentStringMapping |
|
1729 | 215 |
at:'application/x-asn1-source' |
216 |
put:#('--' ('--' '--')). |
|
217 |
||
218 |
||
219 |
"/ st/x support files |
|
220 |
SuffixToCommentStringMapping |
|
221 |
at:'style' |
|
222 |
put:#(';' (nil nil)). |
|
1604 | 223 |
|
1729 | 224 |
SuffixToCommentStringMapping |
225 |
at:'rs' |
|
2298 | 226 |
put:#(';' (nil nil)). |
227 |
||
2937
67ef44218dc0
changed: #initializeCommentStringMappings
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
228 |
"Modified: / 06-09-2011 / 10:46:27 / cg" |
1729 | 229 |
! |
230 |
||
231 |
initializeDefaultCommands |
|
3359 | 232 |
"these are used to select an application to be opened when a file of a particular |
233 |
type is double clicked in the browser. |
|
234 |
TODO: move this to OS" |
|
1729 | 235 |
|
3253 | 236 |
|unixCommands win32Commands unixPrintCommands win32PrintCommands listToTry| |
1729 | 237 |
|
238 |
DefaultCommandPerMIMEPerOS := Dictionary new. |
|
239 |
DefaultCommandPerMIMEPerOS at:#unix put:(unixCommands := Dictionary new). |
|
240 |
DefaultCommandPerMIMEPerOS at:#win32 put:(win32Commands := Dictionary new). |
|
241 |
||
3187 | 242 |
unixCommands at:'application/x-tar-compressed' put:'tar tvf -'. |
1729 | 243 |
|
2141 | 244 |
OperatingSystem isMSWINDOWSlike ifFalse:[ |cmd| |
3253 | 245 |
OperatingSystem isOSXlike ifTrue:[ |
3322 | 246 |
unixCommands at:'text/html' put:('open -a Safari "%1"'). |
247 |
unixCommands at:'application/pdf' put:('open -a Preview "%1"'). |
|
3253 | 248 |
] ifFalse:[ |
3322 | 249 |
listToTry := #('firefox' 'chrome' 'chromium' 'konqueror' 'opera'). |
250 |
cmd := listToTry |
|
251 |
detect:[:aCmd| (OperatingSystem pathOfCommand:aCmd) notEmptyOrNil ] |
|
252 |
ifNone:nil. |
|
253 |
cmd notNil ifTrue:[ |
|
254 |
unixCommands at:'text/html' put:(cmd, ' "%1"') |
|
255 |
]. |
|
3187 | 256 |
|
3322 | 257 |
listToTry := #('acroread' 'okular' 'evince' 'kpdf' 'xpdf'). |
258 |
cmd := listToTry |
|
259 |
detect:[:aCmd| (OperatingSystem pathOfCommand:aCmd) notEmptyOrNil ] |
|
260 |
ifNone:nil. |
|
261 |
cmd notNil ifTrue:[ |
|
262 |
unixCommands at:'application/pdf' put:(cmd, ' "%1"') |
|
263 |
]. |
|
3187 | 264 |
]. |
2141 | 265 |
]. |
266 |
||
267 |
||
2116 | 268 |
DefaultPrintCommandPerMIMEPerOS := Dictionary new. |
269 |
DefaultPrintCommandPerMIMEPerOS at:#unix put:(unixPrintCommands := Dictionary new). |
|
270 |
DefaultPrintCommandPerMIMEPerOS at:#win32 put:(win32PrintCommands := Dictionary new). |
|
271 |
||
272 |
"/ if you have a good (intelligent) spooler ;-) |
|
2904
bb555534881e
changed: #initializeDefaultCommands
Stefan Vogel <sv@exept.de>
parents:
2892
diff
changeset
|
273 |
unixPrintCommands at:'application/pdf' put:'lpr "%1"'. |
2116 | 274 |
"/ if not, you may need more... |
275 |
"/ unixPrintCommands at:'application/pdf' put:'pdfToPS %1 | lpr'. |
|
276 |
||
1729 | 277 |
" |
278 |
self initializeDefaultCommands |
|
279 |
" |
|
1979
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
280 |
|
0612875a95c1
acroread command from registry (win32)
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
281 |
"Modified: / 12-05-2004 / 11:43:23 / cg" |
1729 | 282 |
! |
283 |
||
3359 | 284 |
initializeFileInfoMappings |
285 |
"these are used by the file browser if a 'file' command is not present in the OS" |
|
286 |
||
287 |
TypeToInfoMapping := Dictionary new. |
|
288 |
||
289 |
TypeToInfoMapping at:'application/x-smalltalk-source' put:'Smalltalk source'. |
|
290 |
TypeToInfoMapping at:'text/html' put:'HTML document'. |
|
291 |
TypeToInfoMapping at:'text/xml' put:'XML document'. |
|
292 |
TypeToInfoMapping at:'application/xml' put:'XML document'. |
|
293 |
TypeToInfoMapping at:'application/x-c-source' put:'C source'. |
|
294 |
TypeToInfoMapping at:'application/x-c-header' put:'C header file'. |
|
295 |
TypeToInfoMapping at:'application/x-cpp-source' put:'C++ source'. |
|
296 |
TypeToInfoMapping at:'application/x-csharp-source' put:'C# source'. |
|
297 |
TypeToInfoMapping at:'application/x-java-source' put:'Java source'. |
|
298 |
TypeToInfoMapping at:'application/x-javascript' put:'Javascript source'. |
|
299 |
TypeToInfoMapping at:'application/x-lisp-source' put:'Lisp source'. |
|
3482 | 300 |
TypeToInfoMapping at:'application/x-python-source' put:'Python source'. |
3359 | 301 |
|
302 |
TypeToInfoMapping at:'application/x-make' put:'make rules'. |
|
303 |
TypeToInfoMapping at:'application/binary' put:'binary object file'. |
|
304 |
||
305 |
" |
|
306 |
self initializeFileInfoMappings |
|
307 |
'foo.H' asFilename mimeTypeFromName |
|
308 |
'foo.o' asFilename mimeTypeFromName |
|
309 |
" |
|
310 |
! |
|
311 |
||
1729 | 312 |
initializeFileNameToMimeTypeMapping |
313 |
"initialize wellKnown facts" |
|
314 |
||
315 |
|types| |
|
316 |
||
317 |
FileSuffixToTypeMapping isNil ifTrue:[ |
|
318 |
FileSuffixToTypeMapping := Dictionary new |
|
319 |
]. |
|
1887 | 320 |
TypeToFileSuffixMapping isNil ifTrue:[ |
321 |
TypeToFileSuffixMapping := Dictionary new |
|
322 |
]. |
|
1729 | 323 |
FilenameToTypeMapping isNil ifTrue:[ |
324 |
FilenameToTypeMapping := Dictionary new. |
|
325 |
]. |
|
326 |
||
327 |
types := OrderedCollection new. |
|
328 |
types addAll:self textTypeList. |
|
329 |
types addAll:self imageTypeList. |
|
330 |
types addAll:self videoTypeList. |
|
331 |
types addAll:self audioTypeList. |
|
332 |
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
|
333 |
types addAll:self osSpecificTypeList. |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
334 |
|
1729 | 335 |
types pairWiseDo:[:suff :typeString| |
336 |
|type| |
|
337 |
||
338 |
type := MIMEType fromString:typeString. |
|
339 |
suff isArray ifTrue:[ |
|
1887 | 340 |
suff do:[:s | FileSuffixToTypeMapping at:s put:type]. |
341 |
TypeToFileSuffixMapping at:type put:suff first. |
|
1729 | 342 |
] ifFalse:[ |
1887 | 343 |
FileSuffixToTypeMapping at:suff put:type. |
344 |
TypeToFileSuffixMapping at:type put:suff. |
|
345 |
]. |
|
1729 | 346 |
]. |
347 |
||
348 |
self miscFilenameList pairWiseDo:[:nm :typeString| |
|
349 |
|type| |
|
350 |
||
351 |
type := MIMEType fromString:typeString. |
|
352 |
nm isArray ifTrue:[ |
|
353 |
nm do:[:s | FilenameToTypeMapping at:s put:type] |
|
354 |
] ifFalse:[ |
|
355 |
FilenameToTypeMapping at:nm put:type |
|
356 |
] |
|
357 |
]. |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
358 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
359 |
" |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
360 |
self initializeFileNameToMimeTypeMapping |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
361 |
" |
1729 | 362 |
! |
363 |
||
364 |
initializeImageReaderMappings |
|
3359 | 365 |
"these are used so select an image reader, based on a bitmap image's mime type" |
366 |
||
3295 | 367 |
|rdr| |
368 |
||
1729 | 369 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
370 |
FileSuffixToImageReaderClassMapping := Dictionary new |
|
371 |
]. |
|
372 |
"MIME" TypeToImageReaderClassMapping isNil ifTrue:[ |
|
373 |
TypeToImageReaderClassMapping := Dictionary new |
|
374 |
]. |
|
375 |
||
376 |
"/ setup mimeType to image reader class mapping ... |
|
377 |
TypeToImageReaderClassMapping at:'image/jpeg' put:JPEGReader. |
|
378 |
TypeToImageReaderClassMapping at:'image/gif' put:GIFReader. |
|
379 |
TypeToImageReaderClassMapping at:'image/tiff' put:TIFFReader. |
|
2710 | 380 |
TypeToImageReaderClassMapping at:'image/png' put:PNGReader. |
3380 | 381 |
TypeToImageReaderClassMapping at:'image/icns' put:MacOSXIconReader. |
1729 | 382 |
|
383 |
"/ setup suffix to image reader class mapping ... |
|
384 |
FileSuffixToImageReaderClassMapping at:'jpg' put:JPEGReader. |
|
3295 | 385 |
FileSuffixToImageReaderClassMapping at:'jpeg' put:JPEGReader. |
1729 | 386 |
FileSuffixToImageReaderClassMapping at:'gif' put:GIFReader. |
387 |
FileSuffixToImageReaderClassMapping at:'tif' put:TIFFReader. |
|
3295 | 388 |
FileSuffixToImageReaderClassMapping at:'tiff' put:TIFFReader. |
2710 | 389 |
FileSuffixToImageReaderClassMapping at:'png' put:PNGReader. |
3380 | 390 |
FileSuffixToImageReaderClassMapping at:'icns' put:MacOSXIconReader. |
2570 | 391 |
|
3295 | 392 |
"/ some 'used-to-be-optional' readers |
393 |
(rdr := Smalltalk at:#WindowsIconReader) notNil ifTrue:[ |
|
394 |
TypeToImageReaderClassMapping at:'image/bmp' put:rdr. |
|
395 |
TypeToImageReaderClassMapping at:'image/x-MS-bmp' put:rdr. |
|
3585 | 396 |
TypeToImageReaderClassMapping at:'image/x-ms-bmp' put:rdr. |
3295 | 397 |
TypeToImageReaderClassMapping at:'image/x-MS-ico' put:rdr. |
3585 | 398 |
TypeToImageReaderClassMapping at:'image/x-ms-ico' put:rdr. |
3295 | 399 |
FileSuffixToImageReaderClassMapping at:'bmp' put:rdr. |
400 |
FileSuffixToImageReaderClassMapping at:'ico' put:rdr. |
|
401 |
]. |
|
402 |
(rdr := Smalltalk at:#XBMReader) notNil ifTrue:[ |
|
403 |
TypeToImageReaderClassMapping at:'image/x-xbitmap' put:rdr. |
|
404 |
FileSuffixToImageReaderClassMapping at:'xbm' put:rdr. |
|
405 |
]. |
|
406 |
(rdr := Smalltalk at:#XPMReader) notNil ifTrue:[ |
|
407 |
TypeToImageReaderClassMapping at:'image/x-xpixmap' put:rdr. |
|
408 |
FileSuffixToImageReaderClassMapping at:'pm' put:rdr. |
|
409 |
]. |
|
410 |
(rdr := Smalltalk at:#PBMReader) notNil ifTrue:[ |
|
411 |
TypeToImageReaderClassMapping at:'image/x-portable-pixmap' put:rdr. |
|
412 |
TypeToImageReaderClassMapping at:'image/x-portable-bitmap' put:rdr. |
|
413 |
TypeToImageReaderClassMapping at:'image/x-portable-graymap' put:rdr. |
|
414 |
TypeToImageReaderClassMapping at:'image/x-portable-anymap' put:rdr. |
|
415 |
FileSuffixToImageReaderClassMapping at:'ppm' put:rdr. |
|
416 |
FileSuffixToImageReaderClassMapping at:'pbm' put:rdr. |
|
417 |
FileSuffixToImageReaderClassMapping at:'pgm' put:rdr. |
|
418 |
FileSuffixToImageReaderClassMapping at:'pnm' put:rdr. |
|
419 |
]. |
|
420 |
(rdr := Smalltalk at:#PCXReader) notNil ifTrue:[ |
|
421 |
TypeToImageReaderClassMapping at:'image/x-pcx' put:rdr. |
|
422 |
FileSuffixToImageReaderClassMapping at:'pcx' put:rdr. |
|
423 |
]. |
|
424 |
(rdr := Smalltalk at:#TargaReader) notNil ifTrue:[ |
|
425 |
TypeToImageReaderClassMapping at:'image/x-targa' put:rdr. |
|
426 |
FileSuffixToImageReaderClassMapping at:'tga' put:rdr. |
|
427 |
]. |
|
428 |
(rdr := Smalltalk at:#XWDReader) notNil ifTrue:[ |
|
429 |
TypeToImageReaderClassMapping at:'image/x-xwindowdump' put:rdr. |
|
430 |
TypeToImageReaderClassMapping at:'image/x-windowdump' put:rdr. |
|
431 |
FileSuffixToImageReaderClassMapping at:'xwd' put:rdr. |
|
432 |
]. |
|
433 |
(rdr := Smalltalk at:#BlitImageReader) notNil ifTrue:[ |
|
434 |
TypeToImageReaderClassMapping at:'image/x-blitimage' put:rdr. |
|
435 |
FileSuffixToImageReaderClassMapping at:'48x48x1' put:rdr. |
|
436 |
]. |
|
437 |
(rdr := Smalltalk at:#IrisRGBReader) notNil ifTrue:[ |
|
438 |
TypeToImageReaderClassMapping at:'image/x-rgb' put:rdr. |
|
439 |
FileSuffixToImageReaderClassMapping at:'rgb' put:rdr. |
|
440 |
]. |
|
441 |
(rdr := Smalltalk at:#SunRasterReader) notNil ifTrue:[ |
|
442 |
TypeToImageReaderClassMapping at:'image/x-sunraster' put:rdr. |
|
443 |
FileSuffixToImageReaderClassMapping at:'im8' put:rdr. |
|
444 |
FileSuffixToImageReaderClassMapping at:'icon' put:rdr. |
|
2570 | 445 |
]. |
3295 | 446 |
(rdr := Smalltalk at:#ST80FormReader) notNil ifTrue:[ |
447 |
TypeToImageReaderClassMapping at:'image/x-st80-form' put:rdr. |
|
448 |
FileSuffixToImageReaderClassMapping at:'form' put:rdr. |
|
449 |
]. |
|
450 |
(rdr := Smalltalk at:#FaceReader) notNil ifTrue:[ |
|
451 |
TypeToImageReaderClassMapping at:'image/x-face' put:rdr. |
|
452 |
FileSuffixToImageReaderClassMapping at:'face' put:rdr. |
|
453 |
]. |
|
454 |
(rdr := Smalltalk at:#PCDReader) notNil ifTrue:[ |
|
455 |
TypeToImageReaderClassMapping at:'image/x-photo-cd' put:rdr. |
|
456 |
FileSuffixToImageReaderClassMapping at:'pcd' put:rdr. |
|
457 |
]. |
|
458 |
(rdr := Smalltalk at:#CMURasterReader) notNil ifTrue:[ |
|
459 |
TypeToImageReaderClassMapping at:'image/x-cmu-raster' put:rdr. |
|
460 |
FileSuffixToImageReaderClassMapping at:'ras' put:rdr. |
|
461 |
]. |
|
462 |
||
3359 | 463 |
"/ movie formats - experimental and not yet complete / finished / delivered / published |
3295 | 464 |
"/ (rdr := Smalltalk at:#FLIReader) notNil ifTrue:[ |
465 |
"/ TypeToImageReaderClassMapping at:'video/x-fli' put:rdr. |
|
466 |
"/ FileSuffixToImageReaderClassMapping at:'fli' put:rdr. |
|
467 |
"/ ]. |
|
468 |
"/ (rdr := Smalltalk at:#AVIReader) notNil ifTrue:[ |
|
469 |
"/ TypeToImageReaderClassMapping at:'video/x-msvideo' put:rdr. |
|
470 |
"/ FileSuffixToImageReaderClassMapping at:'avi' put:rdr. |
|
471 |
"/ ]. |
|
472 |
"/ (rdr := Smalltalk at:#AVIReader) notNil ifTrue:[ |
|
473 |
"/ TypeToImageReaderClassMapping at:'video/x-msvideo' put:rdr. |
|
474 |
"/ FileSuffixToImageReaderClassMapping at:'avi' put:rdr. |
|
475 |
"/ ]. |
|
476 |
"/ (rdr := Smalltalk at:#QuickTimeReader) notNil ifTrue:[ |
|
477 |
"/ TypeToImageReaderClassMapping at:'video/quicktime' put:rdr. |
|
478 |
"/ FileSuffixToImageReaderClassMapping at:'qt' put:rdr. |
|
479 |
"/ FileSuffixToImageReaderClassMapping at:'mov' put:rdr. |
|
480 |
"/ FileSuffixToImageReaderClassMapping at:'moov' put:rdr. |
|
481 |
"/ ]. |
|
482 |
"/ (rdr := Smalltalk at:#MPEG2Reader) notNil ifTrue:[ |
|
483 |
"/ TypeToImageReaderClassMapping at:'video/x-mpeg2' put:rdr. |
|
484 |
"/ FileSuffixToImageReaderClassMapping at:'mpg2' put:rdr. |
|
485 |
"/ FileSuffixToImageReaderClassMapping at:'mpv2' put:rdr. |
|
486 |
"/ FileSuffixToImageReaderClassMapping at:'mp2v' put:rdr. |
|
487 |
"/ FileSuffixToImageReaderClassMapping at:'mp2' put:rdr. |
|
488 |
"/ ]. |
|
489 |
"/ (rdr := Smalltalk at:#MPEGReader) notNil ifTrue:[ |
|
490 |
"/ TypeToImageReaderClassMapping at:'video/mpeg' put:rdr. |
|
491 |
"/ FileSuffixToImageReaderClassMapping at:'mpg' put:rdr. |
|
492 |
"/ FileSuffixToImageReaderClassMapping at:'mpeg' put:rdr. |
|
493 |
"/ FileSuffixToImageReaderClassMapping at:'mpe' put:rdr. |
|
494 |
"/ FileSuffixToImageReaderClassMapping at:'mpv' put:rdr. |
|
495 |
"/ FileSuffixToImageReaderClassMapping at:'vps' put:rdr. |
|
496 |
"/ FileSuffixToImageReaderClassMapping at:'mpegv' put:rdr. |
|
497 |
"/ ]. |
|
498 |
"/ (rdr := Smalltalk at:#SGIMovieReader) notNil ifTrue:[ |
|
499 |
"/ TypeToImageReaderClassMapping at:'video/x-sgi-movie' put:rdr. |
|
500 |
"/ FileSuffixToImageReaderClassMapping at:'movie' put:rdr. |
|
501 |
"/ ]. |
|
2298 | 502 |
! |
503 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
504 |
initializeParenthesisSpecMappings |
3359 | 505 |
"these are used by the editors to mark matching parenthesis" |
506 |
||
2298 | 507 |
|spec| |
508 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
509 |
TypeToParenthesisSpecMapping := Dictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
510 |
SuffixToParenthesisSpecMapping := Dictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
511 |
|
2298 | 512 |
"/ ST/X spec |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
513 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
514 |
spec at:#open put:#( $( $[ ${ ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
515 |
spec at:#close put:#( $) $] $} ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
516 |
spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
517 |
spec at:#eolComment put:'"/'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
518 |
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
|
519 |
|
2479 | 520 |
"/ XML & HTML |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
521 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
522 |
spec at:#open put:#( $< ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
523 |
spec at:#close put:#( $> ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
524 |
spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
525 |
#( '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
|
526 |
TypeToParenthesisSpecMapping at:eachXMLType put:spec |
2298 | 527 |
]. |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
528 |
|
3359 | 529 |
"/ ANSI-c, Java, C# |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
530 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
531 |
spec at:#open put:#( $( $[ ${ ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
532 |
spec at:#close put:#( $) $] $} ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
533 |
spec at:#ignore put:#( $' $" ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
534 |
spec at:#eolComment put:'//'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
535 |
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
|
536 |
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
|
537 |
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
|
538 |
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
|
539 |
TypeToParenthesisSpecMapping at:'application/x-javascript' put:spec. |
3482 | 540 |
TypeToParenthesisSpecMapping at:'application/x-python-source' put:spec. |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
541 |
|
3359 | 542 |
"/ Lisp / Scheme |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
543 |
spec := IdentityDictionary new. |
3039 | 544 |
spec at:#open put:#( $( $[ ). |
545 |
spec at:#close put:#( $) $] ). |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
546 |
spec at:#ignore put:#( $" ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
547 |
spec at:#eolComment put:';'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
548 |
TypeToParenthesisSpecMapping at:'application/x-lisp-source' put:spec. |
2298 | 549 |
|
550 |
"Created: / 10-04-2007 / 15:16:37 / cg" |
|
1729 | 551 |
! ! |
552 |
||
553 |
!MIMETypes class methodsFor:'initialization-lists'! |
|
554 |
||
555 |
applicationCompressorsAndArchiveTypeList |
|
1604 | 556 |
^ #( |
1890 | 557 |
'tar' 'application/x-tar' |
558 |
'gtar' 'application/x-gtar' |
|
1891 | 559 |
('tgz' 'tar.gz') 'application/x-tar-gzip-compressed' "/ 'application/x-tar-compressed' |
560 |
('tar.bz2') 'application/x-tar-bzip2-compressed' |
|
1890 | 561 |
'zip' 'application/x-zip-compressed' |
562 |
'bz2' 'application/x-bzip2-compressed' |
|
563 |
('gz' 'z') 'application/x-gzip-compressed' |
|
564 |
'cpio' 'application/x-cpio' |
|
565 |
'shar' 'application/x-shar' |
|
566 |
'jar' 'application/java-archive' |
|
567 |
'sar' 'application/x-squeak-archive' |
|
568 |
'sit' 'application/x-stuffit' |
|
569 |
'hqx' 'application/mac-binhex40' |
|
570 |
'cpt' 'application/mac-compactpro' |
|
3756 | 571 |
'pkg' 'application/x-xar' "/ a mac archiver for packages |
1604 | 572 |
) |
573 |
! |
|
645 | 574 |
|
1609 | 575 |
applicationMiscTypeList |
576 |
"misc applications" |
|
577 |
||
578 |
^ #( |
|
579 |
('a' 'o' 'obj' ) 'application/binary' |
|
2968 | 580 |
('lic') 'application/license' |
1609 | 581 |
('dll' 'so') 'application/shared-library' |
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
582 |
|
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
583 |
('ets') 'application/x-expecco-testsuite' |
3104 | 584 |
('etr') 'application/x-expecco-testrepository' |
2489
b891d96fd496
elf extension: x-expecco-logfile
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
585 |
('elf') 'application/x-expecco-logfile' |
2886
22b48a4da285
comment/format in: #initializeFileNameToMimeTypeMapping
sr
parents:
2830
diff
changeset
|
586 |
('expeccolicense') 'application/x-expecco-license' |
2888 | 587 |
('expeccopatch') 'application/x-expecco-patch' |
1609 | 588 |
) |
2886
22b48a4da285
comment/format in: #initializeFileNameToMimeTypeMapping
sr
parents:
2830
diff
changeset
|
589 |
|
2968 | 590 |
"Modified: / 03-11-2011 / 10:42:28 / sr" |
1609 | 591 |
! |
592 |
||
1604 | 593 |
applicationProgLangTypeList |
3020
3f9c74ff0975
changed: #applicationProgLangTypeList
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
594 |
"applications for programming languages" |
713 | 595 |
|
1604 | 596 |
^ #( |
1609 | 597 |
('st' 'cls' 'rc') 'application/x-smalltalk-source' |
1604 | 598 |
'sif' 'application/x-smalltalk-source-sif' |
1668 | 599 |
'pac' 'application/x-smalltalk-dolphin-package' |
1778 | 600 |
|
601 |
'sts' 'application/x-squeak-source' |
|
602 |
'pr' 'application/x-squeak-project' |
|
603 |
||
1604 | 604 |
'c' 'application/x-c-source' |
605 |
('cc' 'cpp') 'application/x-cpp-source' |
|
2479 | 606 |
'cs' 'application/x-csharp-source' |
1609 | 607 |
('h' 'hi') 'application/x-c-header' |
1604 | 608 |
('js' 'mocha') 'application/x-javascript' |
609 |
('java' 'jav') 'application/x-java-source' |
|
610 |
'sh' 'application/x-sh' |
|
611 |
'csh' 'application/x-csh' |
|
612 |
'tcl' 'application/x-tcl' |
|
613 |
'pl' 'application/x-perl' |
|
3020
3f9c74ff0975
changed: #applicationProgLangTypeList
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
614 |
'dart' 'application/x-dart' |
1604 | 615 |
'mak' 'application/x-make' |
616 |
'bat' 'application/x-batch-script' |
|
3008 | 617 |
('asn1' 'x409' 'gdmo' 'gdm') 'application/x-asn1-source' |
618 |
||
2912
f3466ea0810b
changed: #applicationProgLangTypeList
Claus Gittinger <cg@exept.de>
parents:
2911
diff
changeset
|
619 |
('lisp' 'lsp' 'scm' 'ss' |
f3466ea0810b
changed: #applicationProgLangTypeList
Claus Gittinger <cg@exept.de>
parents:
2911
diff
changeset
|
620 |
'arc' 'cl' 'brg') 'application/x-lisp-source' |
3482 | 621 |
'py' 'application/x-python-source' |
1604 | 622 |
) |
2298 | 623 |
|
3020
3f9c74ff0975
changed: #applicationProgLangTypeList
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
624 |
"Modified (comment): / 21-08-2012 / 20:55:13 / cg" |
1604 | 625 |
! |
1561 | 626 |
|
1604 | 627 |
applicationTextTypeList |
1606 | 628 |
"text applications" |
1604 | 629 |
|
630 |
^ #( |
|
631 |
('ps' 'eps') 'application/postscript' |
|
1778 | 632 |
"/ 'ai' 'application/postscript' |
1604 | 633 |
'pdf' 'application/pdf' |
634 |
'rtf' 'application/rtf' |
|
1778 | 635 |
"/ 'rtf' 'text/rtf' ???? |
3008 | 636 |
'ics' 'text/calendar' |
637 |
'doc' 'application/ms-word-document' |
|
1778 | 638 |
"/ 'doc' 'application/winword' |
639 |
'swf' 'application/x-shockwave-flash' |
|
640 |
('ppt' 'ppz' 'pot' 'pps') 'application/mspowerpoint' |
|
2028 | 641 |
'xls' 'application/x-excel' |
642 |
'slk' 'application/vnd.ms-excel' |
|
2911
7afaf1fdae8b
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
2904
diff
changeset
|
643 |
'txt' 'text/plain' |
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
644 |
'xlsx' 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' |
3476 | 645 |
'xltx' 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' |
646 |
'potx' 'application/vnd.openxmlformats-officedocument.presentationml.template' |
|
647 |
'ppsx' 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' |
|
648 |
'pptx' 'application/vnd.openxmlformats-officedocument.presentationml.presentation' |
|
649 |
'sldx' 'application/vnd.openxmlformats-officedocument.presentationml.slide' |
|
650 |
'docx' 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' |
|
651 |
'dotx' 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' |
|
652 |
'xlam' 'application/vnd.ms-excel.addin.macroEnabled.12' |
|
653 |
'xlsb' 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' |
|
3482 | 654 |
|
655 |
'edi' 'application/EDIFACT' |
|
1604 | 656 |
) |
2911
7afaf1fdae8b
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
2904
diff
changeset
|
657 |
|
3008 | 658 |
"Modified: / 26-05-2012 / 15:27:30 / cg" |
3476 | 659 |
"Modified: / 18-05-2015 / 09:46:47 / sr" |
1604 | 660 |
! |
661 |
||
662 |
applicationTypeList |
|
1606 | 663 |
"applications" |
1604 | 664 |
|
1729 | 665 |
|typeList| |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
666 |
|
1729 | 667 |
typeList := OrderedCollection new. |
668 |
typeList addAll:self applicationProgLangTypeList. |
|
669 |
typeList addAll:self applicationTextTypeList. |
|
670 |
typeList addAll:self applicationCompressorsAndArchiveTypeList. |
|
671 |
typeList addAll:self applicationMiscTypeList. |
|
1616 | 672 |
|
1729 | 673 |
^ typeList |
1604 | 674 |
! |
675 |
||
676 |
audioTypeList |
|
1606 | 677 |
"audio formats ..." |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
678 |
|
1604 | 679 |
^ #( |
1720 | 680 |
('au' 'snd') 'audio/basic' |
1778 | 681 |
('ra') 'audio/x-realaudio' |
682 |
('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
|
683 |
"/ cg: see unixSpecific / windowsSpecific |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
684 |
"/ 'rpm' 'audio/x-pn-realaudio-plugin' |
3008 | 685 |
('mpa' 'mpega' 'mpga') 'audio/mpeg' |
1778 | 686 |
"/ 'mp3' 'audio/x-mp3' |
687 |
('mp3' 'mp2') 'audio/mpeg' |
|
1604 | 688 |
'wav' 'audio/x-wav' |
689 |
('aif' 'aiff' 'aifc') 'audio/x-aiff' |
|
1778 | 690 |
('midi' 'mid') 'audio/midi' |
1604 | 691 |
) |
3008 | 692 |
|
693 |
"Modified: / 26-05-2012 / 15:23:45 / cg" |
|
1604 | 694 |
! |
695 |
||
696 |
imageTypeList |
|
697 |
||
698 |
^ #( |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
699 |
"/ image formats ... |
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
700 |
|
1216 | 701 |
('jpg' 'jpeg') 'image/jpeg' |
1188 | 702 |
'gif' 'image/gif' |
703 |
('tif' 'tiff') 'image/tiff' |
|
3295 | 704 |
('xbm' 'bm') 'image/x-xbitmap' |
1188 | 705 |
'xpm' 'image/x-xpixmap' |
1720 | 706 |
'png' 'image/png' |
1188 | 707 |
'pcd' 'image/x-photo-cd' |
708 |
'bmp' 'image/x-MS-bmp' |
|
709 |
'rgb' 'image/x-rgb' |
|
710 |
'ppm' 'image/x-portable-pixmap' |
|
711 |
'pgm' 'image/x-portable-graymap' |
|
712 |
'pbm' 'image/x-portable-bitmap' |
|
713 |
'pnm' 'image/x-portable-anymap' |
|
714 |
'xwd' 'image/x-xwindowdump' |
|
715 |
'ras' 'image/x-cmu-raster' |
|
1216 | 716 |
'tga' 'image/x-targa' |
2020 | 717 |
'ico' 'image/x-ico' |
3380 | 718 |
'icns' 'image/icns' |
1604 | 719 |
) |
720 |
! |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
721 |
|
1609 | 722 |
miscFilenameList |
3104 | 723 |
"other formats (not by suffix, but by fileName instead) ..." |
1609 | 724 |
|
725 |
^ #( |
|
2113 | 726 |
('makefile' 'make.proto' 'make.spec' 'nt.mak') 'application/x-make' |
2830 | 727 |
('exe' 'bin' 'com') 'application/octet-stream' |
2113 | 728 |
('class') 'application/octet-stream' |
2375 | 729 |
('top') 'application/x-waltop-digital-notepad' |
1609 | 730 |
) |
731 |
! |
|
732 |
||
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
733 |
osSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
734 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
735 |
^ self windowsSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
736 |
]. |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
737 |
^ self unixSpecificTypeList |
2023 | 738 |
|
739 |
" |
|
740 |
self osSpecificTypeList |
|
741 |
" |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
742 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
743 |
|
1604 | 744 |
textTypeList |
745 |
"/ misc text ... |
|
746 |
||
747 |
^ #( |
|
1887 | 748 |
('html' 'htm' 'shtml') 'text/html' |
1604 | 749 |
('txt' 'text') 'text/plain' |
1680 | 750 |
'xml' 'text/xml' |
3517 | 751 |
'xsd' 'text/xml' |
1777 | 752 |
'css' 'text/css' |
2432 | 753 |
'csv' 'text/csv' |
1604 | 754 |
) |
755 |
! |
|
756 |
||
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
757 |
unixSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
758 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
759 |
^ #( |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
760 |
"/ 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
|
761 |
"/ 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
|
762 |
'rpm' 'application/x-rpm' |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
763 |
) |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
764 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
765 |
|
1604 | 766 |
videoTypeList |
767 |
"/ video formats ... |
|
768 |
||
769 |
^ #( |
|
1720 | 770 |
('qt' 'mov' 'moov') 'video/quicktime' |
771 |
('mpv' 'mpegv' 'mpg' 'mpeg' 'mpe') 'video/mpeg' |
|
1604 | 772 |
'movie' 'video/x-sgi-movie' |
1820 | 773 |
('avi' 'wmv' 'asf') 'video/x-msvideo' |
1604 | 774 |
('mpv2' 'mp2v' 'mp2' 'mpeg2') 'video/x-mpeg2' |
3367 | 775 |
('mp4') 'video/mp4' |
1680 | 776 |
'rm' 'application/vnd.rn-realmedia' |
777 |
'rv' 'video/x-pn-realvideo' |
|
3295 | 778 |
'fli' 'video/x-fli' |
3367 | 779 |
'flv' 'video/x-flv' "/ macromedia flash video |
1778 | 780 |
) |
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
781 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
782 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
783 |
windowsSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
784 |
^ #( |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
785 |
"/ 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
|
786 |
"/ 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
|
787 |
'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
|
788 |
) |
643 | 789 |
! ! |
790 |
||
1729 | 791 |
!MIMETypes class methodsFor:'obsolete'! |
1489 | 792 |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
793 |
defaultCommandForMimeType:mimeType |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
794 |
<resource: #obsolete> |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
795 |
self obsoleteMethodWarning:'use #defaultCommandTemplateToOpenMimeType:'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
796 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
797 |
^ self defaultCommandTemplateToOpenMimeType:mimeType |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
798 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
799 |
" |
2758
66e62ceecb67
comment/format in: #defaultCommandForMimeType:
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
800 |
MIMETypes defaultCommandTemplateToOpenMimeType:'application/pdf' |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
801 |
" |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
802 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
803 |
"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
|
804 |
"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
|
805 |
! |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
806 |
|
1729 | 807 |
fontForCharset:aCharSetName |
808 |
"return the font-encoding for an iso-charset" |
|
1489 | 809 |
|
1981 | 810 |
<resource:#obsolete> |
1729 | 811 |
self obsoleteMethodWarning:'use FontDescription >> fontNamePatternForCharset:'. |
812 |
^ FontDescription fontNamePatternForCharset:aCharSetName. |
|
1489 | 813 |
|
814 |
" |
|
1729 | 815 |
MIMETypes fontForCharset:'iso2022-jp' |
816 |
MIMETypes fontForCharset:'euc-jp' |
|
1472 | 817 |
" |
818 |
||
1729 | 819 |
"Modified: / 1.8.1998 / 17:00:57 / cg" |
820 |
! ! |
|
1472 | 821 |
|
1729 | 822 |
!MIMETypes class methodsFor:'queries'! |
1472 | 823 |
|
647 | 824 |
defineImageType:mimeType suffix:aSuffix reader:aReaderClass |
825 |
"register an image reader." |
|
826 |
||
827 |
aSuffix notNil ifTrue:[ |
|
828 |
self imageReaderForSuffix:aSuffix put:aReaderClass. |
|
829 |
]. |
|
830 |
||
831 |
mimeType notNil ifTrue:[ |
|
832 |
self imageReaderForType:mimeType put:aReaderClass |
|
833 |
]. |
|
834 |
||
835 |
(aSuffix notNil and:[mimeType notNil]) ifTrue:[ |
|
836 |
self mimeTypeForSuffix:aSuffix put:mimeType |
|
837 |
]. |
|
838 |
! |
|
839 |
||
3359 | 840 |
fileInfoForMimeType:mimeType |
841 |
"given a mimeType, return an info string similar to what the unix 'file' command |
|
842 |
provides. This info here is returned by systems which have no file (i.e. MSDOS) and |
|
843 |
for types of which file does not know about (smalltalk files, for example)" |
|
844 |
||
3400 | 845 |
TypeToInfoMapping isNil ifTrue:[ |
846 |
self initializeFileInfoMappings |
|
847 |
]. |
|
848 |
||
3359 | 849 |
^ TypeToInfoMapping at:mimeType ifAbsent:nil |
850 |
||
851 |
" |
|
852 |
self fileInfoForMimeType:(MIMEType fromString:'image/gif') |
|
853 |
" |
|
854 |
! |
|
855 |
||
643 | 856 |
fileSuffixToImageReaderMapping |
1021 | 857 |
"return the suffix-to-imageReader mapping" |
858 |
||
643 | 859 |
^ FileSuffixToImageReaderClassMapping ? #() |
860 |
||
1021 | 861 |
"Modified: / 1.8.1998 / 17:00:11 / cg" |
643 | 862 |
! |
863 |
||
864 |
imageFileSuffixes |
|
1021 | 865 |
"return a collection with known file suffixes" |
866 |
||
643 | 867 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[^ #()]. |
868 |
^ FileSuffixToImageReaderClassMapping keys |
|
869 |
||
1021 | 870 |
"Created: / 30.6.1997 / 22:04:48 / cg" |
871 |
"Modified: / 1.8.1998 / 17:01:26 / cg" |
|
643 | 872 |
! |
873 |
||
3014
e6d9a204da08
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
3012
diff
changeset
|
874 |
mimeTypeForFilename:filenameOrString |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
875 |
"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
|
876 |
|
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
877 |
|type filename lcFilename suff suff2| |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
878 |
|
3014
e6d9a204da08
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
3012
diff
changeset
|
879 |
filename := filenameOrString asFilename. |
1474 | 880 |
|
881 |
lcFilename := filename baseName asLowercase. |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
882 |
type := FilenameToTypeMapping at:lcFilename ifAbsent:nil. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
883 |
type isNil ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
884 |
"/ allow for fallback ... |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
885 |
type := OperatingSystem mimeTypeForFilename:lcFilename. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
886 |
"/ 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
|
887 |
"/ 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
|
888 |
"/ the OS. |
1275 | 889 |
"/ type isNil ifTrue:[ |
890 |
"/ FilenameToTypeMapping at:lcFilename put:#unknown |
|
891 |
"/ ]. |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
892 |
]. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
893 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
894 |
type == #unknown ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
895 |
type := nil. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
896 |
]. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
897 |
|
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
898 |
type isNil ifTrue:[ |
1473 | 899 |
suff := filename suffix. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
900 |
suff size ~~ 0 ifTrue:[ |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
901 |
"/ sigh - special code for multiple-suffices... |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
902 |
"/ .tar.gz -> tgz |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
903 |
suff2 := filename withoutSuffix suffix. |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
904 |
suff2 size > 0 ifTrue:[ |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
905 |
type := self mimeTypeForSuffix:(suff2 , '.' , suff). |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
906 |
]. |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
907 |
type isNil ifTrue:[ |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
908 |
type := self mimeTypeForSuffix:suff |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
909 |
]. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
910 |
] |
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
911 |
]. |
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
912 |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
913 |
^ type |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
914 |
|
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
915 |
" |
2820 | 916 |
MIMETypes mimeTypeForFilename:'typeinst.dvi' |
917 |
MIMETypes mimeTypeForFilename:'foo.tar' |
|
918 |
MIMETypes mimeTypeForFilename:'foo.tgz' |
|
919 |
MIMETypes mimeTypeForFilename:'foo.tar.gz' |
|
2911
7afaf1fdae8b
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
2904
diff
changeset
|
920 |
MIMETypes mimeTypeForFilename:'foo.txt' |
3756 | 921 |
MIMETypes mimeTypeForFilename:'foo.pkg' |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
922 |
" |
2911
7afaf1fdae8b
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
2904
diff
changeset
|
923 |
|
7afaf1fdae8b
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
2904
diff
changeset
|
924 |
"Modified: / 10-05-2011 / 11:55:18 / cg" |
3014
e6d9a204da08
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
3012
diff
changeset
|
925 |
"Modified (format): / 28-07-2012 / 09:39:15 / cg" |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
926 |
! |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
927 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
928 |
mimeTypeForFilename:filename put:mimeType |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
929 |
"register a mime type for a filename" |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
930 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
931 |
FilenameToTypeMapping isNil ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
932 |
FilenameToTypeMapping := Dictionary new |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
933 |
]. |
1612 | 934 |
FilenameToTypeMapping at:filename put:(MIMEType fromString:mimeType asLowercase) |
1611 | 935 |
! |
936 |
||
643 | 937 |
mimeTypeForSuffix:suffix |
1021 | 938 |
"given a file suffix, return the mime-type" |
939 |
||
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
940 |
|type lcSuffix| |
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
941 |
|
1837 | 942 |
suffix = LastSuffix ifTrue:[ |
943 |
^ LastType |
|
944 |
]. |
|
945 |
||
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
946 |
lcSuffix := suffix asLowercase. |
1837 | 947 |
type := FileSuffixToTypeMapping at:lcSuffix ifAbsent:nil. |
948 |
type isNil ifTrue:[ |
|
949 |
"/ allow for fallback ... |
|
950 |
type := OperatingSystem mimeTypeForSuffix:lcSuffix. |
|
951 |
"/ the special value #unknown is returned as nil; |
|
952 |
"/ this avoids constant retry if a mimeType is not known in the OS. |
|
953 |
||
954 |
type := type ? #unknown. |
|
955 |
FileSuffixToTypeMapping at:lcSuffix put:type. |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
956 |
]. |
1837 | 957 |
|
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
958 |
type == #unknown ifTrue:[ |
1837 | 959 |
type := nil. |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
960 |
]. |
1840 | 961 |
type notNil ifTrue:[ |
962 |
LastSuffix := suffix. |
|
963 |
LastType := MIMEType fromString:type. |
|
964 |
^ LastType |
|
965 |
]. |
|
1841 | 966 |
^ type |
643 | 967 |
|
1666 | 968 |
" |
1840 | 969 |
self mimeTypeForSuffix:'gif' |
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
970 |
self mimeTypeForSuffix:'rpm' |
2891 | 971 |
self mimeTypeForSuffix:'zip' |
1666 | 972 |
" |
973 |
||
2891 | 974 |
"Created: / 30-06-1997 / 21:55:51 / cg" |
975 |
"Modified: / 14-02-2011 / 17:14:34 / cg" |
|
643 | 976 |
! |
977 |
||
978 |
mimeTypeForSuffix:suffix put:mimeType |
|
1021 | 979 |
"register a mime type for a file suffix" |
980 |
||
643 | 981 |
FileSuffixToTypeMapping isNil ifTrue:[ |
982 |
FileSuffixToTypeMapping := Dictionary new |
|
983 |
]. |
|
984 |
FileSuffixToTypeMapping at:suffix put:mimeType asLowercase |
|
985 |
||
1021 | 986 |
"Created: / 30.6.1997 / 21:56:20 / cg" |
987 |
"Modified: / 1.8.1998 / 17:03:18 / cg" |
|
1593 | 988 |
! |
989 |
||
990 |
mimeTypeForSuffixMapping |
|
991 |
||
992 |
^ FileSuffixToTypeMapping |
|
1611 | 993 |
! |
994 |
||
2023 | 995 |
mimeTypeFromString:mimeTypeString |
996 |
"given a mime-type for a string" |
|
997 |
||
998 |
^ MIMEType fromString:mimeTypeString |
|
999 |
||
1000 |
" |
|
3532 | 1001 |
MIMETypes mimeTypeFromString:'text/html' |
1002 |
MIMETypes mimeTypeFromString:'image/gif' |
|
1003 |
MIMETypes mimeTypeFromString:'application/x-expecco-testsuite' |
|
2023 | 1004 |
" |
1005 |
! |
|
1006 |
||
1611 | 1007 |
mimeTypeOfContents:filename |
1008 |
"given a filename, scan the contents, return the mime-type or nil, if unknown" |
|
1009 |
||
1612 | 1010 |
|typeString| |
1011 |
||
1012 |
typeString := filename mimeTypeOfContents. |
|
1013 |
typeString isNil ifTrue:[^ nil]. |
|
1014 |
^ MIMEType fromString:typeString. |
|
1887 | 1015 |
! |
1016 |
||
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1017 |
mimeTypeOfData:someData |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1018 |
"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
|
1019 |
Returns nil, if unknown. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1020 |
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
|
1021 |
|
3400 | 1022 |
^ self mimeTypeOfData:someData suffix:nil |
1023 |
! |
|
1024 |
||
1025 |
mimeTypeOfData:someData suffix:fileNameSuffixOrNilIfUnknown |
|
1026 |
"this tries to guess the mime type of contents of someData. |
|
1027 |
Returns nil, if unknown. |
|
3691 | 1028 |
In addition to registered detectors (see addMimeTypeDetector:), |
1029 |
this is done using some heuristics, and may need some improvement" |
|
3400 | 1030 |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1031 |
|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
|
1032 |
|
2583 | 1033 |
someData isEmptyOrNil ifTrue:[^ nil]. |
1034 |
||
3691 | 1035 |
TypeFromContentsDetectors notNil ifTrue:[ |
1036 |
TypeFromContentsDetectors do:[:eachDetector | |
|
1037 |
|m| |
|
1038 |
||
1039 |
m := eachDetector value:someData value:fileNameSuffixOrNilIfUnknown. |
|
1040 |
m notNil ifTrue:[^ m] |
|
1041 |
] |
|
1042 |
]. |
|
1043 |
||
2583 | 1044 |
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
|
1045 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1046 |
"/ read some data from the file ... |
2583 | 1047 |
buffer := (someData copyTo:size) asString. |
3691 | 1048 |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1049 |
lcBuffer := buffer asLowercase. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1050 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1051 |
(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
|
1052 |
idx := idx + 'mimetype:' size. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1053 |
idx := lcBuffer indexOfNonSeparatorStartingAt:idx. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1054 |
idx2 := lcBuffer indexOfSeparatorStartingAt:idx. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1055 |
idx2 > idx ifTrue:[ |
2583 | 1056 |
^ 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
|
1057 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1058 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1059 |
|
2924 | 1060 |
"/ real starters |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1061 |
#( |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1062 |
( #[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
|
1063 |
#'application/x-ms-shortcut' ) |
2924 | 1064 |
( 'ITOLITLS' |
1065 |
#'application/x-ms-reader' ) |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1066 |
( 'WALTOP' |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1067 |
#'application/x-waltop-digital-notepad' ) |
2892 | 1068 |
('PK' |
1069 |
#'application/x-zip-compressed') |
|
3113 | 1070 |
('<?xml' |
1071 |
#'text/xml') |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1072 |
) pairsDo:[:pattern :what | |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1073 |
|patternString| |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1074 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1075 |
patternString := pattern asString. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1076 |
(buffer startsWith:patternString) ifTrue:[ |
3400 | 1077 |
what = #'application/x-zip-compressed' ifTrue:[ |
1078 |
fileNameSuffixOrNilIfUnknown = 'jar' ifTrue:[ |
|
1079 |
^ MIMEType fromString: #'application/java-archive' |
|
1080 |
]. |
|
1081 |
]. |
|
2583 | 1082 |
^ MIMEType fromString:what |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1083 |
] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1084 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1085 |
|
2924 | 1086 |
"/ somewhere near the beginning |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1087 |
#( |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1088 |
('<body:' #'text/html') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1089 |
('%!!ps-adobe' #'application/postscript') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1090 |
('%PDF-' #'application/pdf') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1091 |
('#!! /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
|
1092 |
('#!!/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
|
1093 |
"/ ('#!! /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
|
1094 |
"/ ('#!!/bin/bash' 'application/x-bash') |
3482 | 1095 |
('UNB+UNO' #'application/EDIFACT') |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1096 |
|
3113 | 1097 |
('---- encoding: ' #'application/x-smalltalk-source') |
1098 |
('---- timestamp ' #'application/x-smalltalk-source') |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1099 |
('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
|
1100 |
('from visualworks' #'application/x-smalltalk-source') |
3359 | 1101 |
('from squeak' #'application/x-smalltalk-source') |
1102 |
('from smalltalk/x' #'application/x-smalltalk-source') |
|
1103 |
('"{ Package:' #'application(x-smalltalk-source') |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1104 |
('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
|
1105 |
('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
|
1106 |
('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
|
1107 |
('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
|
1108 |
('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
|
1109 |
('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
|
1110 |
('methodsfor:' #'application/x-smalltalk-source') |
3332 | 1111 |
('Application create:' #'application/x-smalltalk-source') |
1112 |
('becomeDefault!!' #'application/x-smalltalk-source') |
|
3451 | 1113 |
('(reader defineClass:' #'application/x-smalltalk-source') "/ gravel smalltalk |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1114 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1115 |
) pairsDo:[:pattern :what | |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1116 |
(lcBuffer findString:pattern) ~~ 0 ifTrue:[ |
2583 | 1117 |
^ MIMEType fromString:what |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1118 |
] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1119 |
]. |
3691 | 1120 |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1121 |
(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
|
1122 |
((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
|
1123 |
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
|
1124 |
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
|
1125 |
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
|
1126 |
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
|
1127 |
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
|
1128 |
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
|
1129 |
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
|
1130 |
ifTrue:[ |
2583 | 1131 |
^ 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
|
1132 |
] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1133 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1134 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1135 |
[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
|
1136 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1137 |
size == 0 ifTrue:[ |
2583 | 1138 |
^ 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
|
1139 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1140 |
^ nil |
2891 | 1141 |
|
2924 | 1142 |
"Modified: / 12-07-2011 / 19:08:17 / cg" |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1143 |
! |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1144 |
|
1887 | 1145 |
suffixForMimeType:mimeType |
1146 |
"given a file suffix, return the mime-type" |
|
1147 |
||
1148 |
^ TypeToFileSuffixMapping at:mimeType ifAbsent:nil |
|
1149 |
||
1150 |
" |
|
1151 |
self suffixForMimeType:(MIMEType fromString:'image/gif') |
|
1152 |
" |
|
1153 |
||
1154 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
|
1155 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
|
1156 |
! |
|
1157 |
||
1158 |
suffixForMimeTypeString:mimeTypeString |
|
1159 |
"given a file suffix, return the mime-type" |
|
1160 |
||
1161 |
^ self suffixForMimeType:(MIMEType fromString:mimeTypeString) |
|
1162 |
||
1163 |
" |
|
1164 |
self suffixForMimeTypeString:'image/gif' |
|
1165 |
" |
|
1166 |
||
1167 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
|
1168 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
|
1612 | 1169 |
! ! |
1170 |
||
2116 | 1171 |
!MIMETypes class methodsFor:'queries-applications'! |
1172 |
||
2117 | 1173 |
defaultCommandPerMIME |
1174 |
"returns the collection which is used to map MIME-type to command-templates." |
|
1175 |
||
1176 |
"TODO: move this to OS/UserPreferences" |
|
1177 |
||
1178 |
DefaultCommandPerMIMEPerOS isNil ifTrue:[ |
|
1179 |
self initializeDefaultCommands |
|
1180 |
]. |
|
1181 |
OperatingSystem isUNIXlike ifTrue:[ |
|
1182 |
^ DefaultCommandPerMIMEPerOS at:#unix |
|
1183 |
]. |
|
1184 |
^ DefaultCommandPerMIMEPerOS at:#win32 |
|
2942
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1185 |
|
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1186 |
" |
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1187 |
MIMETypes defaultCommandPerMIME |
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1188 |
" |
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1189 |
|
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1190 |
"Modified (comment): / 16-09-2011 / 16:20:12 / cg" |
2117 | 1191 |
! |
1192 |
||
2116 | 1193 |
defaultCommandTemplateToOpenMimeType:mimeType |
1194 |
|cmd| |
|
1195 |
||
1196 |
cmd := self defaultCommandPerMIME at:mimeType ifAbsent:nil. |
|
1197 |
cmd isNil ifTrue:[ |
|
1198 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
1199 |
cmd := Win32OperatingSystem::RegistryEntry commandTemplateToOpenMimeType:mimeType |
|
1200 |
]. |
|
1201 |
]. |
|
1202 |
^ cmd |
|
1203 |
||
1204 |
" |
|
1205 |
MIMETypes defaultCommandTemplateToOpenMimeType:'application/pdf' |
|
2118 | 1206 |
MIMETypes defaultCommandTemplateToOpenMimeType:'text/html' |
2116 | 1207 |
" |
1208 |
||
1209 |
"Created: / 12-05-2004 / 11:09:22 / cg" |
|
1210 |
"Modified: / 12-05-2004 / 11:16:53 / cg" |
|
1211 |
! |
|
1212 |
||
1213 |
defaultCommandTemplateToPrintMimeType:mimeType |
|
1214 |
|cmd| |
|
1215 |
||
1216 |
cmd := self defaultPrintCommandPerMIME at:mimeType ifAbsent:nil. |
|
1217 |
cmd isNil ifTrue:[ |
|
1218 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
1219 |
cmd := Win32OperatingSystem::RegistryEntry commandTemplateToPrintMimeType:mimeType |
|
1220 |
]. |
|
1221 |
]. |
|
1222 |
^ cmd |
|
1223 |
||
1224 |
" |
|
1225 |
MIMETypes defaultCommandTemplateToPrintMimeType:'application/pdf' |
|
1226 |
" |
|
2117 | 1227 |
! |
1228 |
||
1229 |
defaultPrintCommandPerMIME |
|
1230 |
"returns the collection which is used to map MIME-type to printing command-templates." |
|
1231 |
||
1232 |
"TODO: move this to OS/UserPreferences" |
|
1233 |
||
1234 |
DefaultPrintCommandPerMIMEPerOS isNil ifTrue:[ |
|
1235 |
self initializeDefaultCommands |
|
1236 |
]. |
|
1237 |
OperatingSystem isUNIXlike ifTrue:[ |
|
1238 |
^ DefaultPrintCommandPerMIMEPerOS at:#unix |
|
1239 |
]. |
|
1240 |
^ DefaultPrintCommandPerMIMEPerOS at:#win32 |
|
2116 | 1241 |
! ! |
1242 |
||
1729 | 1243 |
!MIMETypes class methodsFor:'queries-image formats'! |
1244 |
||
1245 |
imageReaderClasses |
|
1246 |
"return a collection of registered image reader classes" |
|
1247 |
||
1248 |
|setOfClasses| |
|
1249 |
||
1250 |
setOfClasses := IdentitySet new. |
|
1251 |
FileSuffixToImageReaderClassMapping notNil ifTrue:[ |
|
1252 |
FileSuffixToImageReaderClassMapping keysAndValuesDo:[:suff :cls | |
|
1253 |
setOfClasses add:cls |
|
1254 |
]. |
|
1255 |
]. |
|
1256 |
TypeToImageReaderClassMapping notNil ifTrue:[ |
|
1257 |
TypeToImageReaderClassMapping keysAndValuesDo:[:suff :cls | |
|
1258 |
setOfClasses add:cls |
|
1259 |
]. |
|
1260 |
]. |
|
1261 |
^ setOfClasses |
|
1262 |
||
1263 |
"Created: / 30.6.1997 / 22:03:42 / cg" |
|
1264 |
"Modified: / 1.8.1998 / 16:59:52 / cg" |
|
1265 |
! |
|
1266 |
||
1267 |
imageReaderForSuffix:aSuffix |
|
1268 |
"given a file suffix, return an approriate image reader class" |
|
1269 |
||
2724
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1270 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1271 |
self initializeImageReaderMappings |
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1272 |
]. |
1729 | 1273 |
^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil |
1274 |
||
1275 |
"Created: / 30.6.1997 / 21:59:11 / cg" |
|
1276 |
"Modified: / 1.8.1998 / 17:01:58 / cg" |
|
1277 |
! |
|
1278 |
||
1279 |
imageReaderForSuffix:aSuffix put:aReaderClass |
|
1280 |
"register an image reader for a file suffix" |
|
1281 |
||
1282 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
|
2724
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1283 |
self initializeImageReaderMappings |
1729 | 1284 |
]. |
1285 |
FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass |
|
1286 |
||
1287 |
"Created: / 30.6.1997 / 21:59:43 / cg" |
|
1288 |
"Modified: / 1.8.1998 / 17:02:14 / cg" |
|
1289 |
! |
|
1290 |
||
1291 |
imageReaderForType:mimeTypeString |
|
1292 |
"given a mime-type, return an approriate image reader class" |
|
1293 |
||
2724
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1294 |
TypeToImageReaderClassMapping isNil ifTrue:[ |
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1295 |
self initializeImageReaderMappings |
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1296 |
]. |
1729 | 1297 |
^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil |
1298 |
||
1299 |
"Created: / 30.6.1997 / 21:56:01 / cg" |
|
1300 |
"Modified: / 1.8.1998 / 17:02:28 / cg" |
|
1301 |
! |
|
1302 |
||
1303 |
imageReaderForType:mimeTypeString put:aReaderClass |
|
1304 |
"register an image reader for a mime-type" |
|
1305 |
||
1306 |
TypeToImageReaderClassMapping isNil ifTrue:[ |
|
2724
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1307 |
self initializeImageReaderMappings |
1729 | 1308 |
]. |
1309 |
TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass |
|
1310 |
||
1311 |
"Created: / 30.6.1997 / 21:56:11 / cg" |
|
1312 |
"Modified: / 1.8.1998 / 17:02:40 / cg" |
|
1313 |
! ! |
|
1314 |
||
1315 |
!MIMETypes class methodsFor:'queries-language syntax'! |
|
1316 |
||
1317 |
commentStringsForFilename:aFilename |
|
1318 |
"return a useful comment definition; heuristics for now. |
|
1319 |
The returned value is an array of 2 elements; |
|
1320 |
the first is the end-of-line comment string (or nil); |
|
1321 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1322 |
||
1323 |
|mime| |
|
1324 |
||
1325 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
1326 |
^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) |
|
1327 |
||
1328 |
" |
|
1329 |
MIMETypes commentStringsForFilename:'Makefile'. |
|
1330 |
MIMETypes commentStringsForFilename:'Object.st'. |
|
1331 |
MIMETypes commentStringsForFilename:'Foo.java'. |
|
1925 | 1332 |
MIMETypes commentStringsForFilename:'Foo.html'. |
1729 | 1333 |
" |
1334 |
! |
|
1335 |
||
1336 |
commentStringsForFilename:aFilename ifUnknown:alternativeBlockReturningCommentString |
|
1337 |
"return a useful comment definition; heuristics for now. |
|
1338 |
The returned value is an array of 2 elements; |
|
1339 |
the first is the end-of-line comment string (or nil); |
|
1340 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1341 |
||
1342 |
|mime| |
|
1343 |
||
1344 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
1345 |
^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternativeBlockReturningCommentString |
|
1346 |
||
1347 |
" |
|
1348 |
MIMETypes commentStringsForFilename:'Makefile'. |
|
1349 |
MIMETypes commentStringsForFilename:'Object.st'. |
|
1350 |
MIMETypes commentStringsForFilename:'Foo.java'. |
|
1351 |
" |
|
1352 |
! |
|
1353 |
||
1354 |
commentStringsForMimeType:mime suffix:suff |
|
1355 |
"return a useful comment definition; heuristics for now. |
|
1356 |
The returned value is an array of 2 elements; |
|
1357 |
the first is the end-of-line comment string (or nil); |
|
1358 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1359 |
||
1360 |
^ self |
|
1361 |
commentStringsForMimeType:mime suffix:suff |
|
1362 |
ifUnknown: #(';' (nil nil)) |
|
1363 |
||
1364 |
" |
|
1365 |
|mime| |
|
1366 |
||
1367 |
mime := MIMETypes mimeTypeForFilename:'Makefile'. |
|
1368 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1369 |
" |
|
1370 |
||
1371 |
" |
|
1372 |
|mime| |
|
1373 |
||
1374 |
mime := MIMETypes mimeTypeForFilename:'Object.st'. |
|
1375 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1376 |
" |
|
1377 |
! |
|
1378 |
||
1379 |
commentStringsForMimeType:mime suffix:suff ifUnknown:alternativeBlockReturningCommentString |
|
1380 |
"return a useful comment definition; heuristics for now. |
|
1381 |
The returned value is an array of 2 elements; |
|
1382 |
the first is the end-of-line comment string (or nil); |
|
1383 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1384 |
||
1385 |
|commentSpec| |
|
1386 |
||
1387 |
commentSpec := TypeToCommentStringMapping at:mime ifAbsent:nil. |
|
1388 |
commentSpec notNil ifTrue:[ |
|
1389 |
^ commentSpec |
|
1390 |
]. |
|
3492 | 1391 |
suff notNil ifTrue:[ |
1392 |
commentSpec := SuffixToCommentStringMapping at:suff ifAbsent:nil. |
|
1393 |
commentSpec notNil ifTrue:[ |
|
1394 |
^ commentSpec |
|
1395 |
]. |
|
1729 | 1396 |
]. |
1397 |
^ alternativeBlockReturningCommentString value |
|
1398 |
||
1399 |
" |
|
1400 |
|mime| |
|
1401 |
||
1402 |
mime := MIMETypes mimeTypeForFilename:'Makefile'. |
|
1403 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1404 |
" |
|
1405 |
||
1406 |
" |
|
1407 |
|mime| |
|
1408 |
||
1409 |
mime := MIMETypes mimeTypeForFilename:'Object.st'. |
|
1410 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1411 |
" |
|
2298 | 1412 |
! |
1413 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1414 |
parenthesisSpecForFilename:aFilename |
2298 | 1415 |
"return a useful parentesis spec; heuristics for now. |
1416 |
The returned value is a dictionary to be used as parentesis spec in an editor" |
|
1417 |
||
1418 |
|mime| |
|
1419 |
||
1420 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1421 |
^ self parenthesisSpecForMimeType:mime suffix:(aFilename asFilename suffix) |
2298 | 1422 |
|
1423 |
" |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1424 |
MIMETypes parenthesisSpecForFilename:'Object.st'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1425 |
MIMETypes parenthesisSpecForFilename:'Foo.java'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1426 |
MIMETypes parenthesisSpecForFilename:'Foo.html'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1427 |
MIMETypes parenthesisSpecForFilename:'Foo.lsp'. |
2298 | 1428 |
" |
1429 |
||
1430 |
"Created: / 10-04-2007 / 15:18:41 / cg" |
|
1431 |
! |
|
1432 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1433 |
parenthesisSpecForFilename:aFilename ifUnknown:alternative |
2298 | 1434 |
|mime| |
1435 |
||
1436 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1437 |
^ self parenthesisSpecForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternative |
2298 | 1438 |
|
1439 |
"Created: / 10-04-2007 / 15:26:20 / cg" |
|
1440 |
! |
|
1441 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1442 |
parenthesisSpecForMimeType:mime suffix:suff |
2298 | 1443 |
^ self |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1444 |
parenthesisSpecForMimeType:mime suffix:suff |
2298 | 1445 |
ifUnknown: nil |
1446 |
||
1447 |
"Created: / 10-04-2007 / 15:19:39 / cg" |
|
1448 |
! |
|
1449 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1450 |
parenthesisSpecForMimeType:mime suffix:suff ifUnknown:alternativeValue |
2298 | 1451 |
|spec| |
1452 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1453 |
spec := TypeToParenthesisSpecMapping at:mime ifAbsent:nil. |
2298 | 1454 |
spec notNil ifTrue:[ |
1455 |
^ spec |
|
1456 |
]. |
|
1457 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1458 |
spec := SuffixToParenthesisSpecMapping at:suff ifAbsent:nil. |
2298 | 1459 |
spec notNil ifTrue:[ |
1460 |
^ spec |
|
1461 |
]. |
|
1462 |
||
1463 |
^ alternativeValue value |
|
1464 |
||
1465 |
"Created: / 10-04-2007 / 15:20:38 / cg" |
|
1729 | 1466 |
! ! |
1467 |
||
1612 | 1468 |
!MIMETypes::MIMEType class methodsFor:'documentation'! |
1469 |
||
1470 |
documentation |
|
1471 |
" |
|
1864 | 1472 |
like a string, but knows that it represents a mimeType. |
3359 | 1473 |
mimetypes are singletons, remembered in the class variable CachedTypes. |
1612 | 1474 |
" |
1475 |
! ! |
|
1476 |
||
1477 |
!MIMETypes::MIMEType class methodsFor:'instance creation'! |
|
1478 |
||
1479 |
fromString:aString |
|
1480 |
|cachedType newType| |
|
1481 |
||
1482 |
aString class == self ifTrue:[^ aString]. |
|
1483 |
||
3011
f2af94d78383
delay initialization of cachedTypes
Claus Gittinger <cg@exept.de>
parents:
3008
diff
changeset
|
1484 |
CachedTypes isNil ifTrue:[ |
3012 | 1485 |
CachedTypes := Dictionary new:100. |
3011
f2af94d78383
delay initialization of cachedTypes
Claus Gittinger <cg@exept.de>
parents:
3008
diff
changeset
|
1486 |
]. |
1612 | 1487 |
cachedType := CachedTypes at:aString ifAbsent:nil. |
1488 |
cachedType notNil ifTrue:[^ cachedType]. |
|
3011
f2af94d78383
delay initialization of cachedTypes
Claus Gittinger <cg@exept.de>
parents:
3008
diff
changeset
|
1489 |
|
1612 | 1490 |
newType := aString copy changeClassTo:self. |
1491 |
CachedTypes at:aString put:newType. |
|
1492 |
^ newType |
|
1493 |
||
1494 |
" |
|
1495 |
self fromString:'text/html' |
|
1496 |
" |
|
3011
f2af94d78383
delay initialization of cachedTypes
Claus Gittinger <cg@exept.de>
parents:
3008
diff
changeset
|
1497 |
|
3012 | 1498 |
"Modified: / 20-07-2012 / 17:36:31 / cg" |
1612 | 1499 |
! ! |
1500 |
||
1501 |
!MIMETypes::MIMEType methodsFor:'queries'! |
|
1502 |
||
3359 | 1503 |
fileTypeInfo |
1504 |
^ MIMETypes fileTypeInfoForMimeType:self |
|
1505 |
||
1506 |
" |
|
1507 |
(MIMETypes mimeTypeFromString:'application/x-smalltalk-source') fileTypeInfo |
|
1508 |
" |
|
1509 |
! |
|
1510 |
||
1693 | 1511 |
isArchive |
3260 | 1512 |
<resource: #obsolete> |
1513 |
"return true, if I represent an archive type (such as zip or tar)" |
|
1514 |
||
1515 |
^ self isArchiveType |
|
1516 |
! |
|
1517 |
||
1518 |
isArchiveType |
|
1864 | 1519 |
"return true, if I represent an archive type (such as zip or tar)" |
1520 |
||
1612 | 1521 |
|archivTypes| |
1522 |
||
1729 | 1523 |
archivTypes := MIMETypes applicationCompressorsAndArchiveTypeList. |
1612 | 1524 |
archivTypes pairWiseDo:[: ext : type | |
1525 |
self = type ifTrue:[ ^ true]. |
|
1526 |
]. |
|
1527 |
^ false |
|
1528 |
! |
|
1529 |
||
2024 | 1530 |
isBinary |
3260 | 1531 |
<resource: #obsolete> |
1532 |
"return true, if I represent a binary (non-text) type" |
|
1533 |
||
1534 |
^ self isBinaryType |
|
1535 |
! |
|
1536 |
||
1537 |
isBinaryType |
|
2024 | 1538 |
"return true, if I represent a binary (non-text) type" |
1539 |
||
1540 |
^ self isTextType not |
|
1541 |
! |
|
1542 |
||
1612 | 1543 |
isHtml |
3260 | 1544 |
<resource: #obsolete> |
1545 |
"return true, if I represent the html text type" |
|
1546 |
||
1547 |
^ self isHtmlType |
|
1548 |
! |
|
1549 |
||
1550 |
isHtmlType |
|
1864 | 1551 |
"return true, if I represent the html text type" |
1612 | 1552 |
|
1553 |
^ (self = 'text/html') |
|
1554 |
! |
|
1555 |
||
1556 |
isImage |
|
3260 | 1557 |
<resource: #obsolete> |
1558 |
"return true, if I represent an image type (such as gif or jpg)" |
|
1559 |
||
1560 |
^ self isImageType |
|
1561 |
! |
|
1562 |
||
1563 |
isImageType |
|
1864 | 1564 |
"return true, if I represent an image type (such as gif or jpg)" |
1612 | 1565 |
|
1693 | 1566 |
^ (self startsWith:'image/') |
1612 | 1567 |
! |
1568 |
||
1569 |
isPdf |
|
3260 | 1570 |
<resource: #obsolete> |
1571 |
"return true, if I represent the pdf type" |
|
1572 |
||
1573 |
^ self isPdfType |
|
1574 |
! |
|
1575 |
||
1576 |
isPdfType |
|
1864 | 1577 |
"return true, if I represent the pdf type" |
1578 |
||
1612 | 1579 |
^ (self = 'application/pdf') |
1580 |
! |
|
1581 |
||
1582 |
isSmalltalkSource |
|
3260 | 1583 |
<resource: #obsolete> |
1584 |
"return true, if I represent the smalltalk sourcecode type" |
|
1585 |
||
1586 |
^ self isSmalltalkSourceType |
|
1587 |
! |
|
1588 |
||
1589 |
isSmalltalkSourceType |
|
1864 | 1590 |
"return true, if I represent the smalltalk sourcecode type" |
1591 |
||
3359 | 1592 |
^ (self startsWith: 'application/x-smalltalk-source') |
1783 | 1593 |
! |
1594 |
||
2024 | 1595 |
isTextType |
1596 |
"return true, if I represent some text type" |
|
1597 |
||
1598 |
^ self startsWith:'text/' |
|
1599 |
! |
|
1600 |
||
1783 | 1601 |
isXml |
3260 | 1602 |
<resource: #obsolete> |
1603 |
"return true, if I represent the xml text type" |
|
1604 |
||
1605 |
^ self isXmlType |
|
1606 |
! |
|
1607 |
||
1608 |
isXmlType |
|
1864 | 1609 |
"return true, if I represent the xml text type" |
1610 |
||
1783 | 1611 |
^ (self = 'text/xml') |
2490 | 1612 |
! |
1613 |
||
1614 |
suffix |
|
1615 |
^ MIMETypes suffixForMimeType:self |
|
1616 |
||
1617 |
" |
|
1618 |
(MIMETypes mimeTypeFromString:'application/x-expecco-testsuite') suffix |
|
1619 |
" |
|
643 | 1620 |
! ! |
1621 |
||
1622 |
!MIMETypes class methodsFor:'documentation'! |
|
1623 |
||
1624 |
version |
|
3482 | 1625 |
^ '$Header$' |
2758
66e62ceecb67
comment/format in: #defaultCommandForMimeType:
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
1626 |
! |
66e62ceecb67
comment/format in: #defaultCommandForMimeType:
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
1627 |
|
66e62ceecb67
comment/format in: #defaultCommandForMimeType:
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
1628 |
version_CVS |
3482 | 1629 |
^ '$Header$' |
643 | 1630 |
! ! |
1666 | 1631 |
|
3104 | 1632 |
|
643 | 1633 |
MIMETypes initialize! |