Skip to content

Commit f837ee6

Browse files
committed
docs: Mention monkey patching
Raising awareness.
1 parent 6d69768 commit f837ee6

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
+++
2+
title = "Monkey patching"
3+
weight = 30
4+
+++
5+
6+
selfoss will load `user.css` and `user.js` files from the root directory, if present. This allows administrator to adjust the behaviour and appearance of the web client without having to modify the source code itself. This is known as [monkey patching](https://en.wikipedia.org/wiki/Monkey_patch).
7+
8+
<div class="admonition warning">
9+
10+
## Warning
11+
12+
This feature is provided for convenience, **without any promise of backwards compatibility**. Unless explicitly documented, the structure of the HTML elements, their IDs and classes, and available JavaScript symbols can change without any notice.
13+
14+
</div>
15+
16+
## Styling {#css}
17+
18+
Paste custom CSS to `user.css`.
19+
20+
You can find various community-maintained stylesheet snippets [on the wiki](https://github.com/fossar/selfoss/wiki/#style-customizations).
21+
22+
## JavaScript API {#js}
23+
24+
Paste custom JavaScript to `user.js`.
25+
26+
### Custom sharers {#sharers}
27+
28+
You can register custom share buttons. Then, you can enable them by adding the key (`m` in the example below) to [`share` option](@/docs/administration/options.md#share).
29+
30+
```javascript
31+
selfoss.customSharers = {
32+
m: {
33+
label: "Share using Moo",
34+
icon: "🐄",
35+
action: ({ url, title }) => {
36+
const u = encodeURIComponent(url);
37+
const t = encodeURIComponent(title);
38+
window.open(`https://moo.test/share?u=${u}&t=${t}`);
39+
},
40+
},
41+
};
42+
```
43+
44+
You can use arbitrary text (e.g. emoji) or HTML as the icon. For example, `<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path fill="#613583" d="m8 4 8 8-8 8L.246 8.117Z"/></svg>` will work too (<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path fill="#613583" d="m8 4 8 8-8 8L.246 8.117Z"/></svg>).

0 commit comments

Comments
 (0)