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