From ff362484191d08db2e2bda238934b780139b9048 Mon Sep 17 00:00:00 2001 From: slene Date: Mon, 24 Mar 2014 23:56:32 +0800 Subject: raw download --- modules/base/markdown.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules/base/markdown.go') diff --git a/modules/base/markdown.go b/modules/base/markdown.go index 05ce0c83..c722f04b 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -6,6 +6,7 @@ package base import ( "bytes" + "net/http" "path" "path/filepath" "strings" @@ -42,6 +43,14 @@ func IsMarkdownFile(name string) bool { return false } +func IsTextFile(data []byte) (string, bool) { + contentType := http.DetectContentType(data) + if strings.Index(contentType, "text/") != -1 { + return contentType, true + } + return contentType, false +} + func IsReadmeFile(name string) bool { name = strings.ToLower(name) if len(name) < 6 { -- cgit v1.2.3