aboutsummaryrefslogtreecommitdiffstats
path: root/src/types
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-08-13 17:42:34 +0200
committerbptato <nincsnevem662@gmail.com>2023-08-13 17:54:05 +0200
commitd526deb99e44f2a8d1a9c3eea60676703dd64302 (patch)
treef63689ff7654d14ad9bca182a837b3155b2471a0 /src/types
parentf92e30232252deb194596e7c298cc7fcf56517cb (diff)
downloadchawan-d526deb99e44f2a8d1a9c3eea60676703dd64302.tar.gz
Add mailcap, mime.types & misc refactorings
* add mailcap: works with copiousoutput, needsterminal, etc. * add mime.types (only works with mailcap) * refactor pipeBuffer * remove "dispatcher" * fix bug in directory display where baseurl would not be used
Diffstat (limited to 'src/types')
-rw-r--r--src/types/blob.nim2
-rw-r--r--src/types/buffersource.nim2
-rw-r--r--src/types/dispatcher.nim12
-rw-r--r--src/types/mime.nim52
4 files changed, 2 insertions, 66 deletions
diff --git a/src/types/blob.nim b/src/types/blob.nim
index 3af362d4..8bc96db7 100644
--- a/src/types/blob.nim
+++ b/src/types/blob.nim
@@ -1,7 +1,7 @@
import options
import js/javascript
-import types/mime
+import utils/mimeguess
import utils/twtstr
type
diff --git a/src/types/buffersource.nim b/src/types/buffersource.nim
index 109e8361..9235e07f 100644
--- a/src/types/buffersource.nim
+++ b/src/types/buffersource.nim
@@ -14,7 +14,7 @@ type
BufferSource* = object
location*: URL
contenttype*: Option[string] # override
- charset*: Option[Charset] # override
+ charset*: Charset # fallback
case t*: BufferSourceType
of CLONE:
clonepid*: Pid
diff --git a/src/types/dispatcher.nim b/src/types/dispatcher.nim
deleted file mode 100644
index cd668a15..00000000
--- a/src/types/dispatcher.nim
+++ /dev/null
@@ -1,12 +0,0 @@
-import posix
-
-import ips/forkserver
-
-type Dispatcher* = ref object
- forkserver*: ForkServer
- mainproc*: Pid
-
-proc newDispatcher*(): Dispatcher =
- new(result)
- result.forkserver = newForkServer()
- result.mainproc = getpid()
diff --git a/src/types/mime.nim b/src/types/mime.nim
deleted file mode 100644
index 96742337..00000000
--- a/src/types/mime.nim
+++ /dev/null
@@ -1,52 +0,0 @@
-import algorithm
-import tables
-
-const DefaultGuess = [
- ("html", "text/html"),
- ("htm", "text/html"),
- ("xhtml", "application/xhtml+xml"),
- ("xhtm", "application/xhtml+xml"),
- ("xht", "application/xhtml+xml"),
- ("txt", "text/plain"),
- ("css", "text/css"),
- ("png", "image/png"),
- ("", "text/plain")
-].toTable()
-
-proc guessContentType*(path: string, def = DefaultGuess[""]): string =
- var i = path.len - 1
- var n = 0
- while i > 0:
- if path[i] == '/':
- return def
- if path[i] == '.':
- n = i
- break
- dec i
- if n > 0:
- let ext = path.substr(n + 1)
- if ext in DefaultGuess:
- return DefaultGuess[ext]
- return def
-
-const JavaScriptTypes = [
- "application/ecmascript",
- "application/javascript",
- "application/x-ecmascript",
- "application/x-javascript",
- "text/ecmascript",
- "text/javascript",
- "text/javascript1.0",
- "text/javascript1.1",
- "text/javascript1.2",
- "text/javascript1.3",
- "text/javascript1.4",
- "text/javascript1.5",
- "text/jscript",
- "text/livescript",
- "text/x-ecmascript",
- "text/x-javascript"
-]
-
-proc isJavaScriptType*(s: string): bool =
- return binarySearch(JavaScriptTypes, s) != -1