Skip to content

Commit 6cda593

Browse files
authored
Documentation fixes (#177)
* Fix broken link on homepage * Merge instructions on running from source * Bump version number * Version bump reverted to reflect historical practice * Merged new bookmarklet section
1 parent 96d6646 commit 6cda593

File tree

3 files changed

+109
-20
lines changed

3 files changed

+109
-20
lines changed

docs/importers/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ has_children: true
77

88
# Importers
99

10-
Importers are a central feature of VocabSieve, as they enable asynchronous workflows. Importers can be accessed through the "Import" option on the menu bar. As of version 0.11, there are three importers.
10+
Importers are a central feature of VocabSieve, as they enable asynchronous workflows. Importers can be accessed through the "Import" option on the menu bar. As of version 0.11, there are three importers.

docs/index.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@ title: Home
33
layout: default
44
nav_order: 1
55
---
6+
67
# Home
78

89
Welcome to VocabSieve manual.
910

1011
## Quickstart
1112

12-
Go to [Installation]({{site.baseurl}}/installation.html) and [Configuration]({{site.baseurl}}/configuration.html)
13+
Go to [Installation]({{site.baseurl}}/installation.html) and [Configuration]({{site.baseurl}}/configuration)
1314
if you are already familiar with immersion and Anki and just want to quickly set up VocabSieve. If you already have VocabSieve set up, you may want to look at [Resources]({{site.baseurl}}/resources.html) to find dictionaries and other files to use with VocabSieve.
1415

1516
## Community support
1617

1718
You can join FreeLanguageTools chatrooms on multiple platforms. All chatrooms are bridged, so you will not miss any answers by choosing to use one over the other. Please be civil and do not post adult content.
1819

19-
| Platform | Address |
20-
| --- | ---- |
21-
| Matrix (Recommended) | [#general:freelanguagetools.org](https://matrix.to/#/#general:freelanguagetools.org) |
22-
| Telegram (*partly proprietary*) | <https://t.me/fltchat> |
23-
| Discord (*proprietary with history of anti-user behavior*) | <https://discord.gg/DNSsTtHRxz> |
20+
| Platform | Address |
21+
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------ |
22+
| Matrix (Recommended) | [#general:freelanguagetools.org](https://matrix.to/#/#general:freelanguagetools.org) |
23+
| Telegram (_partly proprietary_) | <https://t.me/fltchat> |
24+
| Discord (_proprietary with history of anti-user behavior_) | <https://discord.gg/DNSsTtHRxz> |
2425

2526
## Contributing
2627

27-
This manual is rather rudimentary as this point. You can edit it [on GitHub](https://github.com/FreeLanguageTools/vocabsieve/tree/master/docs) and submit a pull request. Alternatively you can also edit it locally and send the edited files to the chat for someone to pick it up. Unfortunately we do not have the resources needed to properly host and maintain a wiki that is impervious to spam. We apologize for the increased barrier to contributing, but this is what has to be done.
28+
This manual is rather rudimentary as this point. You can edit it [on GitHub](https://github.com/FreeLanguageTools/vocabsieve/tree/master/docs) and submit a pull request. Alternatively you can also edit it locally and send the edited files to the chat for someone to pick it up. Unfortunately we do not have the resources needed to properly host and maintain a wiki that is impervious to spam. We apologize for the increased barrier to contributing, but this is what has to be done.

docs/installation.md

Lines changed: 100 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ If you use other distributions, you should run it from an AppImage distributed o
2424
If you prefer to install it anyways, you can use `pip3 install vocabsieve` (add `-–user` if appropriate). (**Note**: Newer versions of Python will stop you from installing into your global Python environment by default. You may need to create a virtual environment). This will install a desktop file which you should be able to see from your launcher menu. If you do not use a desktop environment, you can launch it through the command line `vocabsieve`.
2525

2626
If you want to test the latest features, you can go to [CI artifacts page](https://nightly.link/FreeLanguageTools/vocabsieve/workflows/build-binaries/master) page to obtain the latest builds, but they are not guaranteed to run. If you notice anything wrong from those builds, open an issue on GitHub. Ensure you are using the latest nightly build before reporting anything.
27+
2728
</details>
2829

2930
### Windows
@@ -34,6 +35,7 @@ Go to the [Github releases page](https://github.com/FreeLanguageTools/vocabsieve
3435
<summary> Click to open instructions to download test releases </summary>
3536

3637
If you want to test the latest features, you can go to [CI artifacts page](https://nightly.link/FreeLanguageTools/vocabsieve/workflows/build-binaries/master) page to obtain the latest builds, but they are not guaranteed to run. If you notice anything wrong from those builds, open an issue on GitHub. Note: ensure you are using the latest nightly build before reporting anything.
38+
3739
</details>
3840

3941
{: .note}
@@ -53,8 +55,19 @@ Open a new terminal window and type the following command
5355
<summary> Click to open instructions to download test releases </summary>
5456

5557
If you want to test the latest features, you can go to [CI artifacts page](https://nightly.link/FreeLanguageTools/vocabsieve/workflows/build-binaries/master) page to obtain the latest builds, but they are not guaranteed to run. If you notice anything wrong from those builds, open an issue on GitHub. Note: ensure you are using the latest nightly build before reporting anything.
58+
5659
</details>
5760

61+
### Running from source (Advanced)
62+
63+
To run from source:
64+
65+
1. Set up a virtual environment `python3 -m venv env`
66+
2. `pip install -r requirements.txt`
67+
3. `python3 vocabsieve.py`
68+
69+
For debugging purposes, set the environmental variable `VOCABSIEVE_DEBUG` to any value. This will create a separate profile (settings and databases for records and dictionaries) so you may perform tests without affecting your normal profile. For each different value of `VOCABSIEVE_DEBUG`, a separate profile is generated. This can be any number or string.
70+
5871
## AnkiConnect (Required for card creation)
5972

6073
Download and install [Anki desktop](https://apps.ankiweb.net/) (Not mobile or Anki Universal). Skip if you already installed it.
@@ -64,15 +77,90 @@ Then, install the [AnkiConnect](https://ankiweb.net/shared/info/2055492159) addo
6477
{: .important }
6578
**MacOS users**: You must have Anki open on the foreground (i.e. visible on your desktop), or otherwise [disable the App Nap feature](https://github.com/FooSoft/anki-connect#notes-for-macos-users). If you do not do this, AnkiConnect will not respond and will cause this program to be very slow and/or unresponsive.
6679

67-
## Browser extension (Optional)
68-
69-
{: .note}
70-
The browser extension should work as is, but is mostly unmaintained
71-
72-
Install the extension for your browser:
73-
74-
- [Firefox](https://addons.mozilla.org/en-GB/firefox/addon/click-copy-sentence/)
75-
76-
- [Chrome/Chromium](https://chrome.google.com/webstore/detail/click-copy-sentence/klhlkoabjmofmjkhbmelmfnhkbjaohdj) (incl. derivatives such as Edge, Brave, etc.)
77-
78-
Note that if you have local ebook files to read, you can use the built-in reader too, accessible by the "Reader" button on the menu bar. When using the reader, you do not need the browser extension.
80+
## Vocabsieve bookmarklet
81+
82+
This bookmarklet allows you to copy the sentence as well as the word under cursor with one click to the word, without selecting anything (only works for languages that use space to separate words).
83+
84+
### Usage
85+
86+
Select the following code and drag it to the bookmark toolbar. Alternatively, copy the code, create a bookmark, and paste the code into the URL field in the popup window.
87+
88+
```js
89+
javascript:(function()%7Bjavascript%3A(function%20()%20%7B%0A%20%20%2F%2F%20Copy%20text%20to%20clipboard%20using%20modern%20Clipboard%20API%0A%20%20function%20copyTextToClipboard(text)%20%7B%0A%20%20%20%20navigator.clipboard.writeText(text).then(function%20()%20%7B%0A%20%20%20%20%20%20console.log('Copying%20to%20clipboard%20was%20successful!')%3B%0A%20%20%20%20%7D).catch(function%20(err)%20%7B%0A%20%20%20%20%20%20console.error('Could%20not%20copy%20text%3A%20'%2C%20err)%3B%0A%20%20%20%20%7D)%3B%0A%20%20%7D%0A%0A%20%20%2F%2F%20Add%20a%20style%20element%20for%20hover%20effects%0A%20%20const%20style%20%3D%20document.createElement('style')%3B%0A%20%20style.textContent%20%3D%20%60%0A%20%20%20%20span.sentence%3Ahover%20%7B%0A%20%20%20%20%20%20text-decoration%3A%20underline%20%236b7%20solid%203px%3B%0A%20%20%20%20%20%20text-decoration-skip-ink%3A%20none%3B%0A%20%20%20%20%7D%0A%20%20%60%3B%0A%20%20document.head.appendChild(style)%3B%0A%0A%20%20%2F%2F%20Process%20all%20paragraphs%0A%20%20document.querySelectorAll(%22p%22).forEach(function%20(paragraph)%20%7B%0A%20%20%20%20paragraph.innerHTML%20%3D%20paragraph.textContent%0A%20%20%20%20%20%20.split(%2F(%3F%3C%3D%5B%5C.%5C%3F!%5D%20)%2F)%0A%20%20%20%20%20%20.map(v%20%3D%3E%20%60%3Cspan%20class%3D%22sentence%22%3E%24%7Bv.trimEnd()%7D%3C%2Fspan%3E%60)%0A%20%20%20%20%20%20.join(%22%20%22)%3B%0A%20%20%7D)%3B%0A%0A%20%20%2F%2F%20Process%20divs%20without%20nested%20divs%0A%20%20document.querySelectorAll(%22div%22).forEach(function%20(div)%20%7B%0A%20%20%20%20if%20(!div.querySelector(%22div%22))%20%7B%0A%20%20%20%20%20%20div.innerHTML%20%3D%20div.textContent%0A%20%20%20%20%20%20%20%20.split(%2F(%3F%3C%3D%5B%5C.%5C%3F!%5D%20)%2F)%0A%20%20%20%20%20%20%20%20.map(v%20%3D%3E%20%60%3Cspan%20class%3D%22sentence%22%3E%24%7Bv.trimEnd()%7D%3C%2Fspan%3E%60)%0A%20%20%20%20%20%20%20%20.join(%22%20%22)%3B%0A%20%20%20%20%7D%0A%20%20%7D)%3B%0A%0A%20%20%2F%2F%20Add%20click%20event%20to%20span%20elements%0A%20%20document.body.addEventListener(%22click%22%2C%20function%20(event)%20%7B%0A%20%20%20%20if%20(event.target.classList.contains(%22sentence%22))%20%7B%0A%20%20%20%20%20%20let%20selection%20%3D%20window.getSelection()%3B%0A%20%20%20%20%20%20selection.modify('extend'%2C%20'backward'%2C%20'word')%3B%0A%20%20%20%20%20%20let%20a%20%3D%20selection.toString()%3B%0A%0A%20%20%20%20%20%20selection.modify('extend'%2C%20'forward'%2C%20'word')%3B%0A%20%20%20%20%20%20while%20(selection.toString().slice(-1)%20%3D%3D%3D%20%22-%22)%20%7B%0A%20%20%20%20%20%20%20%20selection.modify('extend'%2C%20'forward'%2C%20'word')%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20let%20b%20%3D%20selection.toString()%3B%0A%0A%20%20%20%20%20%20selection.modify('move'%2C%20'forward'%2C%20'character')%3B%0A%20%20%20%20%20%20let%20word%20%3D%20(a%20%2B%20b).replace(%2F%5B.%2C%5C%2F%23!%24%25%5C%5E%26%5C*%3B%3A%7B%7D%3D%5C_%E2%80%A6%60~()%5D%2Fg%2C%20%22%22).trim()%3B%0A%0A%20%20%20%20%20%20console.log(word)%3B%0A%20%20%20%20%20%20console.log(event)%3B%0A%0A%20%20%20%20%20%20let%20copyObj%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%22sentence%22%3A%20event.target.textContent.trim()%2C%0A%20%20%20%20%20%20%20%20%22word%22%3A%20word%0A%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%20%20console.log(copyObj)%3B%0A%20%20%20%20%20%20copyTextToClipboard(JSON.stringify(copyObj))%3B%0A%20%20%20%20%7D%0A%20%20%7D)%3B%0A%7D)()%3B%7D)()%3B
90+
```
91+
92+
### Source
93+
94+
The source script (a slightly modified version of the web extension script)
95+
96+
```js
97+
javascript: (function () {
98+
// Copy text to clipboard using modern Clipboard API
99+
function copyTextToClipboard(text) {
100+
navigator.clipboard
101+
.writeText(text)
102+
.then(function () {
103+
console.log("Copying to clipboard was successful!");
104+
})
105+
.catch(function (err) {
106+
console.error("Could not copy text: ", err);
107+
});
108+
}
109+
110+
// Add a style element for hover effects
111+
const style = document.createElement("style");
112+
style.textContent = `
113+
span.sentence:hover {
114+
text-decoration: underline #6b7 solid 3px;
115+
text-decoration-skip-ink: none;
116+
}
117+
`;
118+
document.head.appendChild(style);
119+
120+
// Process all paragraphs
121+
document.querySelectorAll("p").forEach(function (paragraph) {
122+
paragraph.innerHTML = paragraph.textContent
123+
.split(/(?<=[\.\?!] )/)
124+
.map((v) => `<span class="sentence">${v.trimEnd()}</span>`)
125+
.join(" ");
126+
});
127+
128+
// Process divs without nested divs
129+
document.querySelectorAll("div").forEach(function (div) {
130+
if (!div.querySelector("div")) {
131+
div.innerHTML = div.textContent
132+
.split(/(?<=[\.\?!] )/)
133+
.map((v) => `<span class="sentence">${v.trimEnd()}</span>`)
134+
.join(" ");
135+
}
136+
});
137+
138+
// Add click event to span elements
139+
document.body.addEventListener("click", function (event) {
140+
if (event.target.classList.contains("sentence")) {
141+
let selection = window.getSelection();
142+
selection.modify("extend", "backward", "word");
143+
let a = selection.toString();
144+
145+
selection.modify("extend", "forward", "word");
146+
while (selection.toString().slice(-1) === "-") {
147+
selection.modify("extend", "forward", "word");
148+
}
149+
let b = selection.toString();
150+
151+
selection.modify("move", "forward", "character");
152+
let word = (a + b).replace(/[.,\/#!$%\^&\*;:{}=\_…`~()]/g, "").trim();
153+
154+
console.log(word);
155+
console.log(event);
156+
157+
let copyObj = {
158+
sentence: event.target.textContent.trim(),
159+
word: word,
160+
};
161+
console.log(copyObj);
162+
copyTextToClipboard(JSON.stringify(copyObj));
163+
}
164+
});
165+
})();
166+
```

0 commit comments

Comments
 (0)