Skip to content

Syntax highlighter #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def post_config(name: str):
content = flask.request.get_json()
nginx_path = flask.current_app.config['NGINX_PATH']

if not os.path.exists(nginx_path):
return flask.jsonify({'success': False, 'error_msg': 'Config dir is not found, edit config file or create config dir for nginx'}), 500

with io.open(os.path.join(nginx_path, name), 'w') as f:
f.write(content['file'])

Expand All @@ -57,6 +60,10 @@ def get_domains():
sites_available = []
sites_enabled = []

if not os.path.exists(config_path):
return flask.render_template('domains.html', error_msg='Config dir is not found, edit config file or create config dir for nginx'), 500


for _ in os.listdir(config_path):

if os.path.isfile(os.path.join(config_path, _)):
Expand Down Expand Up @@ -127,6 +134,8 @@ def post_domain(name: str):
:return: Returns a status about the success or failure of the action.
"""
config_path = flask.current_app.config['CONFIG_PATH']
if not os.path.exists(config_path):
return flask.jsonify({'success': False, 'error_msg': 'Config dir is not found, edit config file or create config dir for nginx'}), 500
new_domain = flask.render_template('new_domain.j2', name=name)
name = name + '.conf.disabled'

Expand Down
1 change: 1 addition & 0 deletions app/static/ace.min.js

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions app/static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,20 @@ textarea {
[class*="or lower hidden"] {
display: none !important;
}
}
#editor {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.parent-editor{
width:100%;
height: 600px;
display:inline-block;
position:relative;
}
.ace_editor{
font-size: 15px;
}
8 changes: 4 additions & 4 deletions app/static/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function enable_domain(name, enable) {
}

function update_domain(name) {
var _file = $('#file-content').val();
var code = editor.getValue();
$('#dimmer').addClass('active');

$.ajax({
Expand All @@ -60,7 +60,7 @@ function update_domain(name) {
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: JSON.stringify({
file: _file
file: code
}),
statusCode: {
200: function() { setTimeout(function(){ fetch_domain(name) }, 400) }
Expand Down Expand Up @@ -116,7 +116,7 @@ function fetch_html(url) {
}

function update_config(name) {
var _file = $('#file-content').val();
var code = editor.getValue();
$('#dimmer').addClass('active');

$.ajax({
Expand All @@ -125,7 +125,7 @@ function update_config(name) {
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: JSON.stringify({
file: _file
file: code
}),
statusCode: {
200: function() {
Expand Down
2 changes: 1 addition & 1 deletion app/static/custom.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading