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