Skip to content

jefdaj/ortholang-demo

Repository files navigation

ortholang-demo

An interactive web demo + tutorial for OrthoLang. Try the live version at ortholang.pmb.berkeley.edu!

Install as a NixOS service

This is the easiest way to set it up, but requires NixOS. Probably a good choice if you're making a dedicated server. Just add something like this to your /etc/nixos/configuration.nix:

{
  imports =
    [ ...
      /home/jefdaj/ortholang-demo/service.nix
    ];

  ...

  services.ortholangDemo = {
    enable      = true;
    user        = "jefdaj";
    scratchDir  = "/tmp/ortholang-demo";
    logPath     = "/tmp/ortholang-demo.log";
    examplesDir = "/mnt/data/ortholang/examples";
    commentsDir = "/mnt/data/comments";
    uploadsDir  = "/mnt/data/uploads";
    port        = 45772;
  };

  ...

}

Install using Nix on another distro

You can also run it on another linux distro, or probably Mac OSX. First, nix-build ortholang and add it to your PATH. Note that you still need Nix for this.

Then run the server the Nix way:

nix-shell requirements.nix --command \
  ./ortholang-demo.py \
    -l /tmp/ortholang-demo.log \
    -e ortholang/examples \
    -c comments \
    -t /tmp/ortholang-demo \
    -p 5000 \
    -u /mnt/data/ortholang-users \
    -a /mnt/data/ortholang-users/passwords.txt \
    -s /mnt/data/ortholang-shared

... or the regular Debian + Python way:

# TODO need python-twisted-bin too?
sudo apt-get install python-dev
virtualenv .venv
source .venv/bin/activate
pip install -r requirements.txt
./ortholang-demo.py \
  -l /tmp/ortholang-demo.log \
  -e ortholang/examples \
  -c comments \
  -t /tmp/ortholang-demo \
  -p 5000 \
  -u /mnt/data/ortholang-users \
  -a /mnt/data/ortholang-users/passwords.txt \
  -s /mnt/data/ortholang-shared

Finally, visit localhost:5000 in your browser.

Gotchas:

  • do not install actual websockets stuff (gevent, eventlets, etc) as that seems to break it
  • when updating requirements.nix you might have to manually remove some dependencies on self."Twisted" to fix an infinite recursion bug

Serve

This is a terrible idea from a security perspective, but the fastest way to access it from elsewhere on the local network is:

sudo sysctl -w net.ipv4.conf.all.route_localnet=1
sudo iptables -t nat -I PREROUTING -p tcp --dport 5000 -j DNAT --to 127.0.0.1:80

Replace 5000 with whatever port you want.

Files

The server will put tmpfiles in ./tmpdirs. Consider linking that to /tmp or a ramdisk if IO becomes an issue. It will also save user comments in ./comments.

Updating the docs

This part is a little awkward. It uses the ortholang submodule to generate templates/reference.md and check the example scripts. Do something like:

git submodule update --init --recursive
nix-shell docs.nix --command 'stack build && stack exec docs'

TODOs

layout:

  • try highlighting the user tab a different color
  • expand/fix repl sizing on different screens
  • fix ortholang terminal width to match screen?
  • mobile version that only shows the docs half + a warning about that?

docs:

  • update the guest page to be less pushy
  • fix first table in reference.md
  • update reference.md to match current ortholang
  • inputs, outputs -> collapsed into type
  • add a macro to type :help , and use it to make all the functions into links
  • tutorial index at the top

repl:

  • blur the background properly (separate css element for it i guess)
  • try making the background orange too
  • have clients ping the server periodically so their guest repls can be removed on disconnect
  • send repl commands to server and back before showing, so collaborative editing can work
  • make sure all errors are visible in the web repl
    • parse errors not showing up on site; it just silently fails
  • loading a new script should also kill the currently running one
  • should clicking a function name kill the currently running one too? yeah
  • separate signal for the progress bar updates, which should be displayed in the command bar

files:

  • pre-download all the blastdbget databases
  • pre-run all the example scripts and use a shared shake cache (see ortholang todo)
  • new user login needs dir created with examples symlink (done?)
  • zip untyped result lists before downloading (make those first)

ortholang:

  • bug: show when script is empty causes a crash
  • check that no seqid hashes are slipping through to the user-facing output
  • :type should include the thing and a colon before the type
  • add shared shake cache for multi-user setups (mainly the demo)
  • allow result to be a list, and allow the list to be untyped
  • :help should show a list of possible fuzzy matches + completions if nothing matches exactly
  • should allow multiple results in an untyped list
  • zip function that takes an untyped list and creates a zip
  • result var should also be able to be a raw untyped list
  • readable error when calling a fn with wrong types