-
Notifications
You must be signed in to change notification settings - Fork 50
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
Enable gist saving plus other updates #187
base: master
Are you sure you want to change the base?
Conversation
* Converted lots of HTML and JS code to PS * Converted from JQuery to Halogen Hooks * Using Tailwind CSS * Enabled gist saving * Enabled loading files from github repo paths * Editor state tracked in shareable url, rather than local storage
editor.renderer.setShowGutter(true); | ||
editor.setFontSize(13); | ||
editor.setShowPrintMargin(false); | ||
|
||
var session = editor.getSession(); | ||
|
||
session.setMode('ace/mode/haskell'); | ||
session.setOptions({ | ||
tabSize: 2, | ||
useSoftTabs: true | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- showGutter already defaults to true
- original font size is 13, but appears to default to 12. Can't edit this without fixing ace editor library to take a number rather than a string for font size.
- soft tabs enabled by default
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.js"></script> | ||
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/ace.js" charset="utf-8"></script> | ||
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/mode-haskell.js"></script> | ||
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/theme-dawn.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theme-dawn
does not appear to be used, so I removed it.
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Roboto:300,600"> | ||
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Roboto+Slab:300,600"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this font necessary? I think the default font looks pretty nice in the demo app.
@@ -1,17 +1,56 @@ | |||
{ | |||
"name": "trypurescript-client", | |||
"private": true, | |||
"name": "tps", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed from trypurescript-client
to make changing configs with these commands a bit less verbose:
npm config set tps:configpath "config/dev/*.purs"
npm config set tps:configpath "config/prod/*.purs"
|
||
"c1-lock-css": "# -- Strip away unused css from autogenerated purs files.", | ||
"c2-lock-css": "# -- This improves rebuild times, but won't allow adding new css.", | ||
"c3-lock-css": "# -- So re-run gen-css before making additional css changes.", | ||
"lock-css": "npm run bundle && npm run css-purge && npm run css2purs", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out that npm i
will reformat this file and remove the unnecessary newlines I added for readability. Really terrible that you can't add comments to json files without workaround like this. Would like to migrate to something better if it exists.
-- Compress source file contents. | ||
-- This avoids non-trivial HTML + JSON string escaping | ||
let | ||
objcomp = map (unwrap >>> compressToEncodedURIComponent) obj | ||
-- Convert object to JSON string | ||
let | ||
jsonStr = stringify $ encodeJson objcomp | ||
-- Pass JS files to execute in iframe | ||
putOutput $ App jsonStr $ JS js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JS files are compressed with lz-string because I couldn't figure out how to escape the contents correctly to pass to the iframe. It would be nice to escape these a bit more efficiently, although I don't think this compression/decompression step is a major performance issue.
-- | ||
-- Page to launch on startup and when clicking home button | ||
homeRoute :: String | ||
homeRoute = "/?github=milesfrain/tps/demo/examples/Home.purs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering changing these paths to expect the blob
part so they're easier for users to copy while browsing a repo. Then it just needs to be stripped out from the raw
url for loading.
https://github.com /milesfrain/tps/blob/demo/examples/Home.purs
https://raw.githubusercontent.com/milesfrain/tps/ demo/examples/Home.purs
case res of | ||
Left err -> pure { name, path, deps: [], src } | ||
where | ||
src = throwJSError $ "Could not get shim " <> name <> " at " <> shim.url <> ", " <> AX.printError err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should point to a guide on adding new shims
moduleCache :: Ref (Object Module) | ||
moduleCache = unsafePerformEffect (Ref.new Object.empty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping there would be a nice way to do this with memoize, but I couldn't figure it out. It doesn't seem like memoize can be used to bypass repeating effects (such as http requests in this case).
This is very difficult to review as-is because of its size. Can you please break this up into smaller PRs which address individual points? Also can you please back out the changes which already exist in other PRs? It's better to just get those changes in one at a time. |
Thanks for doing this, @milesfrain! I'd love to review this and I'm happy to see some improvements coming in. As @hdgarrood said, it's a little difficult to review a PR of this size, and it would be much easier to review and faster to merge PRs for individual points if it's possible to break this up. |
I agree that a giant wave of changes is not ideal. I can back out these feature additions:
But splitting-apart the remaining changes would involve a lot of throw-away effort to reach a working state between each PR and would be more code to review overall. The only code that ended up being reused across the rewrite is:
The code may be easiest to review by considering it as a full rewrite and exploring it as a fresh new project locally, rather than as an incremental change in the diff viewer. It's 1400 lines of commented PS code. No rush on getting this merged, since these features are available in the live demo, and I'm happy to use that in the meantime. I also don't want to take attention away from other tasks. I'll still do my best to help with the merge effort - starting with making another PR containing fewer new features. |
I would rather have more code to review overall if that allows making changes incrementally; I don't want to do a full rewrite. Most of the individual changes you've listed do make the most sense to do incrementally, in my mind. Also, I don't want to make changes as far-reaching as moving from jquery to halogen hooks, or moving to tailwind css, or changing the iframe strategy, without a proper justification. I think each of these things really needs its own issue to make the case for why it's a good idea. |
I split this up into six PRs: #190 though #195. #192 is still pretty significant. If this needs to be broken-up further, we should first agree on a commit sequence. This is one option:
But there's a pretty significant time cost to doing this, so I don't want to dive into that unless it's the only way to move forward with incorporating these changes. |
Live demo at https://try.ps.ai
Now we can launch cookbook recipes directly in the browser.
PRs and Issues addressed:
New features:
module Main
in editorCode quality improvements:
Questionable design choices:
Try
module prefix toTPS
, to distance from try-catch.Minor changes:
Minor bugs shared with original version:
Missing features:
view
-mode, auto-compile
, show-js
compile=false
there's still one compilation on loadIntegration next steps:
Other todos: