diff --git a/app/config.js b/app/config.js index aecc0e50..b7c79fb5 100644 --- a/app/config.js +++ b/app/config.js @@ -37,7 +37,11 @@ const db = createFiledb(configPath , {raw:true} , { anonymous_uplod_enable:0, - plugin_option:[] + plugin_option:[], + + custom_style:'', + + custom_script:'', }); if(process.env.PORT){ diff --git a/app/controllers/manage.js b/app/controllers/manage.js index f9ab368e..0c375934 100644 --- a/app/controllers/manage.js +++ b/app/controllers/manage.js @@ -64,7 +64,7 @@ const handlers = async (a, body) => { cache.clear() result.message = 'Success' } else if (a == 'cfg') { - let { proxy_enable, preview_enable, readme_enable, max_age_dir, max_age_file,max_age_download, webdav_path, anonymous_uplod_enable, ignore_file_extensions , ignore_paths } = body + let { proxy_enable, preview_enable, readme_enable, max_age_dir, max_age_file,max_age_download, webdav_path, anonymous_uplod_enable, ignore_file_extensions , ignore_paths , custom_style , custom_script } = body let opts = {} if (max_age_dir !== undefined) { max_age_dir = parseInt(max_age_dir) @@ -110,6 +110,8 @@ const handlers = async (a, body) => { if (webdav_path) { opts.webdav_path = webdav_path } + opts.custom_script = custom_script + opts.custom_style = custom_style opts.ignore_paths = config.getConfig('ignore_paths') opts.ignore_file_extensions = ignore_file_extensions opts.ignore_paths.__root__ = ignore_paths.split(',') diff --git a/app/middleware/koa-render.js b/app/middleware/koa-render.js index 7a79f2dd..ad02df29 100644 --- a/app/middleware/koa-render.js +++ b/app/middleware/koa-render.js @@ -1,9 +1,13 @@ -const { getSkin } = require('../config') +const { getSkin , getConfig } = require('../config') module.exports = (ctx, next) => { if(ctx.renderSkin) return next() ctx.response.renderSkin = ctx.renderSkin = (path , options) => { - return ctx.render(getSkin()+'/'+path, options) + let data = { ...options , g_config:{ + custom_style:getConfig('custom_style'), + custom_script:getConfig('custom_script'), + }} + return ctx.render(getSkin()+'/'+path, data) } return next() } \ No newline at end of file diff --git a/app/views/default/manage.pug b/app/views/default/manage.pug index d2a31e80..55634277 100644 --- a/app/views/default/manage.pug +++ b/app/views/default/manage.pug @@ -85,6 +85,18 @@ block content select.form-control(name='anonymous_uplod_enable',value=config.anonymous_uplod_enable,required) option(value='1', selected=config.anonymous_uplod_enable==1 ? 'selected' : null)= __('enable') option(value='0', selected=config.anonymous_uplod_enable==0 ? 'selected' : null)= __('disable') + .form-group + .col-sm-4 + label= __('custom_style') + .col-sm-8 + textarea.form-control(name='custom_style') + | #{config.custom_style} + .form-group + .col-sm-4 + label= __('custom_script') + .col-sm-8 + textarea.form-control(name='custom_script') + | #{config.custom_script} .form-group.text-center button.btn.btn-default(type='submit')= __('save') .panel.panel-default diff --git a/app/views/default/partial/footer.pug b/app/views/default/partial/footer.pug index 57366ee3..ad9e77d7 100644 --- a/app/views/default/partial/footer.pug +++ b/app/views/default/partial/footer.pug @@ -1,4 +1,7 @@ footer p a(href='https://github.com/reruin/sharelist',target='_blank') GitHub - a(href='/manage',target='_blank')= __('manage') \ No newline at end of file + a(href='/manage',target='_blank')= __('manage') +-if(g_config.custom_script) + . + !{g_config.custom_script} \ No newline at end of file diff --git a/app/views/default/partial/layout.pug b/app/views/default/partial/layout.pug index d506f9e2..5e7a8ba5 100644 --- a/app/views/default/partial/layout.pug +++ b/app/views/default/partial/layout.pug @@ -7,8 +7,10 @@ html // META link(rel='stylesheet', href='//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css') - link(rel='stylesheet', type='text/css',href='/style/font/font.css') + link(rel='stylesheet', type='text/css',href='https://fonts.loli.net/css?family=Source+Code+Pro') link(rel='stylesheet', type='text/css', href='/style/main.css') - + -if(g_config && g_config.custom_style) + . + !{g_config.custom_style} body block content diff --git a/example/preview/movie.vtt b/example/preview/movie.vtt new file mode 100644 index 00000000..86ff04d8 --- /dev/null +++ b/example/preview/movie.vtt @@ -0,0 +1,4 @@ +WEBVTT + +00:00:00.001 --> 00:00:03.000 +鸟叫声 diff --git a/locales/en-US.js b/locales/en-US.js index 7ff9d66a..f9ab3c45 100644 --- a/locales/en-US.js +++ b/locales/en-US.js @@ -38,5 +38,7 @@ module.exports = { "ignore_paths":"Ignore Path", "ignore_paths_placeholder":"e.g. /a,/b/c", "plugin_option":"Plugin Option", + "custom_style":"Custom Style", + "custom_script":"Custom Script", "reboot":"Reboot", } \ No newline at end of file diff --git a/locales/zh-CN.js b/locales/zh-CN.js index ebb1a859..2eb14fd0 100644 --- a/locales/zh-CN.js +++ b/locales/zh-CN.js @@ -38,5 +38,7 @@ module.exports = { "ignore_paths":"忽略路径", "ignore_paths_placeholder":"路径,多个用逗号分隔", "plugin_option":"插件配置", + "custom_style":"自定义样式", + "custom_script":"自定义脚本", "reboot":"重启" } \ No newline at end of file diff --git a/locales/zh-TW.js b/locales/zh-TW.js index 0f4f02ee..4a9a02bb 100644 --- a/locales/zh-TW.js +++ b/locales/zh-TW.js @@ -38,5 +38,7 @@ module.exports = { "ignore_paths":"忽略路徑", "ignore_paths_placeholder":"路徑,多個用逗號分隔", "plugin_option":"插件配置", + "custom_style":"自定義樣式", + "custom_script":"自定義腳本", "reboot":"重啟", } \ No newline at end of file diff --git a/plugins/preview.media.js b/plugins/preview.media.js index 4d3e8150..a6ad5a05 100644 --- a/plugins/preview.media.js +++ b/plugins/preview.media.js @@ -42,14 +42,20 @@ module.exports = ({getSource , getPluginOption , setPluginOption}) => { // // `, body: videoPlayer == 'dplayer' ? ` - -
+ +
@@ -77,10 +83,37 @@ module.exports = ({getSource , getPluginOption , setPluginOption}) => { } } + const hls = async (data , req) => { + return { + ...data, + body: ` + + + +
+ + ` + } + } + videoFormat.split(',').forEach( ext => { preview[ext] = video }); + + ['m3u8'].forEach( ext => { + preview[ext] = hls + }); ['mp3','m4a','acc'].forEach( ext => { preview[ext] = audio