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