Skip to content

Commit

Permalink
Merge branch 'mealie-next' into fix/use-utc-for-all-timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
boc-the-git authored Jul 8, 2024
2 parents 2694742 + 17f9eef commit 2b87033
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 29 deletions.
24 changes: 12 additions & 12 deletions docs/docs/documentation/getting-started/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

## How do I enable "smart" ingredient handling?

You might have noticed that scaling up a recipe or making a shopping list doesn't by default handle the ingredients in a way you might expect. Depending on your settings, scaling up might yield things like `2 1 cup broth` instead of `2 cup broth`. And making shopping lists from reciepes that have shared ingredients can yield multiple lines of the same ingredient. **But**, mealie has a mechanism to intelligently handle ingredients and make your day better. How?
You might have noticed that scaling up a recipe or making a shopping list doesn't by default handle the ingredients in a way you might expect. Depending on your settings, scaling up might yield things like `2 1 cup broth` instead of `2 cup broth`. And, making shopping lists from recipes that have shared ingredients can yield multiple lines of the same ingredient. **But**, Mealie has a mechanism to intelligently handle ingredients and make your day better. How?
### Set up your Foods and Units
Do the following just **once**. Doing this applies to your whole group, so be careful.

1. Click on your name in the upper left corner to get to your settings
2. In the bottom right, select `Manage Data`
3. In the Management page, make sure that a little orange button says `Foods`
4. If your Foods database is empty, click `Seed` and choose your language. You should end up with a list of foods. (Wait bit for seeding to happen, and try not to seed more than once or you will have duplicates)
4. If your Foods database is empty, click `Seed` and choose your language. You should end up with a list of foods. (Wait a bit for seeding to happen, and try not to seed more than once or you will have duplicates)
5. Click the little orange `Foods` button and now choose `Units`.
6. Click `Seed` and choose your language. You should end up with a list of units (e.g. `tablespoon`)

Expand All @@ -33,9 +33,9 @@ Do the following for each recipe you want to intelligently handle ingredients.

Scaling up this recipe or adding it to a Shopping List will now smartly take care of ingredient amounts and duplicate combinations.

## Is it Safe to Upgrade Mealie?
## Is it safe to upgrade Mealie?

Yes. If you are using the v1 branches (including beta), you can upgrade to the latest version of Mealie without performing a site Export/Restore. This process was required in previous versions of Mealie, however we've automated the database migration process to make it easier to upgrade. Not that if you were using the v0.5.x version, you CANNOT upgrade to the latest version automatically. You must follow the migration instructions in the documentation.
Yes. If you are using the v1 branches (including beta), you can upgrade to the latest version of Mealie without performing a site Export/Restore. This process was required in previous versions of Mealie, however we've automated the database migration process to make it easier to upgrade. Note that if you were using the v0.5.x version, you CANNOT upgrade to the latest version automatically. You must follow the migration instructions in the documentation.

- [Migration From v0.5.x](./migrating-to-mealie-v1.md)

Expand All @@ -45,15 +45,15 @@ You can change the theme by settings the environment variables.

