Version Release Final Touches (#84)

* Remove slim

* bug: opacity issues

* bug: startup failure with no database

* ci/cd on dev branch

* formatting

* v0.1.0 documentation

Co-authored-by: Hayden <hay-kot@pm.me>
This commit is contained in:
Hayden 2021-01-17 10:53:42 -09:00 committed by GitHub
commit a76f472aa4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 2796 additions and 2704 deletions

49
.github/workflows/dockerbuild.dev.yml vendored Normal file
View file

@ -0,0 +1,49 @@
name: Docker Build Dev
on:
push:
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
#
# Checkout
#
- name: checkout code
uses: actions/checkout@v2
#
# Setup QEMU
#
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
#
# Setup Buildx
#
- name: install buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true
#
# Login to Docker Hub
#
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
#
# Build
#
- name: build the image
run: |
docker build --push \
--tag hkotel/mealie:dev \
--platform linux/amd64,linux/arm/v7,linux/arm64 .

View file

@ -4,24 +4,52 @@ on:
branches: branches:
- master - master
- dev - dev
- cd/cd
pull_request: pull_request:
branches: branches:
- master - master
- dev - dev
jobs: jobs:
build: tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 #----------------------------------------------
- name: Set up Python 3.8 # check-out repo and set-up python
uses: actions/setup-python@v1 #----------------------------------------------
- name: Check out repository
uses: actions/checkout@v2
- name: Set up python
uses: actions/setup-python@v2
with: with:
python-version: 3.8 python-version: 3.8
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1.1.1
with:
virtualenvs-create: true
virtualenvs-in-project: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies - name: Install dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
#----------------------------------------------
# run test suite
#----------------------------------------------
- name: Run tests
run: | run: |
python -m pip install --upgrade pip source .venv/bin/activate
pip install -r requirements.txt pytest mealie/tests/
pip install pytest
- name: Test with pytest
run: pytest -vv

View file

@ -5,21 +5,21 @@ RUN npm install
COPY ./frontend/ . COPY ./frontend/ .
RUN npm run build RUN npm run build
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8-slim # FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8-slim
FROM mrnr91/uvicorn-gunicorn-fastapi:python3.8
COPY ./requirements.txt /app/requirements.txt
WORKDIR /app WORKDIR /app
RUN apt-get update -y && \ RUN apt-get update -y && \
apt-get install -y python-pip python-dev git curl --no-install-recommends && \ apt-get install -y python-pip python-dev git curl python3-dev libxml2-dev libxslt1-dev zlib1g-dev --no-install-recommends && \
rm -rf /var/lib/apt/lists/* && \ rm -rf /var/lib/apt/lists/* && \
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \
cd /usr/local/bin && \ cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \ ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false poetry config virtualenvs.create false
COPY ./pyproject.toml ./app/poetry.lock* /app/ COPY ./pyproject.toml /app/
COPY ./mealie /app COPY ./mealie /app
RUN poetry install --no-root --no-dev RUN poetry install --no-root --no-dev

View file

@ -13,7 +13,7 @@ COPY ./requirements.txt /app/requirements.txt
WORKDIR /app WORKDIR /app
RUN apt-get update -y && \ RUN apt-get update -y && \
apt-get install -y python-pip python-dev git curl --no-install-recommends && \ apt-get install -y python-pip python-dev git curl --no-install-recommends
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \ RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \
cd /usr/local/bin && \ cd /usr/local/bin && \

View file

@ -8,6 +8,7 @@ RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-
ln -s /opt/poetry/bin/poetry && \ ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false poetry config virtualenvs.create false
RUN mkdir /app/
COPY ./pyproject.toml ./app/poetry.lock* /app/ COPY ./pyproject.toml ./app/poetry.lock* /app/
WORKDIR /app WORKDIR /app

View file

@ -7,10 +7,12 @@
- Fixed Images saved with no way to delete when add recipe via URL fails - Closes Issue #43 - Fixed Images saved with no way to delete when add recipe via URL fails - Closes Issue #43
### Features ### Features
- Additional database! SQlite is now supported! Closes #48 - Improved deployment documentation
- Additional database! SQlite is now supported! - Closes #48
- All site data is now backed up. - All site data is now backed up.
- Support for Prep Time, Total Time, and Cook Time field - Closes #63 - Support for Prep Time, Total Time, and Cook Time field - Closes #63
- New backup import process with support for themes and site settings - New backup import process with support for themes and site settings
- **BETA** ARM support! - Closes #69
### Code / Developer Improvements ### Code / Developer Improvements
- Unified Database Access Layers - Unified Database Access Layers

View file

@ -1,41 +1,46 @@
# Installation # Installation
To deploy docker on your local network it is highly recommended to use docker to deploy the image straight from dockerhub. Using the docker-compose below you should be able to get a stack up and running easily by changing a few default values and deploying. Currently the only supported database is Mongo. Mealie is looking for contributors to support additional databases. To deploy docker on your local network it is highly recommended to use docker to deploy the image straight from dockerhub. Using the docker-compose below you should be able to get a stack up and running easily by changing a few default values and deploying. Currently MongoDB and SQLite are supported. MongoDB support will be dropped in v0.2.0 so it is recommended to go with SQLite for new deployments. Postrgres support is planned for the next release, however for most loads you may find SQLite performant enough.
[Get Docker](https://docs.docker.com/get-docker/) [Get Docker](https://docs.docker.com/get-docker/)
[Mealie Docker Image](https://hub.docker.com/r/hkotel/mealie) [Mealie Docker Image](https://hub.docker.com/r/hkotel/mealie)
## Env Variables
| Variables | default | description | ## Quick Start - Docker CLI
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | Deployment with the Docker CLI can be done with `docker run` and specify the database type, in this case `sqlite`, setting the exposed port `9000`, mounting the current directory, and pull the latest image. After the image is up an running you can navigate to http://your.ip.addres:9000 and you'll should see mealie up and running!
| mealie_db_name | mealie | The name of the database to be created in Mongodb |
| mealie_port | 9000 | The port exposed by mealie. **do not change this if you're running in docker** If you'd like to use another port, map 9000 to another port of the host. |
| db_username | root | The Mongodb username you specified in your mongo container |
| db_password | example | The Mongodb password you specified in your mongo container |
| db_host | mongo | The host address of MongoDB if you're in docker and using the same network you can use mongo as the host name |
| db_port | 27017 | the port to access MongoDB 27017 is the default for mongo |
| api_docs | True | Turns on/off access to the API documentation locally. |
| TZ | | You should set your time zone accordingly so the date/time features work correctly |
## Docker CLI
```shell ```shell
docker container run \ docker run \
-e db_type='sql' \ -e db_type='sqlite' \
-p 9000:80 \ -p 9000:80 \
-v `pwd`:'/app/data/' \ -v `pwd`:'/app/data/' \
hkotel/mealie:dev hkotel/mealie:latest
``` ```
```shell ## Docker Compose with SQLite
Deployment with docker-compose is the recommended method for deployment. The example below will create an instance of mealie available on port `9000` with the data volume mounted from the local directory. To use, create a docker-compose.yml file, paste the contents below and save. In the terminal run `docker-compose up -d` to start the container.
```yaml
version: "3.1"
services:
mealie:
container_name: mealie
image: hkotel/mealie:latest
restart: always
ports:
- 9000:80
environment:
db_type: sqlite
TZ: America/Anchorage
volumes:
- ./mealie/data/:/app/data
``` ```
## Docker Compose ## Docker Compose with Mongo - DEPRECIATED
```yaml ```yaml
# docker-compose.yml # docker-compose.yml
@ -76,55 +81,21 @@ services:
``` ```
## Ansible Tasks Template
```yaml ## Env Variables
- name: ensures Mealie directory dir exists
file:
path: "{{ docker_dir }}/mealie/"
state: directory
owner: "{{ main_user}}"
group: "{{ main_group }}"
- name: ensures Mealie directory dir exists | Variables | default | description |
file: | -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
path: "{{ docker_dir }}/mealie/" | db_type | sqlite | The database type to be used. Current Options 'sqlite' and 'mongo' |
state: directory | mealie_db_name | mealie | The name of the database to be created in Mongodb |
owner: "{{ main_user}}" | mealie_port | 9000 | The port exposed by mealie. **do not change this if you're running in docker** If you'd like to use another port, map 9000 to another port of the host. |
group: "{{ main_group }}" | db_username | root | The Mongodb username you specified in your mongo container |
| db_password | example | The Mongodb password you specified in your mongo container |
| db_host | mongo | The host address of MongoDB if you're in docker and using the same network you can use mongo as the host name |
| db_port | 27017 | the port to access MongoDB 27017 is the default for mongo |
| api_docs | True | Turns on/off access to the API documentation locally. |
| TZ | | You should set your time zone accordingly so the date/time features work correctly |
- name: Deploy Monogo Database
docker_container:
name: mealie-mongo
image: mongo
restart_policy: unless-stopped
networks:
- name: web
env:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
- name: deploy Mealie Docker Container
docker_container:
name: mealie
image: hkotel/mealie:latest
restart_policy: unless-stopped
ports:
- 9090:9000
networks:
- name: web
mounts:
- type: bind
source: "{{ docker_dir }}/mealie"
target: /app/data
env:
db_username: root
db_password: example
db_host: mealie-mongo
db_port: "27017"
```
## Deployed as a Python Application ## Deployed as a Python Application
Alternatively, this project is built on Python and Mongodb. If you are dead set on deploying on a linux machine you can run this in an python environment with a dedicated MongoDatabase. Provided that you know thats how you want to host the application, I'll assume you know how to do that. I may or may not get around to writing this guide. I'm open to pull requests if anyone has a good guide on it. Alternatively, this project is built on Python and Mongodb. If you are dead set on deploying on a linux machine you can run this in an python environment with a dedicated MongoDatabase. Provided that you know thats how you want to host the application, I'll assume you know how to do that. I may or may not get around to writing this guide. I'm open to pull requests if anyone has a good guide on it.

View file

@ -6,7 +6,21 @@ In the Admin page on the in the Migration section you can provide a URL for a re
We'd like to support additional migration paths. [See open issues.](https://github.com/hay-kot/mealie/issues) We'd like to support additional migration paths. [See open issues.](https://github.com/hay-kot/mealie/issues)
**Currently Proposed Are:** ### Nextcloud Recipes
Nextcloud recipes can be imported from either a zip file the contains the data stored in Nextcloud. The zip file can be uploaded from the frontend or placed in the data/migrations/Nextcloud directory. See the example folder structure below to ensure your recipes are able to be imported.
- NextCloud Recipes ```
nextcloud_recipes.zip
├── recipe_1
│ ├── recipe.json
│ ├── full.jpg
│ └── thumb.jpg
├── recipe_2
│ ├── recipe.json
│ └── full.jpg
└── recipe_3
└── recipe.json
```
**Currently Proposed Are:**
- Open Eats - Open Eats

File diff suppressed because one or more lines are too long

View file

@ -1,12 +1,12 @@
# Development Road Map # Development Road Map
!!! Current Release !!! Current Release
v0.0.0 ALPHA - This is technically a pre-release, as such there are no release notes and no version. The first version will be version v0.1.0 and will provide a list of release notes with any breaking changes v0.1.0 BETA - This is technically a pre-release, as such take care to backup data and be aware that breaking changes in future releases are a real possibility.
Feature placement is not set in stone. This is much more of a guideline than anything else. Feature placement is not set in stone. This is much more of a guideline than anything else.
## v1.0 Road Map ## v x.x.x - No planned target, but eventually...
### Frontend ### Frontend
- [ ] Login / Logout Navigation - [ ] Login / Logout Navigation
@ -14,6 +14,7 @@ Feature placement is not set in stone. This is much more of a guideline than any
* [ ] Logic / Function Calls * [ ] Logic / Function Calls
* [ ] Password Reset * [ ] Password Reset
### Backend ### Backend
- [ ] Image Minification
- [ ] User Setup - [ ] User Setup
* [ ] Authentication * [ ] Authentication
* [ ] Default Admin/Superuser Account * [ ] Default Admin/Superuser Account
@ -21,25 +22,31 @@ Feature placement is not set in stone. This is much more of a guideline than any
* [ ] User Accounts * [ ] User Accounts
* [ ] Edit / Delete * [ ] Edit / Delete
## v0.1.0 ## v0.2.0 - Targets
### Front End
- [ ] Recipe Editor
* [ ] Basic Form Validation
- [ ] Recipe Viewer
* [ ] Print Page View - Like King Arthur Website
* [ ] Total Time Indicator
* [ ] Bake Time
!!! error "MAJOR BREAKING CHANGE"
MongoDB will no longer be supported as of v0.2.0. Review the database migration page for details on migration to SQL (It's very easy)
## New Features
### Frontend
- [ ] Advanced search
- [ ] Category Filter
- [ ] Tag Filter
- [x] Fuzzy Search
- [ ] Backup card redesign
- [ ] Additional Backup / Import Features
- [ ] Import Recipes Force/Rebase options
- [ ] Upload .zip file
- [ ] Improved Color Picker
- [ ] Meal Plan redesign
### Backend ### Backend
- [ ] Recipe Data - [ ] PostgreSQL Support
* [x] Better Scraper - [ ] Setup SQL Migrations
* [ ] Image Minification
* [x] Scraper Data Validation ## Breaking Changes
- [ ] Category Management - Internal port 9000 changed to port 80 for better Traefik support
* [ ] Lunch / Dinner / Breakfast <- Meal Generation - MongoDB support dropped
* [ ] Dessert / Side / Appetizer / Bread / Drinks / ## Code Chores
- [ ] Backup Options - [ ] Remove MongoDB Interface Code
* [ ] Force Update - [ ] Dockerfile Trim
* [ ] Rebuild

File diff suppressed because it is too large Load diff

View file

@ -12,24 +12,24 @@
"axios": "^0.21.1", "axios": "^0.21.1",
"core-js": "^3.8.2", "core-js": "^3.8.2",
"fuse.js": "^6.4.6", "fuse.js": "^6.4.6",
"qs": "^6.9.4", "qs": "^6.9.6",
"v-jsoneditor": "^1.4.2", "v-jsoneditor": "^1.4.2",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-i18n": "^8.22.3", "vue-i18n": "^8.22.4",
"vue-router": "^3.4.9", "vue-router": "^3.4.9",
"vuetify": "^2.4.2", "vuetify": "^2.4.2",
"vuex": "^3.6.0", "vuex": "^3.6.0",
"vuex-persistedstate": "^4.0.0-beta.2" "vuex-persistedstate": "^4.0.0-beta.3"
}, },
"devDependencies": { "devDependencies": {
"@intlify/vue-i18n-loader": "^1.0.0", "@intlify/vue-i18n-loader": "^1.0.0",
"@vue/cli-plugin-babel": "~4.5.0", "@vue/cli-plugin-babel": "^4.5.10",
"@vue/cli-plugin-eslint": "~4.5.0", "@vue/cli-plugin-eslint": "^4.5.10",
"@vue/cli-service": "~4.5.0", "@vue/cli-service": "^4.5.10",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"eslint": "^6.7.2", "eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2", "eslint-plugin-vue": "^6.2.2",
"sass": "^1.32.0", "sass": "^1.32.4",
"sass-loader": "^8.0.0", "sass-loader": "^8.0.0",
"vue-cli-plugin-i18n": "~1.0.1", "vue-cli-plugin-i18n": "~1.0.1",
"vue-cli-plugin-vuetify": "^2.0.8", "vue-cli-plugin-vuetify": "^2.0.8",

View file

@ -1,5 +1,10 @@
<template> <template>
<v-card color="accent" class="transparent" tile :width="`${timeCardWidth}`"> <v-card
color="accent"
class="custom-transparent"
tile
:width="`${timeCardWidth}`"
>
<v-card-text <v-card-text
class="text-caption white--text" class="text-caption white--text"
v-if="totalTime || prepTime || performTime" v-if="totalTime || prepTime || performTime"
@ -95,8 +100,8 @@ export default {
}; };
</script> </script>
<style> <style scoped>
.transparent { .custom-transparent {
opacity: 70% !important; opacity: 0.7;
} }
</style> </style>

View file

@ -2,7 +2,7 @@ import uvicorn
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles from fastapi.staticfiles import StaticFiles
import utils.startup as startup # import utils.startup as startup
from app_config import PORT, PRODUCTION, WEB_PATH, docs_url, redoc_url from app_config import PORT, PRODUCTION, WEB_PATH, docs_url, redoc_url
from routes import ( from routes import (
backup_routes, backup_routes,
@ -15,8 +15,7 @@ from routes import (
) )
from utils.api_docs import generate_api_docs from utils.api_docs import generate_api_docs
from utils.logger import logger from utils.logger import logger
from utils.startup import post_start
startup.pre_start()
app = FastAPI( app = FastAPI(
title="Mealie", title="Mealie",
@ -54,6 +53,7 @@ def invalid_api():
app.include_router(static_routes.router) app.include_router(static_routes.router)
# post_start()
# Generate API Documentation # Generate API Documentation
if not PRODUCTION: if not PRODUCTION:

View file

@ -6,6 +6,11 @@ import dotenv
CWD = Path(__file__).parent CWD = Path(__file__).parent
def ensure_dirs():
for dir in REQUIRED_DIRS:
dir.mkdir(parents=True, exist_ok=True)
# Register ENV # Register ENV
ENV = CWD.joinpath(".env") ENV = CWD.joinpath(".env")
dotenv.load_dotenv(ENV) dotenv.load_dotenv(ENV)
@ -19,7 +24,7 @@ BACKUP_DIR = DATA_DIR.joinpath("backups")
DEBUG_DIR = DATA_DIR.joinpath("debug") DEBUG_DIR = DATA_DIR.joinpath("debug")
MIGRATION_DIR = DATA_DIR.joinpath("migration") MIGRATION_DIR = DATA_DIR.joinpath("migration")
TEMPLATE_DIR = DATA_DIR.joinpath("templates") TEMPLATE_DIR = DATA_DIR.joinpath("templates")
TINYDB_DIR = DATA_DIR.joinpath("db") SQLITE_DIR = DATA_DIR.joinpath("db")
TEMP_DIR = DATA_DIR.joinpath(".temp") TEMP_DIR = DATA_DIR.joinpath(".temp")
REQUIRED_DIRS = [ REQUIRED_DIRS = [
@ -29,7 +34,7 @@ REQUIRED_DIRS = [
DEBUG_DIR, DEBUG_DIR,
MIGRATION_DIR, MIGRATION_DIR,
TEMPLATE_DIR, TEMPLATE_DIR,
TINYDB_DIR, SQLITE_DIR,
] ]
@ -47,10 +52,12 @@ else:
# DATABASE ENV # DATABASE ENV
DATABASE_TYPE = os.getenv("db_type", "sql") # mongo, tinydb DATABASE_TYPE = os.getenv("db_type", "sqlite") # mongo, sqlite
if DATABASE_TYPE == "sql": if DATABASE_TYPE == "sqlite":
USE_SQL = True USE_SQL = True
USE_MONGO = False USE_MONGO = False
SQLITE_FILE = SQLITE_DIR.joinpath("mealie.sqlite")
elif DATABASE_TYPE == "mongo": elif DATABASE_TYPE == "mongo":
USE_MONGO = True USE_MONGO = True
@ -71,3 +78,6 @@ DB_PORT = os.getenv("db_port", 27017)
# SFTP Email Stuff - For use Later down the line! # SFTP Email Stuff - For use Later down the line!
SFTP_USERNAME = os.getenv("sftp_username", None) SFTP_USERNAME = os.getenv("sftp_username", None)
SFTP_PASSWORD = os.getenv("sftp_password", None) SFTP_PASSWORD = os.getenv("sftp_password", None)
ensure_dirs()

View file

@ -1,10 +1,13 @@
from app_config import DATA_DIR, USE_MONGO, USE_SQL from app_config import SQLITE_FILE, USE_MONGO, USE_SQL
from db.sql.db_session import globa_init as sql_global_init from db.sql.db_session import globa_init as sql_global_init
sql_exists = SQLITE_FILE.is_file()
if USE_SQL: if USE_SQL:
db_file = DATA_DIR.joinpath("db", "mealie.sqlite") sql_global_init(SQLITE_FILE)
sql_global_init(db_file)
pass
elif USE_MONGO: elif USE_MONGO:
from db.mongo.mongo_setup import global_init as mongo_global_init from db.mongo.mongo_setup import global_init as mongo_global_init

View file

@ -13,7 +13,6 @@ def globa_init(db_file: Path):
if __factory: if __factory:
return return
conn_str = "sqlite:///" + str(db_file.absolute()) conn_str = "sqlite:///" + str(db_file.absolute())
engine = sa.create_engine(conn_str, echo=False) engine = sa.create_engine(conn_str, echo=False)

View file

@ -4,9 +4,9 @@ import zipfile
from pathlib import Path from pathlib import Path
from typing import List from typing import List
from app_config import BACKUP_DIR, IMG_DIR, TEMP_DIR
from services.recipe_services import Recipe from services.recipe_services import Recipe
from services.settings_services import SiteSettings, SiteTheme from services.settings_services import SiteSettings, SiteTheme
from app_config import BACKUP_DIR, IMG_DIR, TEMP_DIR
from utils.logger import logger from utils.logger import logger
@ -73,11 +73,6 @@ class ImportDatabase:
with open(recipe, "r") as f: with open(recipe, "r") as f:
recipe_dict = json.loads(f.read()) recipe_dict = json.loads(f.read())
recipe_dict = ImportDatabase._recipe_migration(recipe_dict) recipe_dict = ImportDatabase._recipe_migration(recipe_dict)
recipe_obj = Recipe(**recipe_dict)
recipe_obj.save_to_db()
successful_imports.append(recipe.stem)
logger.info(f"Imported: {recipe.stem}")
try: try:
recipe_obj = Recipe(**recipe_dict) recipe_obj = Recipe(**recipe_dict)
recipe_obj.save_to_db() recipe_obj.save_to_db()

View file

@ -1,6 +1,7 @@
from typing import List, Optional from typing import List, Optional
from db.database import db from db.database import db
from db.db_setup import sql_exists
from pydantic import BaseModel from pydantic import BaseModel
from utils.logger import logger from utils.logger import logger
@ -120,7 +121,7 @@ def default_theme_init():
try: try:
SiteTheme.get_by_name("default") SiteTheme.get_by_name("default")
return "default theme exists" logger.info("Default theme exists... skipping generation")
except: except:
logger.info("Generating Default Theme") logger.info("Generating Default Theme")
colors = Colors(**default_colors) colors = Colors(**default_colors)
@ -128,4 +129,15 @@ def default_theme_init():
default_theme.save_to_db() default_theme.save_to_db()
default_theme_init() def default_settings_init():
try:
document = db.settings.get("main")
except:
webhooks = Webhooks()
default_entry = SiteSettings(name="main", webhooks=webhooks)
document = db.settings.save_new(default_entry.dict(), webhooks.dict())
if not sql_exists:
default_settings_init()
default_theme_init

View file

@ -1,2 +1,2 @@
import db.db_setup
from pytest import fixture from pytest import fixture

View file

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before After
Before After

View file

@ -1,17 +1,16 @@
from pathlib import Path from pathlib import Path
from app_config import REQUIRED_DIRS from app_config import REQUIRED_DIRS
from services.settings_services import default_theme_init
CWD = Path(__file__).parent CWD = Path(__file__).parent
def pre_start(): def post_start():
ensure_dirs() default_theme_init()
def ensure_dirs():
for dir in REQUIRED_DIRS:
dir.mkdir(parents=True, exist_ok=True)
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -1,25 +0,0 @@
aiofiles==0.5.0
apscheduler==3.6.3
async-exit-stack==1.0.1
async-generator==1.10
black==20.8b1
colorama==0.4.3
email-validator==1.1.1
fastapi-login==1.5.1
gitpython==3.1.11
graphene==2.1.8
itsdangerous==1.1.0
mongoengine==0.21.0
nltk==3.5
pdfkit==0.6.1
pip-chill==1.0.0
pylint==2.6.0
pytest==6.2.1
python-dateutil==2.8.1
python-dotenv==0.15.0
python-multipart==0.0.5
python-slugify==4.0.1
scrape-schema-recipe==0.1.1
sqlalchemy==1.3.22
ujson==3.1.0
uvicorn==0.11.8

View file

@ -1,103 +0,0 @@
aiofiles==0.5.0
aniso8601==7.0.0
appdirs==1.4.4
APScheduler==3.6.3
astroid==2.4.2
async-exit-stack==1.0.1
async-generator==1.10
attrs==20.3.0
beautifulsoup4==4.9.1
black==20.8b1
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
colorama==0.4.3
decorator==4.4.2
dnspython==2.0.0
email-validator==1.1.1
extruct==0.10.0
fastapi==0.61.1
fastapi-login==1.5.1
future==0.18.2
gitdb==4.0.5
GitPython==3.1.11
graphene==2.1.8
graphql-core==2.3.2
graphql-relay==2.0.1
h11==0.9.0
html-text==0.5.2
html5lib==1.1
httptools==0.1.1
idna==2.10
iniconfig==1.1.1
isodate==0.6.0
isort==5.4.2
itsdangerous==1.1.0
Jinja2==2.11.2
joblib==1.0.0
jstyleson==0.0.2
lazy-object-proxy==1.4.3
livereload==2.6.3
lunr==0.5.8
lxml==4.6.2
Markdown==3.3.3
MarkupSafe==1.1.1
mccabe==0.6.1
mf2py==1.1.2
mkdocs==1.1.2
mkdocs-material==6.1.7
mkdocs-material-extensions==1.0.1
mongoengine==0.21.0
mypy-extensions==0.4.3
nltk==3.5
packaging==20.8
passlib==1.7.4
pathspec==0.8.0
pdfkit==0.6.1
pip-chill==1.0.0
pluggy==0.13.1
promise==2.3
py==1.10.0
pydantic==1.6.1
Pygments==2.7.3
PyJWT==1.7.1
pylint==2.6.0
pymdown-extensions==8.0.1
pymongo==3.11.1
pyparsing==2.4.7
pytest==6.2.1
python-dateutil==2.8.1
python-dotenv==0.15.0
python-multipart==0.0.5
python-slugify==4.0.1
pytz==2020.4
PyYAML==5.3.1
rdflib==4.2.2
rdflib-jsonld==0.5.0
regex==2020.7.14
requests==2.24.0
Rx==1.6.1
scrape-schema-recipe==0.1.1
six==1.15.0
smmap==3.0.4
soupsieve==2.0.1
SQLAlchemy==1.3.22
starlette==0.13.6
text-unidecode==1.3
tinydb==4.3.0
tinydb-serialization==2.0.0
toml==0.10.1
tornado==6.1
tqdm==4.54.1
typed-ast==1.4.1
typing-extensions==3.7.4.3
tzlocal==2.1
ujson==3.1.0
urllib3==1.25.10
uvicorn==0.11.8
uvloop==0.14.0
validators==0.18.0
w3lib==1.22.0
webencodings==0.5.1
websockets==8.1
wrapt==1.12.1