Add option to specify a different config file; update README and CHANGELOG
This commit is contained in:
parent
249fdad1bc
commit
43a7be95f8
3 changed files with 48 additions and 13 deletions
30
CHANGELOG.md
30
CHANGELOG.md
|
|
@ -1,5 +1,35 @@
|
|||
# What’s 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
|
||||
|
||||
+ Some code refactoring.
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ suitable as a community or team knowledge base.
|
|||
+ Write notes on the go, using Markdown syntax
|
||||
+ Any note can have its own URL
|
||||
+ Revision history
|
||||
+ Stored in SQLite databases
|
||||
+ Stored in SQLite/MySQL databases
|
||||
+ Material Icons
|
||||
+ Light/dark theme
|
||||
+ Works fine even with JavaScript disabled.
|
||||
|
|
@ -19,9 +19,13 @@ suitable as a community or team knowledge base.
|
|||
## Requirements
|
||||
|
||||
+ **Python** 3.6+.
|
||||
+ **Flask** web framework.
|
||||
+ **Flask** web framework (and Flask-Login / Flask-WTF extensions).
|
||||
+ **Peewee** ORM.
|
||||
|
||||
### Optional requirements
|
||||
|
||||
* **Markdown-KaTeX** if you want to display math inside pages.
|
||||
|
||||
## Caveats
|
||||
|
||||
+ All pages created are, as of now, viewable and editable by anyone, with no
|
||||
|
|
|
|||
23
app.py
23
app.py
|
|
@ -32,10 +32,6 @@ try:
|
|||
from slugify import slugify
|
||||
except ImportError:
|
||||
slugify = None
|
||||
try:
|
||||
import markdown_katex
|
||||
except ImportError:
|
||||
markdown_katex = None
|
||||
|
||||
__version__ = '0.6-dev'
|
||||
|
||||
|
|
@ -48,21 +44,17 @@ FK = ForeignKeyField
|
|||
SLUG_RE = r'[a-z0-9]+(?:-[a-z0-9]+)*'
|
||||
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 ####
|
||||
|
||||
CONFIG_FILE = os.environ.get('SALVI_CONF', APP_BASE_DIR + '/site.conf')
|
||||
|
||||
DEFAULT_CONF = {
|
||||
('site', 'title'): 'Salvi',
|
||||
('database', 'directory'): APP_BASE_DIR + "/database",
|
||||
}
|
||||
|
||||
_cfp = ConfigParser()
|
||||
if _cfp.read([APP_BASE_DIR + '/site.conf']):
|
||||
if _cfp.read([CONFIG_FILE]):
|
||||
@lru_cache(maxsize=50)
|
||||
def _getconf(k1, k2, fallback=None, cast=None):
|
||||
if fallback is None:
|
||||
|
|
@ -80,6 +72,15 @@ else:
|
|||
fallback = DEFAULT_CONF.get((k1, k2))
|
||||
return fallback
|
||||
|
||||
#### OPTIONAL IMPORTS ####
|
||||
|
||||
markdown_katex = None
|
||||
try:
|
||||
if _getconf('appearance', 'math') != 'off':
|
||||
import markdown_katex
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
#### misc. helpers ####
|
||||
|
||||
def _makelist(l):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue