https://github.com/codeinwp/otter-query-engine
https://github.com/codeinwp/otter-query-engine
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/codeinwp/otter-query-engine
- Owner: Codeinwp
- Created: 2022-03-09T10:58:01.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-27T10:01:54.000Z (over 3 years ago)
- Last Synced: 2025-03-02T08:38:22.749Z (11 months ago)
- Language: TypeScript
- Size: 85 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Otter Tool Testing - Query Engine
> It allows you to import blocks exported in JSON file from GitHub.

## Getting Started
### Commands
##### Run - run the query from the input field
##### Quick - run the query directly from the clipboard. It will need permission from the browser.
[Optional] Fork [this repo](https://github.com/Codeinwp/otter-blocks-qa-templates). Make a folder, and add some exported blocks in it.
## Load the Query Engine in your browser.
Methods:
1. Load the `dist/index.js` as js file in the page. See `index.html`
```html
```
2. Inject the script via js and CDN link. *You also use [Snippets](https://developer.chrome.com/docs/devtools/javascript/snippets/).*
```javascript
window.addEventListener('load', (event) => {
let count = 0;
const interv = setInterval( () => {
count ++;
const settingsBar = document.querySelector("#editor div.edit-post-header__settings")
if( settingsBar ) {
var s = document.createElement('script');
s.defer = true;
s.type = "module";
s.src = "https://cdn.jsdelivr.net/gh/Codeinwp/otter-query-engine@master/dist/index.js";
(document.head||document.documentElement).appendChild(s);
clearInterval(interv);
}
if(count > 6) {
clearInterval(interv);
}
}, 500);
});
```
**You can also use the Chrome extension. [Link](https://github.com/Codeinwp/otter-blocks-qa-templates)**
## Usage
Insert all the files from the `blocks` folder.
```javascript
new QueryQA().select('blocks').run()
```
Insert all the files from the `blocks` folder in Robert's repo.
```javascript
new QueryQA().select('blocks').from('robert').run()
```
Insert all the files from the `blocks` folder in Robert's repo and specify the repo **(RAW content only)**.
```javascript
new QueryQA().select('blocks').from('robert', 'https://raw.githubusercontent.com/Soare-Robert-Daniel/otter-blocks-qa-templates/main/').run()
```
Insert all the files from the `blocks` folder which have the names `summer-breeze` and `countdown`.
```javascript
new QueryQA().select('blocks').where({ names: ['summer-breeze', 'countdown'] }).run()
```
Insert all the files from the `blocks` folder which have ONLY the `flip` block.
```javascript
new QueryQA().select('blocks').where({ has: { blocks: ['flip'] }}).run()
```
**[Short Syntax]** Insert all the files from the `blocks` folder which have ONLY the `flip` block.
```javascript
new QueryQA().select('blocks').where({ has: ['flip'] }).run()
```
Insert all the files from the `blocks` folder which CONTAINS the `flip` block.
```javascript
new QueryQA().select('blocks').where({ has: ['flip'], mode: 'all' }).run()
```
Insert all the files from the `blocks` folder which have ONLY the `count` plugin.
```javascript
new QueryQA().select('blocks').where({ has: { plugins: ['count'] } }).run()
```
**[Short Syntax]** Insert all the files from the `blocks` folder which have ONLY the `count` plugin.
```javascript
new QueryQA().select('blocks').where({ has: ['count'] }).run()
```
Insert all the files from the `blocks` folder which CONTAINS the `count` plugin.
```javascript
new QueryQA().select('blocks').where({ has: { plugins: ['count'] }, mode: 'all' }).run()
```
Insert the first 5 files from the `blocks` folder.
```javascript
new QueryQA().select('blocks').take(5).run()
```
Shuffle the files from the `blocks` folder then insert the first 5 files .
```javascript
new QueryQA().select('blocks').take(5, {shuffle: true}).run()
```
Shuffle the files which CONTAINS the `flip` block from the `blocks` folder then insert the first file .
```javascript
new QueryQA().select('blocks').where({ has: ['flip'], mode: 'all' }).take(5, {shuffle: true}).run()
```