Skip to content

Commit 1ce36e8

Browse files
Fix the textarea id to search for
... and added a bit more text to the README.
1 parent b84a648 commit 1ce36e8

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,35 @@
11
![Logo](post-local-storage-logo-smaller.png)
22
# post-local-storage
3+
## Locally store the content of a post in the phpBB forum software
34

4-
A very simple phpBB3 extension to locally store the content of a post being written, to avoid losing everything after a crash or session expiration.
5+
A very simple [phpBB3](https://www.phpbb.com/) extension to use the browser's local storage for preventing the content of a post to be lost after a crash or session expiration.
6+
7+
## Reasoning
8+
9+
You know how it is. You've taken four hours to write your latest masterpiece to show off to the world on a phpBB forum. You press <kbd>Submit</kbd> and... well, your session had expired, so _everything is lost_. Irretrievably so. Pressing 'back' on the browser will not help. What to do?... well, nothing, really.
10+
11+
You're used to WYSIWYG editors, where such things _never_ happen in the 2020s, so naturally enough you didn't save a copy _before_ you posted the article. But, alas, there is no official WYSIWYG editor in phpBB, for various reasons.
12+
13+
Why, oh why, didn't phpBB save your data?
14+
15+
Well, there is the 'Draft' facility, but that doesn't work as well as it should. Unless you have an extension for that, by default, forum users have to _manually_ press <kbd>Save Draft</kbd> — and it will mean that some things (such as attachments) will be lost anyway. Drafts are also stored on the phpBB database, on the backend, so if something goes wrong with your connection and/or the database connection... you'll lose your draft as well.
16+
17+
This extension tries to replicate the most basic solution to the above issues. It uses your browser's local storage facility, which can be accessed using JavaScript. Although details differ between browsers, in general, each will persist the data across crashes. It should also be able to deal with most issues of lost typed content on posts as well as on Private Messages (PMs). However, the current version will not be able to
18+
19+
## Installation
20+
21+
If you're reading this on GitHub, then all you need is to either download the last package (on the left) and unzip it to the `ext` directory under the root of your phpBB3 installation.
22+
23+
Alternatively, you can always grab the latest version with `git clone https://github.com/GwynethLlewelyn/post-local-storage`. The plugin itself is inside `gwynethllewelyn/postlocalstorage`. These are the files to upload to your phpBB installation (you'll probably need to create all directories first, e.g. under `ext`, create `gwynethllewelyn/postlocalstorage`).
24+
25+
Then go to the **ACP** > **Extensions**, on the sidebar: **Extension Management** | **Manage extensions** and activate **Locally store the content of a post**.
26+
27+
There is no further configuration required.
28+
29+
## Acknowledgements
30+
31+
Many thanks to
32+
[@Tread](https://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=1973496) and [@cabot](https://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=1337922) for gently 'persuading' me to publish this code as a phpBB3.3 extension, by pointing me to all the appropriate bits and pieces of code to be 'assembled' into an extension. Yay!
533

634
Logo designed by [DALL·E 2](https://openai.com/product/dall-e-2).
735

gwynethllewelyn/postlocalstorage/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"authors": [
1414
{
15-
"name": "gwynethllewelyn",
15+
"name": "Gwyneth Llewelyn",
1616
"email": "[email protected]",
1717
"homepage": "https://gwynethllewelyn.net",
1818
"role": "Overall Coordination"

gwynethllewelyn/postlocalstorage/styles/prosilver/template/custom_functions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(function (message, doc) {
2-
// Cut the mustard.
2+
// If there is no localStorage support, give up
33
if (!message.localStorage) return;
4-
// You should probably use a more specific selector than this.
5-
var textarea = doc.querySelector("textarea");
4+
// phpBB3 uses a textarea with id and class 'message'
5+
var textarea = doc.querySelector("textarea.message");
66
// The key for the key/value pair in localStorage is the current URL.
77
var key = message.location.href;
88
var item = null;

0 commit comments

Comments
 (0)