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