This commit is contained in:
undefined committed 2020-05-04 12:34:00 +08:00
1 parent 649f65b17d
commit e3bbff7e11
22 files changed
+315 -441

No files matched your search

+5 -1
View File
@@ -68,9 +68,13 @@ class DiscussionMainHandler extends DiscussionHandler {
constants.DISCUSSION_PER_PAGE,
);
const udict = await user.getList(ddocs.map((ddoc) => ddoc.owner));
const path = [
['Hydro', '/'],
['discussion_main', null],
];
this.response.template = 'discussion_main_or_node.html';
this.response.body = {
ddocs, dpcount, udict, page, page_name: 'discussion_main', vnode: {},
ddocs, dpcount, udict, page, page_name: 'discussion_main', vnode: {}, path,
};
}
}
+11 -2
View File
@@ -80,9 +80,13 @@ class TrainingMainHandler extends TrainingHandler {
if (enrolledTids.size) tdict = await training.getList(Array.from(enrolledTids));
}
for (const tdoc in tdocs) tdict[tdoc._id] = tdoc;
const path = [
['Hydro', '/'],
['training_main', null],
];
this.response.template = 'training_main.html';
this.response.body = {
tdocs, page, tpcount, qs, tsdict, tdict,
tdocs, page, tpcount, qs, tsdict, tdict, path,
};
}
}
@@ -154,8 +158,13 @@ class TrainingCreateHandler extends TrainingHandler {
}
async get() {
const path = [
['Hydro', '/'],
['problem_main', '/t'],
['problem_create', null],
];
this.response.template = 'training_edit.html';
this.response.body = { page_name: 'training_create' };
this.response.body = { page_name: 'training_create', path };
}
async post({
+3 -1
View File
@@ -28,7 +28,9 @@ String.prototype.rawformat = function rawFormat(object) {
};
String.prototype.translate = function translate(language = 'zh_CN') {
if (locales[language]) return locales[language][this] || this;
if (locales[language]) {
if (locales[language][this] !== undefined) return locales[language][this];
}
return this;
};
+1 -1
View File
@@ -7,7 +7,7 @@ const misc = require('./misc');
function Loader() { }
Loader.prototype.getSource = function getSource(name) {
if (!global.Hydro.template[name]) throw new Error();
if (!global.Hydro.template[name]) throw new Error(`Cannot get template ${name}`);
return {
src: global.Hydro.template[name],
path: name,
+5 -5
View File
@@ -35,13 +35,13 @@ async function handler() {
}
async function locale() {
if (exist('.build/locale.js')) {
global.Hydro.lib.i18n(superRequire('.build/locale.js'));
if (exist('.build/locale.json')) {
global.Hydro.lib.i18n(superRequire('.build/locale.json'));
console.log('Locale init: builtin');
}
for (const i of installed) {
if (exist(`.build/module/${i}/locale.js`)) {
global.Hydro.lib.i18n(superRequire(`.build/module/${i}/locale.js`));
if (exist(`.build/module/${i}/locale.json`)) {
global.Hydro.lib.i18n(superRequire(`.build/module/${i}/locale.json`));
console.log(`Locale init: ${i}`);
}
}
@@ -54,7 +54,7 @@ async function template() {
console.log('Template init: builtin');
}
for (const i of installed) {
if (exist(`.build/module/${i}/locale.js`)) {
if (exist(`.build/module/${i}/template.yaml`)) {
const file = fs.readFileSync(root(`.build/module/${i}/template.yaml`)).toString();
Object.assign(global.Hydro.template, yaml.safeLoad(file));
console.log(`Template init: ${i}`);