|
|
@ -3,6 +3,7 @@ import os
|
|
|
|
|
|
|
|
|
|
|
|
from flask import Flask, render_template, request, url_for, redirect, jsonify, abort, send_from_directory
|
|
|
|
from flask import Flask, render_template, request, url_for, redirect, jsonify, abort, send_from_directory
|
|
|
|
import markdown
|
|
|
|
import markdown
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
import frontmatter
|
|
|
|
import frontmatter
|
|
|
|
from datetime import datetime
|
|
|
|
from datetime import datetime
|
|
|
|
import json
|
|
|
|
import json
|
|
|
@ -40,7 +41,8 @@ def get_md_contents(filename, directory='./contents'):
|
|
|
|
''' Return contents from a filename as frontmatter handler '''
|
|
|
|
''' Return contents from a filename as frontmatter handler '''
|
|
|
|
with open(f"{directory}/{filename}", "r") as f:
|
|
|
|
with open(f"{directory}/{filename}", "r") as f:
|
|
|
|
metadata, content = frontmatter.parse(f.read())
|
|
|
|
metadata, content = frontmatter.parse(f.read())
|
|
|
|
html_content = markdown.markdown(content, extensions=['markdown.extensions.attr_list','markdown.extensions.codehilite','markdown.extensions.fenced_code'])
|
|
|
|
html_content = markdown.markdown(content, extensions=[
|
|
|
|
|
|
|
|
'markdown.extensions.attr_list', 'markdown.extensions.codehilite', 'markdown.extensions.fenced_code'])
|
|
|
|
return metadata, html_content
|
|
|
|
return metadata, html_content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -112,8 +114,6 @@ def p_info(project=None):
|
|
|
|
return render_template(template, **meta, content=content)
|
|
|
|
return render_template(template, **meta, content=content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route(f'/{base_url}/projects/<project>/<path:filename>')
|
|
|
|
@app.route(f'/{base_url}/projects/<project>/<path:filename>')
|
|
|
|
def sendStaticFiles(project, filename):
|
|
|
|
def sendStaticFiles(project, filename):
|
|
|
|
return send_from_directory(app.root_path + f'/projects/{project}/', filename, conditional=True)
|
|
|
|
return send_from_directory(app.root_path + f'/projects/{project}/', filename, conditional=True)
|
|
|
@ -122,11 +122,11 @@ def sendStaticFiles(project, filename):
|
|
|
|
@app.route(f'/{base_url}/hook/', methods=['GET', 'POST'])
|
|
|
|
@app.route(f'/{base_url}/hook/', methods=['GET', 'POST'])
|
|
|
|
def pull():
|
|
|
|
def pull():
|
|
|
|
if request.method == 'POST':
|
|
|
|
if request.method == 'POST':
|
|
|
|
import subprocess
|
|
|
|
subprocess.call(['sh', '/home/kamo/public_html/update.sh'])
|
|
|
|
output = subprocess.call(['sh', '/home/kamo/public_html/update.sh'])
|
|
|
|
print(request.form['payload'])
|
|
|
|
print(output)
|
|
|
|
return 'Updated'
|
|
|
|
return output
|
|
|
|
|
|
|
|
return 'GET method not supported'
|
|
|
|
return 'GET method not supported'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# RUN
|
|
|
|
# RUN
|
|
|
|
app.run(port="3132")
|
|
|
|
app.run(port="3132")
|
|
|
|