• Stars
    star
    474
  • Rank 89,997 (Top 2 %)
  • Language
    Prolog
  • License
    Other
  • Created over 9 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SWI-Prolog for SHaring: a SWI-Prolog web IDE

SWISH: A web based SWI-Prolog environment

There are three ways to use SWISH, which we list in increasing order of complexity:

  1. Use the online version
  2. Deploy the Docker image
  3. Install locally

Online versions

SWISH can be used to access SWI-Prolog at the address below. We try to keep this server continuously online. You can use these servers for playing, courses or sharing and discussing ideas.

We have not yet dealt with scalable hosting nor with really reliable and scalable storage for saved programs. We hope to keep all your programs online for at least multiple years.

Docker image

We maintain Docker images at the swipl organization at Docker Hub. A bluffer's guide to run SWISH with R if you have Docker installed is as simple as this:

docker run -d --net=none --name=rserve swipl/rserve
docker run -d -p 3050:3050 --volumes-from rserve -v $(pwd):/data swipl/swish

There are many configuration options for SWISH, notably for authentication, email notifications and extension plugins. See the docker-swish repo for details.

Local installation

Get submodules

cd to your swish root directory and run

git submodule update --init

If you have make installed you can configure the desired packs by editing the PACKS variable and run the following to download them and configure those that need to be configured.

make packs

Get JavaScript requirements

Using Yarn

Install Yarn for your platform. On Ubuntu, this implies getting node and npm by installing two packages and next use npm to install yarn (some older Linux versions need nodejs-legacy instead of nodejs):

sudo apt install npm nodejs
sudo npm i yarn -g

Once you have yarn, run the following from the toplevel of swish to get the dependencies:

yarn
make src

Download as zip

As installing node and yarn is not a pleasure on all operating systems, you can also download the dependencies as a single zip file from http://www.swi-prolog.org/download/swish/swish-node-modules.zip. Unpack the zip file, maintaining the directory structure, from the swish root directory to create the directory web/node_modules. If you have make installed you can install the above .zip file using

make yarn-zip

Last updated: Dec 16, 2019: upgraded dependencies, new archive name

Get the latest SWI-Prolog

Install the latest SWI-Prolog development version. As SWISH is very much in flux and depends on the recent SWI-Prolog pengines and sandboxing libraries, it is quite common that you need the nightly build (Windows) or build the system from the current git development repository swipl-devel.git.

Apr 25, 2019: Works for a quite large range of SWI-Prolog versions. The current swipl-devel.git snapshot fixes an issue in CSV downloading, emitting CORS and cache control HTTP headers near the end of the CSV output.

Other dependencies

Rendering Prolog terms as graphs requires Graphviz. The avatar system requires the convert utility from ImageMagic. These are available as packages for virtually any Linux system, e.g., on Debian based systems do

sudo apt-get install imagemagick
sudo apt-get install graphviz

Running SWISH

With a sufficiently recent Prolog installed, start the system by opening run.pl either by running swipl run.pl (Unix) or opening run.pl from the Windows explorer.

Now direct your browser to http://localhost:3050/

If you want to know what the latest version looks like, go to https://swish.swi-prolog.org/

Configuring SWISH

There is a lot that can be configured in SWISH. Roughly:

  • Make additional libraries available, e.g., RDF support, database connections, link to R, etc.

  • Configure authentication and authorization. The default is not to demand and run commands sandboxed. At the other extreme you can configure the system to demand login for all access and provide full access to Prolog.

Configuration is done by reading *.pl files from the directory config-enabled. The directory config-available contains templates that can be copied and optionally edited to create a configuration.

See README.md in config-available for details.

Running SWISH without sandbox limitations

By default, SWISH does not require the user to login but lets you run only safe commands. If you want to use SWISH for unrestricted development, enable the config file auth_http_always.pl:

mkdir -p config-enabled
(cd config-enabled && ln -s ../config-available/auth_http_always.pl)

Next, for first usage, you need to create a user. The authentication module defines swish_add_user/0, which asks for details about the user to be created and updates or creates a file called passwd. At the moment Group and E-Mail are stored, but not used.

?- swish_add_user.
% Password file: /home/jan/src/prolog/swish/passwd (update)
User name: bob
Real name: Bob Hacker
Group:     user
E-Mail:    [email protected]
Password:
(again):
true.

If you now try to run a command in SWISH, it will prompt for a user and password. After authentication you can run any Prolog predicate.

NOTE Authentication uses HTTP digest authentication by default. This authentication method uses a challenge-response method to verify the password and ensures the credentials change with every request such that old credentials cannot be re-used by an attacker. Unfortunately, the server stores the password as the SHA1 hash created from the user, password and realm. This is relatively vulnerable to brute-force attacks for anyone who gains access to the password file due to the low computational overhead of SHA1 and the lack of a user-specific salt. Also note that the exchanged commands and replies are not encrypted. Secure servers should use HTTPS.

