diff --git a/src/app.py b/src/app.py
index e3ae692..1e98859 100644
--- a/src/app.py
+++ b/src/app.py
@@ -12,10 +12,13 @@ def create_app():
from api import api_document
app.register_blueprint(api_document.bp)
- from web import web_admin
- app.register_blueprint(web_admin.bp)
-
from web import web_document
app.register_blueprint(web_document.bp)
+
+ from web.admin import admin
+ app.register_blueprint(admin.bp)
+
+ from web.admin import admin_document
+ app.register_blueprint(admin_document.bp)
return app
diff --git a/src/data/document.py b/src/data/document.py
index 2a4ee34..b57ca54 100644
--- a/src/data/document.py
+++ b/src/data/document.py
@@ -52,6 +52,13 @@ class Document:
def pull(self):
return run("cd \"" + self.doc_path + "/repo\" && git pull")
+ def delete(self):
+ shutil.rmtree(self.doc_path)
+
+ def delete_folder(self):
+ doc_path = Document.make_doc_path(self.doc_name, self.branch)
+ shutil.rmtree(doc_path)
+
def get_url(self):
return "/doc/" + sanitize_name(self.doc_name)+'/'+sanitize_name(self.branch) + "/index.html"
diff --git a/src/static/app.js b/src/static/app.js
new file mode 100644
index 0000000..d6aa92c
--- /dev/null
+++ b/src/static/app.js
@@ -0,0 +1,8 @@
+var confirm_elements = document.querySelectorAll('a[data-confirm]');
+for (let elt of confirm_elements)
+{
+ elt.addEventListener('click', (e) => {
+ if(!confirm(elt.getAttribute('data-confirm')))
+ e.preventDefault();
+ }, false);
+}
diff --git a/src/static/style.css b/src/static/style.css
new file mode 100644
index 0000000..e69de29
diff --git a/src/templates/admin/command_output.html b/src/templates/admin/command_output.html
new file mode 100644
index 0000000..7f7d776
--- /dev/null
+++ b/src/templates/admin/command_output.html
@@ -0,0 +1,8 @@
+{% extends 'base.html' %}
+
+{% block title %}Exécution...{% endblock %}
+
+{% block content %}
+
{{ output }}
+ OK
+{% endblock %}
diff --git a/src/templates/admin/document/manage.html b/src/templates/admin/document/manage.html
new file mode 100644
index 0000000..b29df97
--- /dev/null
+++ b/src/templates/admin/document/manage.html
@@ -0,0 +1,11 @@
+{% extends 'base.html' %}
+
+{% block title %}{{ doc.doc_name }} / {{ doc.branch }} (admin){% endblock %}
+
+{% block content %}
+ Gestion de {{ doc.doc_name }} / {{ doc.branch }}
+ Consulter
+ Compiler
+
+ Supprimer
+{% endblock %}
diff --git a/src/templates/admin/document/new.html b/src/templates/admin/document/new.html
new file mode 100644
index 0000000..ac12dd5
--- /dev/null
+++ b/src/templates/admin/document/new.html
@@ -0,0 +1,14 @@
+{% extends 'base.html' %}
+
+{% block title %}Nouveau document{% endblock %}
+
+{% block content %}
+
+{% endblock %}
diff --git a/src/templates/admin/index.html b/src/templates/admin/index.html
new file mode 100644
index 0000000..585a591
--- /dev/null
+++ b/src/templates/admin/index.html
@@ -0,0 +1,22 @@
+{% extends 'base.html' %}
+
+{% block title %}Documentation (admin){% endblock %}
+
+{% block content %}
+ Administration des documents
+ Nouveau document...
+ Liste des documents
+ {% if documents|length > 0 %}
+
+ {% for doc in documents %}
+ {% if doc.valid %}
+ - {{ doc.doc_name }} / {{ doc.branch }} Consulter Gérer
+ {% else %}
+ - {{ doc.doc_name }} / {{ doc.branch }} (document invalide) Supprimer le dossier
+ {% endif %}
+ {% endfor %}
+
+ {% else %}
+ Aucun document
+ {% endif %}
+{% endblock %}
diff --git a/src/templates/base.html b/src/templates/base.html
new file mode 100644
index 0000000..cec48f7
--- /dev/null
+++ b/src/templates/base.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+ {% block title %}{% endblock %}
+
+
+
+
+ {% block content %}{% endblock %}
+
+
+
diff --git a/src/templates/index.html b/src/templates/index.html
deleted file mode 100644
index e6a7abe..0000000
--- a/src/templates/index.html
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
- Documentation (admin)
-
-
-
- Administration des documents
- Nouveau document...
- Liste des documents
-
- {% for doc in documents %}
- {% if doc.valid %}
- - {{ doc.doc_name }} / {{ doc.branch }} Consulter
- {% else %}
- - {{ doc.doc_name }} / {{ doc.branch }} (document invalide)
- {% endif %}
- {% endfor %}
-
-
-
-
diff --git a/src/web/admin/admin.py b/src/web/admin/admin.py
new file mode 100644
index 0000000..a6436ff
--- /dev/null
+++ b/src/web/admin/admin.py
@@ -0,0 +1,9 @@
+from flask import Blueprint, render_template
+
+from data.document import Document
+
+bp = Blueprint('admin', __name__, url_prefix='/admin')
+
+@bp.route('/')
+def index():
+ return render_template("admin/index.html", documents=Document.list())
diff --git a/src/web/admin/admin_document.py b/src/web/admin/admin_document.py
new file mode 100644
index 0000000..d45f83c
--- /dev/null
+++ b/src/web/admin/admin_document.py
@@ -0,0 +1,41 @@
+import os
+from flask import Blueprint, render_template, redirect, url_for, request
+
+from web_utils.get_arg import get_arg
+
+from data.document import Document
+
+bp = Blueprint('admin_document', __name__, url_prefix='/admin/doc')
+
+@bp.route('/new', methods=['GET', 'POST'])
+def new():
+ if request.method == 'POST':
+ repo = request.form.get('repo')
+ doc_name = request.form.get('doc')
+ branch = request.form.get('branch')
+ source_dir = request.form.get('source')
+
+ if doc_name == "":
+ doc_name = os.path.splitext(os.path.basename(repo))[0]
+
+ output = Document.clone(repo, branch, doc_name, source_dir)
+
+ return render_template("admin/command_output.html", output = output, next = url_for('admin_document.manage', doc_name = doc_name, branch = branch))
+ else:
+ return render_template("admin/document/new.html")
+
+@bp.route('/manage//')
+def manage(doc_name, branch):
+ return render_template("admin/document/manage.html", doc=Document(doc_name, branch))
+
+@bp.route('/delete//')
+def delete(doc_name, branch):
+ doc = Document(doc_name, branch)
+ doc.delete()
+ return redirect(url_for('admin.index'), code=302)
+
+@bp.route('/delete_invalid//')
+def delete_invalid(doc_name, branch):
+ doc = Document(doc_name, branch, allow_invalid = True)
+ doc.delete_folder()
+ return redirect(url_for('admin.index'), code=302)
diff --git a/src/web/web_admin.py b/src/web/web_admin.py
deleted file mode 100644
index 0604826..0000000
--- a/src/web/web_admin.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from flask import Blueprint, render_template
-
-from data.document import Document
-
-bp = Blueprint('web_admin', __name__, url_prefix='/admin')
-
-@bp.route('/')
-def index():
- return render_template("index.html", documents=Document.list())