Go to file
Nicolas Wavrant 46a08fb2de README: Add example of nginx config 2024-01-08 01:38:51 +00:00
dev sw.js: support calling /edit on a directory path 2020-07-10 08:41:30 +02:00
priv Make /dev folder public 2017-11-08 20:49:19 +01:00
.gitignore Add .gitignore 2017-11-08 21:05:14 +01:00
README.md README: Add example of nginx config 2024-01-08 01:38:51 +00:00

README.md

PlayJS

PlayJS is a simple-to-use fully web implemented web IDE, using only web standards and latest HTML5 features.

Using only web standards, PlayJS allow you to download your website sources locally in your browser, to edit it, test it still locally, and then push the changes live.

Requirements

Thanks to web capabilities, PlayJS only needs in order to work :

  • A recent web browser
  • A web server with Redirect and DAV mods enabled

Installation

  1. clone this repository in /var/html
  2. Generate a htpasswd with htpasswd -c /etc/apache2/htpasswd your_username
  3. Copy the apache configuration file below, replacing the variables ${} as needed.
  4. Reload apache
  5. Connect to your website with your browser and start hacking !

Example of web server config

Apache

<VirtualHost *:443>
    ServerName ${DOMAIN_NAME}

    SSLEngine on
    SSLProtocol ALL -SSLv2 -SSLv3
    SSLCertificateFile ${PATH_TO_SSL_CERTIFICATE}
    SSLCertificateKeyFile ${PATH_TO_SSL_KEY}

    # Turn off automatic DirectoryIndexing 
    # And use RewriteEnigne to emulate it
    DirectoryIndex disabled

    RewriteEngine On

    # Rewrite rules for the root directory
    RewriteCond "%{REQUEST_METHOD}" "(GET)"
    RewriteRule "^/(.*)/$" "/$1/index.html" [PT,L]
    RewriteCond "%{REQUEST_METHOD}" "(GET)"
    RewriteRule "^/$" "/index.html" [PT,L]

    SetEnvIf Origin "^https://${DOMAIN_NAME}" ORIGIN_DOMAIN=$0
    Header always set Access-Control-Allow-Origin "%{ORIGIN_DOMAIN}e" env=ORIGIN_DOMAIN
    Header always set Access-Control-Allow-Credentials "true" env=ORIGIN_DOMAIN
    Header always set Access-Control-Allow-Methods "PROPFIND, PROPPATCH, COPY, MOVE, DELETE, MKCOL, LOCK, UNLOCK, PUT, GETLIB, VERSION-CONTROL, CHECKIN, CHECKOUT, UNCHECKOUT, REPORT, UPDATE, CANCELUPLOAD, HEAD, OPTIONS, GET, POST" env=ORIGIN_DOMAIN
    Header always set Access-Control-Allow-Headers "Overwrite, Destination, Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control, Authorization" env=ORIGIN_DOMAIN
    Header set Cache-Control "private, max-age=0, must-revalidate"
    Header set Vary "Origin,Cookie,Authorization"

    Header set Service-Worker-Allowed "/"

    DeflateCompressionLevel 9
    DavLockDB /var/www/play.dav.lock

    AddCharset utf-8 .txt

    DocumentRoot /var/www/play

	<Directory "/var/www/play">
        Dav On
        Options -Indexes

        AuthType Basic
        AuthName "Authentification Required"
        AuthUserFile "/etc/apache2/htpasswd"

        <LimitExcept GET OPTIONS>
            Require valid-user
        </LimitExcept>
	</Directory>

	<Directory "/var/www/play/priv">
        Dav On
        AuthType Basic
        AuthName "Authentification Required"
        AuthUserFile "/etc/apache2/htpasswd"
        Options -Indexes

        <LimitExcept OPTIONS>
            Require valid-user
        </LimitExcept>
	</Directory>

	<Directory /var/www/play/.git>
		Options -Indexes
		Order deny,allow
        Deny from all
	</Directory>

    CustomLog /var/log/apache2/play-access.log combined
	ErrorLog /var/log/apache2/play-error.log
</VirtualHost>

Nginx

server {
  listen 443 ssl;
  server_name play.wavrant.xyz;

  ssl_certificate     ${PATH_TO_SSL_CERTIFICATE};
  ssl_certificate_key ${PATH_TO_SSL_KEY};

  access_log  /var/log/nginx/play_access.log;
  error_log  /var/log/nginx/play_error.log info;

  # Service worker is set up only if user accesses /dev.
  # Then it should serve the full website, which is the whole
  # point of this app. For this, we need to widen the service
  # work scope by using this header.
  add_header Service-Worker-Allowed /;

  root /srv/www/play/;
  index index.html;

  location / {
    dav_methods PUT DELETE MKCOL COPY MOVE;
    dav_ext_methods OPTIONS PROPFIND LOCK UNLOCK;
    dav_access user:rw;

    limit_except GET OPTIONS {
      auth_basic "Authentification Required";
      auth_basic_user_file /etc/nginx/htpasswd;
    }
  }

  location /priv {
    dav_methods PUT DELETE MKCOL COPY MOVE;
    dav_ext_methods OPTIONS PROPFIND LOCK UNLOCK;
    dav_access user:rw;

    auth_basic "Authentification Required";
    auth_basic_user_file /etc/nginx/htpasswd;
  }
}