-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "entity_macro" | ||
authors.workspace = true | ||
edition.workspace = true | ||
version.workspace = true | ||
license.workspace = true | ||
documentation.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
rust-version.workspace = true | ||
exclude.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[lib] | ||
proc-macro = true | ||
|
||
[dependencies] | ||
quote = "1" | ||
proc-macro2 = "1.0" | ||
syn = "1.0" | ||
sea-orm.workspace=true | ||
sea-query.workspace=true | ||
|
||
serde = { version = "1.0.193", features = ["derive"] } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// pub mod model; | ||
|
||
extern crate proc_macro; | ||
use proc_macro::TokenStream; | ||
|
||
// use syn::{parse_macro_input, DeriveInput}; | ||
use quote::quote; | ||
use syn::{DeriveInput, parse_macro_input}; | ||
|
||
|
||
/// Example of user-defined [derive mode macro][1] | ||
/// | ||
/// [1]: https://doc.rust-lang.org/reference/procedural-macros.html#derive-mode-macros | ||
#[proc_macro_derive(MyDerive)] | ||
pub fn my_derive(input: TokenStream) -> TokenStream { | ||
eprintln!("input : {:#?}", input); | ||
// Parse the input tokens into a syntax tree | ||
let input = parse_macro_input!(input as DeriveInput); | ||
|
||
// Extract the name of the struct | ||
let struct_name = &input.ident; | ||
|
||
// Generate the new field to be added | ||
let new_field = quote! { | ||
new_field: i32, | ||
}; | ||
|
||
eprintln!("marco input : {:#?}", input); | ||
|
||
// Generate the implementation of the trait for the struct | ||
let expanded = quote! { | ||
pub struct #struct_name { | ||
#new_field | ||
} | ||
}; | ||
eprintln!("expanded: {:#?}", expanded); | ||
// | ||
// // Return the generated implementation as a TokenStream | ||
expanded.into() | ||
// let tokens = quote! { | ||
// struct Hello; | ||
// }; | ||
// tokens.into() | ||
} | ||
|
||
// /// Example of user-defined [procedural macro attribute][1]. | ||
// /// | ||
// /// [1]: https://doc.rust-lang.org/reference/procedural-macros.html#attribute-macros | ||
// #[proc_macro_attribute] | ||
// pub fn my_attribute(_args: TokenStream, input: TokenStream) -> TokenStream { | ||
// let input = parse_macro_input!(input as DeriveInput); | ||
// | ||
// let tokens = quote! { | ||
// #input | ||
// | ||
// struct Hello; | ||
// }; | ||
// | ||
// tokens.into() | ||
// } | ||
// | ||
// | ||
// #[proc_macro_derive(AnswerFn)] | ||
// pub fn derive_answer_fn(_item: TokenStream) -> TokenStream { | ||
// "fn answer() -> u32 { 42 }".parse().unwrap() | ||
// } | ||
// |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
name = "chrome" | ||
authors.workspace = true | ||
edition.workspace = true | ||
version.workspace = true | ||
license.workspace = true | ||
documentation.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
rust-version.workspace = true | ||
exclude.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
chromiumoxide = { git = "https://github.com/mattsse/chromiumoxide", branch = "main"} | ||
async-std = "1.12.0" | ||
futures = "0.3.29" | ||
headless_chrome = {git = "https://github.com/rust-headless-chrome/rust-headless-chrome", features = ["fetch"]} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
|
||
// use futures::StreamExt; | ||
// | ||
// use chromiumoxide::browser::{Browser, BrowserConfig}; | ||
// | ||
// #[async_std::main] | ||
// async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// | ||
// // create a `Browser` that spawns a `chromium` process running with UI (`with_head()`, headless is default) | ||
// // and the handler that drives the websocket etc. | ||
// let (mut browser, mut handler) = | ||
// Browser::launch(BrowserConfig::builder().with_head().build()?).await?; | ||
// | ||
// // spawn a new task that continuously polls the handler | ||
// let handle = async_std::task::spawn(async move { | ||
// while let Some(h) = handler.next().await { | ||
// if h.is_err() { | ||
// break; | ||
// } | ||
// } | ||
// }); | ||
// | ||
// // create a new browser page and navigate to the url | ||
// let page = browser.new_page("https://en.wikipedia.org").await?; | ||
// | ||
// // find the search bar type into the search field and hit `Enter`, | ||
// // this triggers a new navigation to the search result page | ||
// page.find_element("input#searchInput") | ||
// .await? | ||
// .click() | ||
// .await? | ||
// .type_str("Rust programming language") | ||
// .await? | ||
// .press_key("Enter") | ||
// .await?; | ||
// | ||
// let html = page.wait_for_navigation().await?.content().await?; | ||
// println!("{}", html); | ||
// | ||
// browser.close().await?; | ||
// handle.await; | ||
// Ok(()) | ||
// } | ||
|
||
use std::error::Error; | ||
|
||
use headless_chrome::Browser; | ||
use headless_chrome::protocol::cdp::Page; | ||
|
||
// fn browse_wikipedia() -> Result<(), Box<dyn Error>> { | ||
|
||
#[async_std::main] | ||
async fn main() -> Result<(), Box<dyn Error>> { | ||
let browser = Browser::default()?; | ||
|
||
let tab = browser.new_tab()?; | ||
|
||
/// Navigate to wikipedia | ||
Check warning Code scanning / clippy unused doc comment Warning
unused doc comment
|
||
tab.navigate_to("https://www.wikipedia.org")?; | ||
Check warning Code scanning / clippy unused doc comment Warning
unused doc comment
|
||
|
||
/// Wait for network/javascript/dom to make the search-box available | ||
Check warning Code scanning / clippy unused doc comment Warning
unused doc comment
|
||
/// and click it. | ||
Check warning Code scanning / clippy unused doc comment Warning
unused doc comment
|
||
tab.wait_for_element("input#searchInput")?.click()?; | ||
Check warning Code scanning / clippy unused doc comment Warning
unused doc comment
Check warning Code scanning / clippy unused doc comment Warning
unused doc comment
|
||
|
||
/// Type in a query and press `Enter` | ||
Check warning Code scanning / clippy unused doc comment Warning
unused doc comment
|
||
tab.type_str("WebKit")?.press_key("Enter")?; | ||
Check warning Code scanning / clippy unused doc comment Warning
unused doc comment
|
||
|
||
/// We should end up on the WebKit-page once navigated | ||
Check warning Code scanning / clippy unused doc comment Warning
unused doc comment
|
||
let elem = tab.wait_for_element("#firstHeading")?; | ||
Check warning Code scanning / clippy unused doc comment Warning
unused doc comment
|
||
assert!(tab.get_url().ends_with("WebKit")); | ||
|
||
/// Take a screenshot of the entire browser window | ||
Check warning Code scanning / clippy unused doc comment Warning
unused doc comment
|
||
let _jpeg_data = tab.capture_screenshot( | ||
Page::CaptureScreenshotFormatOption::Jpeg, | ||
None, | ||
None, | ||
true)?; | ||
Check warning Code scanning / clippy unused doc comment Warning
unused doc comment
|
||
|
||
/// Take a screenshot of just the WebKit-Infobox | ||
Check warning Code scanning / clippy unused doc comment Warning
unused doc comment
|
||
let _png_data = tab | ||
.wait_for_element("#mw-content-text > div > table.infobox.vevent")? | ||
.capture_screenshot(Page::CaptureScreenshotFormatOption::Png)?; | ||
Check warning Code scanning / clippy unused doc comment Warning
unused doc comment
|
||
|
||
// Run JavaScript in the page | ||
let remote_object = elem.call_js_fn(r#" | ||
function getIdTwice () { | ||
// `this` is always the element that you called `call_js_fn` on | ||
const id = this.id; | ||
return id + id; | ||
} | ||
"#, vec![], false)?; | ||
match remote_object.value { | ||
Some(returned_string) => { | ||
dbg!(&returned_string); | ||
assert_eq!(returned_string, "firstHeadingfirstHeading".to_string()); | ||
} | ||
_ => unreachable!() | ||
}; | ||
|
||
Ok(()) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Getting Started with Create React App | ||
|
||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). | ||
|
||
## Available Scripts | ||
|
||
In the project directory, you can run: | ||
|
||
### `npm start` | ||
|
||
Runs the app in the development mode.\ | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
|
||
The page will reload if you make edits.\ | ||
You will also see any lint errors in the console. | ||
|
||
### `npm test` | ||
|
||
Launches the test runner in the interactive watch mode.\ | ||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||
|
||
### `npm run build` | ||
|
||
Builds the app for production to the `build` folder.\ | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
The build is minified and the filenames include the hashes.\ | ||
Your app is ready to be deployed! | ||
|
||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||
|
||
### `npm run eject` | ||
|
||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!** | ||
|
||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. | ||
|
||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. | ||
|
||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. | ||
|
||
## Learn More | ||
|
||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). | ||
|
||
To learn React, check out the [React documentation](https://reactjs.org/). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "new-york", | ||
"rsc": false, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.js", | ||
"css": "src/app/global.css", | ||
"baseColor": "zinc", | ||
"cssVariables": true, | ||
"prefix": "src" | ||
}, | ||
"aliases": { | ||
"components": "@/components", | ||
"utils": "@/lib/utils" | ||
} | ||
} |