Add option to specify a different config file; update README and CHANGELOG

This commit is contained in:
Yusur 2022-06-12 11:10:41 +02:00
parent 249fdad1bc
commit 43a7be95f8
3 changed files with 48 additions and 13 deletions

View file

@ -1,5 +1,35 @@
# Whats New # Whats New
## 0.6
+ Added support for database URLs: you can now specify the URL of the database
in `site.conf` by setting `[database]url`, be it MySQL, PostgreSQL or SQLite.
+ Added experimental math support, with `markdown_katex` library. The math
parsing can be opted out in many ways.
+ Backlinks can now be accessed for each page.
+ Spoiler tags at beginning of line now work. Just for now.
+ Removed `Upload` table.
+ Added `PageLink` table.
## 0.5
+ Removed support for uploads. The `/upload/` endpoint now points to an info
page, and the “Upload image” button and gallery from home page are now gone.
+ `markdown_strikethrough` extension is no more needed. Now there are two new
built-in extensions: `StrikethroughExtension` and `SpoilerExtension` (the
last one is buggy tho).
+ Removed support for magic words (the commands between `{{` `}}`). These
features are now lost: `backto`, `media` and `gallery` (easily replaceable
with simple Markdown).
+ Added app version to site footer.
+ Added client-side drafts (they require JS enabled).
## 0.4
## 0.3
## 0.2 ## 0.2
+ Some code refactoring. + Some code refactoring.

View file

@ -11,7 +11,7 @@ suitable as a community or team knowledge base.
+ Write notes on the go, using Markdown syntax + Write notes on the go, using Markdown syntax
+ Any note can have its own URL + Any note can have its own URL
+ Revision history + Revision history
+ Stored in SQLite databases + Stored in SQLite/MySQL databases
+ Material Icons + Material Icons
+ Light/dark theme + Light/dark theme
+ Works fine even with JavaScript disabled. + Works fine even with JavaScript disabled.
@ -19,9 +19,13 @@ suitable as a community or team knowledge base.
## Requirements ## Requirements
+ **Python** 3.6+. + **Python** 3.6+.
+ **Flask** web framework. + **Flask** web framework (and Flask-Login / Flask-WTF extensions).
+ **Peewee** ORM. + **Peewee** ORM.
### Optional requirements
* **Markdown-KaTeX** if you want to display math inside pages.
## Caveats ## Caveats
+ All pages created are, as of now, viewable and editable by anyone, with no + All pages created are, as of now, viewable and editable by anyone, with no

23
app.py
View file

@ -32,10 +32,6 @@ try:
from slugify import slugify from slugify import slugify
except ImportError: except ImportError:
slugify = None slugify = None
try:
import markdown_katex
except ImportError:
markdown_katex = None
__version__ = '0.6-dev' __version__ = '0.6-dev'
@ -48,21 +44,17 @@ FK = ForeignKeyField
SLUG_RE = r'[a-z0-9]+(?:-[a-z0-9]+)*' SLUG_RE = r'[a-z0-9]+(?:-[a-z0-9]+)*'
ILINK_RE = r'\]\(/(p/\d+|' + SLUG_RE + ')/?\)' ILINK_RE = r'\]\(/(p/\d+|' + SLUG_RE + ')/?\)'
upload_types = {'jpeg': 1, 'jpg': 1, 'png': 2}
upload_types_rev = {1: 'jpg', 2: 'png'}
UPLOAD_DIR = APP_BASE_DIR + '/media'
DATABASE_DIR = APP_BASE_DIR + "/database"
#### GENERAL CONFIG #### #### GENERAL CONFIG ####
CONFIG_FILE = os.environ.get('SALVI_CONF', APP_BASE_DIR + '/site.conf')
DEFAULT_CONF = { DEFAULT_CONF = {
('site', 'title'): 'Salvi', ('site', 'title'): 'Salvi',
('database', 'directory'): APP_BASE_DIR + "/database", ('database', 'directory'): APP_BASE_DIR + "/database",
} }
_cfp = ConfigParser() _cfp = ConfigParser()
if _cfp.read([APP_BASE_DIR + '/site.conf']): if _cfp.read([CONFIG_FILE]):
@lru_cache(maxsize=50) @lru_cache(maxsize=50)
def _getconf(k1, k2, fallback=None, cast=None): def _getconf(k1, k2, fallback=None, cast=None):
if fallback is None: if fallback is None:
@ -80,6 +72,15 @@ else:
fallback = DEFAULT_CONF.get((k1, k2)) fallback = DEFAULT_CONF.get((k1, k2))
return fallback return fallback
#### OPTIONAL IMPORTS ####
markdown_katex = None
try:
if _getconf('appearance', 'math') != 'off':
import markdown_katex
except ImportError:
pass
#### misc. helpers #### #### misc. helpers ####
def _makelist(l): def _makelist(l):