5 <meta name=
"viewport" content=
"width=device-width, initial-scale=1" />
7 <link rel=
"stylesheet" href=
"../style.css#" type=
"text/css" />
8 <title>Custom file handling
</title>
9 <script type=
"text/javascript">
11 let href
= location
.href
;
12 for(let i
=href
.length
-1;i
>0;i
--){
13 if('/'==href
.charAt(i
) && '/'==href
.charAt(i
-3))
20 location
.href
= location
.href
.substring(0,i
+1)+page
;
22 function nav2Lang(lang
){
24 let href
= location
.href
;
25 location
.href
= location
.href
.substring(0,i
-2)+lang
+location
.href
.substring(i
);
30 <header class='header'
>
31 <a class=
"logo" href=
"javascript:void(0)" onclick=
"return nav2('index.html#')">Home
</a> <a class=
"logo" href=
"javascript:void(0)" onclick=
"return nav2('tags/index.html#')">Tags
</a>
34 <a class=
"logo" href=
"javascript:void(0)" onclick=
"return nav2Lang('zh')">简体中文
</a>
42 <div class=
"container">
43 <h1 class=
"title">Custom file handling
45 <span class=
"subtitle"></span>
49 <li><a href=
"../tags/termux/index.html#">termux
</a> </li>
51 <li><a href=
"../tags/curl/index.html#">curl
</a> </li>
54 <p>Long press the settings button, check the option
"custom file handling
" to enable the functionality.
</p>
55 <p>The custom file handling configuration file is
"default.filecap
", each line of it has the format as follows:
<br>
56 [file extension]:[mimetype]:[command line]
</p>
57 <p>The
"[file extension]
" part can have at most two-segment of extensions such as
"txt.xz
",
"html.gz
".
<br>
58 "[mimetype]
" indicates the type of
"[command line]
" output.
<br>
59 "[command line]
" is same as the one in
<a href=
"../cmds/index.html#">default.cmds
</a>. The most often used replacements are:
<br>
60 %u (url), %U (urlencoded url), %c (cookie), %p (site password, curl format).
</p>
61 <p>default.filecap example:
</p>
62 <pre><code>txt:text/html:curl %p
"%u"
63 mp3:text/html:echo '
<audio controls width=
100% height=
100%
><source
src=
"%u"></audio
>'
64 m4b:text/html:echo '
<audio controls width=
100% height=
100%
><source
src=
"%u"></audio
>'
65 m3u8:text/html:echo '
<video controls width=
100% height=
100%
><source
src=
"%u"></video
>'
66 mp4:text/html:echo '
<video controls width=
100% height=
100%
><source
src=
"%u"></video
>'
67 mkv:text/html:echo '
<video controls width=
100% height=
100%
><source
src=
"%u"></video
>'
68 doc:uweb:echo http://docs.google.com/gview?embedded=true&url=%U
69 xls:uweb:echo http://docs.google.com/gview?embedded=true&url=%U
70 ppt:uweb:echo http://docs.google.com/gview?embedded=true&url=%U
71 docx:uweb:echo http://docs.google.com/gview?embedded=true&url=%U
72 xlsx:uweb:echo http://docs.google.com/gview?embedded=true&url=%U
73 pptx:uweb:echo http://docs.google.com/gview?embedded=true&url=%U
74 xz:text/plain:curl %p
"%u"|xz -d --
</code></pre>
75 <p>Examples for
<a href=
"../html5/index.html#">html5 application
</a>:
</p>
76 <pre><code>pdf:uweb:echo file:///data/data/info.torapp.uweb/files/app/pdf.js/web/viewer.html?file=%u
77 djvu:uweb:echo file:///data/data/info.torapp.uweb/files/app/djvu.html?url=%u
78 epub:uweb:echo file:///data/data/info.torapp.uweb/files/app/reader/index.html#?bookPath==%u
</code></pre>
81 <p>Last Modified:
2 April
2024<br>
82 add js function in README
<br>
87 src='https://giscus.app/client.js'
88 data-repo=
"torappinfo/uweb"
89 data-repo-id=
"MDEwOlJlcG9zaXRvcnkzMDIyMDU3MjE="
90 data-category=
"Announcements"
91 data-category-id=
"DIC_kwDOEgNLGc4CQjsh"
94 data-reactions-enabled=
"1"
95 data-emit-metadata=
"0"
96 data-input-position=
"top"
100 crossorigin=
"anonymous" async
>
103 <footer class=
"site-footer">
104 <div class=
"container">
105 © 2018-
2024 Richard H. Cao
108 <!-- This document is licensed under the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at <https://www.gnu.org/licenses/>. -->