xref: /plugin/bookmark2wiki/README.md (revision 429d4b5dae3ad4b54c28929c71127bd7a84f3dbf)
1
2# bookmark2wiki
3
4A DokuWiki plugin to save bookmarks from your browser to configurable wiki pages using a bookmarklet. Forked from `post2wiki.php` by riny [at] bk [dot] ru.
5
6## Overview
7
8This plugin allows users to bookmark webpages by sending the URL, title, and optionally highlighted text to a specified DokuWiki page. The bookmark can be added either after the first heading (prepend) or at the end of the page (append), as configured in DokuWiki's Admin > Configuration. The plugin uses DokuWiki's standard functions (`rawWiki` and `saveWikiText`) to append content without direct file system access, ensuring compatibility with DokuWiki's security model.
9
10- **Version**: 1.0
11- **License**: GPL 2 (http://www.gnu.org/licenses/gpl.html)
12- **Author**: edwardcodelab (https://github.com/edwardcodelab)
13- **Todo**: Enhance input validation for security (e.g., stricter sanitization of URL, title, and text).
14
15## Features
16
17- Save bookmarks to user-defined wiki pages via a dropdown selection in a popup.
18- Configurable insertion point: after the first heading (prepend) or at the end of the page (append).
19- Supports highlighted text from the webpage, appended as part of the bookmark entry.
20- Uses DokuWiki's permission system to ensure only authorized users can edit pages.
21- Simple bookmarklet for easy browser integration.
22
23## Installation
24
251. Clone or download the repository to your DokuWiki plugin directory:
26   ```
27   /lib/plugins/bookmark2wiki/
28   ```
29   Ensure the directory contains:
30   - `action.php`
31   - `conf/default.php`
32   - `conf/metadata.php`
33   - `plugin.info.txt`
34
352. Clear DokuWiki's cache if needed
36
373. Configure the plugin:
38   - In **Admin > Configuration**, find the `bookmark2wiki` settings.
39   - Set `pages`: Enter page IDs (e.g., `new_bookmarks`, `namespace:bookmarks`) one per line.
40   - Set `position`: Choose "After Heading (prepend)" or "End of Page (append)" from the dropdown.
41
424. Create the bookmarklet:
43   - Copy the JavaScript below, replacing `https://myserver/doku.php` with your DokuWiki base URL.
44   - Drag the bookmarklet to your browser's toolbar or add it manually.
45
46   **Bookmarklet**:
47   ```javascript
48   javascript:(function(){Q=document.selection?document.selection.createRange().text:document.getSelection();void(window.open('https://myserver/doku.php?do=bookmark2wiki&te='+encodeURIComponent(Q)+'&ur='+encodeURIComponent(location.href)+'&ti='+encodeURIComponent(document.title),'dokuwikiadd','scrollbars=yes,resizable=yes,toolbar=no,width=400,height=200,left=200,top=200,status=yes'));})();
49   ```
50
51## Usage
52
531. Navigate to a webpage you want to bookmark.
542. Optionally, highlight text on the page to include in the bookmark.
553. Click the bookmarklet in your browser toolbar.
564. In the popup, select a target page from the dropdown (configured in Admin > Configuration).
575. Click "Save" to add the bookmark.
58   - If set to "After Heading (prepend)", the bookmark appears after the first heading (e.g., `====== New Articles ======`) in the page.
59   - If set to "End of Page (append)", the bookmark is added at the page's end.
606. The popup confirms the save and closes automatically after 3 seconds.
61
62**Bookmark Format**:
63```
64  * [[URL|Title]] \\ HighlightedText -- YYYY:MM:DD:HH:MM:SS
65```
66
67## Notes
68
69- **Security**: The plugin includes basic input sanitization (e.g., URL validation, HTML escaping). Further security enhancements are planned (e.g., rate limiting, stricter input checks).
70- **Permissions**: Users must be logged into DokuWiki with edit permissions for the target page. The plugin checks this using `auth_quickaclcheck`.
71- **Configuration**: Ensure pages listed in the `pages` setting exist or are editable, and verify the `position` setting in Admin > Configuration.
72- **Debugging**: If issues occur, check `conf/local.php` for correct `position` value (`'top'` or `'bottom'`) and clear cache after changes.
73
74## Troubleshooting
75
76- **Bookmarklet fails**: Ensure the URL in the bookmarklet matches your DokuWiki installation (e.g., `https://myserver/doku.php`).
77- **Wrong insertion point**: Verify the `position` setting in Admin > Configuration is set to "After Heading (prepend)" for top insertion.
78- **No pages in dropdown**: Check that `pages` in Admin > Configuration contains valid page IDs (e.g., `new_bookmarks`).
79- **Contact**: Report issues at https://github.com/edwardcodelab/bookmark2wiki.
80
81