mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
wiki
This commit is contained in:
1 parent
649f65b17d
commit
e3bbff7e11
22 files changed
+315
-441
No files matched your search
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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
@@ -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}`);
|
||||
|
||||
Reference in new issue
Block a user