diff --git a/wikilain/blueprints/article_default.py b/wikilain/blueprints/article_default.py
index 37878f4..dd701b2 100644
--- a/wikilain/blueprints/article_default.py
+++ b/wikilain/blueprints/article_default.py
@@ -1,23 +1,26 @@
from flask import Blueprint, render_template, g, session, redirect, request, url_for, flash, current_app, abort
import secrets
from datetime import datetime
-import re
from sqlalchemy import func
from ..models import *
from ..markdown import *
+from ..util import *
article_provider = Blueprint("article", __name__, template_folder='templates')
-blacklisted_titles = ["new", "by-id"]
-allowed_titles = re.compile(r"^[a-zA-Z0-9 \(\)\.\,:;]+$")
-
-def urlify(title):
- return title.replace(" ", "_")
+class DefaultSection:
+ def __init__(self, articles):
+ self.title = "No Section"
+ self.articles = articles
-def unurlify(title):
- return title.replace("_", " ")
+@article_provider.route("/")
+def index():
+ sections = Section.query.all()
+ uncat = Article.query.filter_by(section_id=None).all()
+ sections.append(DefaultSection(uncat))
+ return render_template("article_index.html", sections=sections)
@article_provider.route("/
")
@@ -55,9 +58,7 @@ def new():
return render_template("article_new.html",
csrf=csrf, article_title=article_title,
article_content=article_content)
- if (len(article_title) == 0
- or article_title in blacklisted_titles
- or not allowed_titles.match(article_title)):
+ if not title_valid(article_title):
flash("Invalid title", "error")
return render_template("article_new.html",
csrf=csrf, article_title=article_title,
diff --git a/wikilain/blueprints/templates/article_index.html b/wikilain/blueprints/templates/article_index.html
new file mode 100644
index 0000000..029a4fd
--- /dev/null
+++ b/wikilain/blueprints/templates/article_index.html
@@ -0,0 +1,25 @@
+{% extends 'base.html' %}
+
+{% block title %}
+Articles
+{% endblock %}
+
+{% block content %}
+
+ Articles
+
+
+ {% for section in sections %}
+ -
+ {{ section.title }}
+
+
+ {% endfor %}
+
+{% endblock %}
diff --git a/wikilain/blueprints/templates/user_list.html b/wikilain/blueprints/templates/user_list.html
index 6a5c38e..48ec428 100644
--- a/wikilain/blueprints/templates/user_list.html
+++ b/wikilain/blueprints/templates/user_list.html
@@ -6,7 +6,7 @@ User List
{% block content %}
- User list
+ User List
{% for user in users %}
diff --git a/wikilain/blueprints/user_default.py b/wikilain/blueprints/user_default.py
index 683d100..488b46f 100644
--- a/wikilain/blueprints/user_default.py
+++ b/wikilain/blueprints/user_default.py
@@ -8,13 +8,13 @@ __all__ = ["user_provider"]
user_provider = Blueprint("user", __name__, template_folder='templates')
@user_provider.route("/")
-def show_user_list():
+def list():
users = User.query.all()
# TODO: pagination...
return render_template("user_list.html", users=users)
@user_provider.route("/")
-def show_user(username):
+def show(username):
is_self = g.wl_user is not None and username == g.wl_user.username
if is_self:
user = g.wl_user
diff --git a/wikilain/models.py b/wikilain/models.py
index 39a596d..2980462 100644
--- a/wikilain/models.py
+++ b/wikilain/models.py
@@ -1,6 +1,8 @@
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
+from .util import urlify
+
db = SQLAlchemy()
migrate = Migrate(None, db)
@@ -23,8 +25,6 @@ class Section(db.Model):
def __repr__(self):
return f""
-DEFAULT_SECTION = 1
-
class Article(db.Model):
__tablename__ = "articles"
id = db.Column(db.Integer, primary_key=True)
@@ -35,6 +35,9 @@ class Article(db.Model):
def __repr__(self):
return f""
+ def title_urlify(self):
+ return urlify(self.title)
+
class ArticleRevision(db.Model):
__tablename__ = "articlerevisions"
id = db.Column(db.Integer, primary_key=True)
diff --git a/wikilain/templates/base.html b/wikilain/templates/base.html
index fd42516..5621e3e 100644
--- a/wikilain/templates/base.html
+++ b/wikilain/templates/base.html
@@ -16,7 +16,7 @@
- - Sections
+ - Article Index
{% if not g.wl_user %}
-
diff --git a/wikilain/util.py b/wikilain/util.py
new file mode 100644
index 0000000..c1d1816
--- /dev/null
+++ b/wikilain/util.py
@@ -0,0 +1,17 @@
+import re
+
+blacklisted_titles = ["new", "by-id"]
+allowed_titles = re.compile(r"^[a-zA-Z0-9 \(\)\.\,:;]+$")
+
+def urlify(title):
+ return title.replace(" ", "_")
+
+
+def unurlify(title):
+ return title.replace("_", " ")
+
+
+def title_valid(title):
+ return (len(article_title) > 0
+ and article_title not in blacklisted_titles
+ and allowed_titles.match(article_title))