mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-17 16:38:18 +00:00
feature: common: entity: migrate to ESM
This commit is contained in:
parent
c3b71653bb
commit
ebabad948f
10 changed files with 61 additions and 66 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import rendy from 'rendy';
|
||||
import currify from 'currify';
|
||||
import store from 'fullstore';
|
||||
import {encode} from './entity.js';
|
||||
import {encode} from '#common/entity';
|
||||
|
||||
export const getHeaderField = currify(_getHeaderField);
|
||||
|
||||
|
|
@ -168,7 +168,6 @@ export const buildFromJSON = (params) => {
|
|||
Path(path);
|
||||
|
||||
fileTable += `${header}<ul data-name="js-files" class="files">`;
|
||||
|
||||
/* Если мы не в корне */
|
||||
if (path !== '/') {
|
||||
const dotDot = getDotDot(path);
|
||||
|
|
@ -199,43 +198,43 @@ export const buildFromJSON = (params) => {
|
|||
|
||||
fileTable += files
|
||||
.filter(filterOutDotFiles({
|
||||
showDotFiles,
|
||||
}))
|
||||
showDotFiles,
|
||||
}))
|
||||
.map(updateField)
|
||||
.map((file) => {
|
||||
const name = encode(file.name);
|
||||
const link = prefix + FS + path + name;
|
||||
|
||||
const {
|
||||
type,
|
||||
mode,
|
||||
date,
|
||||
owner,
|
||||
size,
|
||||
} = file;
|
||||
|
||||
const linkResult = rendy(templateLink, {
|
||||
link,
|
||||
title: name,
|
||||
name,
|
||||
attribute: getAttribute(file.type),
|
||||
});
|
||||
|
||||
const dataName = _getDataName(file.name);
|
||||
const attribute = `draggable="true" ${dataName}`;
|
||||
|
||||
return rendy(templateFile, {
|
||||
tag: 'li',
|
||||
attribute,
|
||||
className: '',
|
||||
type,
|
||||
name: linkResult,
|
||||
size,
|
||||
date,
|
||||
owner,
|
||||
mode,
|
||||
});
|
||||
})
|
||||
const name = encode(file.name);
|
||||
const link = prefix + FS + path + name;
|
||||
|
||||
const {
|
||||
type,
|
||||
mode,
|
||||
date,
|
||||
owner,
|
||||
size,
|
||||
} = file;
|
||||
|
||||
const linkResult = rendy(templateLink, {
|
||||
link,
|
||||
title: name,
|
||||
name,
|
||||
attribute: getAttribute(file.type),
|
||||
});
|
||||
|
||||
const dataName = _getDataName(file.name);
|
||||
const attribute = `draggable="true" ${dataName}`;
|
||||
|
||||
return rendy(templateFile, {
|
||||
tag: 'li',
|
||||
attribute,
|
||||
className: '',
|
||||
type,
|
||||
name: linkResult,
|
||||
size,
|
||||
date,
|
||||
owner,
|
||||
mode,
|
||||
});
|
||||
})
|
||||
.join('');
|
||||
|
||||
fileTable += '</ul>';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
'use strict';
|
||||
|
||||
const Entities = {
|
||||
// ' ': ' ',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
|
|
@ -9,7 +6,7 @@ const Entities = {
|
|||
|
||||
const keys = Object.keys(Entities);
|
||||
|
||||
module.exports.encode = (str) => {
|
||||
export const encode = (str) => {
|
||||
for (const code of keys) {
|
||||
const char = Entities[code];
|
||||
const reg = RegExp(char, 'g');
|
||||
|
|
@ -20,7 +17,7 @@ module.exports.encode = (str) => {
|
|||
return str;
|
||||
};
|
||||
|
||||
module.exports.decode = (str) => {
|
||||
export const decode = (str) => {
|
||||
for (const code of keys) {
|
||||
const char = Entities[code];
|
||||
const reg = RegExp(code, 'g');
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
const {test} = require('supertape');
|
||||
const entity = require('./entity');
|
||||
import {test} from 'supertape';
|
||||
import * as entity from '#common/entity';
|
||||
|
||||
test('cloudcmd: entity: encode', (t) => {
|
||||
const result = entity.encode('<hello> ');
|
||||
Loading…
Add table
Add a link
Reference in a new issue