Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
8e81842
gen code
julien-gautier-munic Mar 8, 2023
ec9c833
Import BookMetadataFinder rust code and basic UI
julien-gautier-munic Mar 9, 2023
d57e930
Rework cache so it works with flutter run
julien-gautier-munic Mar 9, 2023
50c362d
Better UI, display images
julien-gautier-munic Mar 9, 2023
87973a0
Publish ad with images, simplify GoogleBooks, show better error for c…
julien-gautier-munic Mar 9, 2023
abd20ee
clean
julien-gautier-munic Mar 9, 2023
cbc2551
WIP drag and drop
julien-gautier-munic Mar 10, 2023
2103ece
drop clean
julien-gautier-munic Mar 10, 2023
c1a6ddb
Drag and Drop works
julien-gautier-munic Mar 10, 2023
785d486
Make babelio more resistant to no blurb
julien-gautier-munic Mar 11, 2023
5d483dd
Undo part of commit 50c362d, which oversimplified GoogleBooks
julien-gautier-munic Mar 11, 2023
c59fdc7
Add GoogleBook comment
julien-gautier-munic Mar 11, 2023
1105a53
Babelio return None instead of panic if there is no book itemscope
julien-gautier-munic Mar 12, 2023
3360a4d
GoogleBooks better handle no matche for isbn
julien-gautier-munic Mar 12, 2023
b1f0cf1
Big refacto
julien-gautier-munic Mar 15, 2023
6999e83
compile
julien-gautier-munic Mar 15, 2023
eb099d0
Add isbn decoder
julien-gautier-munic Mar 15, 2023
dcd3aaa
show basic metadatacollecting
julien-gautier-munic Mar 15, 2023
c53ef46
Use gridview for MetadataCollectingStep
julien-gautier-munic Mar 15, 2023
3ed60c5
SelectableText non scroll grid view
julien-gautier-munic Mar 15, 2023
a99a42c
Use Table instead of GridView
julien-gautier-munic Mar 16, 2023
e8390e4
Mock Step2
julien-gautier-munic Mar 16, 2023
d02b912
Add FutureWidget
julien-gautier-munic Mar 16, 2023
70704a4
Going to AdEditing works
julien-gautier-munic Mar 16, 2023
a22da44
Remove Windows, macos and ios target
julien-gautier-munic Mar 16, 2023
40052c7
Small adjustment in justfile
julien-gautier-munic Mar 16, 2023
ba4f122
AdEditing: Fix scrolling, add check before enabling publishing
julien-gautier-munic Mar 16, 2023
cbba5a4
Fix lint
julien-gautier-munic Mar 17, 2023
1c3e2f8
Clean and use book title as ad title if only one book
julien-gautier-munic Mar 17, 2023
557e97e
Clean
julien-gautier-munic Mar 17, 2023
e8d6ea1
Better description if one book
julien-gautier-munic Mar 17, 2023
b732991
publish_ad return bool
julien-gautier-munic Mar 17, 2023
8e351c5
Better handle BookMD = null, add begining of test when desc is better…
julien-gautier-munic Mar 17, 2023
cbe554d
Convert title to Option, Add GB.extract_metadata_from_isbn_response a…
julien-gautier-munic Mar 19, 2023
26421ad
Rust: GB: remove all field not useful
julien-gautier-munic Mar 19, 2023
3b6e135
Babelio handle authors with only last name
julien-gautier-munic Mar 22, 2023
22fa294
All test pass without internet. GB with mock folder, Babelio with cache
julien-gautier-munic Mar 22, 2023
5750c5f
Move credential to dart
julien-gautier-munic Mar 23, 2023
d9cb49b
MetadataCollectingWidget: Add deep copy to fix bug where manual blurb…
julien-gautier-munic Mar 23, 2023
5f9cc9d
MetadataCollectingWidget: add controller and SelectableTextAndUse for…
julien-gautier-munic Mar 23, 2023
aaffa87
Replace title from provider if better
julien-gautier-munic Mar 24, 2023
40c1130
Replace blurb from provider if better
julien-gautier-munic Mar 24, 2023
ed5096a
Store LBC credential in credential.json
julien-gautier-munic Mar 24, 2023
5a8583f
Add jwt token validator
julien-gautier-munic Mar 25, 2023
dca23c1
Add bookprices with basic example of Selenium
julien-gautier-munic Mar 27, 2023
2c95d48
WIP Selenium offline test work
julien-gautier-munic Mar 29, 2023
398cac9
WIP
julien-gautier-munic Mar 29, 2023
3098a29
Parse booksPrice works
julien-gautier-munic Apr 1, 2023
ad31bd2
clean
julien-gautier-munic Apr 1, 2023
cee744c
Extract selenium POC into useful function
julien-gautier-munic Apr 3, 2023
40b2e48
Add market price and add BooksPrice provider
julien-gautier-munic Apr 3, 2023
82593b0
Run rust codegen
julien-gautier-munic Apr 3, 2023
3884605
Rename BookMetaData to BookMetaDataFromProvider
julien-gautier-munic Apr 4, 2023
54790b4
Adaot flutter
julien-gautier-munic Apr 4, 2023
624eca7
BooksPrice: remove assert, add wait_until
julien-gautier-munic Apr 4, 2023
4719031
Price works
julien-gautier-munic Apr 10, 2023
6a8a8b0
Convert html encoded text to String
julien-gautier-munic Apr 12, 2023
f7c39e1
ISBNDeconding: use Wrap
julien-gautier-munic Apr 12, 2023
c3869d0
Select bundle from phone
julien-gautier-munic Apr 18, 2023
5975106
Add drag and drop images
julien-gautier-munic Apr 18, 2023
f32ebfc
Remove LBC tokenm cookie and publish button
julien-gautier-munic Apr 18, 2023
b8340b2
Add state and weight in AdEditing
julien-gautier-munic Apr 18, 2023
ec4cc4e
Add copy button for text field
julien-gautier-munic Apr 18, 2023
1cf3257
Remove unused credentials
julien-gautier-munic Apr 18, 2023
a6bd4ab
Fix Authors not taken into account in AdEditing step. Better hanle Au…
julien-gautier-munic Apr 18, 2023
cf4be4a
BundleSelection: sort images by date, antialiase
julien-gautier-munic Apr 19, 2023
35010be
AdEditing: images are draggable, add "Mark as Publish" button
julien-gautier-munic Apr 19, 2023
87513e4
Come back to BundleSelection after publish
julien-gautier-munic Apr 19, 2023
9861383
Fix ISBN decoding split on new line
julien-gautier-munic Apr 19, 2023
e2ca448
Move 4 steps into enrichment/
julien-gautier-munic Apr 27, 2023
08a0e30
Merge Camera_app. Compile on Android
julien-gautier-munic Apr 27, 2023
6751dcf
Camera: initialize _camera list
julien-gautier-munic Apr 27, 2023
707373a
Add storage permission to write metadata.json
julien-gautier-munic Apr 28, 2023
f342949
Better explorer, use Card
julien-gautier-munic Apr 28, 2023
c2a009a
Better ISBNDecoding ui
julien-gautier-munic Apr 28, 2023
7fd9a64
BundleSelection: delete button move to booky_deleted
julien-gautier-munic Apr 28, 2023
bb1fd7f
Bundle Selection: Better message if no device connected
julien-gautier-munic Apr 28, 2023
7defe21
ISBNDecding: Add AppBar and back button
julien-gautier-munic Apr 28, 2023
a992c39
Add README
julien-gautier-munic Apr 30, 2023
b1501df
Add TODO
julien-gautier-munic Apr 30, 2023
f2dce6f
Update scraper requirement from 0.14.0 to 0.16.0 in /native
dependabot[bot] Apr 30, 2023
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
.pub/
/build/

personal_info.*
credential.json

# Web related

# Symbolication related
Expand Down
136 changes: 86 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,97 @@
# flutter_rust_bridge_template
# Booky

This repository serves as a template for Flutter projects calling into native Rust
libraries via `flutter_rust_bridge`.
Booky is an application to help publish second-hand book.
It enable taking multiple picture of the book(s). Add books state (brand new, worn out), add the weight (for shipping), then extract the ISBN from the barcode in the pictures to have additional metadata by scrapping some website.

## Getting Started
Metadata include:
- Title
- Author
- Blurb. A book blurb is a short promotional description, whereas a synopsis summarizes the twists, turns, and conclusion of the story.
- Keywords or genres

To begin, ensure that you have a working installation of the following items:
- [Flutter SDK](https://docs.flutter.dev/get-started/install)
- [Rust language](https://rustup.rs/)
- `flutter_rust_bridge_codegen` [cargo package](https://cjycode.com/flutter_rust_bridge/integrate/deps.html#build-time-dependencies)
- Appropriate [Rust targets](https://rust-lang.github.io/rustup/cross-compilation.html) for cross-compiling to your device
- For Android targets:
- Install [cargo-ndk](https://github.com/bbqsrc/cargo-ndk#installing)
- Install [Android NDK 22](https://github.com/android/ndk/wiki/Unsupported-Downloads#r22b), then put its path in one of the `gradle.properties`, e.g.:
## Enrichment
### Example using Babelio as source
#### Input

```rust
let isbn = 9782266071529;
```
echo "ANDROID_NDK=.." >> ~/.gradle/gradle.properties
```

- For iOS targets:
- Install [cargo-xcode](https://gitlab.com/kornelski/cargo-xcode#installation)
- [Web dependencies](http://cjycode.com/flutter_rust_bridge/template/setup_web.html) for the Web

Then go ahead and run `flutter run` (for web, run `dart run flutter_rust_bridge:serve` instead). When you're ready, refer to our documentation
[here](https://fzyzcjy.github.io/flutter_rust_bridge/index.html) to learn how to write and use binding code.

Once you have edited `api.rs` to incorporate your own Rust code, the bridge files `bridge_definitions.dart` and `bridge_generated.dart` are generated using the following command (note: append ` --wasm` to add web support):

### Windows
```
flutter_rust_bridge_codegen --rust-input native\src\api.rs --dart-output .\lib\bridge_generated.dart --dart-decl-output .\lib\bridge_definitions.dart
#### Output
```rust
BookMetaData {
title: "Le nom de la bête",
author: {
surname: "Daniel",
name: "Easterman",
},
blurb: "Janvier 1999. Peu à peu, les pays arabes ont sombré dans l'intégrisme. Les attentats terroristes se multiplient en Europe attisant la haine et le racisme. Au Caire, un coup d'état fomenté par les fondamentalistes permet à leur chef Al-Kourtoubi de s'installer au pouvoir et d'instaurer la terreur. Le réseau des agents secrets britanniques en Égypte ayant été anéanti, Michael Hunt est obligé de reprendre du service pour enquêter sur place. Aidé par son frère Paul, prêtre catholique et agent du Vatican, il apprend que le Pape doit se rendre à Jérusalem pour participer à une conférence œcuménique. Au courant de ce projet, le chef des fondamentalistes a prévu d'enlever le saint père.Dans ce récit efficace et à l'action soutenue, le héros lutte presque seul contre des groupes fanatiques puissants et sans grand espoir de réussir. Comme dans tous ses autres livres, Daniel Easterman, spécialiste de l'islam, part du constat que le Mal est puissant et il dénonce l'intolérance et les nationalismes qui engendrent violence et chaos.--Claude Mesplède<br>\t\t",
key_words: [
"roman", "fantastique", "policier historique", "romans policiers et polars", "thriller", "terreur", "action", "démocratie", "mystique", "islam", "intégrisme religieux", "catholicisme", "religion", "terrorisme", "extrémisme", "egypte", "médias", "thriller religieux", "littérature irlandaise", "irlande"
],
}
```

### Linux/MacOS/any other Unix
```
flutter_rust_bridge_codegen --rust-input native/src/api.rs --dart-output ./lib/bridge_generated.dart --dart-decl-output ./lib/bridge_definitions.dart
### Sources

| Source | Metadata (in addition to title and authors) | Notes |
|-------------------------------------------------------|---------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Babelio](https://www.babelio.com/) | blurb, keyword | No API available. No plan to build one.<br/>Babelio seem to block the IP if it detect this bot is doing some scrapping |
| [Decitre](https://www.decitre.fr/) | blurb, keywords in commentaries | |
| [GoodReads](https://www.goodreads.com/) | blurb, genres in english | An API was available, but GoodRead does not create new developer key. [See this](https://help.goodreads.com/s/article/Does-Goodreads-support-the-use-of-APIs) |
| [Google Books](https://www.google.fr/books/) | blurb, genres | [A real API](https://developers.google.com/books/docs/overview) is available to look up a book by ISBN <br/> Some book can't be search by ISBN, even though a search by title can find them, and they display the right ISBN |
| [ISBSearcher](https://www.isbnsearcher.com/) | blurb, main category in english | |
| [Label Emmaus](https://www.label-emmaus.co/) | blurb, genres | |
| [OpenLibrary](https://openlibrary.org/) | blurb are not translated | Its is based on physical books, it is not really a book database |
| [Chasse Aux Livre](https://www.chasse-aux-livres.fr/) | price only | it is not possible to parse with Selenium |
| [AbeBooks](https://www.abebooks.fr/) | Seems to have good french blurb | |

#### GoogleBooks
GoogleBooks has some inconsistencies:
https://www.googleapis.com/books/v1/volumes?q=isbn:9782744170812
says te publishedDate is 2004.
But https://www.googleapis.com/books/v1/volumes/DQUFSQAACAAJ
says the publishedDate is 2005.

In the first response, we don't have a publisher, in the second we have.
In the first response, the title use a big C for "Cité", but in the second, it use a small 'c'

## Contributing
### Build the barcode detector binary
Clone the 3 OpenCV repo:
- https://github.com/opencv/opencv.git (main repo)
- https://github.com/opencv/opencv_contrib.git (contain the barcode contrib module)
- https://github.com/opencv/opencv_extra.git (optionnal, contain the test data to test OpenCV)

```shell
$ cd <open_cv>/
$ mkdir build
$ cd build/
build/ $ cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules ..
```

## Scaffolding in existing projects

If you would like to generate boilerplate for using `flutter_rust_bridge` in your existing projects,
check out the [`flutter_rust_bridge` brick](https://brickhub.dev/bricks/flutter_rust_bridge/)
for more details.

## Disclaimer

This template is not affiliated with flutter_rust_bridge. Please file issues and PRs related to the template here,
not flutter_rust_bridge.

## License

Copyright 2022 Viet Dinh.

This template is licensed under either of
- [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) ([LICENSE-APACHE](LICENSE-APACHE))
- [MIT license](https://opensource.org/licenses/MIT) ([LICENSE-MIT](LICENSE-MIT))

at your option.
You can test the barcode module with:
```shell
build/ $ make opencv_test_barcode
build/ $ OPENCV_TEST_DATA_PATH=<opencv_extra>/testdata/ bin/opencv_test_barcode
```

The [SPDX](https://spdx.dev/) license identifier for this project is `MIT OR Apache-2.0`.
### Install the rust/android toolchain
#### flutter_rust_bridge_template
Follow the instruction of flutter_rust_bridge_template. Here is an extract

> To begin, ensure that you have a working installation of the following items:
> - [Flutter SDK](https://docs.flutter.dev/get-started/install)
> - [Rust language](https://rustup.rs/)
> - `flutter_rust_bridge_codegen` [cargo package](https://cjycode.com/flutter_rust_bridge/integrate/deps.html#build-time-dependencies)
> - Appropriate [Rust targets](https://rust-lang.github.io/rustup/cross-compilation.html) for cross-compiling to your device
> - For Android targets:
> - Install [cargo-ndk](https://github.com/bbqsrc/cargo-ndk#installing)
> - Install [Android NDK 22](https://github.com/android/ndk/wiki/Unsupported-Downloads#r22b), then put its path in one of the `gradle.properties`, e.g.:
>
> ```
> echo "ANDROID_NDK=.." >> ~/.gradle/gradle.properties
> ```

#### super_native_extension
Follow this tutorial: https://pub.dev/packages/super_clipboard
7 changes: 7 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# TODO

* [ ] Grab the ISBN in real-time with ML Kit
* [ ] Search with Selenium in headless mode
* [ ] Price auto fill
* [ ] Compress the images to upload them quicker
* [ ] Launch the scrapping asynchronously to avoid waiting for the provider (notably BooksPrice)
40 changes: 15 additions & 25 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
use_key_in_widget_constructors: false
avoid_print: false
prefer_single_quotes: true
prefer_interpolation_to_compose_strings: false
prefer_is_empty: false
avoid_function_literals_in_foreach_calls: false
analyzer:
enable-experiment:
- records
- patterns
- sealed-class
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
ndkVersion "25.2.9519653"

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -47,7 +47,7 @@ android {
applicationId "com.example.flutter_rust_bridge_template"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
minSdkVersion 23
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
3 changes: 2 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flutter_rust_bridge_template">
<application
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<application
android:label="flutter_rust_bridge_template"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
Expand Down
1 change: 1 addition & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
ANDROID_NDK=/home/julien/Android/Sdk/ndk/
34 changes: 0 additions & 34 deletions ios/.gitignore

This file was deleted.

26 changes: 0 additions & 26 deletions ios/Flutter/AppFrameworkInfo.plist

This file was deleted.

1 change: 0 additions & 1 deletion ios/Flutter/Debug.xcconfig

This file was deleted.

1 change: 0 additions & 1 deletion ios/Flutter/Release.xcconfig

This file was deleted.

Loading