Optional login

Instead of using auth_http_always.pl you can use auth_http.pl, which allows for unauthenticated -sandboxed- usage as well as logging in to the server and get unrestricted access. In addition, several social login modules are provided to login using Google, etc. Currently these provide no additional rights. A more fine grained authorization scheme is planned.

Running as a service

The script daemon.pl is provided to run SWISH as a service or daemon on Unix systems. Run this to get an overview of the options.

./daemon.pl --help

This script can be used to start SWISH as a daemon from the command line, start SWISH from service managers such as upstart or systemd and simplifies running as an HTTPS server. See https://github.com/triska/letswicrypt.

Running SWISH as additional local IDE

You can run SWISH alongside your normal Prolog development tools. The cleanest way to do so is by using myswish.pl and install this in your local Prolog library. See myswish.pl for details on how to set this up.

Design

Most of the application is realised using client-side JavaScript, which can be found in the directory web/js. The JavaScript files use RequireJS for dependency tracking and jQuery for structuring the JavaScript as jQuery plugins. The accompanying CSS is in web/css. More details about the organization of the JavaScript is in web/js/README.md

There are two overal pages. web/swish.html provides a static page and lib/page.pl provides a Prolog frontend to generate the overal page or parts thereof dynamically. The latter facilitates smoothless embedding in SWI-Prolog web applications.

Development and debugging

No building is needed to run the system from sources. For public installations you probably want to create the minified JavaScript and CSS files to reduce network traffic and startup time. You need some more tools for that:

% sudo npm install -g jsdoc
% sudo npm install -g requirejs
% sudo npm install -g clean-css-cli

You also need GNU make installed as make and SWI-Prolog as swipl. With all that in place, the following command creates the minified versions:

% make min

The default main page (/) is generated from lib/page.pl. It uses minified JavaScript and CSS from web/js/swish-min.js web/css/swish-min.css when available. If the minified files are not present, the server automatically includes the full source. The generated files may be removed using

make clean

Alternatively, use of the minified files can be disable from Prolog using this command and reloading the page:

?- debug(nominified).

Documentation

The JavaScript is documented using JsDoc. The generated documentation is available in web/js/doc/index.html.

More Repositories

1

swipl-devel

SWI-Prolog Main development repository
C
895
star
2

swipl

SWI-Prolog stable releases
C
203
star
3

swipl-wasm

Run SWI-Prolog in your browser using WebAssemply
HTML
74
star
4

pengines

Pengine and Prolog scratchpad
HTML
56
star
5

packages-jpl

JPL: The Prolog <-> Java interface
Java
48
star
6

npm-swipl-wasm

SWI-Prolog WebAssembly build as a NPM package
JavaScript
29
star
7

packages-cpp

The SWI-Prolog C++ interface
C++
28
star
8

packages-swipy

Python interface for SWI-Prolog
C
28
star
9

packages-semweb

The SWI-Prolog RDF store
Prolog
28
star
10

contrib-swiplcs

Interface from C# to SWI-Prolog
C#
22
star
11

packages-chr

CHR: Leuven Constraint Handling Rules
Prolog
22
star
12

packages-http

The SWI-Prolog HTTP server and client libraries
Prolog
22
star
13

roadmap

Discuss future development
20
star
14

tabled-prolog-book

Programming in Tabled Prolog by David S Warren
TeX
20
star
15

sCASP

Top-down interpreter for ASP programs with Constraints
Prolog
19
star
16

plweb

SWI-Prolog web server sources for www.swi-prolog.org
Prolog
16
star
17

packages-xpce

The graphics toolkit for SWI-Prolog
C
14
star
18

packages-mqi

Machine Query Interface
Python
13
star
19

bench

