Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
cb0d373
Move md files to new directory
shaedrich Apr 12, 2023
04ed734
Setup enhance.dev
shaedrich Apr 12, 2023
dd6b690
move more stuff
shaedrich Apr 12, 2023
8a29e71
Setup new basic app structure
shaedrich Apr 12, 2023
ee3f1c9
enhance about and license page
shaedrich Apr 13, 2023
86b4a87
error handling
shaedrich Apr 13, 2023
94121d0
Note about the 2023 enhance.dev rework
shaedrich Apr 13, 2023
3e5479d
Restore original index behavior
shaedrich Apr 13, 2023
bfc7e3a
remove unused lines of code
shaedrich Apr 13, 2023
83a9d72
Remove old pre-enhance.dev stuff
shaedrich Apr 13, 2023
bfffd86
remove unused images
shaedrich Apr 13, 2023
d75aee5
refactor(listing): :recycle: Sort index md list desc
shaedrich May 6, 2024
d82c3c0
fix(markdown): :truck: Fix missing file extension
shaedrich May 6, 2024
99bdd74
feat(setup): :sparkles: Add option for static build
shaedrich May 6, 2024
9e61605
feat(setup): :rocket: Add deployment action (for static build)
shaedrich May 6, 2024
39de6e6
fix(markdown): :fire: remove duplicated file
shaedrich May 6, 2024
eba1653
fix(setup): :bug: YAML ident (who doesn't love that?)
shaedrich May 6, 2024
c1eefb1
refactor(setup): :rocket: Use runner OS from GitHub standard runners
shaedrich May 6, 2024
fa12891
feat(setup): :rocket: Recursive directory creation
shaedrich May 6, 2024
2146460
refactor(setup): :rocket: More explicit directory creation
shaedrich May 6, 2024
ed77764
fix(setup): :rocket: Add environment to action job for secrets
shaedrich May 6, 2024
7985169
refactor(listing): :recycle: Loop md files in reverse order for desc …
shaedrich May 7, 2024
c288911
refactor(skeleton): :truck: Change links to correct repository
shaedrich May 8, 2024
859b3db
refactor(skeleton): :truck: Rename wtf.com to wtf.org
shaedrich May 8, 2024
29845c2
fix(skeleton): :adhesive_bandage: Re-add GitHub ribbon
shaedrich May 8, 2024
6b6ac6b
refactor(skeleton): :truck: Replace AWS links with data URIs
shaedrich May 8, 2024
3807689
fix(skeleton): :bug: Re-add static license page
shaedrich May 8, 2024
9020055
fix(skeleton): :bug: For some reason, the array was seen as part of t…
shaedrich May 8, 2024
471564c
refactor(skeleton): :adhesive_bandage: Add HTML file extension to lic…
shaedrich May 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .arc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ wtfjs.com
@static
staging wtfjs-staging
production wtfjs-production
prune true

@aws
profile personal
Expand All @@ -18,3 +19,6 @@ get /about
get /license
get /wtfs
get /wtfs/:wtfID

@plugins
enhance/arc-plugin-enhance
23 changes: 23 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on:
push:
branches:
- feature/enhance.dev-rework

jobs:
build:
environment: production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Install Dependencies
run: npm install
- run: node build-static.mjs
- name: 📂 Sync files
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.ftp_host }}
username: ${{ secrets.ftp_username }}
password: ${{ secrets.ftp_password }}
local-dir: ./static/

17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
node_modules/
.env

# Enhance temp files
.enhance/

# Generated assets
public/static.json
public/bundles/
public/pages/

# Architect CloudFormation
sam.json
sam.yaml

.DS_Store

# Static built
static/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Share your wtfjs moment
---

It has never been easier to contribute a wtf to wtfjs.com!
It has never been easier to contribute a wtf to wtfjs.org!

- fork this repo
- add your wtf under `src/shared/md` (format: `yyyy-mm-dd-title.md`)
Expand Down
20 changes: 20 additions & 0 deletions app/api/$$.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { readdirSync } from 'fs'
import { URL } from 'url'

export async function get() {
// Read markdown file
const docsURL = new URL(`../md`, import.meta.url)
const docs = readdirSync(docsURL.pathname, 'utf-8')

return {
json: {
docs: docs.map(doc => {
let docName = doc.replace(/\.md$/, '')
return {
url: `/wtfs/${docName}`,
title: docName.replace(/-/g, ' '),
}
}),
}
}
}
33 changes: 33 additions & 0 deletions app/api/wtfs/$wtfId.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { readFileSync } from 'fs'
import { URL } from 'url'
import { Arcdown } from 'arcdown'
const arcdown = new Arcdown()