- [Backend Config - Themeing](./installation/backend-config.md#themeing)

## How can I change the Login Session Timeout?
## How can I change the login session timeout?

Login session can be configured by setting the `TOKEN_TIME` variable on the backend container.

- [Backend Config](./installation/backend-config.md)

## Can I serve Mealie on a subpath?

No. Due to limitations from the Javascript Framework, mealie doesn't support serving Mealie on a subpath.
No. Due to limitations from the JavaScript Framework, Mealie doesn't support serving Mealie on a subpath.

## Can I install Mealie without docker?

Expand Down Expand Up @@ -130,20 +130,20 @@ stateDiagram-v2

For more information, check out the [Permissions and Public Access guide](./usage/permissions-and-public-access.md).

## Can I use fail2ban with mealie?
Yes, mealie is configured to properly forward external IP addresses into the `mealie.log` logfile. Note that due to restrictions in docker, IP address forwarding only works on Linux.
## Can I use fail2ban with Mealie?
Yes, Mealie is configured to properly forward external IP addresses into the `mealie.log` logfile. Note that due to restrictions in docker, IP address forwarding only works on Linux.

Your fail2ban usage should look like the following:
```
Use datepattern : %d-%b-%y %H:%M:%S : Day-MON-Year2 24hour:Minute:Second
Use failregex line : ^ERROR:\s+Incorrect username or password from <HOST>
```

## Why An API?
An API allows integration into applications like [Home Assistant](https://www.home-assistant.io/) that can act as notification engines to provide custom notifications based on Meal Plan data to remind you to defrost the chicken, marinade the steak, or start the CrockPot. Additionally, you can access nearly any backend service via the API giving you total control to extend the application. To explore the API spin up your server and navigate to http://yourserver.com/docs for interactive API documentation.
## Why an API?
An API allows integration into applications like [Home Assistant](https://www.home-assistant.io/) that can act as notification engines to provide custom notifications based on Meal Plan data to remind you to defrost the chicken, marinate the steak, or start the CrockPot. Additionally, you can access nearly any backend service via the API giving you total control to extend the application. To explore the API spin up your server and navigate to http://yourserver.com/docs for interactive API documentation.

## Why a Database?
Some users of static-site generator applications like ChowDown have expressed concerns about their data being stuck in a database. Considering this is a new project, it is a valid concern to be worried about your data. Mealie specifically addresses this concern by provided automatic daily backups that export your data in json, plain-text markdown files, and/or custom Jinja2 templates. **This puts you in control of how your data is represented** when exported from Mealie, which means you can easily migrate to any other service provided Mealie doesn't work for you.
## Why a database?
Some users of static-site generator applications like ChowDown have expressed concerns about their data being stuck in a database. Considering this is a new project, it is a valid concern to be worried about your data. Mealie specifically addresses this concern by providing automatic daily backups that export your data in json, plain-text markdown files, and/or custom Jinja2 templates. **This puts you in control of how your data is represented** when exported from Mealie, which means you can easily migrate to any other service provided Mealie doesn't work for you.

As to why we need a database?

Expand Down
11 changes: 3 additions & 8 deletions mealie/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,24 @@

settings = get_app_settings()

description = f"""
description = """
Mealie is a web application for managing your recipes, meal plans, and shopping lists. This is the Restful
API interactive documentation that can be used to explore the API. If you're justing getting started with
the API and want to get started quickly, you can use the
[API Usage | Mealie Docs](https://nightly.mealie.io/documentation/getting-started/api-usage/)
[API Usage | Mealie Docs](https://docs.mealie.io/documentation/getting-started/api-usage/)
as a reference for how to get started.
As of this release <b>{APP_VERSION}</b>, Mealie is still in rapid development and therefore some of these APIs may
change from version to version.
If you have any questions or comments about mealie, please use the discord server to talk to the developers or other
community members. If you'd like to file an issue, please use the
[GitHub Issue Tracker | Mealie](https://github.com/mealie-recipes/mealie/issues/new/choose)
## Helpful Links
- [Home Page](https://mealie.io)
- [Documentation](https://nightly.mealie.io)
- [Documentation](https://docs.mealie.io)
- [Discord](https://discord.gg/QuStdQGSGK)
- [Demo](https://demo.mealie.io)
- [Beta](https://demo.mealie.io)
"""

logger = get_logger()
Expand Down
2 changes: 1 addition & 1 deletion mealie/routes/_base/base_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class BaseCrudController(BaseUserController):
Base class for all CRUD controllers to facilitate common CRUD functions.
"""

event_bus: EventBusService = Depends(EventBusService.create)
event_bus: EventBusService = Depends(EventBusService.as_dependency)

def publish_event(self, event_type: EventTypes, document_data: EventDocumentDataBase, message: str = "") -> None:
self.event_bus.dispatch(
Expand Down
2 changes: 1 addition & 1 deletion mealie/routes/admin/admin_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from mealie.schema.analytics.analytics import MealieAnalytics
from mealie.services.analytics.service_analytics import AnalyticsService

router = APIRouter(prefix="/analytics")
router = APIRouter(prefix="/analytics", include_in_schema=False) # deprecated - use statistics route instead


@controller(router)
Expand Down
2 changes: 1 addition & 1 deletion mealie/routes/groups/controller_group_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

@controller(router)
class GroupEventsNotifierController(BaseUserController):
event_bus: EventBusService = Depends(EventBusService.create)
event_bus: EventBusService = Depends(EventBusService.as_dependency)

@cached_property
def repo(self):
Expand Down
4 changes: 2 additions & 2 deletions mealie/routes/spa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,6 @@ def mount_spa(app: FastAPI):
global __contents
__contents = pathlib.Path(__app_settings.STATIC_FILES).joinpath("index.html").read_text()

app.get("/g/{group_slug}/r/{recipe_slug}")(serve_recipe_with_meta)
app.get("/g/{group_slug}/shared/r/{token_id}")(serve_shared_recipe_with_meta)
app.get("/g/{group_slug}/r/{recipe_slug}", include_in_schema=False)(serve_recipe_with_meta)
app.get("/g/{group_slug}/shared/r/{token_id}", include_in_schema=False)(serve_shared_recipe_with_meta)
app.mount("/", SPAStaticFiles(directory=__app_settings.STATIC_FILES, html=True), name="spa")
2 changes: 1 addition & 1 deletion mealie/routes/users/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@controller(router)
class RegistrationController(BasePublicController):
event_bus: EventBusService = Depends(EventBusService.create)
event_bus: EventBusService = Depends(EventBusService.as_dependency)

@router.post("", response_model=UserOut, status_code=status.HTTP_201_CREATED)
def register_new_user(self, data: CreateUserRegistration):
Expand Down
2 changes: 1 addition & 1 deletion mealie/routes/validators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

router = APIRouter()

router.include_router(validators.router, prefix=prefix, tags=["Validators"])
router.include_router(validators.router, prefix=prefix, tags=["Validators"], include_in_schema=False)
10 changes: 8 additions & 2 deletions mealie/services/event_bus_service/event_bus_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fastapi import BackgroundTasks, Depends
from fastapi import BackgroundTasks, Depends, Query
from pydantic import UUID4
from sqlalchemy.orm.session import Session

Expand Down Expand Up @@ -84,5 +84,11 @@ def publish_event(self, event: Event) -> None:
listener.publish_to_subscribers(event, subscribers)

@classmethod
def create(cls, bg: BackgroundTasks, session=Depends(generate_session), group_id: UUID4 | None = None):
def as_dependency(
cls,
bg: BackgroundTasks,
session=Depends(generate_session),
group_id: UUID4 | None = Query(None, include_in_schema=False),
):
"""Convenience method to use as a dependency in FastAPI routes"""
return cls(bg, session, group_id)

0 comments on commit 2b87033

Please sign in to comment.