-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3728488
commit 8ff5758
Showing
11 changed files
with
671 additions
and
11 deletions.
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
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,47 @@ | ||
/* https://css-tricks.com/box-sizing/#aa-universal-box-sizing-with-inheritance */ | ||
html { | ||
box-sizing: border-box; | ||
} | ||
*, *:before, *:after { | ||
box-sizing: inherit; | ||
} | ||
|
||
.vstack { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
min-height: 100%; | ||
justify-content: center; | ||
} | ||
|
||
body > .vstack, body.vstack { | ||
min-height: 100vh; | ||
} | ||
|
||
.vstack>*.expand { | ||
flex-grow: 1; | ||
} | ||
|
||
.vstack>*.cover { | ||
align-self: stretch; | ||
} | ||
|
||
.hstack { | ||
display: flex; | ||
/* not sure why this needs width 100% but vstack is flex grow */ | ||
width: 100%; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
body>.hstack { | ||
min-height: 100vh; | ||
} | ||
|
||
.hstack>*.expand { | ||
flex-grow: 1; | ||
} | ||
|
||
.hstack>*.cover { | ||
align-self: stretch; | ||
} |
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,136 @@ | ||
import eyg/website/news/archive | ||
import eyg/website/news/edition.{Edition} | ||
import eyg/website/utils | ||
import gleam/bit_array | ||
import gleam/int | ||
import gleam/list | ||
import gleam/result | ||
import gleam/string | ||
import lustre/attribute as a | ||
import lustre/element | ||
import lustre/element/html as h | ||
import midas/task as t | ||
import snag | ||
|
||
const replace_string = "!CONTENT!" | ||
|
||
pub fn build() { | ||
use layout <- t.do(t.read("layout2.css")) | ||
let layout = #("/assets/layout.css", layout) | ||
use pea <- t.do(t.read("src/eyg/website/news/pea.webp")) | ||
let pea = #("/assets/pea.webp", pea) | ||
use brocolli <- t.do(t.read("src/eyg/website/news/brocolli.webp")) | ||
let brocolli = #("/assets/brocolli.webp", brocolli) | ||
|
||
use template <- t.do(t.read("src/eyg/website/news/edition/email.html")) | ||
use template <- t.try( | ||
bit_array.to_string(template) | ||
|> result.replace_error(snag.new("not a utf8 string")), | ||
) | ||
let assert [latest, ..] = archive.published | ||
let content = | ||
element.to_string(edition.render(latest, list.length(archive.published))) | ||
let template = string.replace(template, replace_string, content) | ||
|
||
t.done([ | ||
#("/news/_email.html", <<template:utf8>>), | ||
layout, | ||
pea, | ||
brocolli, | ||
..web_editions(archive.published, layout) | ||
]) | ||
} | ||
|
||
// archive is a reverse order stack of editions | ||
fn web_editions(editions, layout) { | ||
list.index_map(list.reverse(editions), fn(edition, index) { | ||
let index = index + 1 | ||
let Edition(title: title, ..) = edition | ||
let edition = edition.render(edition, index) | ||
|
||
let path = "/news/editions/" <> int.to_string(index) <> "/index.html" | ||
let page = | ||
h.html([], [ | ||
h.head([], [ | ||
h.meta([a.attribute("charset", "UTF-8")]), | ||
h.meta([ | ||
a.name("viewport"), | ||
a.attribute("content", "width=device-width, initial-scale=1.0"), | ||
]), | ||
h.title([], "EYG news: " <> title), | ||
h.meta([ | ||
a.name("description"), | ||
a.attribute( | ||
"content", | ||
"Updates from the development of the EYG language and editor.", | ||
), | ||
]), | ||
utils.css(layout), | ||
h.link([a.rel("shortcut icon"), a.href("/assets/pea.webp")]), | ||
h.script( | ||
[ | ||
a.attribute("defer", ""), | ||
a.attribute("data-domain", "eyg.run"), | ||
a.src("https://plausible.io/js/script.js"), | ||
], | ||
"", | ||
), | ||
]), | ||
h.body( | ||
[ | ||
a.class("vstack"), | ||
a.style([ | ||
// #("margin", "12px auto"), | ||
// #("max-width", "660px"), | ||
#("background", edition.charcoal), | ||
// #("padding", "12px"), | ||
#("border-radius", "12px"), | ||
]), | ||
], | ||
[ | ||
// inline_subscribe(), | ||
h.div( | ||
[ | ||
a.style([ | ||
#("margin", "12px auto"), | ||
#("max-width", "660px"), | ||
#("background", "white"), | ||
#("padding", "12px"), | ||
#("border-radius", "12px"), | ||
]), | ||
], | ||
[edition], | ||
), | ||
inline_subscribe(), | ||
], | ||
), | ||
]) | ||
|> element.to_document_string | ||
|> bit_array.from_string | ||
#(path, page) | ||
}) | ||
} | ||
|
||
fn inline_subscribe() { | ||
h.div( | ||
[ | ||
a.style([ | ||
#("margin", "0 auto"), | ||
#("width", "600px"), | ||
#("background", "white"), | ||
]), | ||
], | ||
[ | ||
h.script( | ||
[ | ||
a.src( | ||
"https://eocampaign1.com/form/b3a478b8-39e2-11ef-97b9-955caf3f5f36.js", | ||
), | ||
a.attribute("async", ""), | ||
a.attribute("data-form", "b3a478b8-39e2-11ef-97b9-955caf3f5f36"), | ||
], | ||
"", | ||
), | ||
], | ||
) | ||
} |
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,13 @@ | ||
Edition has articles/stories/features/items, which are multiple so not used | ||
instead we say an edition has content. Content could be anything, discounted word was material/subject | ||
|
||
periodical/newsletter/publication refer to the total sequence of editions | ||
newsletter sounds like the thing that is shipped to subscribers so the whole thread is called news | ||
|
||
Edition is a singal instance issue/volume where other names | ||
Chapters is a subset of an article or somethingelse | ||
almanac as the yearly summary | ||
|
||
New issues are added to the archive which is the source of truth, | ||
not called source because articles can have sources | ||
|
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,55 @@ | ||
import eyg/website/news/edition.{Edition} | ||
|
||
pub const published = [ | ||
Edition( | ||
"2024-08-24", | ||
"JavaScript interpreter available on npm", | ||
" | ||
EYG is an intermediate representation for programs that never crash and can run in all kinds of environments. | ||
Running EYG programs in JavaScript environments is now possible using the `eyg-run` package published to [npm](https://www.npmjs.com/package/eyg-run). | ||
This interpreter can be used on [node.js](https://nodejs.org) and in the browser. | ||
## Running programs on node. | ||
EYG programs can be run on node, using npx, as follows: | ||
```json | ||
echo '{\"0\":\"a\",\"f\":{\"0\":\"p\",\"l\":\"Log\"},\"a\":{\"0\":\"s\",\"v\":\"Hello, World!\"}}' > hello.json | ||
cat hello.json | npx eyg-run | ||
``` | ||
The default node runner includes only the `Log` effect. | ||
To implement other external effects, follow the browser instructions. | ||
## Running in the browser. | ||
To run in the browser requires building a runner. | ||
In this example the `Log` effect is handled by the `window.alert` API. | ||
```js | ||
import { exec, Record, native } from \"https://esm.run/eyg-run\"; | ||
const extrinsic = { | ||
Log(message) { | ||
window.alert(message) | ||
return (Record()) | ||
} | ||
} | ||
async function run() { | ||
let source = {\"0\":\"a\",\"f\":{\"0\":\"p\",\"l\":\"Log\"},\"a\":{\"0\":\"s\",\"v\":\"Hello, World!\"}} | ||
let result = await exec(source, extrinsic) | ||
console.log(native(result)) | ||
} | ||
run() | ||
``` | ||
## Documentation of the EYG intermediate representation (IR) | ||
Documentation describing the JSON format for EYG programs is now available on github. | ||
[https://github.com/CrowdHailer/eyg-lang/tree/main/ir](https://github.com/CrowdHailer/eyg-lang/tree/main/ir)", | ||
), | ||
] |
Binary file not shown.
Oops, something went wrong.