Skip to content

Commit 303448e

Browse files
committed
feat: support filter and render for readme.md
1 parent 6073980 commit 303448e

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

internal/bootstrap/data/setting.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ func InitialSettings() []model.SettingItem {
139139
{Key: "audio_cover", Value: "https://jsd.nn.ci/gh/alist-org/logo@main/logo.svg", Type: conf.TypeString, Group: model.PREVIEW},
140140
{Key: conf.AudioAutoplay, Value: "true", Type: conf.TypeBool, Group: model.PREVIEW},
141141
{Key: conf.VideoAutoplay, Value: "true", Type: conf.TypeBool, Group: model.PREVIEW},
142+
{Key: conf.ReadMeAutoRender, Value: "false", Type: conf.TypeBool, Group: model.PREVIEW},
143+
{Key: conf.FilterReadMeScripts, Value: "true", Type: conf.TypeBool, Group: model.PREVIEW},
142144
// global settings
143145
{Key: conf.HideFiles, Value: "/\\/README.md/i", Type: conf.TypeText, Group: model.GLOBAL},
144146
{Key: "package_download", Value: "true", Type: conf.TypeBool, Group: model.GLOBAL},

internal/conf/const.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ const (
2222
MainColor = "main_color"
2323

2424
// preview
25-
TextTypes = "text_types"
26-
AudioTypes = "audio_types"
27-
VideoTypes = "video_types"
28-
ImageTypes = "image_types"
29-
ProxyTypes = "proxy_types"
30-
ProxyIgnoreHeaders = "proxy_ignore_headers"
31-
AudioAutoplay = "audio_autoplay"
32-
VideoAutoplay = "video_autoplay"
25+
TextTypes = "text_types"
26+
AudioTypes = "audio_types"
27+
VideoTypes = "video_types"
28+
ImageTypes = "image_types"
29+
ProxyTypes = "proxy_types"
30+
ProxyIgnoreHeaders = "proxy_ignore_headers"
31+
AudioAutoplay = "audio_autoplay"
32+
VideoAutoplay = "video_autoplay"
33+
ReadMeAutoRender = "readme_autorender"
34+
FilterReadMeScripts = "filter_readme_scripts"
3335

3436
// global
3537
HideFiles = "hide_files"

server/common/proxy.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import (
99
"net/url"
1010
"strconv"
1111

12+
"github.com/alist-org/alist/v3/internal/conf"
1213
"github.com/alist-org/alist/v3/internal/model"
1314
"github.com/alist-org/alist/v3/internal/net"
15+
"github.com/alist-org/alist/v3/internal/setting"
1416
"github.com/alist-org/alist/v3/internal/stream"
1517
"github.com/alist-org/alist/v3/pkg/http_range"
1618
"github.com/alist-org/alist/v3/pkg/utils"
@@ -30,7 +32,7 @@ func processMarkdown(content []byte) ([]byte, error) {
3032
func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.Obj) error {
3133

3234
//优先处理md文件
33-
if utils.Ext(file.GetName()) == "md" {
35+
if utils.Ext(file.GetName()) == "md" && setting.GetBool(conf.FilterReadMeScripts) {
3436
var markdownContent []byte
3537
var err error
3638

0 commit comments

Comments
 (0)