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