Skip to content

Commit

Permalink
Replace forum options with account settings (#1742)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalp committed Jun 12, 2024
1 parent abad4f0 commit 993b0d5
Show file tree
Hide file tree
Showing 191 changed files with 5,921 additions and 3,628 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ Preferred way to run Misago development instances on your machine is with [Docke

To start, clone the repository and run `./dev init` command in your terminal. This will build necessary docker containers, install python dependencies and initialize the database. After command does its magic, you will be able to start development server using the `docker compose up` command.

After development server starts, visit the `http://127.0.0.1:8000/` in your browser to see your Misago installation.
After development server starts, visit the <http://127.0.0.1:8000/> in your browser to see your Misago installation.

Admin Control Panel is available under the `http://127.0.0.1:8000/admincp/` address. To log in to it use `Admin` username and `password` password.
Admin Control Panel is available under the <http://127.0.0.1:8000/admincp/> address. To log in to it use `Admin` username and `password` password.

The `./dev` utility implements other features besides the `init`. Run it without any arguments to get the list of available actions.

Expand Down Expand Up @@ -106,6 +106,13 @@ To work on admin's JavaScript or CSS, `cd` to `misago-admin` and install depende
* `npm run dev`: does quick build for JavaScript and CSS assets, only bundling but not minifying. Also does a rebuild when one of the files changes.


### E-mails

Misago uses [Mailpit](https://github.com/axllent/mailpit) to capture emails sent from the development instance.

To browse those emails, visit the <http://127.0.0.1:8025> in your browser for the web interface.


Providing feedback and contributing
-----------------------------------

Expand Down
49 changes: 43 additions & 6 deletions dev-docs/menus.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ plugin_menu.add_item(
)
```

To get list of menu items to display in template, call the `get_items` method with Django's `HttpRequest` instance:
To get menu instance for displaying in a template, call the `get_items` method with Django's `HttpRequest` instance:

```python
# my_plugin.views.py
Expand All @@ -53,12 +53,12 @@ from .menu import plugin_menu

def my_view(request):
render(request, "my_plugin/template.html", {
"menu": plugin_menu.get_items(request)
"menu": plugin_menu.bind_to_request(request)
})
```


### `Menu.add_item` method
#### `Menu.add_item` method

`Menu.add_item` method adds new item to the menu. It requires following named arguments:

Expand Down Expand Up @@ -90,12 +90,49 @@ plugin_menu.add_item(
```


### `Menu.get_items` method
#### `Menu.bind_to_request` method

`Menu.get_items` requires single argument, an instance of Django's `HttpRequest`, and returns a Python `list` of all visible menu items with their URL names reversed to URLs and `label`s casted to `str`. Each list item is an instance of frozen dataclass with following attributes:
`Menu.bind_to_request` requires single argument, an instance of Django's `HttpRequest`, and returns a `BoundMenu` instance.


#### `BoundMenu.items` attribute

`BoundMenu.items` attribute contains all visible menu items with their URL names reversed to URLs and `label`s casted to `str`. Each list item is an instance of frozen dataclass with following attributes:

- `active`: a `bool` specifying if this item is currently active.
- `key`: a `str` with item's key.
- `url`: a `str` with reversed URL.
- `label`: a `str` with item's label.
- `icon`: a `str` with item's icon or `None`.
- `icon`: a `str` with item's icon or `None`.


#### `BoundMenu.active` attribute

`BoundMenu.active` attribute contains the active menu item, or `None`.


### Adding new items to existing menus

To extend an existing menu with new items, import it in your plugin's `apps.py`, in the `ready` method of it's `AppConfig`:

```python
# misago_plugin/apps.py
from django.apps import AppConfig
from misago.account import account_settings_menu


class MisagoPlugin(AppConfig):
name = "misago_plugin"

def ready(self):
account_settings_menu.add_item(...)
```

See the next section for list of available menus.


#### Standard menus

Below list contains all standard menus in Misago that plugins can extend with new items:

- `misago.account.account_settings_menu`: the "Account settings" menu.
8 changes: 6 additions & 2 deletions devproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,13 @@
]


# Set dev instance to send e-mails to console
# Set dev instance to send e-mails to the mailpit

EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "mailpit"
EMAIL_PORT = "1025"

DEFAULT_FROM_EMAIL = "Misago <misago@example.com>"


# Display debug toolbar if IN_MISAGO_DOCKER enviroment var is set to "1"
Expand Down
21 changes: 16 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This compose setup is only meant for local development of Misago itself
# This is not for running your Misago site in docker
version: "3.0"

services:
postgres:
image: postgres:15
Expand All @@ -10,9 +11,11 @@ services:
- POSTGRES_PASSWORD=misago
ports:
- '127.0.0.1:5432:5432'

redis:
image: redis:6
restart: unless-stopped

misago:
build: .
command: python manage.py runserver 0.0.0.0:8000
Expand All @@ -36,9 +39,10 @@ services:
- redis
tty: true
volumes:
# Map in the entire project into the container
# This makes sure files in the container updates on the fly as we were working locally
# Map the entire project into the container
# This makes sure files in the container update on the fly as we were working locally
- .:/app:Z

celery-worker:
build: .
command: celery -A devproject worker --loglevel=info
Expand All @@ -54,6 +58,13 @@ services:
- redis
tty: true
volumes:
# Map in the entire project into the container
# This makes sure files in the container updates on the fly as we were working locally
- .:/app:Z
# Map the entire project into the container
# This makes sure files in the container update on the fly as we were working locally
- .:/app:Z

mailpit:
image: axllent/mailpit
ports:
- 1025:1025
- 8025:8025
restart: unless-stopped
11 changes: 11 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"cropit": "^0.5.1",
"dropzone": "^4.2.0",
"history": "^2.0.2",
"htmx.org": "^1.9.12",
"jquery": "2.2.x",
"jquery-mockjax": "^2.0.1",
"jquery.caret": "^0.3.1",
Expand Down
37 changes: 37 additions & 0 deletions frontend/src/ajaxIndicator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const indicator = document.getElementById("misago-ajax-indicator")

let requests = 0
let timeout = null

function updateIndicator(visible) {
if (timeout) {
window.clearTimeout(timeout)
}

if (visible) {
indicator.classList.add("busy")
indicator.classList.remove("complete")
} else {
indicator.classList.remove("busy")
indicator.classList.add("complete")

timeout = setTimeout(() => {
indicator.classList.remove("complete")
}, 1500)
}
}

document.addEventListener("htmx:beforeSend", () => {
requests += 1
updateIndicator(requests !== 0)
})

document.addEventListener("htmx:afterOnLoad", () => {
requests -= 1
updateIndicator(requests !== 0)
})

document.addEventListener("htmx:sendError", () => {
requests -= 1
updateIndicator(requests !== 0)
})
2 changes: 1 addition & 1 deletion frontend/src/components/UserNav/UserNavMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class UserNavMenu extends React.Component {
)}
<DropdownDivider />
<DropdownSubheader className="user-nav-options">
{pgettext("user nav section", "Change options")}
{pgettext("user nav section", "Account settings")}
</DropdownSubheader>
<DropdownMenuItem>
<button
Expand Down
15 changes: 0 additions & 15 deletions frontend/src/components/options/change-username/form-loading.js

This file was deleted.

41 changes: 0 additions & 41 deletions frontend/src/components/options/change-username/form-locked.js

This file was deleted.

Loading

0 comments on commit 993b0d5

Please sign in to comment.