markdown语法增强,错误修复

This commit is contained in:
undefined committed 2020-06-16 12:10:55 +08:00
1 parent 4b3c10b4eb
commit a29b801e72
22 files changed
+311 -200

No files matched your search

-33
View File
@@ -1,33 +0,0 @@
const { Route, Handler } = global.Hydro.service.server;
const { PERM_MANAGE } = global.Hydro.permission;
const { message } = global.Hydro.model;
class MigrateVijosHandler extends Handler {
async prepare() {
this.checkPerm(PERM_MANAGE);
}
async get() {
const path = [
['Hydro', 'homepage'],
['migrate_vijos', null],
];
this.response.body = { path };
this.response.template = 'migrate_vijos.html';
}
async post({
host, port, name, username, password,
}) {
global.Hydro.script.migrateVijos({
host, port, name, username, password,
}, (data) => message.send(1, 1, data));
this.response.redirect = '/manage/log';
}
}
async function apply() {
Route('migrate_vijos', '/migrate/vijos', MigrateVijosHandler);
}
global.Hydro.handler.migrateVijos = module.exports = apply;
-1
View File
@@ -1,4 +1,3 @@
const { md5, sha1 } = global.Hydro.lib;
global.Hydro.lib['hash.vj2'] = module.exports = {
+10 -6
View File
@@ -3,6 +3,9 @@ const { mongodb } = global.nodeModules;
const dst = global.Hydro.service.db;
const { file, problem, discussion } = global.Hydro.model;
// TODO read config file
// TODO output enhancement
const map = {};
const pid = (id) => {
@@ -114,7 +117,6 @@ const tasks = {
domain_id: 'domainId',
num_accept: 'nAccept',
num_submit: 'nSubmit',
rp: 'rp',
status: 'status',
accept: 'accept',
vote: 'vote',
@@ -259,6 +261,8 @@ async function domainUser(src, report) {
num_problems: 'nProblems',
domain_id: 'domainId',
level: 'level',
rp: null,
rank: null,
};
const d = {};
for (const key in doc) {
@@ -269,7 +273,7 @@ async function domainUser(src, report) {
} else if (mapper[key] === null) {
// Ignore this key
} else {
console.log('Unknown key:', key);
await report({ message: `Unknown key ${key} in collection domain.user` });
}
}
const docWithoutId = {};
@@ -282,7 +286,7 @@ async function domainUser(src, report) {
{ _id: d._id },
{
$set: {
...docWithoutId, docType: 0, docId: 1, role: docWithoutId.role || 'default',
...docWithoutId, docType: 0, docId: 0, role: docWithoutId.role || 'default',
},
},
{ upsert: true },
@@ -349,7 +353,7 @@ async function task(name, src, report) {
} else if (mapper[key] === null) {
// Ignore this key
} else {
console.log('Unknown key:', key);
await report({ message: `Unknown key ${key} in collection ${name}` });
}
}
}
@@ -392,7 +396,7 @@ async function task(name, src, report) {
} else res.push(dst.collection(name).insertOne(d));
}
}
await Promise.all(res).catch((e) => console.log(e));
await Promise.all(res).catch((e) => report({ message: `${e}\n${e.stack}` }));
const progress = Math.round(100 * ((i + 1) / (total + 1)));
if (progress > lastProgress) {
await report({ progress });
@@ -403,7 +407,7 @@ async function task(name, src, report) {
async function migrateVijos({
host, port, name, username, password,
}, report = () => { }) {
}, report) {
let mongourl = 'mongodb://';
if (username) mongourl += `${username}:${password}@`;
mongourl += `${host}:${port}/${name}`;
@@ -1,58 +0,0 @@
{% extends "layout/basic.html" %}
{% block content %}
<div class="row">
<div class="medium-9 columns">
<div class="section">
<div class="section__body">
<form method="post">
<div class="row">
{{ form.form_text({
columns:8,
label:'Source Database Host',
name:'host',
value:'127.0.0.1',
autofocus:true,
row:false
}) }}
{{ form.form_text({
columns:4,
label:'Source Database Port',
name:'post',
value:'27017',
row:false
}) }}
</div><div class="row">
{{ form.form_text({
columns:4,
label:'Source Database Name',
name:'name',
value:'vijos',
row:false
}) }}
{{ form.form_text({
columns:4,
label:'Source Database Username',
name:'username',
placeholder:'Leave empty if none.',
row:false
}) }}
{{ form.form_text({
columns:4,
label:'Source Database Password',
name:'password',
placeholder:'Leave empty if none.',
row:false
}) }}
</div>
<div class="row"><div class="columns">
<input type="hidden" name="csrfToken" value="{{ handler.csrfToken }}">
<button type="submit" class="rounded primary button">
{{ _('Migrate') }}
</button>
</div></div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}