Skip to content

Commit fc87def

Browse files
committed
Add documentation for widget
Added documentation for current widget usage, currently supported arguments, using custom CSS/JS
1 parent 09dc6f9 commit fc87def

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Welcome to libkiwix's documentation!
1212

1313
usage
1414
api/ref_api
15+
widget

docs/widget.rst

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
Kiwix serve widget
2+
====================
3+
4+
Introduction
5+
------------
6+
7+
The kiwix-serve widget provides an easy to embed way to show the `kiwix-serve` homepage.
8+
9+
Usage
10+
-----
11+
12+
To use the widget, simply add an iframe with its `src` attribute set to the `widget` endpoint.
13+
Example HTML Page ::
14+
15+
<!DOCTYPE html>
16+
<html lang="en">
17+
<head>
18+
<title>Widget Test</title>
19+
</head>
20+
<body>
21+
<iframe src="http://192.168.18.8:8080/widget?disabledesc&disablefilter&disabledownload" width=1000 height=1000></iframe>
22+
</body>
23+
</html>
24+
25+
This creates an iframe with the kiwix-serve homepage contents.
26+
27+
Arguments are explained below.
28+
29+
Possible Arguments
30+
-------------------
31+
32+
Currently, the following arguments are supported.
33+
34+
disabledesc (value = N/A)
35+
Disables the description part of a tile.
36+
37+
disablefilter (value = N/A)
38+
Disables the search filters: language, category, tag and search function.
39+
40+
disableclick (value = N/A)
41+
Disables clicking the book to open it for reading.
42+
43+
disabledownload (value = N/A)
44+
Disables the download button (if avaialable at all) on the tile.
45+
46+
47+
Custom CSS and JS
48+
-----------------
49+
50+
You can add your custom CSS rules and Javascript code to the widget.
51+
52+
To do that, use the following code as template::
53+
54+
<iframe id="receiver" src="http://192.168.18.8:8080/widget?disabledesc=&disablefilter=&disabledownload=" width="1000" height="1000">
55+
<p>Your browser does not support iframes.</p>
56+
</iframe>
57+
58+
<script>
59+
window.onload = function() {
60+
var receiver = document.getElementById('receiver').contentWindow;
61+
function sendMessage() {
62+
let msg = {
63+
css: `
64+
.book__header {
65+
color:red;
66+
}`,
67+
js: `
68+
function widgetTest() {
69+
console.log("Testing widget");
70+
}
71+
widgetTest();
72+
`
73+
}
74+
receiver.postMessage(msg, 'http://192.168.18.8:8080/widget');
75+
}
76+
sendMessage();
77+
}
78+
</script>
79+
80+
81+
The CSS/JS fields are optional, you may send both or only one.
82+

0 commit comments

Comments
 (0)