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

Replace roc-lang.org with WIP site #6004

Merged
merged 12 commits into from
Nov 20, 2023
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ roc_linux_x86_64.tar.gz
# nix
result

# tutorial
www/src/roc-tutorial

# Only keep Cargo.lock dependencies for the main compiler.
# Examples and test only crates should be fine to be unlocked.
# This remove unneccessary lock file versioning.
Expand All @@ -77,7 +74,11 @@ www/src/roc-tutorial
# checkmate
checkmate_*.json

www/build/
www/main
www/dist

# ignore the examples folder in the WIP website, this is copied from roc-lang/examples in when building the site
www/wip_new_website/content/examples
www/content/examples
www/examples-main.zip
www/examples-main
3 changes: 0 additions & 3 deletions www/.gitignore

This file was deleted.

File renamed without changes.
33 changes: 29 additions & 4 deletions www/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
# www.roc-lang.org

To view the website after you've made a change, execute:
## Prerequisites

- Linux or MacOS operating system, Windows users can use linux through WSL.
- Install [git](https://chat.openai.com/share/71fb3ae6-80d7-478c-8a27-a36aaa5ba921)
- Install [nix](https://nixos.org/download.html)

## Building the website from scratch

```bash
git clone https://github.com/roc-lang/roc.git
cd roc
nix develop
./www/build.sh
cd www/build
simple-http-server --nocache --index # already installed if you're using `nix develop`, otherwise use `cargo install simple-http-server`
# make the roc command available
export PATH="$(pwd)/target/release/:$PATH"
bash build-dev-local.sh
```

Open http://0.0.0.0:8080 in your browser.

## After you've made a change locally

In the terminal where the web server is running:
1. kill the server with Ctrl+C
2. re-run the build script
3. refresh the page in your browser

To view the website after you've made a change, execute:
```bash
bash build-dev-local.sh
```
Open http://0.0.0.0:8000 in your browser.
Open http://0.0.0.0:8080 in your browser.



Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ DIR="$(dirname "$0")"
cd "$DIR" || exit

rm -rf dist/
cp -r ../build dist/
mkdir -p dist/wip
roc run main.roc -- content/ dist/wip/
cp -r static/* dist/wip/
cp -r build dist/
cp -r public/* dist/
roc run main.roc -- content/ dist/

npx http-server dist/ -p 8080 -c-1 --cors
31 changes: 9 additions & 22 deletions www/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ cd $SCRIPT_RELATIVE_DIR

rm -rf build/
cp -r public/ build/
mkdir build/wip # for WIP site

# download the latest code for the examples
echo 'Downloading latest examples...'
curl -fLJO https://github.com/roc-lang/examples/archive/refs/heads/main.zip
unzip examples-main.zip
cp -R examples-main/examples/ wip_new_website/content/examples/
curl -fL -o examples-main.zip https://github.com/roc-lang/examples/archive/refs/heads/main.zip
rm -rf examples-main/
unzip -o examples-main.zip
cp -R examples-main/examples/ content/examples/

# relace links in wip_new_website/content/examples/index.md to work on the WIP site
sed -i 's|](/|](/wip/examples/|g' wip_new_website/content/examples/index.md
# relace links in content/examples/index.md to work on the WIP site
perl -pi -e 's|\]\(/|\]\(/examples/|g' content/examples/index.md

# clean up examples artifacts
rm -rf examples-main examples-main.zip
Expand All @@ -48,11 +48,10 @@ curl -fLJO https://github.com/roc-lang/roc/archive/www.tar.gz
# Download the latest pre-built Web REPL as a zip file. (Build takes longer than Netlify's timeout.)
REPL_TARFILE="roc_repl_wasm.tar.gz"
curl -fLJO https://github.com/roc-lang/roc/releases/download/nightly/$REPL_TARFILE
mkdir repl
tar -xzf $REPL_TARFILE -C repl
tar -xzf $REPL_TARFILE -C wip # note we also need this for WIP repl
rm $REPL_TARFILE
ls -lh repl
ls -lh wip

popd

Expand All @@ -77,9 +76,6 @@ rm -rf roc_nightly roc_releases.json

# we use `! [ -v GITHUB_TOKEN_READ_ONLY ];` to check if we're on a netlify server
if ! [ -v GITHUB_TOKEN_READ_ONLY ]; then
echo 'Building tutorial.html from tutorial.md...'
mkdir www/build/tutorial

cargo build --release --bin roc

roc=target/release/roc
Expand All @@ -96,19 +92,12 @@ else
mv roc_nightly* roc_nightly

roc='./roc_nightly/roc'

echo 'Building tutorial.html from tutorial.md...'
mkdir www/build/tutorial
fi

$roc version
$roc run www/generate_tutorial/src/tutorial.roc -- www/generate_tutorial/src/input/ www/build/tutorial/
mv www/build/tutorial/tutorial.html www/build/tutorial/index.html

# For WIP site
echo 'Building WIP site...'
$roc run www/wip_new_website/main.roc -- www/wip_new_website/content/ www/build/wip/
cp -r www/wip_new_website/static/* www/build/wip/
echo 'Building site markdown content'
$roc run www/main.roc -- www/content/ www/build/

# cleanup
rm -rf roc_nightly roc_releases.json
Expand Down Expand Up @@ -153,5 +142,3 @@ if [ -v GITHUB_TOKEN_READ_ONLY ]; then
rm -rf $BASIC_CLI_DIR/generated-docs
done <<< "$VERSION_NUMBERS"
fi

popd
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ In the future, a language reference will be on this page too.
## [Guides](#guides) {#guides}

- [FAQ (Frequently Asked Questions)](https://github.com/roc-lang/roc/blob/main/FAQ.md)
- [Platforms & Applications](/platforms)
- [Roc for Elm Programmers](https://github.com/roc-lang/roc/blob/main/roc-for-elm-programmers.md)
- [Tutorial](/tutorial)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ You can donate to Roc's development using:
- [GitHub Sponsors](https://github.com/sponsors/roc-lang)
- [Liberapay](https://liberapay.com/roc_lang)

All donations go through the [Roc Programming Language Foundation](https://foundation.roc-lang.org/), a registered [US 501(c)(3) nonprofit organization](https://en.wikipedia.org/wiki/501(c)(3)_organization), which means these donations are tax-exempt in the US.
All donations go through the [Roc Programming Language Foundation](https://foundation.roc-lang.org/), a registered <a href="https://en.wikipedia.org/wiki/501(c)(3)_organization">US <span class="nowrap">501(c)(3)</span> nonprofit organization</a>, which means these donations are tax-exempt in the US.

It also means that the foundation's tax filings are a [matter of public record](https://en.wikipedia.org/wiki/501(c)(3)_organization#Transparency), so you have real transparency into how your donations are advancing Roc!

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions www/wip_new_website/content/index.md → www/content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@

<section class="home-goals-container" aria-label="Roc's Design: Fast, Friendly, Functional">
<div role="presentation" class="home-goals-column">
<a href="/wip/fast" class="home-goals-content">
<a href="/fast" class="home-goals-content">
<h3 class="home-goals-title">Fast</h3>
<p class="home-goals-description">Roc code is designed to build fast and <span class="nowrap">run fast</span>. It compiles to machine code or WebAssembly.</p>
<p class="home-goals-learn-more">What does <i>fast</i> mean here?</p>
</a>
</div>
<div role="presentation" class="home-goals-column">
<a href="/wip/friendly" class="home-goals-content">
<a href="/friendly" class="home-goals-content">
<h3 class="home-goals-title">Friendly</h3>
<p class="home-goals-description">Roc's syntax, semantics, and included toolset all prioritize user-friendliness.</p>
<p class="home-goals-learn-more">What does <i>friendly</i> mean here?</p>
</a>
</div>
<div role="presentation" class="home-goals-column">
<a href="/wip/functional" class="home-goals-content">
<a href="/functional" class="home-goals-content">
<h3 class="home-goals-title">Functional</h3>
<p class="home-goals-description">
Roc has a small number of simple language primitives. It's a single-paradigm <span class="nowrap">functional language.</span></p>
Expand Down Expand Up @@ -57,7 +57,7 @@
<textarea aria-label="Input Roc code here, then press Enter to submit it to the REPL" rows="5" id="source-input" placeholder="Enter some Roc code here."></textarea>
</div>
</div>
<script type="module" src="/wip/site.js"></script>
<script type="module" src="/site.js"></script>
</section>

## [Examples](#examples) {#examples}
Expand All @@ -75,14 +75,14 @@ Here are some examples of how it can be used today.
<pre><samp class="code-snippet">main <span class="kw">=</span>
Stdout<span class="punctuation section">.</span>line <span class="literal">"Hello!"</span></samp></pre>
<p>You can use Roc to create scripts and command-line interfaces (CLIs). The compiler produces binary executables, so Roc programs can run on devices that don't have Roc itself installed.</p>
<p>As an example, the HTML for this website is generated using a simple Roc script. You can see <a href="https://github.com/roc-lang/roc/blob/main/www/wip_new_website/main.roc">the code for it</a> in the main Roc code repository.</p>
<p>If you're looking for a starting point for building a command-line program in Roc, <a href="https://github.com/roc-lang/basic-cli">basic-cli</a> is a popular platform to check out.</p>
<p>As an example, the HTML for this website is generated using a simple Roc script. You can see <a href="https://github.com/roc-lang/roc/blob/main/www/generate_website/main.roc">the code for it</a> in the main Roc code repository.</p>
<p>If youre looking for a starting point for building a command-line program in Roc, <a href="https://github.com/roc-lang/basic-cli">basic-cli</a> is a popular <a href="/platforms">platform</a> to check out.</p>
</div>
<div role="presentation" class="home-examples-column">
<h3 class="home-examples-title">Web Servers</h3>
<pre><samp class="code-snippet">handleReq <span class="kw">=</span> <span class="kw">\</span>request <span class="kw">-&gt;</span>
Task<span class="punctuation section">.</span>ok <span class="literal">{</span> body: <span class="comment">…</span> <span class="literal">}</span></samp></pre>
<p>You can also build web servers in Roc. <a href="https://github.com/roc-lang/basic-webserver">basic-webserver</a> is a platform with
<p>You can also build web servers in Roc. <a href="https://github.com/roc-lang/basic-webserver">basic-webserver</a> is a <a href="/platforms">platform</a> with
a simple interface: you write a function which takes a <code>Request</code>, does some I/O, and returns a <code>Response</code>.</p>
<p>Behind the scenes, it uses Rust's high-performance <a href="https://docs.rs/hyper/latest/hyper/">hyper</a> and <a href="https://tokio.rs/">tokio</a> libraries to execute your Roc function on incoming requests.</p>
<p>For database access, <a href="https://github.com/agu-z/roc-pg">roc-pg</a> lets you access a <a href="https://www.postgresql.org/">PostgreSQL</a> database&mdash;with your Roc types checked against the types in your database's schema.</p>
Expand All @@ -98,7 +98,7 @@ log(<span class="string">`Roc says </span><span class="kw">${</span>fn()<span cl
</div>

### [Other Examples](#other-examples) {#other-examples}
You can find more use cases and examples on the [examples page](/wip/examples)!
You can find more use cases and examples on the [examples page](/examples)!
</section>


Expand Down
File renamed without changes.
Loading