Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
srvpro
Commits
c50bdccb
Commit
c50bdccb
authored
Mar 04, 2018
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update pre util to prevent some ISP from cache file
parent
606510e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
ygopro-pre.js
ygopro-pre.js
+12
-2
No files found.
ygopro-pre.js
View file @
c50bdccb
...
...
@@ -26,6 +26,8 @@ config=settings.modules.pre_util;
var
cardHTMLs
=
[];
//http长连接
var
responder
;
//URL里的更新时间戳
var
dataver
=
moment
().
format
(
"
YYYYMMDDHHmmss
"
);
//输出反馈信息,如有http长连接则输出到http,否则输出到控制台
var
sendResponse
=
function
(
text
)
{
...
...
@@ -187,6 +189,7 @@ var loadDb = function(db_file) {
sendResponse
(
db_file
+
"
:
"
+
err
);
}
else
{
dataver
=
moment
().
format
(
"
YYYYMMDDHHmmss
"
);
sendResponse
(
"
已加载数据库
"
+
db_file
+
"
,共
"
+
num
+
"
张卡。
"
);
}
});
...
...
@@ -197,6 +200,8 @@ var writeToFile = function(message) {
var
fileContent
=
fs
.
readFileSync
(
config
.
html_path
+
config
.
html_filename
,
{
"
encoding
"
:
"
utf-8
"
});
var
newContent
=
cardHTMLs
.
join
(
"
\n
"
);
fileContent
=
fileContent
.
replace
(
/<tbody class="auto-generated">
[\w\W]
*<
\/
tbody>/
,
'
<tbody class="auto-generated">
\n
'
+
newContent
+
'
\n
</tbody>
'
);
fileContent
=
fileContent
.
replace
(
/data-ygosrv233-download="
(
http.+
)
" href="http.+"/g
,
'
data-ygosrv233-download="$1" href="$1"
'
);
fileContent
=
fileContent
.
replace
(
/href="
(
http.+
)
dataver/g
,
'
href="$1
'
+
dataver
);
if
(
message
)
{
message
=
"
<li>
"
+
moment
().
format
(
'
L HH:mm
'
)
+
"
<ul><li>
"
+
message
.
split
(
"
!换行符!
"
).
join
(
"
</li><li>
"
)
+
"
</li></ul></li>
"
;
fileContent
=
fileContent
.
replace
(
/<ul class="auto-generated">/
,
'
<ul class="auto-generated">
\n
'
+
message
);
...
...
@@ -251,12 +256,17 @@ var fetchDatas = function() {
//更新本地网页到服务器,异步
var
pushDatas
=
function
()
{
if
(
config
.
cdn
.
enabled
)
{
uploadCDN
(
config
.
cdn
.
local
,
config
.
cdn
.
remote
,
function
()
{
uploadCDN
(
config
.
cdn
.
local
,
config
.
cdn
.
remote
+
"
/
"
+
dataver
,
function
()
{
uploadCDN
(
config
.
db_path
+
"
pics
"
,
config
.
cdn
.
pics_remote
+
"
pics
"
,
function
()
{
sendResponse
(
"
CDN上传全部完成。
"
);
pushHTMLs
();
});
});
}
}
var
pushHTMLs
=
function
()
{
sendResponse
(
"
开始上传到网页。
"
);
try
{
execSync
(
'
git add --all .
'
,
{
cwd
:
config
.
git_html_path
,
env
:
process
.
env
});
execSync
(
'
git commit -m update-auto
'
,
{
cwd
:
config
.
git_html_path
,
env
:
process
.
env
});
...
...
@@ -428,7 +438,7 @@ http.createServer(function (req, res) {
}
else
if
(
u
.
pathname
===
'
/api/push_datas
'
)
{
res
.
writeHead
(
200
);
res
.
end
(
u
.
query
.
callback
+
'
({"message":"开始上传
到网页
。"});
'
);
res
.
end
(
u
.
query
.
callback
+
'
({"message":"开始上传
数据
。"});
'
);
pushDatas
();
}
else
if
(
u
.
pathname
===
'
/api/write_to_file
'
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment