From fe3270c99a03f759a18b4b36227189fee5e0ecea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=96=B0=E5=8D=8E?= Date: Sat, 4 Mar 2023 10:29:46 +0800 Subject: [PATCH 1/7] modify cdn --- .air.conf | 2 +- cmd/server.go | 1 + docker-compose.yml | 8 +- global/app.go | 4 +- sg.service | 13 + static/dist/js/sg_libs.js | 814 +++++++++--------- static/dist/js/sg_libs.min.js | 2 +- static/js/libs/jquery.githubRepoWidget.min.js | 2 +- template/articles/detail.html | 2 +- template/atom.html | 2 +- template/books/detail.html | 4 +- template/books/list.html | 2 +- template/rich/add.html | 4 +- 13 files changed, 435 insertions(+), 425 deletions(-) create mode 100644 sg.service diff --git a/.air.conf b/.air.conf index ba3cff6e..c29c615d 100644 --- a/.air.conf +++ b/.air.conf @@ -19,7 +19,7 @@ log = "air_errors.log" # Watch these filename extensions. include_ext = ["go", "tpl", "tmpl", "html"] # Ignore these filename extensions or directories. -exclude_dir = ["log", "tmp", "vendor", "node_modules", "template", "static", "docs", "bin", "sitemap", "data", "config", "pid"] +exclude_dir = ["log", "tmp", "vendor", "node_modules", "template", "static", "docs", "bin", "sitemap", "data", "config", "pid", "docker"] # There's no necessary to trigger build each time file changes if it's too frequency. delay = 1000 # ms diff --git a/cmd/server.go b/cmd/server.go index af65870c..b2b050cc 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -31,6 +31,7 @@ func IndexingServer() { } if *manualIndex { + logger.Infoln("manual indexing") indexing(true) } diff --git a/docker-compose.yml b/docker-compose.yml index 8807d74d..c8cbb7f3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,11 +24,7 @@ services: restart: always nginx: container_name: nginx - build: ./nginx - depends_on: - - play - links: - - play:play + build: ./docker/nginx volumes: - /data/www:/data/www:rw - ./nginx/conf.d:/etc/nginx/conf.d:ro @@ -69,4 +65,4 @@ services: networks: app_net: - external: true \ No newline at end of file + external: true diff --git a/global/app.go b/global/app.go index 86bdfa2c..c2893f0f 100644 --- a/global/app.go +++ b/global/app.go @@ -37,8 +37,8 @@ import ( ) const ( - DefaultCDNHttp = "http://test.static.studygolang.com/" - DefaultCDNHttps = "https://static.studygolang.com/" + DefaultCDNHttp = "http://test.static.golangjob.cn/" + DefaultCDNHttps = "https://static.golangjob.cn/" ) var Build string diff --git a/sg.service b/sg.service new file mode 100644 index 00000000..fcb57bcd --- /dev/null +++ b/sg.service @@ -0,0 +1,13 @@ +[Unit] +Description=studygolang + +[Service] +ExecStart=/data/www/studygolang/bin/studygolang +ExecReload=/bin/kill -USR2 $MAINPID +PIDFile=/data/www/studygolang/pid/studygolang.pid +Restart=always +User=xuxinhua +Group=xuxinhua + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/static/dist/js/sg_libs.js b/static/dist/js/sg_libs.js index 7a8bfcdf..59146ed0 100644 --- a/static/dist/js/sg_libs.js +++ b/static/dist/js/sg_libs.js @@ -88,290 +88,290 @@ var emojis = [ ]; emojis = $.map(emojis, function(value, i) {return {key:':'+value+':', name:value}}); -(function($){ -$.fn.Huploadify = function(opts){ - var itemTemp = '
${fileName}上传删除
'; - var defaults = { - fileTypeExts:'*.*',//允许上传的文件类型,格式'*.jpg;*.doc' - uploader:'',//文件提交的地址 - auto:false,//是否开启自动上传 - method:'post',//发送请求的方式,get或post - multi:true,//是否允许选择多个文件 - formData:null,//发送给服务端的参数,格式:{key1:value1,key2:value2} - fileObjName:'file',//在后端接受文件的参数名称,如PHP中的$_FILES['file'] - fileSizeLimit:2048,//允许上传的文件大小,单位KB - showUploadedPercent:true,//是否实时显示上传的百分比,如20% - showUploadedSize:false,//是否实时显示已上传的文件大小,如1M/2M - buttonText:'选择文件',//上传按钮上的文字 - removeTimeout: 1000,//上传完成后进度条的消失时间 - itemTemplate:itemTemp,//上传队列显示的模板 - onUploadStart:null,//上传开始时的动作 - onUploadSuccess:null,//上传成功的动作 - onUploadComplete:null,//上传完成的动作 - onUploadAllComplete: null, // 批量上传时,所有的都上传完后回调 - onUploadError:null, //上传失败的动作 - onInit:null,//初始化时的动作 - onCancel:null//删除掉某个文件后的回调函数,可传入参数file - } - - var option = $.extend(defaults,opts); - - //将文件的单位由bytes转换为KB或MB,若第二个参数指定为true,则永远转换为KB - var formatFileSize = function(size,byKB){ - if (size> 1024 * 1024&&!byKB){ - size = (Math.round(size * 100 / (1024 * 1024)) / 100).toString() + 'MB'; - } - else{ - size = (Math.round(size * 100 / 1024) / 100).toString() + 'KB'; - } - return size; - } - //根据文件序号获取文件 - var getFile = function(index,files){ - for(var i=0;i