author | Stefan Vogel <sv@exept.de> |
Tue, 09 Jan 2018 17:36:51 +0100 | |
changeset 4039 | f21b5b4936f4 |
parent 4030 | 837bae830c08 |
child 4043 | d7895e68fa21 |
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'. |
|
4030 | 298 |
TypeToInfoMapping at:'application/x-javascript' put:'JavaScript source'. |
3359 | 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 |
" |
|
4030 | 310 |
|
311 |
"Modified: / 30-11-2017 / 07:54:23 / mawalch" |
|
3359 | 312 |
! |
313 |
||
1729 | 314 |
initializeFileNameToMimeTypeMapping |
315 |
"initialize wellKnown facts" |
|
316 |
||
317 |
|types| |
|
318 |
||
319 |
FileSuffixToTypeMapping isNil ifTrue:[ |
|
3870 | 320 |
FileSuffixToTypeMapping := Dictionary new:270. |
1729 | 321 |
]. |
1887 | 322 |
TypeToFileSuffixMapping isNil ifTrue:[ |
3870 | 323 |
TypeToFileSuffixMapping := Dictionary new:105. |
1887 | 324 |
]. |
1729 | 325 |
FilenameToTypeMapping isNil ifTrue:[ |
3870 | 326 |
FilenameToTypeMapping := Dictionary new:16. |
1729 | 327 |
]. |
328 |
||
329 |
types := OrderedCollection new. |
|
330 |
types addAll:self textTypeList. |
|
331 |
types addAll:self imageTypeList. |
|
332 |
types addAll:self videoTypeList. |
|
333 |
types addAll:self audioTypeList. |
|
334 |
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
|
335 |
types addAll:self osSpecificTypeList. |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
336 |
|
1729 | 337 |
types pairWiseDo:[:suff :typeString| |
3870 | 338 |
|mimeType| |
1729 | 339 |
|
3870 | 340 |
mimeType := MIMEType fromString:typeString. |
1729 | 341 |
suff isArray ifTrue:[ |
3870 | 342 |
suff do:[:s |FileSuffixToTypeMapping at:s put:mimeType]. |
343 |
TypeToFileSuffixMapping at:mimeType put:suff first. |
|
1729 | 344 |
] ifFalse:[ |
3870 | 345 |
FileSuffixToTypeMapping at:suff put:mimeType. |
346 |
TypeToFileSuffixMapping at:mimeType put:suff. |
|
1887 | 347 |
]. |
1729 | 348 |
]. |
349 |
||
3870 | 350 |
self miscFilenameList pairWiseDo:[:suffixes :typeString| |
351 |
|mimeType| |
|
1729 | 352 |
|
3870 | 353 |
mimeType := MIMEType fromString:typeString. |
354 |
suffixes isArray ifTrue:[ |
|
355 |
suffixes do:[:eachSuffix | FilenameToTypeMapping at:eachSuffix put:mimeType] |
|
1729 | 356 |
] ifFalse:[ |
3870 | 357 |
FilenameToTypeMapping at:suffixes put:mimeType |
1729 | 358 |
] |
359 |
]. |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
360 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
361 |
" |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
362 |
self initializeFileNameToMimeTypeMapping |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
363 |
" |
3870 | 364 |
|
365 |
"Modified (format): / 09-02-2017 / 14:59:33 / stefan" |
|
1729 | 366 |
! |
367 |
||
368 |
initializeImageReaderMappings |
|
3359 | 369 |
"these are used so select an image reader, based on a bitmap image's mime type" |
370 |
||
3295 | 371 |
|rdr| |
372 |
||
1729 | 373 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
374 |
FileSuffixToImageReaderClassMapping := Dictionary new |
|
375 |
]. |
|
376 |
"MIME" TypeToImageReaderClassMapping isNil ifTrue:[ |
|
377 |
TypeToImageReaderClassMapping := Dictionary new |
|
378 |
]. |
|
379 |
||
380 |
"/ setup mimeType to image reader class mapping ... |
|
3870 | 381 |
self imageReaderForType:'image/jpeg' put:JPEGReader. |
382 |
self imageReaderForType:'image/gif' put:GIFReader. |
|
383 |
self imageReaderForType:'image/tiff' put:TIFFReader. |
|
3978 | 384 |
self imageReaderForType:'image/x-adobe-dng' put:TIFFReader. |
3870 | 385 |
self imageReaderForType:'image/png' put:PNGReader. |
386 |
self imageReaderForType:'image/icns' put:MacOSXIconReader. |
|
1729 | 387 |
|
388 |
"/ setup suffix to image reader class mapping ... |
|
3870 | 389 |
self imageReaderForSuffix:'jpg' put:JPEGReader. |
390 |
self imageReaderForSuffix:'jpeg' put:JPEGReader. |
|
391 |
self imageReaderForSuffix:'gif' put:GIFReader. |
|
392 |
self imageReaderForSuffix:'tif' put:TIFFReader. |
|
393 |
self imageReaderForSuffix:'tiff' put:TIFFReader. |
|
394 |
self imageReaderForSuffix:'png' put:PNGReader. |
|
395 |
self imageReaderForSuffix:'icns' put:MacOSXIconReader. |
|
2570 | 396 |
|
3295 | 397 |
"/ some 'used-to-be-optional' readers |
398 |
(rdr := Smalltalk at:#WindowsIconReader) notNil ifTrue:[ |
|
3870 | 399 |
self imageReaderForType:'image/bmp' put:rdr. |
400 |
self imageReaderForType:'image/x-MS-bmp' put:rdr. |
|
401 |
self imageReaderForType:'image/x-ms-bmp' put:rdr. |
|
402 |
self imageReaderForType:'image/x-MS-ico' put:rdr. |
|
403 |
self imageReaderForType:'image/x-ms-ico' put:rdr. |
|
404 |
self imageReaderForSuffix:'bmp' put:rdr. |
|
405 |
self imageReaderForSuffix:'ico' put:rdr. |
|
3295 | 406 |
]. |
407 |
(rdr := Smalltalk at:#XBMReader) notNil ifTrue:[ |
|
3870 | 408 |
self imageReaderForType:'image/x-xbitmap' put:rdr. |
409 |
self imageReaderForSuffix:'xbm' put:rdr. |
|
3295 | 410 |
]. |
411 |
(rdr := Smalltalk at:#XPMReader) notNil ifTrue:[ |
|
3870 | 412 |
self imageReaderForType:'image/x-xpixmap' put:rdr. |
413 |
self imageReaderForSuffix:'pm' put:rdr. |
|
3295 | 414 |
]. |
415 |
(rdr := Smalltalk at:#PBMReader) notNil ifTrue:[ |
|
3870 | 416 |
self imageReaderForType:'image/x-portable-pixmap' put:rdr. |
417 |
self imageReaderForType:'image/x-portable-bitmap' put:rdr. |
|
418 |
self imageReaderForType:'image/x-portable-graymap' put:rdr. |
|
419 |
self imageReaderForType:'image/x-portable-anymap' put:rdr. |
|
420 |
self imageReaderForSuffix:'ppm' put:rdr. |
|
421 |
self imageReaderForSuffix:'pbm' put:rdr. |
|
422 |
self imageReaderForSuffix:'pgm' put:rdr. |
|
423 |
self imageReaderForSuffix:'pnm' put:rdr. |
|
3295 | 424 |
]. |
425 |
(rdr := Smalltalk at:#PCXReader) notNil ifTrue:[ |
|
3870 | 426 |
self imageReaderForType:'image/x-pcx' put:rdr. |
427 |
self imageReaderForSuffix:'pcx' put:rdr. |
|
3295 | 428 |
]. |
429 |
(rdr := Smalltalk at:#TargaReader) notNil ifTrue:[ |
|
3870 | 430 |
self imageReaderForType:'image/x-targa' put:rdr. |
431 |
self imageReaderForSuffix:'tga' put:rdr. |
|
3295 | 432 |
]. |
433 |
(rdr := Smalltalk at:#XWDReader) notNil ifTrue:[ |
|
3870 | 434 |
self imageReaderForType:'image/x-xwindowdump' put:rdr. |
435 |
self imageReaderForType:'image/x-windowdump' put:rdr. |
|
436 |
self imageReaderForSuffix:'xwd' put:rdr. |
|
3295 | 437 |
]. |
438 |
(rdr := Smalltalk at:#BlitImageReader) notNil ifTrue:[ |
|
3870 | 439 |
self imageReaderForType:'image/x-blitimage' put:rdr. |
440 |
self imageReaderForSuffix:'48x48x1' put:rdr. |
|
3295 | 441 |
]. |
442 |
(rdr := Smalltalk at:#IrisRGBReader) notNil ifTrue:[ |
|
3870 | 443 |
self imageReaderForType:'image/x-rgb' put:rdr. |
444 |
self imageReaderForSuffix:'rgb' put:rdr. |
|
3295 | 445 |
]. |
446 |
(rdr := Smalltalk at:#SunRasterReader) notNil ifTrue:[ |
|
3870 | 447 |
self imageReaderForType:'image/x-sunraster' put:rdr. |
448 |
self imageReaderForSuffix:'im8' put:rdr. |
|
449 |
self imageReaderForSuffix:'icon' put:rdr. |
|
2570 | 450 |
]. |
3295 | 451 |
(rdr := Smalltalk at:#ST80FormReader) notNil ifTrue:[ |
3870 | 452 |
self imageReaderForType:'image/x-st80-form' put:rdr. |
453 |
self imageReaderForSuffix:'form' put:rdr. |
|
3295 | 454 |
]. |
455 |
(rdr := Smalltalk at:#FaceReader) notNil ifTrue:[ |
|
3870 | 456 |
self imageReaderForType:'image/x-face' put:rdr. |
457 |
self imageReaderForSuffix:'face' put:rdr. |
|
3295 | 458 |
]. |
459 |
(rdr := Smalltalk at:#PCDReader) notNil ifTrue:[ |
|
3870 | 460 |
self imageReaderForType:'image/x-photo-cd' put:rdr. |
461 |
self imageReaderForSuffix:'pcd' put:rdr. |
|
3295 | 462 |
]. |
463 |
(rdr := Smalltalk at:#CMURasterReader) notNil ifTrue:[ |
|
3870 | 464 |
self imageReaderForType:'image/x-cmu-raster' put:rdr. |
465 |
self imageReaderForSuffix:'ras' put:rdr. |
|
3295 | 466 |
]. |
467 |
||
3359 | 468 |
"/ movie formats - experimental and not yet complete / finished / delivered / published |
3295 | 469 |
"/ (rdr := Smalltalk at:#FLIReader) notNil ifTrue:[ |
3870 | 470 |
"/ self imageReaderForType:'video/x-fli' put:rdr. |
471 |
"/ self imageReaderForSuffix:'fli' put:rdr. |
|
3295 | 472 |
"/ ]. |
473 |
"/ (rdr := Smalltalk at:#AVIReader) notNil ifTrue:[ |
|
3870 | 474 |
"/ self imageReaderForType:'video/x-msvideo' put:rdr. |
475 |
"/ self imageReaderForSuffix:'avi' put:rdr. |
|
3295 | 476 |
"/ ]. |
477 |
"/ (rdr := Smalltalk at:#AVIReader) notNil ifTrue:[ |
|
3870 | 478 |
"/ self imageReaderForType:'video/x-msvideo' put:rdr. |
479 |
"/ self imageReaderForSuffix:'avi' put:rdr. |
|
3295 | 480 |
"/ ]. |
481 |
"/ (rdr := Smalltalk at:#QuickTimeReader) notNil ifTrue:[ |
|
3870 | 482 |
"/ self imageReaderForType:'video/quicktime' put:rdr. |
483 |
"/ self imageReaderForSuffix:'qt' put:rdr. |
|
484 |
"/ self imageReaderForSuffix:'mov' put:rdr. |
|
485 |
"/ self imageReaderForSuffix:'moov' put:rdr. |
|
3295 | 486 |
"/ ]. |
487 |
"/ (rdr := Smalltalk at:#MPEG2Reader) notNil ifTrue:[ |
|
3870 | 488 |
"/ self imageReaderForType:'video/x-mpeg2' put:rdr. |
489 |
"/ self imageReaderForSuffix:'mpg2' put:rdr. |
|
490 |
"/ self imageReaderForSuffix:'mpv2' put:rdr. |
|
491 |
"/ self imageReaderForSuffix:'mp2v' put:rdr. |
|
492 |
"/ self imageReaderForSuffix:'mp2' put:rdr. |
|
3295 | 493 |
"/ ]. |
494 |
"/ (rdr := Smalltalk at:#MPEGReader) notNil ifTrue:[ |
|
3870 | 495 |
"/ self imageReaderForType:'video/mpeg' put:rdr. |
496 |
"/ self imageReaderForSuffix:'mpg' put:rdr. |
|
497 |
"/ self imageReaderForSuffix:'mpeg' put:rdr. |
|
498 |
"/ self imageReaderForSuffix:'mpe' put:rdr. |
|
499 |
"/ self imageReaderForSuffix:'mpv' put:rdr. |
|
500 |
"/ self imageReaderForSuffix:'vps' put:rdr. |
|
501 |
"/ self imageReaderForSuffix:'mpegv' put:rdr. |
|
3295 | 502 |
"/ ]. |
503 |
"/ (rdr := Smalltalk at:#SGIMovieReader) notNil ifTrue:[ |
|
3870 | 504 |
"/ self imageReaderForType:'video/x-sgi-movie' put:rdr. |
505 |
"/ self imageReaderForSuffix:'movie' put:rdr. |
|
3295 | 506 |
"/ ]. |
3870 | 507 |
|
508 |
"Modified (format): / 09-02-2017 / 15:46:48 / stefan" |
|
3978 | 509 |
"Modified: / 25-08-2017 / 15:24:51 / cg" |
2298 | 510 |
! |
511 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
512 |
initializeParenthesisSpecMappings |
3359 | 513 |
"these are used by the editors to mark matching parenthesis" |
514 |
||
2298 | 515 |
|spec| |
516 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
517 |
TypeToParenthesisSpecMapping := Dictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
518 |
SuffixToParenthesisSpecMapping := Dictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
519 |
|
2298 | 520 |
"/ ST/X spec |
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 |
spec at:#eolComment put:'"/'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
526 |
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
|
527 |
|
2479 | 528 |
"/ XML & HTML |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
529 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
530 |
spec at:#open put:#( $< ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
531 |
spec at:#close put:#( $> ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
532 |
spec at:#ignore put:#( $' $" '$[' '$]' '${' '$)' ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
533 |
#( '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
|
534 |
TypeToParenthesisSpecMapping at:eachXMLType put:spec |
2298 | 535 |
]. |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
536 |
|
3359 | 537 |
"/ ANSI-c, Java, C# |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
538 |
spec := IdentityDictionary new. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
539 |
spec at:#open put:#( $( $[ ${ ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
540 |
spec at:#close put:#( $) $] $} ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
541 |
spec at:#ignore put:#( $' $" ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
542 |
spec at:#eolComment put:'//'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
543 |
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
|
544 |
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
|
545 |
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
|
546 |
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
|
547 |
TypeToParenthesisSpecMapping at:'application/x-javascript' put:spec. |
3482 | 548 |
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
|
549 |
|
3359 | 550 |
"/ Lisp / Scheme |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
551 |
spec := IdentityDictionary new. |
3039 | 552 |
spec at:#open put:#( $( $[ ). |
553 |
spec at:#close put:#( $) $] ). |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
554 |
spec at:#ignore put:#( $" ). |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
555 |
spec at:#eolComment put:';'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
556 |
TypeToParenthesisSpecMapping at:'application/x-lisp-source' put:spec. |
2298 | 557 |
|
558 |
"Created: / 10-04-2007 / 15:16:37 / cg" |
|
1729 | 559 |
! ! |
560 |
||
561 |
!MIMETypes class methodsFor:'initialization-lists'! |
|
562 |
||
563 |
applicationCompressorsAndArchiveTypeList |
|
3862 | 564 |
"compressor applications" |
565 |
||
1604 | 566 |
^ #( |
3862 | 567 |
"/ the first column is a list of extensions, the second the more-or-less official mimetype |
568 |
||
1890 | 569 |
'tar' 'application/x-tar' |
570 |
'gtar' 'application/x-gtar' |
|
1891 | 571 |
('tgz' 'tar.gz') 'application/x-tar-gzip-compressed' "/ 'application/x-tar-compressed' |
572 |
('tar.bz2') 'application/x-tar-bzip2-compressed' |
|
1890 | 573 |
'zip' 'application/x-zip-compressed' |
574 |
'bz2' 'application/x-bzip2-compressed' |
|
575 |
('gz' 'z') 'application/x-gzip-compressed' |
|
576 |
'cpio' 'application/x-cpio' |
|
577 |
'shar' 'application/x-shar' |
|
578 |
'jar' 'application/java-archive' |
|
579 |
'sar' 'application/x-squeak-archive' |
|
580 |
'sit' 'application/x-stuffit' |
|
581 |
'hqx' 'application/mac-binhex40' |
|
582 |
'cpt' 'application/mac-compactpro' |
|
3756 | 583 |
'pkg' 'application/x-xar' "/ a mac archiver for packages |
1604 | 584 |
) |
3862 | 585 |
|
586 |
"Modified (format): / 05-02-2017 / 19:37:10 / cg" |
|
1604 | 587 |
! |
645 | 588 |
|
1609 | 589 |
applicationMiscTypeList |
590 |
"misc applications" |
|
591 |
||
592 |
^ #( |
|
3862 | 593 |
"/ the first column is a list of extensions, the second the more-or-less official mimetype |
594 |
||
3870 | 595 |
('a' 'o' 'obj' ) 'application/binary' |
596 |
'lic' 'application/license' |
|
597 |
('dll' 'so') 'application/shared-library' |
|
2486
42063a7fc3db
mimeType: x-expecco-testSuite (extension: ets)
Claus Gittinger <cg@exept.de>
parents:
2479
diff
changeset
|
598 |
|
3870 | 599 |
'ets' 'application/x-expecco-testsuite' |
600 |
'etr' 'application/x-expecco-testrepository' |
|
601 |
'elf' 'application/x-expecco-logfile' |
|
602 |
'expeccolicense' 'application/x-expecco-license' |
|
603 |
'expeccopatch' 'application/x-expecco-patch' |
|
1609 | 604 |
) |
2886
22b48a4da285
comment/format in: #initializeFileNameToMimeTypeMapping
sr
parents:
2830
diff
changeset
|
605 |
|
2968 | 606 |
"Modified: / 03-11-2011 / 10:42:28 / sr" |
3862 | 607 |
"Modified (format): / 05-02-2017 / 19:37:05 / cg" |
3870 | 608 |
"Modified: / 09-02-2017 / 14:31:45 / stefan" |
1609 | 609 |
! |
610 |
||
1604 | 611 |
applicationProgLangTypeList |
3020
3f9c74ff0975
changed: #applicationProgLangTypeList
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
612 |
"applications for programming languages" |
713 | 613 |
|
1604 | 614 |
^ #( |
3862 | 615 |
"/ the first column is a list of extensions, the second the more-or-less official mimetype |
616 |
||
1609 | 617 |
('st' 'cls' 'rc') 'application/x-smalltalk-source' |
1604 | 618 |
'sif' 'application/x-smalltalk-source-sif' |
1668 | 619 |
'pac' 'application/x-smalltalk-dolphin-package' |
1778 | 620 |
|
621 |
'sts' 'application/x-squeak-source' |
|
622 |
'pr' 'application/x-squeak-project' |
|
623 |
||
1604 | 624 |
'c' 'application/x-c-source' |
625 |
('cc' 'cpp') 'application/x-cpp-source' |
|
2479 | 626 |
'cs' 'application/x-csharp-source' |
1609 | 627 |
('h' 'hi') 'application/x-c-header' |
1604 | 628 |
('js' 'mocha') 'application/x-javascript' |
629 |
('java' 'jav') 'application/x-java-source' |
|
630 |
'sh' 'application/x-sh' |
|
631 |
'csh' 'application/x-csh' |
|
632 |
'tcl' 'application/x-tcl' |
|
633 |
'pl' 'application/x-perl' |
|
3020
3f9c74ff0975
changed: #applicationProgLangTypeList
Claus Gittinger <cg@exept.de>
parents:
3014
diff
changeset
|
634 |
'dart' 'application/x-dart' |
1604 | 635 |
'mak' 'application/x-make' |
636 |
'bat' 'application/x-batch-script' |
|
3008 | 637 |
('asn1' 'x409' 'gdmo' 'gdm') 'application/x-asn1-source' |
638 |
||
2912
f3466ea0810b
changed: #applicationProgLangTypeList
Claus Gittinger <cg@exept.de>
parents:
2911
diff
changeset
|
639 |
('lisp' 'lsp' 'scm' 'ss' |
f3466ea0810b
changed: #applicationProgLangTypeList
Claus Gittinger <cg@exept.de>
parents:
2911
diff
changeset
|
640 |
'arc' 'cl' 'brg') 'application/x-lisp-source' |
3961 | 641 |
|
3482 | 642 |
'py' 'application/x-python-source' |
3961 | 643 |
('pyc' 'pyo' ) 'application/x-python-compiled-bytecode' |
644 |
'pyd' 'application/x-python-compiled-code' |
|
645 |
'whl' 'application/x-python-wheel-package' |
|
1604 | 646 |
) |
2298 | 647 |
|
3961 | 648 |
"Modified: / 23-06-2017 / 13:34:37 / cg" |
1604 | 649 |
! |
1561 | 650 |
|
1604 | 651 |
applicationTextTypeList |
1606 | 652 |
"text applications" |
1604 | 653 |
|
654 |
^ #( |
|
3862 | 655 |
"/ the first column is a list of extensions, the second the more-or-less official mimetype |
656 |
||
1604 | 657 |
('ps' 'eps') 'application/postscript' |
1778 | 658 |
"/ 'ai' 'application/postscript' |
1604 | 659 |
'pdf' 'application/pdf' |
660 |
'rtf' 'application/rtf' |
|
1778 | 661 |
"/ 'rtf' 'text/rtf' ???? |
3008 | 662 |
'ics' 'text/calendar' |
663 |
'doc' 'application/ms-word-document' |
|
1778 | 664 |
"/ 'doc' 'application/winword' |
665 |
'swf' 'application/x-shockwave-flash' |
|
666 |
('ppt' 'ppz' 'pot' 'pps') 'application/mspowerpoint' |
|
2028 | 667 |
'xls' 'application/x-excel' |
668 |
'slk' 'application/vnd.ms-excel' |
|
2911
7afaf1fdae8b
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
2904
diff
changeset
|
669 |
'txt' 'text/plain' |
2970
8b91ec204044
comment/format in: #initialize
Claus Gittinger <cg@exept.de>
parents:
2968
diff
changeset
|
670 |
'xlsx' 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' |
3476 | 671 |
'xltx' 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' |
672 |
'potx' 'application/vnd.openxmlformats-officedocument.presentationml.template' |
|
673 |
'ppsx' 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' |
|
674 |
'pptx' 'application/vnd.openxmlformats-officedocument.presentationml.presentation' |
|
675 |
'sldx' 'application/vnd.openxmlformats-officedocument.presentationml.slide' |
|
676 |
'docx' 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' |
|
677 |
'dotx' 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' |
|
678 |
'xlam' 'application/vnd.ms-excel.addin.macroEnabled.12' |
|
679 |
'xlsb' 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' |
|
3952 | 680 |
'xhtml' 'application/xhtml+xml' |
3482 | 681 |
|
682 |
'edi' 'application/EDIFACT' |
|
1604 | 683 |
) |
2911
7afaf1fdae8b
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
2904
diff
changeset
|
684 |
|
3008 | 685 |
"Modified: / 26-05-2012 / 15:27:30 / cg" |
3476 | 686 |
"Modified: / 18-05-2015 / 09:46:47 / sr" |
3862 | 687 |
"Modified (format): / 05-02-2017 / 19:37:20 / cg" |
1604 | 688 |
! |
689 |
||
690 |
applicationTypeList |
|
1606 | 691 |
"applications" |
1604 | 692 |
|
1729 | 693 |
|typeList| |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
694 |
|
1729 | 695 |
typeList := OrderedCollection new. |
696 |
typeList addAll:self applicationProgLangTypeList. |
|
697 |
typeList addAll:self applicationTextTypeList. |
|
698 |
typeList addAll:self applicationCompressorsAndArchiveTypeList. |
|
699 |
typeList addAll:self applicationMiscTypeList. |
|
1616 | 700 |
|
1729 | 701 |
^ typeList |
1604 | 702 |
! |
703 |
||
704 |
audioTypeList |
|
1606 | 705 |
"audio formats ..." |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
706 |
|
1604 | 707 |
^ #( |
3862 | 708 |
"/ the first column is a list of extensions, the second the more-or-less official mimetype |
709 |
||
1720 | 710 |
('au' 'snd') 'audio/basic' |
3870 | 711 |
'ra' 'audio/x-realaudio' |
1778 | 712 |
('ram' 'rm') 'audio/x-pn-realaudio' |
3862 | 713 |
"/ cg: see unixSpecific / windowsSpecific |
714 |
"/ 'rpm' 'audio/x-pn-realaudio-plugin' |
|
3008 | 715 |
('mpa' 'mpega' 'mpga') 'audio/mpeg' |
3862 | 716 |
"/ 'mp3' 'audio/x-mp3' |
1778 | 717 |
('mp3' 'mp2') 'audio/mpeg' |
1604 | 718 |
'wav' 'audio/x-wav' |
719 |
('aif' 'aiff' 'aifc') 'audio/x-aiff' |
|
1778 | 720 |
('midi' 'mid') 'audio/midi' |
1604 | 721 |
) |
3008 | 722 |
|
723 |
"Modified: / 26-05-2012 / 15:23:45 / cg" |
|
3862 | 724 |
"Modified (comment): / 05-02-2017 / 19:37:48 / cg" |
3870 | 725 |
"Modified: / 09-02-2017 / 14:29:59 / stefan" |
1604 | 726 |
! |
727 |
||
728 |
imageTypeList |
|
4013 | 729 |
"/ wellknown image formats ... |
1604 | 730 |
|
731 |
^ #( |
|
3862 | 732 |
"/ the first column is a list of extensions, the second the more-or-less official mimetype |
733 |
||
1216 | 734 |
('jpg' 'jpeg') 'image/jpeg' |
1188 | 735 |
'gif' 'image/gif' |
736 |
('tif' 'tiff') 'image/tiff' |
|
3295 | 737 |
('xbm' 'bm') 'image/x-xbitmap' |
1188 | 738 |
'xpm' 'image/x-xpixmap' |
1720 | 739 |
'png' 'image/png' |
1188 | 740 |
'pcd' 'image/x-photo-cd' |
741 |
'bmp' 'image/x-MS-bmp' |
|
742 |
'rgb' 'image/x-rgb' |
|
743 |
'ppm' 'image/x-portable-pixmap' |
|
744 |
'pgm' 'image/x-portable-graymap' |
|
745 |
'pbm' 'image/x-portable-bitmap' |
|
746 |
'pnm' 'image/x-portable-anymap' |
|
747 |
'xwd' 'image/x-xwindowdump' |
|
748 |
'ras' 'image/x-cmu-raster' |
|
1216 | 749 |
'tga' 'image/x-targa' |
4013 | 750 |
'ico' 'image/x-icon' |
3380 | 751 |
'icns' 'image/icns' |
3978 | 752 |
'dng' 'image/x-adobe-dng' |
3862 | 753 |
) |
754 |
||
4013 | 755 |
"Modified: / 13-09-2017 / 09:05:15 / cg" |
1604 | 756 |
! |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
757 |
|
1609 | 758 |
miscFilenameList |
3104 | 759 |
"other formats (not by suffix, but by fileName instead) ..." |
1609 | 760 |
|
761 |
^ #( |
|
3862 | 762 |
"/ the first column is a list of extensions, the second the more-or-less official mimetype |
763 |
||
2113 | 764 |
('makefile' 'make.proto' 'make.spec' 'nt.mak') 'application/x-make' |
2830 | 765 |
('exe' 'bin' 'com') 'application/octet-stream' |
2113 | 766 |
('class') 'application/octet-stream' |
2375 | 767 |
('top') 'application/x-waltop-digital-notepad' |
1609 | 768 |
) |
3862 | 769 |
|
770 |
"Modified (comment): / 05-02-2017 / 19:38:00 / cg" |
|
1609 | 771 |
! |
772 |
||
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
773 |
osSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
774 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
775 |
^ self windowsSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
776 |
]. |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
777 |
^ self unixSpecificTypeList |
2023 | 778 |
|
779 |
" |
|
780 |
self osSpecificTypeList |
|
781 |
" |
|
1888
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 |
|
1604 | 784 |
textTypeList |
785 |
"/ misc text ... |
|
786 |
||
787 |
^ #( |
|
3862 | 788 |
"/ the first column is a list of extensions, the second the more-or-less official mimetype |
789 |
||
1887 | 790 |
('html' 'htm' 'shtml') 'text/html' |
1604 | 791 |
('txt' 'text') 'text/plain' |
1680 | 792 |
'xml' 'text/xml' |
3862 | 793 |
'fxml' 'text/xml' |
3517 | 794 |
'xsd' 'text/xml' |
1777 | 795 |
'css' 'text/css' |
2432 | 796 |
'csv' 'text/csv' |
1604 | 797 |
) |
3862 | 798 |
|
799 |
"Modified: / 05-02-2017 / 19:38:12 / cg" |
|
1604 | 800 |
! |
801 |
||
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
802 |
unixSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
803 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
804 |
^ #( |
3862 | 805 |
"/ the first column is a list of extensions, the second the more-or-less official mimetype |
806 |
||
807 |
"/ cg: RPM is 'audio/x-pn-realaudio-plugin' for WIN32 |
|
808 |
"/ and 'application/x-rpm' for Unix |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
809 |
'rpm' 'application/x-rpm' |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
810 |
) |
3862 | 811 |
|
812 |
"Modified (comment): / 05-02-2017 / 19:38:23 / cg" |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
813 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
814 |
|
1604 | 815 |
videoTypeList |
816 |
"/ video formats ... |
|
817 |
||
818 |
^ #( |
|
3862 | 819 |
"/ the first column is a list of extensions, the second the more-or-less official mimetype |
820 |
||
1720 | 821 |
('qt' 'mov' 'moov') 'video/quicktime' |
822 |
('mpv' 'mpegv' 'mpg' 'mpeg' 'mpe') 'video/mpeg' |
|
1604 | 823 |
'movie' 'video/x-sgi-movie' |
1820 | 824 |
('avi' 'wmv' 'asf') 'video/x-msvideo' |
1604 | 825 |
('mpv2' 'mp2v' 'mp2' 'mpeg2') 'video/x-mpeg2' |
3367 | 826 |
('mp4') 'video/mp4' |
1680 | 827 |
'rm' 'application/vnd.rn-realmedia' |
828 |
'rv' 'video/x-pn-realvideo' |
|
3295 | 829 |
'fli' 'video/x-fli' |
3367 | 830 |
'flv' 'video/x-flv' "/ macromedia flash video |
1778 | 831 |
) |
3862 | 832 |
|
833 |
"Modified (comment): / 05-02-2017 / 19:38:33 / cg" |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
834 |
! |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
835 |
|
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
836 |
windowsSpecificTypeList |
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
837 |
^ #( |
3862 | 838 |
"/ the first column is a list of extensions, the second the more-or-less official mimetype |
839 |
||
840 |
"/ cg: RPM is 'audio/x-pn-realaudio-plugin' for WIN32 |
|
841 |
"/ and 'application/x-rpm' for Unix |
|
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
842 |
'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
|
843 |
) |
3862 | 844 |
|
845 |
"Modified (comment): / 05-02-2017 / 19:38:42 / cg" |
|
643 | 846 |
! ! |
847 |
||
1729 | 848 |
!MIMETypes class methodsFor:'obsolete'! |
1489 | 849 |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
850 |
defaultCommandForMimeType:mimeType |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
851 |
<resource: #obsolete> |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
852 |
self obsoleteMethodWarning:'use #defaultCommandTemplateToOpenMimeType:'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
853 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
854 |
^ self defaultCommandTemplateToOpenMimeType:mimeType |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
855 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
856 |
" |
2758
66e62ceecb67
comment/format in: #defaultCommandForMimeType:
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
857 |
MIMETypes defaultCommandTemplateToOpenMimeType:'application/pdf' |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
858 |
" |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
859 |
|
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
860 |
"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
|
861 |
"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
|
862 |
! |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
863 |
|
1729 | 864 |
fontForCharset:aCharSetName |
865 |
"return the font-encoding for an iso-charset" |
|
1489 | 866 |
|
1981 | 867 |
<resource:#obsolete> |
1729 | 868 |
self obsoleteMethodWarning:'use FontDescription >> fontNamePatternForCharset:'. |
869 |
^ FontDescription fontNamePatternForCharset:aCharSetName. |
|
1489 | 870 |
|
871 |
" |
|
1729 | 872 |
MIMETypes fontForCharset:'iso2022-jp' |
873 |
MIMETypes fontForCharset:'euc-jp' |
|
1472 | 874 |
" |
875 |
||
1729 | 876 |
"Modified: / 1.8.1998 / 17:00:57 / cg" |
877 |
! ! |
|
1472 | 878 |
|
1729 | 879 |
!MIMETypes class methodsFor:'queries'! |
1472 | 880 |
|
647 | 881 |
defineImageType:mimeType suffix:aSuffix reader:aReaderClass |
882 |
"register an image reader." |
|
883 |
||
3981 | 884 |
self defineImageType:mimeType suffix:aSuffix reader:aReaderClass info:nil |
885 |
||
886 |
"Modified: / 26-08-2017 / 10:30:00 / cg" |
|
887 |
! |
|
888 |
||
889 |
defineImageType:mimeType suffix:aSuffix reader:aReaderClass info:info |
|
890 |
"register an image reader." |
|
891 |
||
647 | 892 |
aSuffix notNil ifTrue:[ |
893 |
self imageReaderForSuffix:aSuffix put:aReaderClass. |
|
894 |
]. |
|
895 |
||
896 |
mimeType notNil ifTrue:[ |
|
897 |
self imageReaderForType:mimeType put:aReaderClass |
|
898 |
]. |
|
899 |
||
900 |
(aSuffix notNil and:[mimeType notNil]) ifTrue:[ |
|
901 |
self mimeTypeForSuffix:aSuffix put:mimeType |
|
902 |
]. |
|
3981 | 903 |
|
904 |
(info notNil and:[mimeType notNil]) ifTrue:[ |
|
3982 | 905 |
self typeToInfoMapping at:mimeType put:info. |
3981 | 906 |
]. |
907 |
||
908 |
"Created: / 26-08-2017 / 10:29:11 / cg" |
|
3982 | 909 |
"Modified: / 27-08-2017 / 14:30:53 / cg" |
647 | 910 |
! |
911 |
||
3359 | 912 |
fileInfoForMimeType:mimeType |
913 |
"given a mimeType, return an info string similar to what the unix 'file' command |
|
914 |
provides. This info here is returned by systems which have no file (i.e. MSDOS) and |
|
915 |
for types of which file does not know about (smalltalk files, for example)" |
|
916 |
||
3982 | 917 |
^ self typeToInfoMapping at:mimeType ifAbsent:nil |
3359 | 918 |
|
919 |
" |
|
3982 | 920 |
self fileInfoForMimeType:(MIMEType fromString:'text/html') |
3359 | 921 |
self fileInfoForMimeType:(MIMEType fromString:'image/gif') |
922 |
" |
|
3982 | 923 |
|
924 |
"Modified (comment): / 27-08-2017 / 14:31:33 / cg" |
|
3359 | 925 |
! |
926 |
||
643 | 927 |
fileSuffixToImageReaderMapping |
1021 | 928 |
"return the suffix-to-imageReader mapping" |
929 |
||
643 | 930 |
^ FileSuffixToImageReaderClassMapping ? #() |
931 |
||
1021 | 932 |
"Modified: / 1.8.1998 / 17:00:11 / cg" |
643 | 933 |
! |
934 |
||
935 |
imageFileSuffixes |
|
1021 | 936 |
"return a collection with known file suffixes" |
937 |
||
643 | 938 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[^ #()]. |
939 |
^ FileSuffixToImageReaderClassMapping keys |
|
940 |
||
1021 | 941 |
"Created: / 30.6.1997 / 22:04:48 / cg" |
942 |
"Modified: / 1.8.1998 / 17:01:26 / cg" |
|
643 | 943 |
! |
944 |
||
3014
e6d9a204da08
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
3012
diff
changeset
|
945 |
mimeTypeForFilename:filenameOrString |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
946 |
"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
|
947 |
|
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
948 |
|type filename lcFilename suff suff2| |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
949 |
|
3014
e6d9a204da08
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
3012
diff
changeset
|
950 |
filename := filenameOrString asFilename. |
1474 | 951 |
|
952 |
lcFilename := filename baseName asLowercase. |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
953 |
type := FilenameToTypeMapping at:lcFilename ifAbsent:nil. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
954 |
type isNil ifTrue:[ |
3962 | 955 |
"/ allow for fallback (maybe Windows registry knows something)... |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
956 |
type := OperatingSystem mimeTypeForFilename:lcFilename. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
957 |
"/ 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
|
958 |
"/ 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
|
959 |
"/ the OS. |
1275 | 960 |
"/ type isNil ifTrue:[ |
961 |
"/ FilenameToTypeMapping at:lcFilename put:#unknown |
|
962 |
"/ ]. |
|
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
963 |
]. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
964 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
965 |
type == #unknown ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
966 |
type := nil. |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
967 |
]. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
968 |
|
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
969 |
type isNil ifTrue:[ |
1473 | 970 |
suff := filename suffix. |
3962 | 971 |
suff notEmpty ifTrue:[ |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
972 |
"/ sigh - special code for multiple-suffices... |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
973 |
"/ .tar.gz -> tgz |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
974 |
suff2 := filename withoutSuffix suffix. |
3962 | 975 |
suff2 notEmpty ifTrue:[ |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
976 |
type := self mimeTypeForSuffix:(suff2 , '.' , suff). |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
977 |
]. |
3983 | 978 |
(type isNil or:[type == #unknown]) ifTrue:[ |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
979 |
type := self mimeTypeForSuffix:suff |
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
980 |
]. |
1273
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
981 |
] |
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
982 |
]. |
7a52d4bcdb10
filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
983 |
|
3871 | 984 |
type == #unknown ifTrue:[ |
985 |
type := nil. |
|
986 |
]. |
|
987 |
||
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
988 |
^ type |
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
989 |
|
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
990 |
" |
2820 | 991 |
MIMETypes mimeTypeForFilename:'typeinst.dvi' |
992 |
MIMETypes mimeTypeForFilename:'foo.tar' |
|
993 |
MIMETypes mimeTypeForFilename:'foo.tgz' |
|
994 |
MIMETypes mimeTypeForFilename:'foo.tar.gz' |
|
2911
7afaf1fdae8b
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
2904
diff
changeset
|
995 |
MIMETypes mimeTypeForFilename:'foo.txt' |
3756 | 996 |
MIMETypes mimeTypeForFilename:'foo.pkg' |
3871 | 997 |
MIMETypes mimeTypeForFilename:'foo.sm' |
3983 | 998 |
MIMETypes mimeTypeForFilename:'/Users/cg/work/stx/goodies/bitmaps/tiffimages/moreSamples/multi-channel.ome.tif' |
999 |
MIMETypes mimeTypeForFilename:'multi-channel.ome.tif' |
|
1000 |
MIMETypes mimeTypeForFilename:'multi-channel.tif' |
|
1001 |
' |
|
1780
ba94d562efe8
support double-suffix such as '.tar.gz'
Claus Gittinger <cg@exept.de>
parents:
1779
diff
changeset
|
1002 |
" |
2911
7afaf1fdae8b
comment/format in: #mimeTypeForFilename:
Claus Gittinger <cg@exept.de>
parents:
2904
diff
changeset
|
1003 |
|
3962 | 1004 |
"Modified (format): / 27-06-2017 / 16:25:40 / stefan" |
3983 | 1005 |
"Modified: / 27-08-2017 / 16:35:37 / cg" |
1272
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
1006 |
! |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
1007 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
1008 |
mimeTypeForFilename:filename put:mimeType |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
1009 |
"register a mime type for a filename" |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
1010 |
|
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
1011 |
FilenameToTypeMapping isNil ifTrue:[ |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
1012 |
FilenameToTypeMapping := Dictionary new |
91ba4078b690
additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents:
1269
diff
changeset
|
1013 |
]. |
1612 | 1014 |
FilenameToTypeMapping at:filename put:(MIMEType fromString:mimeType asLowercase) |
1611 | 1015 |
! |
1016 |
||
643 | 1017 |
mimeTypeForSuffix:suffix |
1021 | 1018 |
"given a file suffix, return the mime-type" |
1019 |
||
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
1020 |
|type lcSuffix| |
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
1021 |
|
1837 | 1022 |
suffix = LastSuffix ifTrue:[ |
1023 |
^ LastType |
|
1024 |
]. |
|
1025 |
||
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
1026 |
lcSuffix := suffix asLowercase. |
1837 | 1027 |
type := FileSuffixToTypeMapping at:lcSuffix ifAbsent:nil. |
1028 |
type isNil ifTrue:[ |
|
1029 |
"/ allow for fallback ... |
|
1030 |
type := OperatingSystem mimeTypeForSuffix:lcSuffix. |
|
1031 |
"/ the special value #unknown is returned as nil; |
|
3870 | 1032 |
"/ this avoids constant retry if a suffix is not known in the OS. |
1033 |
type := type isNil ifTrue:[#unknown] ifFalse:[MIMEType fromString:type]. |
|
1837 | 1034 |
FileSuffixToTypeMapping at:lcSuffix put:type. |
1180
c3309b30d14f
code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents:
1023
diff
changeset
|
1035 |
]. |
1837 | 1036 |
|
3870 | 1037 |
LastSuffix := suffix. |
1038 |
LastType := type. |
|
1841 | 1039 |
^ type |
643 | 1040 |
|
1666 | 1041 |
" |
1840 | 1042 |
self mimeTypeForSuffix:'gif' |
1888
ef0f346b8f43
rpm suffix is RPM-package under unix (realplayer under windows)
Claus Gittinger <cg@exept.de>
parents:
1887
diff
changeset
|
1043 |
self mimeTypeForSuffix:'rpm' |
2891 | 1044 |
self mimeTypeForSuffix:'zip' |
1666 | 1045 |
" |
1046 |
||
2891 | 1047 |
"Created: / 30-06-1997 / 21:55:51 / cg" |
1048 |
"Modified: / 14-02-2011 / 17:14:34 / cg" |
|
3870 | 1049 |
"Modified: / 09-02-2017 / 14:57:52 / stefan" |
643 | 1050 |
! |
1051 |
||
1052 |
mimeTypeForSuffix:suffix put:mimeType |
|
1021 | 1053 |
"register a mime type for a file suffix" |
1054 |
||
643 | 1055 |
FileSuffixToTypeMapping isNil ifTrue:[ |
1056 |
FileSuffixToTypeMapping := Dictionary new |
|
1057 |
]. |
|
3870 | 1058 |
FileSuffixToTypeMapping at:suffix ifAbsentPut:[MIMEType fromString:mimeType asLowercase]. |
643 | 1059 |
|
3870 | 1060 |
"Created: / 30-06-1997 / 21:56:20 / cg" |
1061 |
"Modified: / 01-08-1998 / 17:03:18 / cg" |
|
1062 |
"Modified: / 09-02-2017 / 15:09:17 / stefan" |
|
1593 | 1063 |
! |
1064 |
||
1065 |
mimeTypeForSuffixMapping |
|
1066 |
||
1067 |
^ FileSuffixToTypeMapping |
|
1611 | 1068 |
! |
1069 |
||
2023 | 1070 |
mimeTypeFromString:mimeTypeString |
1071 |
"given a mime-type for a string" |
|
1072 |
||
1073 |
^ MIMEType fromString:mimeTypeString |
|
1074 |
||
1075 |
" |
|
3532 | 1076 |
MIMETypes mimeTypeFromString:'text/html' |
1077 |
MIMETypes mimeTypeFromString:'image/gif' |
|
1078 |
MIMETypes mimeTypeFromString:'application/x-expecco-testsuite' |
|
2023 | 1079 |
" |
1080 |
! |
|
1081 |
||
1611 | 1082 |
mimeTypeOfContents:filename |
1083 |
"given a filename, scan the contents, return the mime-type or nil, if unknown" |
|
1084 |
||
1612 | 1085 |
|typeString| |
1086 |
||
1087 |
typeString := filename mimeTypeOfContents. |
|
1088 |
typeString isNil ifTrue:[^ nil]. |
|
1089 |
^ MIMEType fromString:typeString. |
|
1887 | 1090 |
! |
1091 |
||
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1092 |
mimeTypeOfData:someData |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1093 |
"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
|
1094 |
Returns nil, if unknown. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1095 |
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
|
1096 |
|
3400 | 1097 |
^ self mimeTypeOfData:someData suffix:nil |
1098 |
! |
|
1099 |
||
1100 |
mimeTypeOfData:someData suffix:fileNameSuffixOrNilIfUnknown |
|
1101 |
"this tries to guess the mime type of contents of someData. |
|
1102 |
Returns nil, if unknown. |
|
3691 | 1103 |
In addition to registered detectors (see addMimeTypeDetector:), |
1104 |
this is done using some heuristics, and may need some improvement" |
|
3400 | 1105 |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1106 |
|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
|
1107 |
|
2583 | 1108 |
someData isEmptyOrNil ifTrue:[^ nil]. |
1109 |
||
3691 | 1110 |
TypeFromContentsDetectors notNil ifTrue:[ |
1111 |
TypeFromContentsDetectors do:[:eachDetector | |
|
1112 |
|m| |
|
1113 |
||
1114 |
m := eachDetector value:someData value:fileNameSuffixOrNilIfUnknown. |
|
1115 |
m notNil ifTrue:[^ m] |
|
1116 |
] |
|
1117 |
]. |
|
1118 |
||
2583 | 1119 |
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
|
1120 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1121 |
"/ read some data from the file ... |
2583 | 1122 |
buffer := (someData copyTo:size) asString. |
3691 | 1123 |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1124 |
lcBuffer := buffer asLowercase. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1125 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1126 |
(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
|
1127 |
idx := idx + 'mimetype:' size. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1128 |
idx := lcBuffer indexOfNonSeparatorStartingAt:idx. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1129 |
idx2 := lcBuffer indexOfSeparatorStartingAt:idx. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1130 |
idx2 > idx ifTrue:[ |
2583 | 1131 |
^ 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
|
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 |
|
2924 | 1135 |
"/ real starters |
2582
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 |
( #[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
|
1138 |
#'application/x-ms-shortcut' ) |
2924 | 1139 |
( 'ITOLITLS' |
1140 |
#'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
|
1141 |
( 'WALTOP' |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1142 |
#'application/x-waltop-digital-notepad' ) |
2892 | 1143 |
('PK' |
1144 |
#'application/x-zip-compressed') |
|
3113 | 1145 |
('<?xml' |
1146 |
#'text/xml') |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1147 |
) pairsDo:[:pattern :what | |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1148 |
|patternString| |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1149 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1150 |
patternString := pattern asString. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1151 |
(buffer startsWith:patternString) ifTrue:[ |
3400 | 1152 |
what = #'application/x-zip-compressed' ifTrue:[ |
1153 |
fileNameSuffixOrNilIfUnknown = 'jar' ifTrue:[ |
|
1154 |
^ MIMEType fromString: #'application/java-archive' |
|
1155 |
]. |
|
1156 |
]. |
|
2583 | 1157 |
^ MIMEType fromString:what |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1158 |
] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1159 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1160 |
|
2924 | 1161 |
"/ 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
|
1162 |
#( |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1163 |
('<body:' #'text/html') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1164 |
('%!!ps-adobe' #'application/postscript') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1165 |
('%PDF-' #'application/pdf') |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1166 |
('#!! /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
|
1167 |
('#!!/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
|
1168 |
"/ ('#!! /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
|
1169 |
"/ ('#!!/bin/bash' 'application/x-bash') |
3482 | 1170 |
('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
|
1171 |
|
3113 | 1172 |
('---- encoding: ' #'application/x-smalltalk-source') |
1173 |
('---- 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
|
1174 |
('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
|
1175 |
('from visualworks' #'application/x-smalltalk-source') |
3359 | 1176 |
('from squeak' #'application/x-smalltalk-source') |
1177 |
('from smalltalk/x' #'application/x-smalltalk-source') |
|
1178 |
('"{ 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
|
1179 |
('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
|
1180 |
('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
|
1181 |
('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
|
1182 |
('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
|
1183 |
('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
|
1184 |
('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
|
1185 |
('methodsfor:' #'application/x-smalltalk-source') |
3332 | 1186 |
('Application create:' #'application/x-smalltalk-source') |
1187 |
('becomeDefault!!' #'application/x-smalltalk-source') |
|
3451 | 1188 |
('(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
|
1189 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1190 |
) pairsDo:[:pattern :what | |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1191 |
(lcBuffer findString:pattern) ~~ 0 ifTrue:[ |
2583 | 1192 |
^ MIMEType fromString:what |
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1193 |
] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1194 |
]. |
3691 | 1195 |
|
2582
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1196 |
(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
|
1197 |
((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
|
1198 |
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
|
1199 |
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
|
1200 |
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
|
1201 |
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
|
1202 |
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
|
1203 |
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
|
1204 |
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
|
1205 |
ifTrue:[ |
2583 | 1206 |
^ 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
|
1207 |
] |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1208 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1209 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1210 |
[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
|
1211 |
|
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1212 |
size == 0 ifTrue:[ |
2583 | 1213 |
^ 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
|
1214 |
]. |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1215 |
^ nil |
2891 | 1216 |
|
2924 | 1217 |
"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
|
1218 |
! |
298203fdb64d
mime type detection from conents moved from fileName to here
Claus Gittinger <cg@exept.de>
parents:
2570
diff
changeset
|
1219 |
|
1887 | 1220 |
suffixForMimeType:mimeType |
1221 |
"given a file suffix, return the mime-type" |
|
1222 |
||
1223 |
^ TypeToFileSuffixMapping at:mimeType ifAbsent:nil |
|
1224 |
||
1225 |
" |
|
1226 |
self suffixForMimeType:(MIMEType fromString:'image/gif') |
|
1227 |
" |
|
1228 |
||
1229 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
|
1230 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
|
1231 |
! |
|
1232 |
||
1233 |
suffixForMimeTypeString:mimeTypeString |
|
1234 |
"given a file suffix, return the mime-type" |
|
1235 |
||
1236 |
^ self suffixForMimeType:(MIMEType fromString:mimeTypeString) |
|
1237 |
||
1238 |
" |
|
1239 |
self suffixForMimeTypeString:'image/gif' |
|
1240 |
" |
|
1241 |
||
1242 |
"Created: / 30.6.1997 / 21:55:51 / cg" |
|
1243 |
"Modified: / 23.12.1999 / 22:30:55 / cg" |
|
3982 | 1244 |
! |
1245 |
||
1246 |
typeToInfoMapping |
|
1247 |
TypeToInfoMapping isNil ifTrue:[ |
|
1248 |
self initializeFileInfoMappings |
|
1249 |
]. |
|
1250 |
^ TypeToInfoMapping |
|
1251 |
||
1252 |
"Created: / 27-08-2017 / 14:30:44 / cg" |
|
1612 | 1253 |
! ! |
1254 |
||
2116 | 1255 |
!MIMETypes class methodsFor:'queries-applications'! |
1256 |
||
2117 | 1257 |
defaultCommandPerMIME |
1258 |
"returns the collection which is used to map MIME-type to command-templates." |
|
1259 |
||
1260 |
"TODO: move this to OS/UserPreferences" |
|
1261 |
||
1262 |
DefaultCommandPerMIMEPerOS isNil ifTrue:[ |
|
1263 |
self initializeDefaultCommands |
|
1264 |
]. |
|
1265 |
OperatingSystem isUNIXlike ifTrue:[ |
|
1266 |
^ DefaultCommandPerMIMEPerOS at:#unix |
|
1267 |
]. |
|
1268 |
^ DefaultCommandPerMIMEPerOS at:#win32 |
|
2942
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1269 |
|
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1270 |
" |
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1271 |
MIMETypes defaultCommandPerMIME |
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1272 |
" |
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1273 |
|
693d381bc775
comment/format in: #defaultCommandPerMIME
Claus Gittinger <cg@exept.de>
parents:
2937
diff
changeset
|
1274 |
"Modified (comment): / 16-09-2011 / 16:20:12 / cg" |
2117 | 1275 |
! |
1276 |
||
2116 | 1277 |
defaultCommandTemplateToOpenMimeType:mimeType |
1278 |
|cmd| |
|
1279 |
||
1280 |
cmd := self defaultCommandPerMIME at:mimeType ifAbsent:nil. |
|
1281 |
cmd isNil ifTrue:[ |
|
1282 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
1283 |
cmd := Win32OperatingSystem::RegistryEntry commandTemplateToOpenMimeType:mimeType |
|
1284 |
]. |
|
1285 |
]. |
|
1286 |
^ cmd |
|
1287 |
||
1288 |
" |
|
1289 |
MIMETypes defaultCommandTemplateToOpenMimeType:'application/pdf' |
|
2118 | 1290 |
MIMETypes defaultCommandTemplateToOpenMimeType:'text/html' |
2116 | 1291 |
" |
1292 |
||
1293 |
"Created: / 12-05-2004 / 11:09:22 / cg" |
|
1294 |
"Modified: / 12-05-2004 / 11:16:53 / cg" |
|
1295 |
! |
|
1296 |
||
1297 |
defaultCommandTemplateToPrintMimeType:mimeType |
|
1298 |
|cmd| |
|
1299 |
||
1300 |
cmd := self defaultPrintCommandPerMIME at:mimeType ifAbsent:nil. |
|
1301 |
cmd isNil ifTrue:[ |
|
1302 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
1303 |
cmd := Win32OperatingSystem::RegistryEntry commandTemplateToPrintMimeType:mimeType |
|
1304 |
]. |
|
1305 |
]. |
|
1306 |
^ cmd |
|
1307 |
||
1308 |
" |
|
1309 |
MIMETypes defaultCommandTemplateToPrintMimeType:'application/pdf' |
|
1310 |
" |
|
2117 | 1311 |
! |
1312 |
||
1313 |
defaultPrintCommandPerMIME |
|
1314 |
"returns the collection which is used to map MIME-type to printing command-templates." |
|
1315 |
||
1316 |
"TODO: move this to OS/UserPreferences" |
|
1317 |
||
1318 |
DefaultPrintCommandPerMIMEPerOS isNil ifTrue:[ |
|
1319 |
self initializeDefaultCommands |
|
1320 |
]. |
|
1321 |
OperatingSystem isUNIXlike ifTrue:[ |
|
1322 |
^ DefaultPrintCommandPerMIMEPerOS at:#unix |
|
1323 |
]. |
|
1324 |
^ DefaultPrintCommandPerMIMEPerOS at:#win32 |
|
2116 | 1325 |
! ! |
1326 |
||
1729 | 1327 |
!MIMETypes class methodsFor:'queries-image formats'! |
1328 |
||
1329 |
imageReaderClasses |
|
1330 |
"return a collection of registered image reader classes" |
|
1331 |
||
3870 | 1332 |
TypeToImageReaderClassMapping notNil ifTrue:[ |
1333 |
^ TypeToImageReaderClassMapping values asSet. |
|
1729 | 1334 |
]. |
3870 | 1335 |
^ #(). |
1729 | 1336 |
|
3870 | 1337 |
"Created: / 30-06-1997 / 22:03:42 / cg" |
1338 |
"Modified: / 01-08-1998 / 16:59:52 / cg" |
|
1339 |
"Modified: / 09-02-2017 / 15:23:52 / stefan" |
|
1729 | 1340 |
! |
1341 |
||
1342 |
imageReaderForSuffix:aSuffix |
|
1343 |
"given a file suffix, return an approriate image reader class" |
|
1344 |
||
2724
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1345 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1346 |
self initializeImageReaderMappings |
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1347 |
]. |
1729 | 1348 |
^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil |
1349 |
||
1350 |
"Created: / 30.6.1997 / 21:59:11 / cg" |
|
1351 |
"Modified: / 1.8.1998 / 17:01:58 / cg" |
|
1352 |
! |
|
1353 |
||
1354 |
imageReaderForSuffix:aSuffix put:aReaderClass |
|
1355 |
"register an image reader for a file suffix" |
|
1356 |
||
1357 |
FileSuffixToImageReaderClassMapping isNil ifTrue:[ |
|
2724
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1358 |
self initializeImageReaderMappings |
1729 | 1359 |
]. |
1360 |
FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass |
|
1361 |
||
1362 |
"Created: / 30.6.1997 / 21:59:43 / cg" |
|
1363 |
"Modified: / 1.8.1998 / 17:02:14 / cg" |
|
1364 |
! |
|
1365 |
||
1366 |
imageReaderForType:mimeTypeString |
|
1367 |
"given a mime-type, return an approriate image reader class" |
|
1368 |
||
2724
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1369 |
TypeToImageReaderClassMapping isNil ifTrue:[ |
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1370 |
self initializeImageReaderMappings |
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1371 |
]. |
1729 | 1372 |
^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil |
1373 |
||
1374 |
"Created: / 30.6.1997 / 21:56:01 / cg" |
|
1375 |
"Modified: / 1.8.1998 / 17:02:28 / cg" |
|
1376 |
! |
|
1377 |
||
1378 |
imageReaderForType:mimeTypeString put:aReaderClass |
|
1379 |
"register an image reader for a mime-type" |
|
1380 |
||
1381 |
TypeToImageReaderClassMapping isNil ifTrue:[ |
|
2724
8e834e62dbbc
Initialize when querying for image type and not yet initialized
Stefan Vogel <sv@exept.de>
parents:
2710
diff
changeset
|
1382 |
self initializeImageReaderMappings |
1729 | 1383 |
]. |
3870 | 1384 |
TypeToImageReaderClassMapping |
1385 |
at:(MIMEType fromString:mimeTypeString asLowercase) |
|
1386 |
put:aReaderClass |
|
1729 | 1387 |
|
3870 | 1388 |
"Created: / 30-06-1997 / 21:56:11 / cg" |
1389 |
"Modified: / 01-08-1998 / 17:02:40 / cg" |
|
1390 |
"Modified: / 09-02-2017 / 15:32:58 / stefan" |
|
1729 | 1391 |
! ! |
1392 |
||
1393 |
!MIMETypes class methodsFor:'queries-language syntax'! |
|
1394 |
||
1395 |
commentStringsForFilename:aFilename |
|
1396 |
"return a useful comment definition; heuristics for now. |
|
1397 |
The returned value is an array of 2 elements; |
|
1398 |
the first is the end-of-line comment string (or nil); |
|
1399 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1400 |
||
1401 |
|mime| |
|
1402 |
||
1403 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
1404 |
^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) |
|
1405 |
||
1406 |
" |
|
1407 |
MIMETypes commentStringsForFilename:'Makefile'. |
|
1408 |
MIMETypes commentStringsForFilename:'Object.st'. |
|
1409 |
MIMETypes commentStringsForFilename:'Foo.java'. |
|
1925 | 1410 |
MIMETypes commentStringsForFilename:'Foo.html'. |
1729 | 1411 |
" |
1412 |
! |
|
1413 |
||
1414 |
commentStringsForFilename:aFilename ifUnknown:alternativeBlockReturningCommentString |
|
1415 |
"return a useful comment definition; heuristics for now. |
|
1416 |
The returned value is an array of 2 elements; |
|
1417 |
the first is the end-of-line comment string (or nil); |
|
1418 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1419 |
||
1420 |
|mime| |
|
1421 |
||
1422 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
1423 |
^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternativeBlockReturningCommentString |
|
1424 |
||
1425 |
" |
|
1426 |
MIMETypes commentStringsForFilename:'Makefile'. |
|
1427 |
MIMETypes commentStringsForFilename:'Object.st'. |
|
1428 |
MIMETypes commentStringsForFilename:'Foo.java'. |
|
1429 |
" |
|
1430 |
! |
|
1431 |
||
1432 |
commentStringsForMimeType:mime suffix:suff |
|
1433 |
"return a useful comment definition; heuristics for now. |
|
1434 |
The returned value is an array of 2 elements; |
|
1435 |
the first is the end-of-line comment string (or nil); |
|
1436 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1437 |
||
1438 |
^ self |
|
1439 |
commentStringsForMimeType:mime suffix:suff |
|
1440 |
ifUnknown: #(';' (nil nil)) |
|
1441 |
||
1442 |
" |
|
1443 |
|mime| |
|
1444 |
||
1445 |
mime := MIMETypes mimeTypeForFilename:'Makefile'. |
|
1446 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1447 |
" |
|
1448 |
||
1449 |
" |
|
1450 |
|mime| |
|
1451 |
||
1452 |
mime := MIMETypes mimeTypeForFilename:'Object.st'. |
|
1453 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1454 |
" |
|
1455 |
! |
|
1456 |
||
1457 |
commentStringsForMimeType:mime suffix:suff ifUnknown:alternativeBlockReturningCommentString |
|
1458 |
"return a useful comment definition; heuristics for now. |
|
1459 |
The returned value is an array of 2 elements; |
|
1460 |
the first is the end-of-line comment string (or nil); |
|
1461 |
the second an array of opening/closing delimiters (or an array of nils)" |
|
1462 |
||
1463 |
|commentSpec| |
|
1464 |
||
1465 |
commentSpec := TypeToCommentStringMapping at:mime ifAbsent:nil. |
|
1466 |
commentSpec notNil ifTrue:[ |
|
1467 |
^ commentSpec |
|
1468 |
]. |
|
3492 | 1469 |
suff notNil ifTrue:[ |
1470 |
commentSpec := SuffixToCommentStringMapping at:suff ifAbsent:nil. |
|
1471 |
commentSpec notNil ifTrue:[ |
|
1472 |
^ commentSpec |
|
1473 |
]. |
|
1729 | 1474 |
]. |
1475 |
^ alternativeBlockReturningCommentString value |
|
1476 |
||
1477 |
" |
|
1478 |
|mime| |
|
1479 |
||
1480 |
mime := MIMETypes mimeTypeForFilename:'Makefile'. |
|
1481 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1482 |
" |
|
1483 |
||
1484 |
" |
|
1485 |
|mime| |
|
1486 |
||
1487 |
mime := MIMETypes mimeTypeForFilename:'Object.st'. |
|
1488 |
MIMETypes commentStringsForMimeType:mime suffix:nil. |
|
1489 |
" |
|
2298 | 1490 |
! |
1491 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1492 |
parenthesisSpecForFilename:aFilename |
2298 | 1493 |
"return a useful parentesis spec; heuristics for now. |
1494 |
The returned value is a dictionary to be used as parentesis spec in an editor" |
|
1495 |
||
1496 |
|mime| |
|
1497 |
||
1498 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1499 |
^ self parenthesisSpecForMimeType:mime suffix:(aFilename asFilename suffix) |
2298 | 1500 |
|
1501 |
" |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1502 |
MIMETypes parenthesisSpecForFilename:'Object.st'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1503 |
MIMETypes parenthesisSpecForFilename:'Foo.java'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1504 |
MIMETypes parenthesisSpecForFilename:'Foo.html'. |
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1505 |
MIMETypes parenthesisSpecForFilename:'Foo.lsp'. |
2298 | 1506 |
" |
1507 |
||
1508 |
"Created: / 10-04-2007 / 15:18:41 / cg" |
|
1509 |
! |
|
1510 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1511 |
parenthesisSpecForFilename:aFilename ifUnknown:alternative |
2298 | 1512 |
|mime| |
1513 |
||
1514 |
mime := MIMETypes mimeTypeForFilename:aFilename. |
|
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1515 |
^ self parenthesisSpecForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternative |
2298 | 1516 |
|
1517 |
"Created: / 10-04-2007 / 15:26:20 / cg" |
|
1518 |
! |
|
1519 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1520 |
parenthesisSpecForMimeType:mime suffix:suff |
2298 | 1521 |
^ self |
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1522 |
parenthesisSpecForMimeType:mime suffix:suff |
2298 | 1523 |
ifUnknown: nil |
1524 |
||
1525 |
"Created: / 10-04-2007 / 15:19:39 / cg" |
|
1526 |
! |
|
1527 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1528 |
parenthesisSpecForMimeType:mime suffix:suff ifUnknown:alternativeValue |
2298 | 1529 |
|spec| |
1530 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1531 |
spec := TypeToParenthesisSpecMapping at:mime ifAbsent:nil. |
2298 | 1532 |
spec notNil ifTrue:[ |
1533 |
^ spec |
|
1534 |
]. |
|
1535 |
||
2491
831417cc1e5b
Change bas spelling: parentesis to good spellinge parenthesis
Stefan Vogel <sv@exept.de>
parents:
2490
diff
changeset
|
1536 |
spec := SuffixToParenthesisSpecMapping at:suff ifAbsent:nil. |
2298 | 1537 |
spec notNil ifTrue:[ |
1538 |
^ spec |
|
1539 |
]. |
|
1540 |
||
1541 |
^ alternativeValue value |
|
1542 |
||
1543 |
"Created: / 10-04-2007 / 15:20:38 / cg" |
|
1729 | 1544 |
! ! |
1545 |
||
1612 | 1546 |
!MIMETypes::MIMEType class methodsFor:'documentation'! |
1547 |
||
1548 |
documentation |
|
1549 |
" |
|
1864 | 1550 |
like a string, but knows that it represents a mimeType. |
3359 | 1551 |
mimetypes are singletons, remembered in the class variable CachedTypes. |
1612 | 1552 |
" |
1553 |
! ! |
|
1554 |
||
1555 |
!MIMETypes::MIMEType class methodsFor:'instance creation'! |
|
1556 |
||
1557 |
fromString:aString |
|
1558 |
|cachedType newType| |
|
1559 |
||
1560 |
aString class == self ifTrue:[^ aString]. |
|
1561 |
||
3011
f2af94d78383
delay initialization of cachedTypes
Claus Gittinger <cg@exept.de>
parents:
3008
diff
changeset
|
1562 |
CachedTypes isNil ifTrue:[ |
3012 | 1563 |
CachedTypes := Dictionary new:100. |
3011
f2af94d78383
delay initialization of cachedTypes
Claus Gittinger <cg@exept.de>
parents:
3008
diff
changeset
|
1564 |
]. |
1612 | 1565 |
cachedType := CachedTypes at:aString ifAbsent:nil. |
1566 |
cachedType notNil ifTrue:[^ cachedType]. |
|
3011
f2af94d78383
delay initialization of cachedTypes
Claus Gittinger <cg@exept.de>
parents:
3008
diff
changeset
|
1567 |
|
1612 | 1568 |
newType := aString copy changeClassTo:self. |
1569 |
CachedTypes at:aString put:newType. |
|
1570 |
^ newType |
|
1571 |
||
1572 |
" |
|
3870 | 1573 |
CachedTypes := nil. |
1612 | 1574 |
self fromString:'text/html' |
1575 |
" |
|
3011
f2af94d78383
delay initialization of cachedTypes
Claus Gittinger <cg@exept.de>
parents:
3008
diff
changeset
|
1576 |
|
3012 | 1577 |
"Modified: / 20-07-2012 / 17:36:31 / cg" |
3870 | 1578 |
"Modified (comment): / 09-02-2017 / 15:36:06 / stefan" |
1612 | 1579 |
! ! |
1580 |
||
1581 |
!MIMETypes::MIMEType methodsFor:'queries'! |
|
1582 |
||
3359 | 1583 |
fileTypeInfo |
1584 |
^ MIMETypes fileTypeInfoForMimeType:self |
|
1585 |
||
1586 |
" |
|
1587 |
(MIMETypes mimeTypeFromString:'application/x-smalltalk-source') fileTypeInfo |
|
1588 |
" |
|
1589 |
! |
|
1590 |
||
1693 | 1591 |
isArchive |
3260 | 1592 |
<resource: #obsolete> |
1593 |
"return true, if I represent an archive type (such as zip or tar)" |
|
1594 |
||
1595 |
^ self isArchiveType |
|
1596 |
! |
|
1597 |
||
1598 |
isArchiveType |
|
1864 | 1599 |
"return true, if I represent an archive type (such as zip or tar)" |
1600 |
||
1612 | 1601 |
|archivTypes| |
1602 |
||
1729 | 1603 |
archivTypes := MIMETypes applicationCompressorsAndArchiveTypeList. |
1612 | 1604 |
archivTypes pairWiseDo:[: ext : type | |
1605 |
self = type ifTrue:[ ^ true]. |
|
1606 |
]. |
|
1607 |
^ false |
|
1608 |
! |
|
1609 |
||
2024 | 1610 |
isBinary |
3260 | 1611 |
<resource: #obsolete> |
1612 |
"return true, if I represent a binary (non-text) type" |
|
1613 |
||
1614 |
^ self isBinaryType |
|
1615 |
! |
|
1616 |
||
1617 |
isBinaryType |
|
2024 | 1618 |
"return true, if I represent a binary (non-text) type" |
1619 |
||
1620 |
^ self isTextType not |
|
1621 |
! |
|
1622 |
||
1612 | 1623 |
isHtml |
3260 | 1624 |
<resource: #obsolete> |
1625 |
"return true, if I represent the html text type" |
|
1626 |
||
1627 |
^ self isHtmlType |
|
1628 |
! |
|
1629 |
||
1630 |
isHtmlType |
|
1864 | 1631 |
"return true, if I represent the html text type" |
1612 | 1632 |
|
1633 |
^ (self = 'text/html') |
|
1634 |
! |
|
1635 |
||
1636 |
isImage |
|
3260 | 1637 |
<resource: #obsolete> |
1638 |
"return true, if I represent an image type (such as gif or jpg)" |
|
1639 |
||
1640 |
^ self isImageType |
|
1641 |
! |
|
1642 |
||
1643 |
isImageType |
|
1864 | 1644 |
"return true, if I represent an image type (such as gif or jpg)" |
1612 | 1645 |
|
1693 | 1646 |
^ (self startsWith:'image/') |
1612 | 1647 |
! |
1648 |
||
1649 |
isPdf |
|
3260 | 1650 |
<resource: #obsolete> |
1651 |
"return true, if I represent the pdf type" |
|
1652 |
||
1653 |
^ self isPdfType |
|
1654 |
! |
|
1655 |
||
1656 |
isPdfType |
|
1864 | 1657 |
"return true, if I represent the pdf type" |
1658 |
||
1612 | 1659 |
^ (self = 'application/pdf') |
1660 |
! |
|
1661 |
||
1662 |
isSmalltalkSource |
|
3260 | 1663 |
<resource: #obsolete> |
1664 |
"return true, if I represent the smalltalk sourcecode type" |
|
1665 |
||
1666 |
^ self isSmalltalkSourceType |
|
1667 |
! |
|
1668 |
||
1669 |
isSmalltalkSourceType |
|
1864 | 1670 |
"return true, if I represent the smalltalk sourcecode type" |
1671 |
||
3359 | 1672 |
^ (self startsWith: 'application/x-smalltalk-source') |
1783 | 1673 |
! |
1674 |
||
2024 | 1675 |
isTextType |
1676 |
"return true, if I represent some text type" |
|
1677 |
||
1678 |
^ self startsWith:'text/' |
|
1679 |
! |
|
1680 |
||
1783 | 1681 |
isXml |
3260 | 1682 |
<resource: #obsolete> |
1683 |
"return true, if I represent the xml text type" |
|
1684 |
||
1685 |
^ self isXmlType |
|
1686 |
! |
|
1687 |
||
1688 |
isXmlType |
|
1864 | 1689 |
"return true, if I represent the xml text type" |
1690 |
||
3941 | 1691 |
^ self = 'text/xml' or:[self = 'application/xml'] |
1692 |
||
1693 |
"Modified (format): / 13-03-2017 / 09:41:52 / stefan" |
|
2490 | 1694 |
! |
1695 |
||
1696 |
suffix |
|
1697 |
^ MIMETypes suffixForMimeType:self |
|
1698 |
||
1699 |
" |
|
1700 |
(MIMETypes mimeTypeFromString:'application/x-expecco-testsuite') suffix |
|
1701 |
" |
|
643 | 1702 |
! ! |
1703 |
||
1704 |
!MIMETypes class methodsFor:'documentation'! |
|
1705 |
||
1706 |
version |
|
3482 | 1707 |
^ '$Header$' |
2758
66e62ceecb67
comment/format in: #defaultCommandForMimeType:
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
1708 |
! |
66e62ceecb67
comment/format in: #defaultCommandForMimeType:
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
1709 |
|
66e62ceecb67
comment/format in: #defaultCommandForMimeType:
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
1710 |
version_CVS |
3482 | 1711 |
^ '$Header$' |
643 | 1712 |
! ! |
1666 | 1713 |
|
3104 | 1714 |
|
643 | 1715 |
MIMETypes initialize! |