Prolog benchmarks (`van Roy' set)
Prolog
13
star
20

docker-swipl

Docker images for SWI-Prolog
Dockerfile
12
star
21

packages-pengines

Pengines: Prolog engines
Prolog
11
star
22

docker-swish

Docker file for SWISH
Shell
9
star
23

packages-swipl-win

Portable Qt-based console for SWI-Prolog by Carlo Capelli
C++
9
star
24

packages-clpqr

CLP(Q,R): constraints over rational numbers and floats by Leslie de Koninck
Prolog
8
star
25

issues

Dummy repository for issue tracking
8
star
26

packages-plunit

The SWI-Prolog Unit Testing library
Prolog
8
star
27

packages-R

SWI-Prolog to R Project for Statistical Computing interface
Prolog
8
star
28

contrib-protobufs

An interface to Google Protocol Buffers (protobuf)
Prolog
7
star
29

packages-inclpr

Constraint solver for nonlinear (polynomial) constraints over reals
Prolog
7
star
30

packages-sweep

GNU-Emacs interface that embeds Prolog as an Emacs module
Emacs Lisp
7
star
31

packages-clib

Assorted external libraries: processes, sockets, MIME, CGI, etc.
C
7
star
32

rclswi

ROS2 bridge for SWI-Prolog
Prolog
7
star
33

webstat

Examine SWI-Prolog resources and data using your browser
JavaScript
6
star
34

packages-cql

High level database interface
Prolog
6
star
35

packages-odbc

The SWI-Prolog ODBC interface
C
6
star
36

packages-nlp

The SWI-Prolog NLP support library (stemming, etc.)
C
6
star
37

packages-regex

Pure Prolog regex implementation
Prolog
6
star
38

packages-table

The SWI-Prolog library for accessing structured files
C
5
star
39

contrib-plfann

SWI-Prolog interface to FANN (http://leenissen.dk/fann/)
C
5
star
40

packages-indent

Reformatter for Prolog source code
Prolog
5
star
41

packages-pldoc

The SWI-Prolog documentation system
Prolog
5
star
42

packages-RDF

The SWI-Prolog RDF/XML parser
Prolog
5
star
43

misc-emacs

Demo customization for PceEmacs
Prolog
4
star
44

packages-ssl

The SWI-Prolog SSL interface
C
4
star
45

packages-paxos

SWI-Prolog replicating key-value store
Prolog
4
star
46

packages-PDT

Support files for PDT: Prolog Development Tools
C
4
star
47

docker-swipl-build-mingw

Docker to cross-compile SWI-Prolog for Windows
Dockerfile
4
star
48

contrib-space

SWI-Prolog spatial indexing package
C++
4
star
49

packages-utf8proc

Provide Unicode normalization and info using utf8proc
C
4
star
50

plweb-www

Submodule of plweb.git that contains the (wiki) web-pages
HTML
4
star
51

packages-sgml

The SWI-Prolog SGML/XML/HTML parser
C
4
star
52

contrib-plosc

Open Sound Control (OSC) for SWI-Prolog
C
3
star
53

plweb-examples

3
star
54

contrib-InterProlog

InterProlog, adusted for SWI-Prolog
Java
3
star
55

misc-winlibs

Required libraries for compiling on Windows (binaries)
C++
3
star
56

packages-cppproxy

A network-based SWI-Prolog <-> C++ interface
Prolog
3
star
57

packages-bdb

The SWI-Prolog BerkelyDB interface
C
3
star
58

packages-redis

Redis client library
Prolog
3
star
59

docker-swish-public

Docker spec used to run the public swish instance
Shell
3
star
60

packages-pcre

SWI-Prolog package for access to Perl Regular Expressions
Prolog
3
star
61

packages-jasmine

The SWI-Prolog interface to the Jasmine OODB
C
3
star
62

SWI-Prolog.github.io

Organization pages
3
star
63

packages-zlib

The SWI-Prolog zlib compressed stream interface
Prolog
3
star
64

packages-windows

Example DLL and windows registry access library
C
2
star
65

packages-ltx2htm

SWI-Prolog LaTeX to HTML translation for the documentation
Prolog
2
star
66

contrib-tipc

The SWI-Prolog TIPC interface
C
2
star
67

libXpm

XPM image library for xpce
C
2
star
68

dleak

Memory leak debugger
C
2
star
69

packages-prosqlite

Prolog to SQLite interface
Prolog
2
star
70

clpqr-examples

Examples and test cases for clp(QR)
Prolog
2
star
71

contrib-minisat

minisat solver by Michael Codish, Vitaly Lagoon, Peter J. Stuckey.
C++
1
star
72

distro-debian

Configuration files for creating a Debian package
Makefile
1
star
73

packages-yaml

YAML reader and writer
C
1
star
74

plweb-blog

Blog posts on SWI-Prolog
1
star
75

misc-libXpm

Modified version of libXpm used by XPCE on MS-Windows
C
1
star
76

misc-macos-build

Setup to make binaries for MacOS
1
star
77

misc-bdwgc

The Boehm-Demers-Weiser garbage collector for SWI-Prolog
C
1
star
78

misc-C-sicstus

Use SWI-Prolog foreign code on SICStus Prolog
C
1
star
79

py-swi-prolog

Build SWI-Prolog as a Python package
Python
1
star
80

packages-archive

Interface to libarchive
C
1
star
81

packages-stomp

STOMP client for message brokers
Prolog
1
star