Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Halogen #215

Merged
merged 5 commits into from
Apr 28, 2021
Merged

Migrate to Halogen #215

merged 5 commits into from
Apr 28, 2021

Conversation

thomashoneyman
Copy link
Member

@thomashoneyman thomashoneyman commented Mar 28, 2021

This PR continues #199 by replacing the existing jQuery with Halogen, except for the iframe -- the iframe deserves its own conversation and so I've left it untouched for this pull request. I have avoided changing any features and the application should look and behave the exact same as it currently does.

Well...there's one difference: the old code tried to apply the Ace 'Dawn' theme, but it wasn't working; in this version the dawn theme is present. I can remove the theme altogether if desired, which I believe will default to the TextMate theme.

To review the code I would recommend pulling up the old index.html and old Main.purs files against the new Container.purs Halogen component, as the component wraps in functionality that was previously spread across those two files. To review the functionality I'd just make sure the editor works fine for you. I tested it by putting up the old editor and the new one side-by-side in browser tabs.

I've avoided doing some things that could be changed in the future if we want to clean things up a little:

  • I didn't introduce any routing; I instead still rely on the existing query string parsing
  • I didn't update to PureScript 0.14 / Halogen 6 (though I'd like to in the near future)
  • I only updated one line of CSS (the editor font size), but otherwise left it untouched.
  • I matched the Halogen HTML as exactly as possible to the old contents of index.html
  • I didn't introduce any new features or update any existing ones

My hope is that this unblocks some of the useful improvements @milesfrain provided a proof-of-concept for (like storing contents in the URL, re-enabling saving gists, and so on); with everything converted to Halogen those could be introduced one-by-one.


Here's a brief demonstration of the before-and-after. First, the current try.purescript.org:

Old.mov

Next, the Halogen version on localhost:

New.mov

@milesfrain
Copy link
Contributor

It looks like the CORS issue is introduced in #212.

For testing, I'm just pointing to:

  • https://compile.purescript.org for compilation
  • localhost/local path for serving all the prebuild .js files (which are built with purs 0.13.8 for all tests, even when the client is sometimes built with 0.14).

Here's a snapshot of a branch with the last working commit before CORS issues. You can cherry-pick the next commit to trigger the failure. Best guess on a possible cause (comment).

@thomashoneyman
Copy link
Member Author

thomashoneyman commented Mar 30, 2021

I followed up on that comment and that's absolutely the issue. I don't know why using a Json request body type causes a problem and using a String request body does not; I'll take a deeper look tomorrow, but if anyone else has ideas about this I'd appreciate hearing them.

@thomashoneyman
Copy link
Member Author

I've updated the request in question and things appear to be working correctly now. Now that I'm able to run things properly I can test this out and make sure it's ready for review.

@@ -181,6 +181,7 @@ body {
left: 0;
right: 0;
bottom: 0;
font-size: 13px;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the font size on the editor container works fine; setting it via the Ace bindings is not currently working and I'll need to file a bug with purescript-contrib/purescript-ace.

client/public/index.html Show resolved Hide resolved
client/src/Try/API.purs Show resolved Hide resolved
client/src/Try/Container.purs Show resolved Hide resolved
@thomashoneyman thomashoneyman marked this pull request as ready for review March 31, 2021 00:18
@thomashoneyman
Copy link
Member Author

If we agree to move this direction and this PR looks good, then I'd like to explore deploying a new version of Try PureScript for 0.14 before we start adding any new features.

@hdgarrood
Copy link
Collaborator

I followed up on that comment and that's absolutely the issue. I don't know why using a Json request body type causes a problem and using a String request body does not; I'll take a deeper look tomorrow, but if anyone else has ideas about this I'd appreciate hearing them.

I suspect that you were sending a JSON-encoded string to the server, e.g. the request might have looked like

POST /compile HTTP/1.1

"module Main where\nfoo = bar\n"

as opposed to what the server was expecting, which would have been

POST /compile HTTP/1.1

module Main where
foo = bar

This is where the "network" tab in the browser dev tools comes in handy.

Copy link
Collaborator

@hdgarrood hdgarrood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave it up to you to decide what you want to do about the debouncing. This looks good - I'm not a Halogen expert but the code is still relatively easy to follow, so nice work 👍

@thomashoneyman thomashoneyman merged commit 0bd14e2 into master Apr 28, 2021
@thomashoneyman thomashoneyman deleted the halogen-migration branch April 28, 2021 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants