Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files #154

Merged
merged 4 commits into from
Dec 1, 2024
Merged

Files #154

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ Cosma uses the following libraries:
- Webpack-cli : 4.10.0
- Webpack-dev-server : 4.11.1
- Yaml : 2.2.1
- Zettlr/citr : 1.2.2

8 changes: 4 additions & 4 deletions controllers/batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { parse } from 'csv-parse/sync';
import fs from 'node:fs';
import fsPromises from 'node:fs/promises';
import path from 'node:path';
import Rrecord from '../core/models/_record.js';
import Record from '../core/models/record.js';
import Config from '../core/models/config.js';
import findMarkdownFilesRecursively from '../core/utils/findMarkdownFilesRecursively.js';
import isTimestampIncrement from '../core/utils/isTimestampIncrement.js';
Expand Down Expand Up @@ -36,7 +36,7 @@ async function batch(filePath, saveIdOnYmlFrontMatter) {
await Promise.all(
files.map(async (filePath) => {
const content = await fsPromises.readFile(filePath, 'utf8');
const record = Rrecord.recordFromFile(content, config);
const record = Record.recordFromFile(content, config);
if (isTimestampIncrement(record.id)) {
timestamps.push(record.id);
}
Expand All @@ -47,7 +47,7 @@ async function batch(filePath, saveIdOnYmlFrontMatter) {
const heigtherTimestamp = timestamps[0];
const increment = heigtherTimestamp - todayMaxTimestamp + 1;

/** @type {Rrecord[]} */
/** @type {Record[]} */
let records = [];

fs.readFile(filePath, 'utf-8', async (err, data) => {
Expand Down Expand Up @@ -93,7 +93,7 @@ async function batch(filePath, saveIdOnYmlFrontMatter) {
throw new Error('Batch data should be array');
}

records = data.map((e, i) => Rrecord.recordWithIncrementedTimestamp(e, config, increment + i));
records = data.map((e, i) => Record.recordWithIncrementedTimestamp(e, config, increment + i));

await Promise.all(
records.map(async (record) => {
Expand Down
4 changes: 2 additions & 2 deletions controllers/create-record.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import fs from 'node:fs';
import path from 'node:path';
import readline from 'node:readline';
import Config from '../core/models/config.js';
import Reecord from '../core/models/_record.js';
import Record from '../core/models/record.js';

/**
* Format data, prompt warnings and create record file
Expand Down Expand Up @@ -62,7 +62,7 @@ function createRecord(
);
}

const record = Reecord.recordWithTimestamp(
const record = Record.recordWithTimestamp(
{
title,
types,
Expand Down
12 changes: 6 additions & 6 deletions controllers/modelize.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'node:fs';
import fsPromise from 'node:fs/promises';
import path from 'node:path';
import { finished } from 'stream/promises';
import Rrecord from '../core/models/_record.js';
import Record from '../core/models/record.js';
import Bibliography from '../core/models/bibliography.js';
import Config from '../core/models/config.js';
import Template from '../core/models/template.js';
Expand Down Expand Up @@ -77,7 +77,7 @@ async function modelize(options) {

const files = await findMarkdownFilesRecursively(config.opts['files_origin']);

/** @type {Map<string, Rrecord>} */
/** @type {Map<string, Record>} */
const records = new Map();

async function processNodes(filePath) {
Expand All @@ -91,7 +91,7 @@ async function modelize(options) {
parser.on('readable', function () {
let line;
while ((line = parser.read()) !== null) {
const record = Rrecord.recordFromCsv(line, config);
const record = Record.recordFromCsv(line, config);
records.set(record.id, record);
}
});
Expand All @@ -118,7 +118,7 @@ async function modelize(options) {
parser.on('readable', function () {
let line;
while ((line = parser.read()) !== null) {
const record = Rrecord.recordFromCsv(line, config);
const record = Record.recordFromCsv(line, config);
records.set(record.id, record);
}
});
Expand Down Expand Up @@ -194,14 +194,14 @@ async function modelize(options) {
await Promise.all(
files.map(async (filePath) => {
const content = await fsPromise.readFile(filePath, 'utf8');
const record = Rrecord.recordFromFile(content, config);
const record = Record.recordFromFile(content, config);
records.set(record.id, record);

if (bibliography) {
const citeExtract = extractCitations(record.content);
citeExtract.forEach((extract) =>
extract.citations.forEach((cite) => {
const recordCite = Rrecord.recordFromCiteItem(cite, config, bibliography);
const recordCite = Record.recordFromCiteItem(cite, config, bibliography);
records.set(recordCite.id, recordCite);
}),
);
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion core/models/_record.spec.js → core/models/record.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Record from './_record.js';
import Record from './record.js';
import Config from './config.js';

jest.mock('../i18n.yml', () => ({}));
Expand Down
2 changes: 1 addition & 1 deletion core/models/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Template {

/**
* Get data from graph and make a web app
* @param {Map<string, import('../models/_record.js').default>} records
* @param {Map<string, import('../models/record.js').default>} records
* @param {GraphEngine} graph
* @param {string[]} params
* @exemple
Expand Down
50 changes: 0 additions & 50 deletions core/test/bibliography.js

This file was deleted.

Loading