|
| 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 | +book (value = yes) |
| 47 | + Multivalue argument. Takes the name of books to display. |
| 48 | + |
| 49 | + Example:: |
| 50 | + |
| 51 | + <iframe src="http://192.168.18.8:8080/widget?book=wikiversity_en_all&book=bitcoin_en_all"> |
| 52 | + |
| 53 | +Custom CSS and JS |
| 54 | +----------------- |
| 55 | + |
| 56 | +You can add your custom CSS rules and Javascript code to the widget. |
| 57 | + |
| 58 | +To do that, use the following code as template:: |
| 59 | + |
| 60 | + <iframe id="receiver" src="http://192.168.18.8:8080/widget?disabledesc=&disablefilter=&disabledownload=" width="1000" height="1000"> |
| 61 | + <p>Your browser does not support iframes.</p> |
| 62 | + </iframe> |
| 63 | + |
| 64 | + <script> |
| 65 | + window.onload = function() { |
| 66 | + var receiver = document.getElementById('receiver').contentWindow; |
| 67 | + function sendMessage() { |
| 68 | + let msg = { |
| 69 | + css: ` |
| 70 | + .book__header { |
| 71 | + color:red; |
| 72 | + }`, |
| 73 | + js: ` |
| 74 | + function widgetTest() { |
| 75 | + console.log("Testing widget"); |
| 76 | + } |
| 77 | + widgetTest(); |
| 78 | + ` |
| 79 | + } |
| 80 | + receiver.postMessage(msg, 'http://192.168.18.8:8080/widget'); |
| 81 | + } |
| 82 | + sendMessage(); |
| 83 | + } |
| 84 | + </script> |
| 85 | + |
| 86 | + |
| 87 | +The CSS/JS fields are optional, you may send both or only one. |
| 88 | + |
0 commit comments