-
Notifications
You must be signed in to change notification settings - Fork 50
Enable gist saving plus other updates #187
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
Open
milesfrain
wants to merge
5
commits into
purescript:master
Choose a base branch
from
milesfrain:demo
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,794
−2,284
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Rewrite of TryPureScript using latest features of PS ecosystem, such as: | ||
* Halogen Hooks | ||
* Tailwind CSS | ||
|
||
Lots of HTML and JS code was eliminated. | ||
|
||
Also enables gist saving and tracking state in URL rather than local storage. | ||
|
||
### Local Development | ||
``` | ||
npm i | ||
npm config set tps:configpath "config/dev/*.purs" | ||
npm run gen-css # Create initial tailwind css files | ||
npm run start # Launch local dev server with automatic reload/refresh. | ||
|
||
# Optional: | ||
npm run build # To manually rebuild if IDE does not do this automatically. | ||
npm run lock-css # To speed up rebuilds if you're not adding new css classes. | ||
``` | ||
|
||
### Building for production | ||
``` | ||
npm config set tps:configpath "config/prod/*.purs" | ||
npm run prod # Create minified production build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
module Try.Config where | ||
|
||
appDomain :: String | ||
appDomain = "http://localhost:1234" | ||
|
||
tokenServerUrl :: String | ||
--tokenServerUrl = "http://localhost:7071/api/localtrigger" | ||
tokenServerUrl = "https://localtpsfunction.azurewebsites.net/api/localtps?code=Il1fqBKydiLWqoognUIzgppwi10qfmXjkhAa75yRg5S4S10LNfsiTw==" | ||
|
||
-- GitHub OAuth app for saving gists. | ||
-- This is tied to a specific app domain. | ||
clientID :: String | ||
clientID = "6f4e10fd8cef6995ac09" | ||
|
||
loaderUrl :: String | ||
loaderUrl = "js/output" | ||
--loaderUrl = "js/output" | ||
--loaderUrl = "http://localhost:8080" | ||
loaderUrl = "https://compile.purescript.org/output" | ||
|
||
compileUrl :: String | ||
compileUrl = "http://localhost:8081" | ||
|
||
mainGist :: String | ||
mainGist = "7ad2b2eef11ac7dcfd14aa1585dd8f69" | ||
--compileUrl = "http://localhost:8081" | ||
compileUrl = "https://compile.purescript.org" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require("../output/Main/index.js").main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
module Try.Config where | ||
|
||
appDomain :: String | ||
appDomain = "https://try.ps.ai" | ||
|
||
tokenServerUrl :: String | ||
tokenServerUrl = "https://tpsfunction.azurewebsites.net/api/tps?code=JmxFIJvNG9E4qFtrwyD2v40YIWAtKUt1HDxLQ9rjmP4bRafnxWjNZg==" | ||
|
||
-- GitHub OAuth app for saving gists. | ||
-- This is tied to a specific app domain. | ||
clientID :: String | ||
clientID = "3634da383bb531261af5" | ||
|
||
loaderUrl :: String | ||
loaderUrl = "https://compile.purescript.org/output" | ||
|
||
compileUrl :: String | ||
compileUrl = "https://compile.purescript.org" | ||
|
||
mainGist :: String | ||
mainGist = "7ad2b2eef11ac7dcfd14aa1585dd8f69" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/python3 | ||
import re | ||
import fileinput | ||
|
||
# Usage: | ||
# cat tailwind.css | ./css2purs.py > Tailwind.purs | ||
|
||
# vim Regex | ||
# /^\s*\.[^ ]* | ||
|
||
# Using list rather than set to preserve sorted order | ||
# Assuming that duplicates are always adjacent | ||
cssNames = [] | ||
|
||
def process(line): | ||
# Example input: | ||
# line = ' .-sm\:-space-y-0-w-1\/2:hover {' | ||
regName = re.compile('^\s*\.([^ ]*?[^\\\\])(:.*)? .*$') | ||
|
||
m = regName.match(line) | ||
|
||
if m: | ||
escaped = m.group(1) | ||
# Just escaped class name | ||
# -sm\:-space-y-0-w-1\/2 | ||
|
||
cssStr = escaped.replace('\\', '') | ||
# Remove escaped symbols - this is the CSS string | ||
# -sm:-space-y-0-w-1/2 | ||
|
||
# don't add duplicates | ||
# assuming always adjacent | ||
if len(cssNames) and cssNames[-1] == cssStr: | ||
return | ||
|
||
cssNames.append(cssStr) | ||
|
||
def cssToPs(cssStr): | ||
# Conversion to PureScript-compatible name | ||
# Must remove symbols | ||
|
||
def negRepl(m): | ||
return m.group(1) + 'neg' + m.group(3).upper() | ||
negSub = re.sub(r'(^|:)(-)(.)', negRepl, cssStr) | ||
# Replace leading dashes (used to represent negatives) with 'neg' | ||
# Camel-case for next word | ||
# negSm:negSpace-y-0-w-1/2 | ||
|
||
colonDivSub = negSub.replace(':', '-').replace('/', 'd') | ||
# replace colon separator with dash | ||
# replace division sign for fractions with 'd' | ||
# negSm-negSpace-y-0-w-1d2 | ||
|
||
def dashRepl(m): | ||
return m.group(1).upper() | ||
dashSub = re.sub(r'-(.)', dashRepl, colonDivSub) | ||
# Convert dash-separator to camelCase | ||
# negSmNegSpaceY0W1d2 | ||
|
||
# Debug prints | ||
# print('cssStr', cssStr) | ||
# print(escaped) | ||
# print(negSub) | ||
# print(colonDivSub) | ||
# print(dashSub) | ||
|
||
psName = dashSub | ||
print() | ||
print('-- | ' + cssStr) | ||
print(psName + ' :: ClassName') | ||
print(psName + ' = ClassName "' + cssStr + '"') | ||
|
||
for line in fileinput.input(): | ||
process(line) | ||
|
||
print('-- | Autogenerated from tailwind.css') | ||
print('module Tailwind where') | ||
print() | ||
print('import Halogen.HTML.Core (ClassName(..))') | ||
|
||
for cssName in cssNames: | ||
cssToPs(cssName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,56 @@ | ||
{ | ||
"name": "trypurescript-client", | ||
"name": "tps", | ||
"private": true, | ||
"config": { | ||
"configpath": "config/dev/*.purs" | ||
}, | ||
"scripts": { | ||
"clean": "rimraf output", | ||
"build": "spago bundle-app --path $npm_package_config_configpath --purs-args '--censor-lib --strict' --to public/js/index.js" | ||
"c-user-facing": "# --------- user facing scripts -------", | ||
|
||
"c-gen-css": "# -- Generate tailwind css AND purs css wrapper", | ||
"gen-css": "npm run build-css-only && npm run css2purs", | ||
|
||
"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", | ||
|
||
Comment on lines
+12
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It turns out that |
||
"c-build": "# -- Build purs code in project", | ||
"build": "spago build --path $npm_package_config_configpath", | ||
|
||
"c-start": "# -- Launch development server in web browser", | ||
"start": "npm run build && cp config/dev/index.js public && webpack-dev-server --port 1234 --open --config webpack.dev.js", | ||
|
||
"c-prod": "# -- Create minified production build", | ||
"prod": "npm run bundle && npm run css-purge && webpack --config webpack.prod.js", | ||
|
||
"c-wp-dev-build": "# -- Create unminified dev build. This is useful for troubleshooting the production build.", | ||
"wp-dev-build": "cp config/dev/index.js public && webpack --config webpack.dev.js", | ||
|
||
"c-serve-static": "# -- serves static files locally. For checking if everything was bundled correctly.", | ||
"serve-static": "http-server dist/ -c-1 -o tps --port 1234 -P http://localhost:1234\\?", | ||
|
||
"c-internal": "# -------- internal helper scripts -------", | ||
|
||
"bundle": "spago bundle-app --path $npm_package_config_configpath --to public/index.js", | ||
"build-css-only": "tailwindcss build css/tailwind_inputs.css -o public/tailwind.css", | ||
"css2purs": "cat public/tailwind.css | ./css/css2purs.py > src/Tailwind.purs", | ||
"css-purge": "NODE_ENV=production npm run build-css-only" | ||
}, | ||
"devDependencies": { | ||
"purescript": "^0.13.6", | ||
"purescript-psa": "^0.7.3", | ||
"rimraf": "^2.5.4", | ||
"spago": "^0.14.0" | ||
"clean-webpack-plugin": "^3.0.0", | ||
"copy-webpack-plugin": "^6.0.3", | ||
"css-loader": "^3.6.0", | ||
"cssnano": "^4.1.10", | ||
"exports-loader": "^1.1.0", | ||
"file-loader": "^6.0.0", | ||
"html-webpack-plugin": "^4.3.0", | ||
"style-loader": "^1.2.1", | ||
"tailwindcss": "^1.4.6", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.12", | ||
"webpack-dev-server": "^3.11.0", | ||
"webpack-merge": "^5.0.9", | ||
"xhr2": "^0.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
try.ps.ai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.error { | ||
position: absolute; | ||
z-index: 20; | ||
border-bottom: 2px dotted red; | ||
} | ||
|
||
/* Currently unsued, but can re-enable. Assuming it's spammy */ | ||
.warning { | ||
position: absolute; | ||
z-index: 20; | ||
border-bottom: 2px dotted #c4953a; | ||
} | ||
|
||
/* Can re-enable if there's an issue without this option | ||
.ace_gutter-tooltip { | ||
white-space: pre-wrap; | ||
} | ||
*/ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: