Skip to content

Commit

Permalink
refactor: rename content
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 31, 2021
1 parent 13c4444 commit 4473aae
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions quake_core/src/usecases/entry_usecases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@ pub fn sync_in_path(paths: &EntryPaths) -> Result<(), Box<dyn Error>> {

if size > 0 {
fs::write(&paths.entries_csv, content)?;
update_entry_info(&paths.entry_node_info, &mut EntryNodeInfo::new(size));
save_entry_info(&paths.entry_node_info, &mut EntryNodeInfo::new(size));
}

Ok(())
}

pub fn update_entry_info(entry_info_path: &Path, entry_info: &mut EntryNodeInfo) {
let result = serde_yaml::to_string(&entry_info).expect("cannot convert to yaml");
fs::write(&entry_info_path, result).expect("cannot write to file");
}

/// create entry by `path`, `type`, `text`
/// process:
/// 1. looking for entry define file
Expand Down Expand Up @@ -56,11 +51,16 @@ pub fn create_entry(
entry_file.id = new_index;

entry_info.inc();
update_entry_info(&paths.entry_node_info, &mut entry_info);
save_entry_info(&paths.entry_node_info, &mut entry_info);

Ok((target_path, entry_file))
}

fn save_entry_info(entry_info_path: &Path, entry_info: &mut EntryNodeInfo) {
let result = serde_yaml::to_string(&entry_info).expect("cannot convert to yaml");
fs::write(&entry_info_path, result).expect("cannot write to file");
}

/// create really entry file
pub fn create_entry_file(
entry_define: &EntryDefine,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ export class EmbedLink {
</Host>
);
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Component, h, Host, Prop} from '@stencil/core';
import * as echarts from "echarts";
import {EChartsOption} from "echarts";
import {QuakeDownType} from "../../markdown/quake-down.type";
import {EChartsType} from "echarts/types/dist/echarts";
import {QuakeDownType} from "../../markdown/quake-down.type";

@Component({
tag: 'graph-bar',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class QuakeRender {
}

private tableToJson(code: QuakeDownType.Code): QuakeDownType.Table | null {
let data = this.quakeDown.build_data(code.text);
let data = this.quakeDown.buildData(code.text);
for (let datum of data) {
if (datum.type == 'table') {
return datum;
Expand Down
6 changes: 3 additions & 3 deletions quake_webapp/quake-render/src/markdown/quake-down.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class QuakeDown {
});
this.renderer = new marked.Renderer();

return this.build_data(this.content);
return this.buildData(this.content);
}

// add extensions in extension.ts file for split
private static extensions() {
return getExtensions();
}

build_data(src: string) {
buildData(src: string) {
let output = [];
const tokens = marked.lexer(src);

Expand Down Expand Up @@ -143,7 +143,7 @@ class QuakeDown {
let data;
switch (token.type) {
case 'admonition':
let content = this.build_data(token.body);
let content = this.buildData(token.body);
data = {
type: 'admonition',
title: token.title,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/entry_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ impl EntryAction {
pub fn entry_action(expr: &QuakeActionNode, conf: QuakeConfig) -> Result<(), Box<dyn Error>> {
let paths = EntryPaths::init(&conf.workspace, &expr.object);

// todo: export api for search
match expr.action.as_str() {
"add" => {
let target_file =
entry_usecases::create_entry(&conf.workspace, &expr.object, &expr.text)?.0;

if !conf.editor.is_empty() {
editor_exec::edit_file(conf.editor, format!("{:}", target_file.display()))?;
}
Expand Down
7 changes: 4 additions & 3 deletions src/cli/quake_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ pub fn quake_action(action: String, conf: &QuakeConfig) -> Result<(), Box<dyn Er
QuakeAction::Sync => {
sync_defines(conf)?;
}
QuakeAction::Migration => {}
QuakeAction::Migration => {
// TBD
}
QuakeAction::Feed => {
feed_data(conf)?;
}
QuakeAction::Refs => {
let path = PathBuf::from(&conf.workspace);
create_entries_refs(&path)?;
create_entries_refs(&PathBuf::from(&conf.workspace))?;
}
QuakeAction::Error => {
return Err(Box::new(QuakeError(format!(
Expand Down

0 comments on commit 4473aae

Please sign in to comment.