export async function get(req) {
// Get requested path
const { path: activePath } = req
let docPath = activePath.replace(/^\/?wtfs\//, '') || 'index'

// Read markdown file
const docURL = new URL(`../../md/${docPath}.md`, import.meta.url)
let docMarkdown
try {
docMarkdown = readFileSync(docURL.pathname, 'utf-8')
} catch(err) {
if (err.code === 'ENOENT') {
return {
statusCode: 404,
}
}
throw err
}

// Convert to HTML and add to store
const doc = await arcdown.render(docMarkdown)
return {
json: {
title: docPath.replace(/-/g, ' '),
message: doc,
}
}
}
31 changes: 6 additions & 25 deletions src/shared/layout.js → app/elements/site-layout.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
var fs = require('fs')
var path = require('path')
var css = fs.readFileSync(path.join(__dirname, 'index.css')).toString()

module.exports = function layout(body) {
return `
<!DOCTYPE html> <!-- OOoooooh HTML5! -->
<html>
<head>
<title>wtfjs - a little code blog about that language we love despite giving us so much to hate</title>
<style type=text/css>${css}</style>
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<!--
JavaScript is a language we love despite it giving us so much to hate.

This is a collection of those very special irregularities, inconstancies and just plain painfully unintuitive moments for the language of the web.
-->
</head>
<body>
export default function layout({ html }) {
return html`
<div id="wrap">
<div id="nav">
<ul>
Expand All @@ -34,12 +16,11 @@ module.exports = function layout(body) {
<a href="http://dtrejo.com">David Trejo</a>.
</h2>

<div id="content">${body}</div>
<div id="foot">wtfjs is <a href="/license">free software</a>. get the <a href="http://github.com/brianleroux/wtfjs">source on github</a>. </div>
<div id="content"><slot></slot></div>
<div id="foot">wtfjs is <a href="/license">free software</a>. get the <a href="http://github.com/shaedrich/wtfjs">source on github</a>. </div>
</div>
<a href="http://github.com/brianleroux/wtfjs"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub" /></a>
<a href="http://github.com/shaedrich/wtfjs"><img style="position: absolute; top: 0; right: 0; border: 0;" src="data:application/xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPEVycm9yPjxDb2RlPkFjY2Vzc0RlbmllZDwvQ29kZT48TWVzc2FnZT5BY2Nlc3MgRGVuaWVkPC9NZXNzYWdlPjxSZXF1ZXN0SWQ+UlRXM0NQQjFXNEtFUEZCWDwvUmVxdWVzdElkPjxIb3N0SWQ+UW1nM2ZJRkRxU1hLNkJ4NFJtUzBpdVVwMDJGUzFWdGJtT2tXOVh4K0MraHBGSmFuMDU2MDNzSDhMUWpKc2F4Qjl2OHhXaFIvRE5vPTwvSG9zdElkPjwvRXJyb3I+" alt="Fork me on GitHub" /></a>
<script src="/jquery-1.4.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/app.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-190386-6']);
Expand All @@ -55,4 +36,4 @@ module.exports = function layout(body) {
</html>
<!-- 3 > 2 >= 1 -->
`
}
}
23 changes: 23 additions & 0 deletions app/head.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//import { getStyles } from '@enhance/arc-plugin-styles'

//const { linkTag } = getStyles

export default function Head () {
return `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>wtfjs - a little code blog about that language we love despite giving us so much to hate</title>
<link rel="icon" href="/_public/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="/_public/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="/_public/index.css">
<!--
JavaScript is a language we love despite it giving us so much to hate.

This is a collection of those very special irregularities, inconstancies and just plain painfully unintuitive moments for the language of the web.
-->
</head>
`
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Ha! This one is great.
3 > 2 > 1 // false
</code>

Remember how [true sometimes has a value](https://wtfjs.com/wtfs/2010-02-15-true-has-a-value) so in the above 3 > 2 evaluates to true making the second part of the expression evaluate true > 1 which is false. Of course! Thanks to [void_0](http://twitter.com/void_0) for this one!
Remember how [true sometimes has a value](https://wtfjs.org/wtfs/2010-02-15-true-has-a-value) so in the above 3 > 2 evaluates to true making the second part of the expression evaluate true > 1 which is false. Of course! Thanks to [void_0](http://twitter.com/void_0) for this one!
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
So, [null is not an object](https://wtfjs.com/wtfs/2010-02-12-null-is-not-an-object) though sometimes null is a Number.
So, [null is not an object](https://wtfjs.org/wtfs/2010-02-12-null-is-not-an-object) though sometimes null is a Number.

```
isNaN( null ); // false
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
console.log(Math.pow(NaN, 42) === NaN)
```

[Oops, sorry.](https://wtfjs.com/wtfs/2010-02-12-not-a-number-is-not-a-not-a-number)
[Oops, sorry.](https://wtfjs.org/wtfs/2010-02-12-not-a-number-is-not-a-not-a-number)

```
console.log(Math.pow(NaN, 42)); // NaN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// = [1,15,2,3,30,45,5,60,7]
```

See [String Integers Comparison](https://wtfjs.com/wtfs/2014-03-13-String-Integers-Comparison) for the explanation.
See [String Integers Comparison](https://wtfjs.org/wtfs/2014-03-13-String-Integers-Comparison) for the explanation.

&mdash;[@stuartpb][]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Javascript numbers are facetious, sometimes they [play hide and seek](https://wtfjs.com/wtfs/2010-07-22-magic-increasing-number), sometimes they just won't obey:
Javascript numbers are facetious, sometimes they [play hide and seek](https://wtfjs.org/wtfs/2010-07-22-magic-increasing-number), sometimes they just won't obey:

<code>
1 << 32 // 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ a instanceof Object; // true WTF?
```

[ref](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof)
"The instanceof operator tests whether an object has in its prototype chain the prototype property of a constructor."

"The instanceof operator tests whether an object has in its prototype chain the prototype property of a constructor."
9 changes: 9 additions & 0 deletions app/pages/$$.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function wtf({ html, state }) {
const { store } = state

return html`
<site-layout>
${store.docs.sort((a, b) => b.title.localeCompare(a.title)).map(doc => html`<li><a href="${doc.url}">${doc.title}</a>`).join(html`<br />`)}
</site-layout>
`
}
1 change: 1 addition & 0 deletions app/pages/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<site-layout>wtf! not found</site-layout>
1 change: 1 addition & 0 deletions app/pages/500.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
internal serverless error
30 changes: 30 additions & 0 deletions app/pages/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<site-layout>
<h1>about</h1>
<p>JavaScript is a language we love despite it giving us so much to hate. This is a collection of those very special irregularities, inconsistencies and just plain painfully unintuitive moments for the language of the web.</p>


<h2>contributing authors</h2>
<p>
These <a href="https://github.com/brianleroux/wtfjs/network/members">fine folk</a> have been the brave warriors of code whom kicked out a wtf for your laughter (or perhaps compassionate tears). Adding a post is simple:
</p>

<ol>
<li><a href="http://github.com/shaedrich/wtfjs">Fork the code on Github</a></li>
<li>Add a post to the <code>./posts</code> folder in the following format: <code>yyyy-mm-dd-title-text-here.md</code> ..yes its Markdown. See the other posts for examples.</li>
<li>Send <a href="http://twitter.com/brianleroux">@brianleroux</a> a pull request.</li>
</ol>

<h2>Meta</h2>
<p>

The first crack at this site was a quick and dirty Tumblr thing authored w/
<a href="http://twitter.com/alunny">@alunny</a>. The second iteration was a
ground up custom authored NodeJS (0.1.x) blog by <a
href="http://twitter.com/brianleroux">@brianleroux</a>. This most recent
incarnation is an evolution of the original NodeJS codebase (0.4.x) with
help from <a href="http://dtrejo.com">David Trejo</a> (<a href="http://twitter.com/ddtrejo">@ddtrejo</a>). The latest
latest incarnation is an migration from 0.4.x to 0.8.x, also with help from
<a href="http://twitter.com/ddtrejo">@ddtrejo</a>.
The 2023 version comes with a port to <a href="https://enhance.dev/">enhance.dev</a>, which, under the hood, also uses <a href="https://arc.codes">Architect</a>.
</p>
</site-layout>
19 changes: 19 additions & 0 deletions app/pages/license.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<site-layout>
<pre>
<code>
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2010 Brian LeRoux

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.
</code>
</pre>
</site-layout>
12 changes: 12 additions & 0 deletions app/pages/wtfs/$wtfId.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default function wtf({ html, state }) {
const { store } = state

return html`
<site-layout>
<article>
<h1>${store.title}</h1>
<p>${store.message.html}</p>
</article>
</site-layout>
`
}
Loading