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