mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-30 01:37:17 +00:00
New script create_new_web_module permits to rapidly create a new pre-configured webpage from a template.
This commit is contained in:
parent
6afbf77af0
commit
71b2757ed2
6 changed files with 132 additions and 2 deletions
30
var/www/Flask_base_template.py
Normal file
30
var/www/Flask_base_template.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python2
|
||||
# -*-coding:UTF-8 -*
|
||||
|
||||
'''
|
||||
Flask functions and routes for the trending modules page
|
||||
'''
|
||||
import redis
|
||||
from flask import Flask, render_template, jsonify, request, Blueprint
|
||||
|
||||
# ============ VARIABLES ============
|
||||
import Flask_config
|
||||
|
||||
app = Flask_config.app
|
||||
cfg = Flask_config.cfg
|
||||
|
||||
MODULENAME = Blueprint('MODULENAME', __name__, template_folder='templates')
|
||||
|
||||
# ============ FUNCTIONS ============
|
||||
def one():
|
||||
return 1
|
||||
|
||||
# ============= ROUTES ==============
|
||||
|
||||
@MODULENAME.route("/MODULENAME/", methods=['GET'])
|
||||
def MODULENAME_page():
|
||||
return render_template("MODULENAME.html")
|
||||
|
||||
|
||||
# ========= REGISTRATION =========
|
||||
app.register_blueprint(MODULENAME)
|
44
var/www/create_new_web_module.py
Executable file
44
var/www/create_new_web_module.py
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env python2
|
||||
# -*-coding:UTF-8 -*
|
||||
|
||||
"Hepler to create a new webpage associated with a module."
|
||||
|
||||
import os
|
||||
|
||||
def createModuleFolder(modulename):
|
||||
path_module = os.path.join('modules', modulename)
|
||||
os.mkdir(path_module)
|
||||
|
||||
# create html template
|
||||
with open('templates/base_template.html', 'r') as templateFile:
|
||||
template = templateFile.read()
|
||||
template = template.replace('MODULENAME', modulename)
|
||||
|
||||
os.mkdir(os.path.join(path_module, 'templates'))
|
||||
with open(os.path.join(os.path.join(path_module, 'templates'), modulename+'.html'), 'w') as toWriteTemplate:
|
||||
toWriteTemplate.write(template)
|
||||
|
||||
# create html header template
|
||||
with open('templates/header_base_template.html', 'r') as header_templateFile:
|
||||
header = header_templateFile.read()
|
||||
header = header.replace('MODULENAME', modulename)
|
||||
|
||||
with open(os.path.join(os.path.join(path_module, 'templates'), 'header_{}.html'.format(modulename) ), 'w') as toWriteHeader:
|
||||
toWriteHeader.write(header)
|
||||
|
||||
|
||||
#create flask template
|
||||
with open('Flask_base_template.py', 'r') as flaskFile:
|
||||
flask = flaskFile.read()
|
||||
flask = flask.replace('MODULENAME', modulename)
|
||||
|
||||
with open(os.path.join(path_module, 'Flask_{}.py'.format(modulename)), 'w') as toWriteFlask:
|
||||
toWriteFlask.write(flask)
|
||||
|
||||
|
||||
def main():
|
||||
rep1 = raw_input('New module name: ')
|
||||
createModuleFolder(rep1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -25,7 +25,13 @@
|
|||
{% include 'navbar.html' %}
|
||||
|
||||
<div id="page-wrapper">
|
||||
<p> Raw skeleton webpage </p>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header" data-page="page-rawSkeleton" >rawSkeleton</h1>
|
||||
</div>
|
||||
<!-- /.col-lg-12 -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
</div>
|
||||
<!-- /#page-wrapper -->
|
||||
|
||||
|
|
48
var/www/templates/base_template.html
Normal file
48
var/www/templates/base_template.html
Normal file
|
@ -0,0 +1,48 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Analysis Information Leak framework Dashboard</title>
|
||||
|
||||
<!-- Core CSS -->
|
||||
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='font-awesome/css/font-awesome.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='css/sb-admin-2.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='css/dygraph_gallery.css') }}" rel="stylesheet" type="text/css" />
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="{{ url_for('static', filename='js/dygraph-combined.js') }}"></script>
|
||||
<script language="javascript" src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/jquery.flot.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/jquery.flot.pie.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/jquery.flot.time.js') }}"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{% include 'navbar.html' %}
|
||||
|
||||
<div id="page-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header" data-page="page-termsfrequency" >MODULENAME</h1>
|
||||
</div>
|
||||
<!-- /.col-lg-12 -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
|
||||
</div>
|
||||
<!-- /#page-wrapper -->
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
activePage = "page-MODULENAME"
|
||||
$("#"+activePage).addClass("active");
|
||||
});
|
||||
</script>
|
||||
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -25,6 +25,7 @@
|
|||
</ul>
|
||||
</li>
|
||||
|
||||
<li id='page-myNewModule'><a href="{{ url_for('myNewModule.myNewModule_page') }}"><i class="glyphicon glyphicon-new-window"></i> myNewModule page</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
|
1
var/www/templates/header_base_template.html
Normal file
1
var/www/templates/header_base_template.html
Normal file
|
@ -0,0 +1 @@
|
|||
<li id='page-MODULENAME'><a href="{{ url_for('MODULENAME.MODULENAME_page') }}"><i class="glyphicon glyphicon-new-window"></i> MODULENAME </a></li>
|
Loading…
Reference in a new issue