Introduce migrations folder + improve README.md + add custom CDN for Material Icons
This commit is contained in:
parent
b09d32d5e8
commit
e449e06b5d
5 changed files with 44 additions and 4 deletions
|
|
@ -32,9 +32,11 @@
|
||||||
## 0.4
|
## 0.4
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 0.3
|
## 0.3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 0.2
|
## 0.2
|
||||||
|
|
||||||
+ Some code refactoring.
|
+ Some code refactoring.
|
||||||
|
|
|
||||||
18
README.md
18
README.md
|
|
@ -23,11 +23,29 @@ suitable as a community or team knowledge base.
|
||||||
+ **Peewee** ORM.
|
+ **Peewee** ORM.
|
||||||
+ **Markdown** for page rendering.
|
+ **Markdown** for page rendering.
|
||||||
+ **Python-I18n**.
|
+ **Python-I18n**.
|
||||||
|
+ The database drivers needed for the type of database.
|
||||||
|
|
||||||
### Optional requirements
|
### Optional requirements
|
||||||
|
|
||||||
* **Markdown-KaTeX** if you want to display math inside pages.
|
* **Markdown-KaTeX** if you want to display math inside pages.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
+ Clone this repository: `git clone https://github.com/sakuragasaki46/salvi`
|
||||||
|
+ Edit site.conf with the needed parameters. An example site.conf:
|
||||||
|
|
||||||
|
```
|
||||||
|
[site]
|
||||||
|
name = Salvi
|
||||||
|
|
||||||
|
[database]
|
||||||
|
directory = /path/to/database/
|
||||||
|
```
|
||||||
|
|
||||||
|
+ Run `flask run`.
|
||||||
|
+ You can now access Salvi in your browser at port 5000.
|
||||||
|
|
||||||
|
|
||||||
## 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
|
||||||
|
|
|
||||||
6
app.py
6
app.py
|
|
@ -4,11 +4,10 @@
|
||||||
'''
|
'''
|
||||||
A simple wiki-like note webapp.
|
A simple wiki-like note webapp.
|
||||||
|
|
||||||
Pages are stored in SQLite databases.
|
Pages are stored in SQLite/MySQL databases.
|
||||||
Markdown is used for text formatting.
|
Markdown is used for text formatting.
|
||||||
|
|
||||||
Application is kept compact, with all its core in a single file.
|
Application is kept compact, with all its core in a single file.
|
||||||
Extensions are supported (?), kept in extensions/ folder.
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
#### IMPORTS ####
|
#### IMPORTS ####
|
||||||
|
|
@ -472,7 +471,8 @@ def _inject_variables():
|
||||||
'app_name': _getconf('site', 'title'),
|
'app_name': _getconf('site', 'title'),
|
||||||
'strong': lambda x:Markup('<strong>{0}</strong>').format(x),
|
'strong': lambda x:Markup('<strong>{0}</strong>').format(x),
|
||||||
'app_version': __version__,
|
'app_version': __version__,
|
||||||
'math_version': markdown_katex.__version__ if markdown_katex else None
|
'math_version': markdown_katex.__version__ if markdown_katex else None,
|
||||||
|
'material_icons_url': _getconf('site', 'material_icons_url')
|
||||||
}
|
}
|
||||||
|
|
||||||
@app.template_filter()
|
@app.template_filter()
|
||||||
|
|
|
||||||
17
migrations/0_6to0_7.py
Normal file
17
migrations/0_6to0_7.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
from playhouse.migrate import migrate, SqliteMigrator, MySQLMigrator
|
||||||
|
from peewee import MySQLDatabase, SqliteDatabase
|
||||||
|
from app import database
|
||||||
|
|
||||||
|
if type(database) == MySQLDatabase:
|
||||||
|
migrator = MySQLMigrator(database)
|
||||||
|
elif type(database) == SqliteDatabase:
|
||||||
|
migrator = SqliteMigrator(database)
|
||||||
|
else:
|
||||||
|
print("Unsupported database")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
with database.atomic():
|
||||||
|
migrate(
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
@ -7,8 +7,11 @@
|
||||||
{% block meta %}{% endblock %}
|
{% block meta %}{% endblock %}
|
||||||
<link rel="stylesheet" href="/static/style.css">
|
<link rel="stylesheet" href="/static/style.css">
|
||||||
<!-- material icons -->
|
<!-- material icons -->
|
||||||
<link rel="stylesheet" href="https://cdn.sakuragasaki46.local/common/material-icons.css">
|
{% if material_icons_url %}
|
||||||
|
<link rel="stylesheet" href="{{ material_icons_url }}">
|
||||||
|
{% else %}
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||||
|
{% endif %}
|
||||||
{% block json_info %}{% endblock %}
|
{% block json_info %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
<body{% if request.cookies.get('dark') == '1' %} class="dark"{% endif %}>
|
<body{% if request.cookies.get('dark') == '1' %} class="dark"{% endif %}>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue