diff --git a/CHANGELOG.md b/CHANGELOG.md index 63b5360..a030905 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ caution message when viewing them. + Added Terms and Privacy Policy. + Changed user page URLs (contributions page) from `/u/user` to `/@user`. ++ `/manage/` is now a list of all managing options, including export/import and the brand new + `/manage/accounts`. ++ TOC is now shown in pages where screen width is greater than 960 pixels. + Style changes: added a top bar with the site title. It replaces the floating menu on the top right. + Added a built-in installer (`app_init.py`). You still need to manually create `site.conf`. diff --git a/app.py b/app.py index 94ee51f..95f0ad4 100644 --- a/app.py +++ b/app.py @@ -161,6 +161,12 @@ class User(BaseModel): def is_authenticated(self): return True + def groups(self): + return ( + UserGroup.select().join(UserGroupMembership, on=UserGroupMembership.group) + .where(UserGroupMembership.user == self) + ) + class UserGroup(BaseModel): name = CharField(32, unique=True) permissions = BitField() @@ -295,6 +301,8 @@ class PageRevision(BaseModel): return self.textref.get_content() def html(self, *, math=True): return md(self.text, math=self.page.is_math_enabled and math) + def html_and_toc(self, *, math=True): + return md_and_toc(self.text, math=self.page.is_math_enabled and math) def human_pub_date(self): delta = datetime.datetime.now() - self.pub_date T = partial(get_string, g.lang) @@ -484,7 +492,7 @@ def init_db_and_create_first_user(): #### WIKI SYNTAX #### -def md(text, expand_magic=False, toc=True, math=True): +def md_and_toc(text, expand_magic=False, toc=True, math=True): if expand_magic: # DEPRECATED seeking for a better solution. warnings.warn('Magic words are no more supported.', DeprecationWarning) @@ -502,9 +510,16 @@ def md(text, expand_magic=False, toc=True, math=True): 'insert_fonts_css': not _getconf('site', 'katex_url') } try: - return markdown.Markdown(extensions=extensions, extension_configs=extension_configs).convert(text) + converter = markdown.Markdown(extensions=extensions, extension_configs=extension_configs) + if toc: + return converter.convert(text), converter.toc + else: + return converter.convert(text), '' except Exception as e: - return '
There was an error during rendering: {e.__class__.__name__}: {e}
'.format(e=e) + return 'There was an error during rendering: {e.__class__.__name__}: {e}
'.format(e=e), '' + +def md(text, expand_magic=False, toc=True, math=True): + return md_and_toc(text, expand_magic=expand_magic, toc=toc, math=math)[0] def remove_tags(text, convert=True, headings=True): if headings: @@ -538,7 +553,7 @@ def is_url_available(url): forbidden_urls = [ 'about', 'accounts', 'ajax', 'backlinks', 'calendar', 'circles', 'create', - 'easter', 'edit', 'embed', 'help', 'history', 'init-config', 'kt', + 'easter', 'edit', 'embed', 'group', 'help', 'history', 'init-config', 'kt', 'manage', 'media', 'p', 'privacy', 'protect', 'search', 'static', 'stats', 'tags', 'terms', 'u', 'upload', 'upload-info' ] @@ -783,11 +798,7 @@ def edit(id): @app.route("/__sync_start") def __sync_start(): - if _getconf("sync", "master", "this") == "this": - abort(403) - from app_sync import main - main() - flash("Successfully synced messages.") + flash("Sync is unavailable. Please import and export pages manually.") return redirect("/") @app.route('/_jsoninfo/Administrative tools can be accessed by administrator users only.
+{% endif %} +{% endblock %} \ No newline at end of file diff --git a/templates/base.jinja2 b/templates/base.jinja2 index d66af71..288bd0a 100644 --- a/templates/base.jinja2 +++ b/templates/base.jinja2 @@ -52,6 +52,7 @@