Compare commits
No commits in common. "028e42081f8eee9a398b34ba4bea2f5a8e1c1134" and "e6eee541041cbd14007b6bab9c3c80c72df0afd3" have entirely different histories.
028e42081f
...
e6eee54104
@ -1,8 +1,3 @@
|
|||||||
## 0.0.2
|
|
||||||
* Add MIT License
|
|
||||||
|
|
||||||
## 0.0.1
|
## 0.0.1
|
||||||
|
|
||||||
* Initial release
|
* TODO: Describe initial release.
|
||||||
* Only supports Android for now. iOS support coming soon.
|
|
||||||
|
|
||||||
|
8
LICENSE
8
LICENSE
@ -1,7 +1 @@
|
|||||||
Copyright 2024 Amogh Lele
|
TODO: Add your license here.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
97
README.md
97
README.md
@ -1,16 +1,95 @@
|
|||||||
# readability
|
# readability
|
||||||
|
|
||||||
A flutter plugin that wraps the native Readability [library](https://github.com/go-shiori/go-readability) for Android and iOS.
|
A new Flutter FFI plugin project.
|
||||||
|
|
||||||
## Usage
|
## Getting Started
|
||||||
Simply call the `parseAsync` method with the URL of the article you want to parse. The method returns a `ArticleResult` object with the title, content, and excerpt of the article.
|
|
||||||
|
|
||||||
```dart
|
This project is a starting point for a Flutter
|
||||||
import 'package:readability/readability.dart';
|
[FFI plugin](https://docs.flutter.dev/development/platform-integration/c-interop),
|
||||||
|
a specialized package that includes native code directly invoked with Dart FFI.
|
||||||
|
|
||||||
final result = await Readability.parseAsync('https://example.com/article');
|
## Project structure
|
||||||
print(result.title);
|
|
||||||
print(result.content);
|
This template uses the following structure:
|
||||||
|
|
||||||
|
* `src`: Contains the native source code, and a CmakeFile.txt file for building
|
||||||
|
that source code into a dynamic library.
|
||||||
|
|
||||||
|
* `lib`: Contains the Dart code that defines the API of the plugin, and which
|
||||||
|
calls into the native code using `dart:ffi`.
|
||||||
|
|
||||||
|
* platform folders (`android`, `ios`, `windows`, etc.): Contains the build files
|
||||||
|
for building and bundling the native code library with the platform application.
|
||||||
|
|
||||||
|
## Building and bundling native code
|
||||||
|
|
||||||
|
The `pubspec.yaml` specifies FFI plugins as follows:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
plugin:
|
||||||
|
platforms:
|
||||||
|
some_platform:
|
||||||
|
ffiPlugin: true
|
||||||
```
|
```
|
||||||
|
|
||||||
An example of how to use this plugin can be found in the `example` directory.
|
This configuration invokes the native build for the various target platforms
|
||||||
|
and bundles the binaries in Flutter applications using these FFI plugins.
|
||||||
|
|
||||||
|
This can be combined with dartPluginClass, such as when FFI is used for the
|
||||||
|
implementation of one platform in a federated plugin:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
plugin:
|
||||||
|
implements: some_other_plugin
|
||||||
|
platforms:
|
||||||
|
some_platform:
|
||||||
|
dartPluginClass: SomeClass
|
||||||
|
ffiPlugin: true
|
||||||
|
```
|
||||||
|
|
||||||
|
A plugin can have both FFI and method channels:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
plugin:
|
||||||
|
platforms:
|
||||||
|
some_platform:
|
||||||
|
pluginClass: SomeName
|
||||||
|
ffiPlugin: true
|
||||||
|
```
|
||||||
|
|
||||||
|
The native build systems that are invoked by FFI (and method channel) plugins are:
|
||||||
|
|
||||||
|
* For Android: Gradle, which invokes the Android NDK for native builds.
|
||||||
|
* See the documentation in android/build.gradle.
|
||||||
|
* For iOS and MacOS: Xcode, via CocoaPods.
|
||||||
|
* See the documentation in ios/readability.podspec.
|
||||||
|
* See the documentation in macos/readability.podspec.
|
||||||
|
* For Linux and Windows: CMake.
|
||||||
|
* See the documentation in linux/CMakeLists.txt.
|
||||||
|
* See the documentation in windows/CMakeLists.txt.
|
||||||
|
|
||||||
|
## Binding to native code
|
||||||
|
|
||||||
|
To use the native code, bindings in Dart are needed.
|
||||||
|
To avoid writing these by hand, they are generated from the header file
|
||||||
|
(`src/readability.h`) by `package:ffigen`.
|
||||||
|
Regenerate the bindings by running `dart run ffigen --config ffigen.yaml`.
|
||||||
|
|
||||||
|
## Invoking native code
|
||||||
|
|
||||||
|
Very short-running native functions can be directly invoked from any isolate.
|
||||||
|
For example, see `sum` in `lib/readability.dart`.
|
||||||
|
|
||||||
|
Longer-running functions should be invoked on a helper isolate to avoid
|
||||||
|
dropping frames in Flutter applications.
|
||||||
|
For example, see `sumAsync` in `lib/readability.dart`.
|
||||||
|
|
||||||
|
## Flutter help
|
||||||
|
|
||||||
|
For help getting started with Flutter, view our
|
||||||
|
[online documentation](https://flutter.dev/docs), which offers tutorials,
|
||||||
|
samples, guidance on mobile development, and a full API reference.
|
||||||
|
|
||||||
|
The plugin project was generated without specifying the `--platforms` flag, so no platforms are currently supported.
|
||||||
|
To add platforms, run `flutter create -t plugin_ffi --platforms <platforms> .` in this directory.
|
||||||
|
You can also find a detailed instruction on how to add platforms in the `pubspec.yaml` at https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms.
|
||||||
|
16
pubspec.yaml
16
pubspec.yaml
@ -1,6 +1,6 @@
|
|||||||
name: readability
|
name: readability
|
||||||
description: "A Flutter wrapper for https://github.com/go-shiori/go-readability"
|
description: "A new Flutter FFI plugin project."
|
||||||
version: 0.0.2
|
version: 0.0.1
|
||||||
homepage: https://git.kat.directory/SphericalKat/readability-dart
|
homepage: https://git.kat.directory/SphericalKat/readability-dart
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
@ -26,9 +26,15 @@ dev_dependencies:
|
|||||||
flutter:
|
flutter:
|
||||||
plugin:
|
plugin:
|
||||||
platforms:
|
platforms:
|
||||||
|
# This FFI plugin project was generated without specifying any
|
||||||
|
# platforms with the `--platform` argument. If you see the `some_platform` map below, remove it and
|
||||||
|
# then add platforms following the instruction here:
|
||||||
|
# https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms
|
||||||
|
# -------------------
|
||||||
|
|
||||||
android:
|
android:
|
||||||
pluginClass: ReadabilityPlugin
|
pluginClass: ReadabilityPlugin
|
||||||
ffiPlugin: true
|
ffiPlugin: true
|
||||||
# ios:
|
ios:
|
||||||
# pluginClass: ReadabilityPlugin
|
pluginClass: ReadabilityPlugin
|
||||||
# ffiPlugin: true
|
ffiPlugin: true
|
||||||
|
Loading…
Reference in New Issue
Block a user