Skip to content

Commit

Permalink
Merge pull request #66 from kiwix/Issue#65
Browse files Browse the repository at this point in the history
Updated `README.md` file to demonstrate how devs can use generated binaries in their project.
  • Loading branch information
kelson42 authored Aug 27, 2023
2 parents 574fc63 + ee1f2b4 commit f9dc43e
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,43 @@ Library for accessing [libkiwix](https://github.com/kiwix/libkiwix) and [libzim]

AAR file will be generated in directory `lib/build/outputs/aar`

### Load zim file
### Use the library in your project

First, locate the compiled/generated `lib-debug.aar` in the
`lib/build/outputs/aar` directory. Then open your project's Gradle
configuration file and import the .aar file as a dependency.

If you are using Kotlin for your Gradle file, add the following code snippet:

```kotlin
dependencies {
implementation(files("path-of-aar-file/lib-debug.aar"))
}
```

If you are using Groovy for your Gradle file, use this code snippet:

```kotlin
dependencies {
implementation files("path-to-your-aar-file/lib-debug.aar")
}
```

### Load ZIM file

To load a ZIM file you need to create an `Archive` object.

```kotlin
val archive = Archive("your-file-path")
```

### Load main page
### Load ZIM main page

The `mainPage` property is used to retrieve the path of the main entry page for a Kiwix content archive.
If the main entry is a redirect, it will fetch the path of the redirected item;
otherwise, it will return the path of the main entry itself.
If the main entry is not found, the archive will throw an `EntryNotFoundException`.
The `mainPage` property is used to retrieve the path of the main entry
page for a Kiwix content archive. If the main entry is a redirect, it
will fetch the path of the redirected item; otherwise, it will return
the path of the main entry itself. If the main entry is not found,
the archive will throw an `EntryNotFoundException`.

```kotlin
val mainPage: String?
Expand All @@ -53,7 +76,7 @@ val mainPage: String?
}
```

### Load an article via title
### Load a ZIM article via title

```kotlin
try {
Expand All @@ -67,7 +90,7 @@ val mainPage: String?
}
```

### Load an Article via Path
### Load a ZIM article via path

Ensure that the URL path is properly decode before passing it to `hasEntryByPath`,
as `Libzim` does not support encoded URLs.
Expand Down

0 comments on commit f9dc43e

Please sign in to comment.