Giter Club home page Giter Club logo

pony-playground's Introduction

Pony Playground

A web interface for running Pony code.

Heavily based upon the rust playpen.

Installation

See INSTALL.md for installation instructions for a real box.

Running your own Pony-Playpen locally

System Requirements

  • Docker
  • Rust (E.g. install via Rustup)

Running the web server

First, create the Docker image that playpen will use:

docker build docker -t ponylang-playpen

Get a github personal access token. Only the gist scope needs to be selected. Put it into the GITHUB_TOKEN environment variable.

 export GITHUB_TOKEN="..."

It will be used for creating gists with the playgrounds contents. If you want to test without a valid token, really all you need to do is to set the variable to some gibberish.

Next, spin up the server.

cargo run --bin playpen

You should now be able to browse localhost on port 8000 and play.

pony-playground's People

Contributors

dependabot[bot] avatar alexcrichton avatar thestinger avatar respeccing avatar jonas-schievink avatar chris-morgan avatar shaedrich avatar plietar avatar seantallen avatar timnn avatar brson avatar mfelsche avatar tilpner avatar mcast avatar huonw avatar whipsch avatar birkenfeld avatar cjwelborn avatar frewsxcv avatar richo avatar causal-agent avatar knifa avatar freefull avatar cbreeden avatar semarie avatar crumblingstatue avatar manishearth avatar bfabio avatar diggsey avatar aneeshusa avatar

Stargazers

Sean P. Myrick V19.1.7.2 avatar Emilien Jegou avatar Andrew Chou avatar

Watchers

James Cloos avatar  avatar Sean P. Myrick V19.1.7.2 avatar

pony-playground's Issues

LLVM IR generation is broken

This is the output of current master:



nightly-20191123 [release]
compiled with: llvm 7.1.0 -- cc (Alpine 8.3.0) 8.3.0
Defaults: pic=true
Building builtin -> /root/.pony/ponyup/ponyc-nightly-20191123-musl/packages/builtin
Building . -> /tmp/tmp.olfgho/main
Building collections -> /root/.pony/ponyup/ponyc-nightly-20191123-musl/packages/collections
Building ponytest -> /root/.pony/ponyup/ponyc-nightly-20191123-musl/packages/ponytest
Building time -> /root/.pony/ponyup/ponyc-nightly-20191123-musl/packages/time
Building random -> /root/.pony/ponyup/ponyc-nightly-20191123-musl/packages/random
Building itertools -> /root/.pony/ponyup/ponyc-nightly-20191123-musl/packages/itertools
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Writing ./main.ll

expected output: the LLVM IR from ./main.ll and no compilation logs.

Add Browser based integration tests

It would be finest if we had (headless) browser-based integration tests, verifying the basic operations this playground offers.

Any pointer on good tools to use here are very much welcome.

Meta Tags, OpenGraph and Twitter Cards

Related to ponylang/pony-tutorial#546

This could be implemented statically into static/web.html at first, but it would make sense to prospectively make it dynamic by converting it to a template and creating the tags depending on the Query params.

I know, I'm crazy, but one should be allowed to dream every once in a while ๐Ÿ˜‰

Add (API) Integration Tests for basic operations

To verify that the playground (minus the frontend) is actually working, we need some integration tests to run upon every PR and merge to main:

  • Running some piece of code after calling the API
  • Compiling some piece of code to ASM/LLVM IR output
  • OPTIONAL: sharing a gist using the github API - this one is hard to mock, actually.

For more information on how this is imagined to look like:

Refactor getQueryParameters() to use URL/URLSearchParams

Would it make sense to refactor getQueryParameters() to use URL/URLSearchParams, so we don't have to maintain custom code over native one or do you prefer not to fix something that ain't broken?

function getQueryParameters() {
var a = window.location.search.substr(1).split('&');
if (a === "") return {};
var b = {};
for (var i = 0; i < a.length; i++) {
var p = a[i].split('=');
if (p.length != 2) continue;
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
}
return b;
}

By the way, this

function optionalLocalStorageGetItem(key) {
try {
return localStorage.getItem(key);
} catch (e) {
return null;
}

could also be rewritten as

function optionalLocalStorageGetItem(key) {
    return localStorage.getItem(key) ?? null;
}

and so can

theme = optionalLocalStorageGetItem("theme");
if (theme === null) {
set_theme(editor, themelist, "GitHub");
} else {
set_theme(editor, themelist, theme);
}

as

theme = optionalLocalStorageGetItem("theme");
set_theme(editor, themelist, theme ?? "GitHub");

as well as

var themes = themelist.themes;
themes.sort(function (a, b) {
if (a.caption < b.caption) {
return -1;
} else if (a.caption > b.caption) {
return 1;
}
return 0;
});

which can be shortened to

var themes = themelist.themes;
themes.sort((a, b) => a.caption.localeCompare(b.caption));

Then, we have

var classes = mappings[arguments[1]];
if (classes) {
return '<span class="' + classes + '">' + arguments[2] + '</span>';
} else {
return arguments[2];
}

which doesn't need the else, since it has a return:

var classes = mappings[arguments[1]];
if (classes) {
    return '<span class="' + classes + '">' + arguments[2] + '</span>';
}
return arguments[2];

The following is an interesting case:

if (on_success) {
on_success(req.responseText);
}
} else {
if (on_fail) {
on_fail(req.status, req.responseText);
}
}

it could either be rewritten as

if (req.status == expect) {
    if (on_success) {
        on_success(req.responseText);
    }
} else if (on_fail) {
    on_fail(req.status, req.responseText);
}

or

if (req.status == expect && on_success) {
    on_success(req.responseText);
}
if (req.status != expect && on_fail) {
    on_fail(req.status, req.responseText);
}

Next, we have a bunch of these:

asmButton.onclick = function () {
compile("asm", result, session.getValue(), asmButton);
};
irButton.onclick = function () {
compile("llvm-ir", result, session.getValue(), irButton);
};
gistButton.onclick = function () {
shareGist(result, session.getValue(), gistButton);
};

when they only contain a single function call, instead of creating a bunch of overhead with new anonymous wrapper functions, you could use bind:

asmButton.onclick = compile.bind(window, "asm", result, session.getValue(), asmButton);

irButton.onclick = compile.bind(window, "llvm-ir", result, session.getValue(), irButton);

gistButton.onclick = shareGist.bind(window, result, session.getValue(), gistButton);

clearResultButton.onclick = clear_result.bind(window, result);

themes.onkeyup = themes.onchange = set_theme.bind(window, editor, themelist, themes.options[themes.selectedIndex].text);

request.ontimeout = set_result.bind(window, result, "<p class=error>Connection timed out" +
                "<p class=error-explanation>Are you connected to the Internet?");

One could possibly also refactor editGo(), editShowRegion(), editShowLine(), and editShowPoint(), but that'd be slightly more than a simplification.

Miscellaneous

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.