See #505 and #1494. Fix options of Nginx beautifier

This commit is contained in:
Glavin Wiechert 2017-04-15 02:26:27 -03:00
parent c10c9355d6
commit 85a744fb98
3 changed files with 199 additions and 174 deletions

View File

@ -10,194 +10,194 @@ error_log logs/error.log info;
events events
{ {
worker_connections 1024; worker_connections 1024;
} }
http http
{ {
include mime.types; include mime.types;
default_type application/octet-stream; default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" ' # '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; # '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main; #access_log logs/access.log main;
sendfile on; sendfile on;
#tcp_nopush on; #tcp_nopush on;
#keepalive_timeout 0; #keepalive_timeout 0;
keepalive_timeout 65; keepalive_timeout 65;
#gzip on; #gzip on;
server server
{ {
listen 80; listen 80;
server_name localhost; server_name localhost;
#charset koi8-r; #charset koi8-r;
#access_log logs/host.access.log main; #access_log logs/host.access.log main;
location / location /
{ {
root /usr/share/nginx/html; root /usr/share/nginx/html;
index index.html index.htm; index index.html index.htm;
} }
#error_page 404 /404.html; #error_page 404 /404.html;
# redirect server error pages to the static page /50x.html # redirect server error pages to the static page /50x.html
# #
error_page 500 502 503 504 /50x.html; error_page 500 502 503 504 /50x.html;
location = /50x.html location = /50x.html
{ {
root /usr/share/nginx/html; root /usr/share/nginx/html;
} }
# proxy the PHP scripts to Apache listening on 127.0.0.1:80 # proxy the PHP scripts to Apache listening on 127.0.0.1:80
# #
#location ~ \.php$ { #location ~ \.php$ {
# proxy_pass http://127.0.0.1; # proxy_pass http://127.0.0.1;
#} #}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
# #
#location ~ \.php$ { #location ~ \.php$ {
# root html; # root html;
# fastcgi_pass 127.0.0.1:9000; # fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php; # fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params; # include fastcgi_params;
#} #}
# deny access to .htaccess files, if Apache's document root # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one # concurs with nginx's one
# #
#location ~ /\.ht { #location ~ /\.ht {
# deny all; # deny all;
#} #}
} }
server server
{ {
listen 80; listen 80;
include mime.types; include mime.types;
server_name dv; server_name dv;
location /nginxstatic/ location /nginxstatic/
{ {
alias /srv/http/dv/; alias /srv/http/dv/;
limit_rate 250k; limit_rate 250k;
} }
location / location /
{ {
#root /srv/http/dv/; #root /srv/http/dv/;
#index index.html; #index index.html;
limit_rate 1M; limit_rate 1M;
#limit_conn addr 1; #limit_conn addr 1;
proxy_pass http://localhost:3000/; proxy_pass http://localhost:3000/;
} }
} }
server server
{ {
listen 80; listen 80;
server_name ip.dv; server_name ip.dv;
root /home/http/ip/; root /home/http/ip/;
include mime.types; include mime.types;
location / location /
{ {
try_files $uri $uri/ /index.php; try_files $uri $uri/ /index.php;
} }
location ~ .php$ location ~ .php$
{ {
try_files $uri =404; try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm/socket_name.socket; fastcgi_pass unix:/var/run/php5-fpm/socket_name.socket;
fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php; fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params; include fastcgi_params;
} }
} }
server server
{ {
listen 80; listen 80;
server_name pma.dv; server_name pma.dv;
location / location /
{ {
root /home/http/pma/; root /home/http/pma/;
index index.php; index index.php;
} }
location ~ \.php$ location ~ \.php$
{ {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock; fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php; fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/http/pma/$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /home/http/pma/$fastcgi_script_name;
include fastcgi_params; include fastcgi_params;
} }
} }
server server
{ {
listen 80; listen 80;
server_name swissecurity.coelis; server_name swissecurity.coelis;
location / location /
{ {
root /srv/http/swissecurity-fm/; root /srv/http/swissecurity-fm/;
index index.html; index index.html;
} }
} }
server server
{ {
listen 80; listen 80;
server_name p1.dv; server_name p1.dv;
location / location /
{ {
proxy_pass http://127.0.0.1:1337/; proxy_pass http://127.0.0.1:1337/;
} }
} }
server server
{ {
listen 80; listen 80;
server_name s.dev; server_name s.dev;
location / location /
{ {
proxy_pass http://127.0.0.1:1337/; proxy_pass http://127.0.0.1:1337/;
} }
} }
# another virtual host using mix of IP-, name-, and port-based configuration # another virtual host using mix of IP-, name-, and port-based configuration
# #
#server { #server {
# listen 8000; # listen 8000;
# listen somename:8080; # listen somename:8080;
# server_name somename alias another.alias; # server_name somename alias another.alias;
# location / { # location / {
# root html; # root html;
# index index.html index.htm; # index index.html index.htm;
# } # }
#} #}
# HTTPS server # HTTPS server
# #
#server { #server {
# listen 443 ssl; # listen 443 ssl;
# server_name localhost; # server_name localhost;
# ssl_certificate cert.pem; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # ssl_prefer_server_ciphers on;
# location / { # location / {
# root html; # root html;
# index index.html index.htm; # index index.html index.htm;
# } # }
#} #}
} }

View File

@ -6,7 +6,21 @@ module.exports = class NginxBeautify extends Beautifier
link: "https://github.com/denysvitali/nginxbeautify" link: "https://github.com/denysvitali/nginxbeautify"
options: { options: {
Nginx: true Nginx: {
spaces: ["indent_with_tabs", "indent_size", "indent_char", (indent_with_tabs, indent_size, indent_char) ->
if indent_with_tabs or indent_char is "\t"
0
else
indent_size
]
tabs: ["indent_with_tabs", "indent_size", "indent_char", (indent_with_tabs, indent_size, indent_char) ->
if indent_with_tabs or indent_char is "\t"
indent_size
else
0
]
dontJoinCurlyBracet: true
}
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->

View File

@ -1,3 +1,11 @@
# Get Atom defaults
scope = ['source.conf']
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = { module.exports = {
name: "Nginx" name: "Nginx"
@ -20,16 +28,19 @@ module.exports = {
defaultBeautifier: "Nginx Beautify" defaultBeautifier: "Nginx Beautify"
options: options:
spaces: indent_size:
title: "Spaces" type: 'integer'
type: "number" default: defaultIndentSize
default: 0 minimum: 0
description: "Indent with spaces" description: "Indentation size/length"
tabs: indent_char:
title: "Tabs" type: 'string'
type: "number" default: defaultIndentChar
default: 1 description: "Indentation character"
description: "Indent with tabs" indent_with_tabs:
type: 'boolean'
default: defaultIndentWithTabs
description: "Indentation uses tabs, overrides `Indent Size` and `Indent Char`"
dontJoinCurlyBracet: dontJoinCurlyBracet:
title: "Don't join curly brackets" title: "Don't join curly brackets"
type: "boolean" type: "boolean"