diff --git a/.flake8 b/.flake8
new file mode 100644
index 0000000..3ce2dc7
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,3 @@
+[flake8]
+exclude = .git, __pycache__, docs, old, build, dist, django_project, migrations
+max-line-length = 100
\ No newline at end of file
diff --git a/django_project/settings.py b/django_project/settings.py
index 8862942..af52c4e 100644
--- a/django_project/settings.py
+++ b/django_project/settings.py
@@ -20,19 +20,20 @@ from environ import Env
BASE_DIR = Path(__file__).resolve().parent.parent
LOCAL_DIR = Path(__file__).resolve().parent / "local"
+DEFAULT_SQLITE_DATABASE = str(BASE_DIR / 'db.sqlite3').replace('\\', '/')
ENV = Env(
- DEBUG=(bool,False),
- DOTENV=(Path,LOCAL_DIR/'.env'),
- DOTENV_PROD=(Path,LOCAL_DIR/'.env.prod'),
- DOTENV_DEVEL=(Path,LOCAL_DIR/'.env.dev'),
- DATABASE_URL=(str,f"sqlite:///{str(BASE_DIR/"db.sqlite3").replace("\\","/")}"),
- ALLOWED_HOSTS=(list,['*']),
- STATIC_URL=(str,"static/"),
- STATIC_ROOT=(Path,BASE_DIR/".static"),
- MEDIA_URL=(str,"media/"),
- MEDIA_ROOT=(Path,BASE_DIR/".media"),
- SECRET_KEY=(str,'django-insecure-tqis9c9@z_=cq36ic4h-l7h!ln8*@_*+e96z0m^-^mx_avdcw*'),
- EMAIL_BACKEND=(str,"console"),
+ DEBUG=(bool, False),
+ DOTENV=(Path, LOCAL_DIR/'.env'),
+ DOTENV_PROD=(Path, LOCAL_DIR/'.env.prod'),
+ DOTENV_DEVEL=(Path, LOCAL_DIR/'.env.dev'),
+ DATABASE_URL=(str, f"sqlite:///{DEFAULT_SQLITE_DATABASE}"),
+ ALLOWED_HOSTS=(list, ['*']),
+ STATIC_URL=(str, "static/"),
+ STATIC_ROOT=(Path, BASE_DIR/".static"),
+ MEDIA_URL=(str, "media/"),
+ MEDIA_ROOT=(Path, BASE_DIR/".media"),
+ SECRET_KEY=(str, 'django-insecure-tqis9c9@z_=cq36ic4h-l7h!ln8*@_*+e96z0m^-^mx_avdcw*'),
+ EMAIL_BACKEND=(str, "console"),
)
_env_file = Path(ENV.path("DOTENV"))
diff --git a/tinywiki/parser/bbcode/text_formatters.py b/tinywiki/parser/bbcode/text_formatters.py
index ec25f79..ffa8706 100644
--- a/tinywiki/parser/bbcode/text_formatters.py
+++ b/tinywiki/parser/bbcode/text_formatters.py
@@ -20,7 +20,7 @@ def render_url(tag_name: str, value, options, parent, context) -> str:
if settings.USE_BOOTSTRAP:
if ['noicon in options']:
return f"{value}" # noqa: E501
- return f"{value}" # noqa: E501
+ return f"{value}" # noqa: E501
return f"{value}" # noqa: E501
@@ -178,16 +178,16 @@ def render_image(tag_name: str, value, options, parent, context) -> str:
classes += ["mx-auto","d-block"]
if styles:
- style = f"style=\"{"".join(styles)}\""
+ style = f'style=\"{" ".join(styles)}\"'
else:
style = ""
if fig_styles:
- fig_style = f'style="{"".join(fig_styles)}"'
+ fig_style = f'style="{" ".join(fig_styles)}"'
else:
fig_style = ""
if settings.USE_BOOTSTRAP:
- return f'
{value}' # noqa: E501
+ return f'
{value}' # noqa: E501
else:
return f'
{value}' # noqa: E501
@@ -265,17 +265,17 @@ def render_wiki_image(tag_name: str, value, options, parent, context):
fig_classes += ["mx-auto", "d-block"]
if styles:
- style = f"style=\"{"".join(styles)}\""
+ style = f"style=\"{' '.join(styles)}\""
else:
style = ""
if fig_styles:
- fig_style = f'style="{"".join(fig_styles)}"'
+ fig_style = f'style="{" ".join(fig_styles)}"'
else:
fig_style = ""
if settings.USE_BOOTSTRAP:
- return f'
{image.description_html}' # noqa: E501
+ return f'
{image.description_html}' # noqa: E501
else:
return f'
{image.description}' # noqa: E501
@@ -311,7 +311,7 @@ def render_table(tag_name: str, value, options, parent, context) -> str:
):
classes.append(f"table-{options[tag_name]}")
- return f"
"
+ return f""
return f""
@@ -330,7 +330,7 @@ def render_table_row(tag_name: str, value, options, parent, context) -> str:
"dark"
):
classes.append(f"table-{options[tag_name]}")
- class_attr = f"class=\"{" ".join(classes)}\"" if classes else ""
+ class_attr = f"class=\"{' '.join(classes)}\"" if classes else ""
return f"{value}
"
@@ -354,8 +354,8 @@ def render_table_header(tag_name: str, value, options, parent, context) -> str:
"dark"
):
classes.append(f"table-{options[tag_name]}")
- class_attr = f"class=\"{" ".join(classes)}\"" if classes else ""
- return f"{value} | "
+ class_attr = f"class=\"{' '.join(classes)}\"" if classes else ""
+ return f"{value} | "
def render_table_data(tag_name: str, value, options, parent, context) -> str:
extra_attributes = []
@@ -377,8 +377,8 @@ def render_table_data(tag_name: str, value, options, parent, context) -> str:
"dark"
):
classes.append(f"table-{options[tag_name]}")
- class_attr = f"class=\"{" ".join(classes)}\"" if classes else ""
- return f"{value} | "
+ class_attr = f"class=\"{' '.join(classes)}\"" if classes else ""
+ return f"{value} | "
def render_youtube_video(tag_name: str, value, options, parent, context):
@@ -466,7 +466,7 @@ def render_youtube_video(tag_name: str, value, options, parent, context):
#classes += ["mx-auto", "d-block"]
if styles:
- style = f"style=\"{"".join(styles)}\""
+ style = f"style=\"{' '.join(styles)}\""
else:
style = ""
diff --git a/tinywiki/views/home.py b/tinywiki/views/home.py
index b91f73a..8395e56 100644
--- a/tinywiki/views/home.py
+++ b/tinywiki/views/home.py
@@ -29,25 +29,27 @@ class HomeView(View):
page = None
if self.user_can_create_system_pages:
if settings.USE_BOOTSTRAP:
- create_tw_home = f"{_('create a new page with the slug tw-home')}"
+ create_tw_home = f"{_('create a new page with the slug tw-home')}" # noqa: E501
else:
- create_tw_home = f"{_('create a new page with the slug tw-home')}"
+ create_tw_home = f"{_('create a new page with the slug tw-home')}" # noqa: E501
else:
create_tw_home = "create a new page with the slug tw-home"
if settings.USE_BOOTSTRAP:
- markdown_guide = f"{_('Guide for markdown used by TinyWiki')}"
- bbcode_guide = f"{_('Guide for BBCode used by TinyWiki')}"
+ markdown_guide = f"{_('Guide for markdown used by TinyWiki')}" # noqa: E501
+ bbcode_guide = f"{_('Guide for BBCode used by TinyWiki')}" # noqa: E501
else:
- markdown_guide = f"{_('Guide for markdown used by TinyWiki')}"
- bbcode_guide = f"{_('Guide for BBCode used by TinyWiki')}"
+ markdown_guide = f"{_('Guide for markdown used by TinyWiki')}" # noqa: E501
+ bbcode_guide = f"{_('Guide for BBCode used by TinyWiki')}" # noqa: E501
return render(request,
self.get_template_name(),
- self.get_context_data(page=page,
- user_can_create_system_pages=self.user_can_create_system_pages,
- create_tw_home=mark_safe(create_tw_home),
- markdown_guide=mark_safe(markdown_guide),
- bbcode_guide=mark_safe(bbcode_guide)))
+ self.get_context_data(
+ page=page,
+ user_can_create_system_pages=self.user_can_create_system_pages,
+ create_tw_home=mark_safe(create_tw_home),
+ markdown_guide=mark_safe(markdown_guide),
+ bbcode_guide=mark_safe(bbcode_guide)))
+
class TocView(View):
template_name = "tinywiki/home/wiki-content.html"
@@ -59,9 +61,11 @@ class TocView(View):
return cls.bs_template_name
return cls.template_name
- def get(self,request):
- def mkdict(page:Page):
- return {'slug':page.slug,'title':page.title, 'is_system':page.slug.startswith('tw-')}
+ def get(self, request):
+ def mkdict(page: Page):
+ return {'slug': page.slug,
+ 'title': page.title,
+ 'is_system': page.slug.startswith('tw-')}
user = self.request.user
if (user.is_staff or user.has_perm('page.read_all')):
@@ -107,12 +111,12 @@ class TocView(View):
else:
toc_section = f"{key}..."
- toc_section = ngettext("{toc_section} ({n} page)","{toc_section} ({n} pages)", count).format(
+ toc_section = ngettext("{toc_section} ({n} page)", "{toc_section} ({n} pages)", count).format(
toc_section=toc_section,
n=count,
)
- toc.append((toc_section,pages_0,pages_1))
+ toc.append((toc_section, pages_0, pages_1))
return render(request,
self.get_template_name(),
- self.get_context_data(toc=toc,subtitle=_("Table of Contents")))
\ No newline at end of file
+ self.get_context_data(toc=toc, subtitle=_("Table of Contents")))
\ No newline at end of file