Skip to content

Commit

Permalink
refactor: rename create index
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 31, 2021
1 parent 5f5980e commit 13c4444
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 112 deletions.
106 changes: 2 additions & 104 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,108 +154,6 @@ router.setRoutes([

使用标准的 Stencil.js 开发即可。

## Others

## Transflow 转换数据流

Quake 采用了简单的 Transflow DSL 设计:

```groovy
transflow {
from('todo','blog').to(<quake-calendar>);
}
```

即将 `todo``blog` 渲染到 `<quake-calendar>` 组件中:

在组件和数据对应的情况下,上述的代码,可以生成如下的两部分代码:

```javascript
// 数据转换
function from_todo_blog_to_quake_calendar(todos, blogs) {
let results = [];
results = results.concat(todos);
results = results.concat(blogs);
return results;
}

// 渲染组件
const tl_show_timeline = async (context, commands) => {
const el = document.createElement('quake-calendar');

let todos = await Quake.query('todo');

let blogs = await Quake.query('blog');

let data = from_todo_blog_to_quake_calendar(todos, blogs);
el.setAttribute('data', JSON.stringify(data));

return el;
}
```


可以通过 `transflows.yaml` 来自定义不同的数据流及转换:


```yaml
- name: "show_timeline"
target: "quake-calendar-timeline"
defines_map: ~
flows:
- name: "from_todo_blog_to_quake_calendar_timeline"
from: [ "todo", "blog" ]
to: "<quake-calendar-timeline>"
mappings:
- entry: "todo"
source: ["id", "title", "content", "created_date", "updated_date"]
target: ["id", "title", "content", "created_date", "updated_date"]
- entry: "blog"
source: ["id", "title", "content", "created_date", "updated_date"]
target: ["id", "title", "content", "created_date", "updated_date"]
filter: # 尚在开发中
- entry: "todo"
expression: "created_date > 2020.12.30 AND updated_date < 2022.01.01"
```


还有尚在开发中的数据过滤。


## Query Syntax

more in: [quake.pest](quake_core/src/parser/quake.pest)

```pest
action_decl = {
object ~ "." ~ action ~ parameters? ~ ":"? ~ " "* ~ text?
}
parameters = {
"(" ~ parameter ~ ("," ~ parameter)* ~ ")"
}
```

## Markdown Extends syntax [TBD]

1. tag: `#{tag}`
2. custom function: `#{$block}, #{$toc}, #{$link}, #{$file = Hello.pptx}`

## Quake Output

examples output:

```
├── entries-define.yaml # define all type data
├── web
│   ├── index.html
│   └── js
├── yarn.lock
└── yiki # data type
├── 0001-hello-world.md # a `yiki` file
├── entries.csv # tables for all `yiki`
└── entry-node-info.yaml # `yiki` node info
```

# Issues

IndexMap not working: [https://github.com/intellij-rust/intellij-rust/issues/8007](https://github.com/intellij-rust/intellij-rust/issues/8007)
see in [Quake book](examples/quake_book/)
2 changes: 1 addition & 1 deletion quake_core/src/entry/entry_defines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl EntryDefines {
}
}

pub fn entries_define_from_path(config_path: &Path) -> Vec<EntryDefine> {
pub fn from_path(config_path: &Path) -> Vec<EntryDefine> {
let entries_str = fs::read_to_string(config_path).expect("cannot read entries-define.yaml");
let entries: EntryDefines = serde_yaml::from_str(&*entries_str).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion quake_core/src/usecases/entry_define_usecases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::entry::{entry_defines, EntryDefine};
use std::path::Path;

pub fn find_entry_define(target_entry: &str, path: &Path) -> EntryDefine {
let entries: Vec<EntryDefine> = entry_defines::entries_define_from_path(path)
let entries: Vec<EntryDefine> = entry_defines::from_path(path)
.into_iter()
.filter(|define| define.entry_type.eq(target_entry))
.collect();
Expand Down
5 changes: 2 additions & 3 deletions quake_core/src/usecases/entry_usecases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ pub fn create_entry(
let mut entry_info = entry_node_info::entry_info_from_path(&paths.entry_node_info);

let new_index = entry_info.index + 1;
let index = new_index;
let text = entry_text;
let new_md_file = EntryFile::file_name(index, text);
let new_md_file = EntryFile::file_name(new_index, entry_text);

let mut target_path = paths.entry_path.join(new_md_file);
File::create(&target_path)?;

Expand Down
5 changes: 2 additions & 3 deletions quake_tui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,8 @@ impl App {
"listAll" => {
let entry_defines_path =
Path::new(&self.config.workspace).join(EntryPaths::entries_define());
self.main_widget = MainWidget::EntryTypes(entry_defines::entries_define_from_path(
&entry_defines_path,
));
self.main_widget =
MainWidget::EntryTypes(entry_defines::from_path(&entry_defines_path));
}
"save" => self.save_entry(),
other => {
Expand Down

0 comments on commit 13c4444

Please sign in to comment.