Skip to content

Commit 8cbf2e0

Browse files
committed
Merge branch 'release/1.0.0' into main
* release/1.0.0: Bump version. Remove Rust reference. Add basis of site Add base project
2 parents ad47b8a + 4ae77d7 commit 8cbf2e0

6 files changed

Lines changed: 921 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: yarn start

index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const express = require("express");
2+
const mf2 = require("microformat-node");
3+
const undici = require("undici");
4+
const app = express();
5+
const port = 9000;
6+
7+
app.set("view engine", "ejs");
8+
app.use(express.static("public"));
9+
app.get("/", async (req, res) => {
10+
if (req.query.url) {
11+
const url = req.query.url;
12+
const { body } = await undici.request(url);
13+
mf2.get({ baseUrl: url, html: await body.text() }, (err, data) => {
14+
res.send(err || data);
15+
});
16+
} else {
17+
res.render("index.html.ejs", { version: "1.0.0" });
18+
}
19+
});
20+
app.post("/", (req, res) => {});
21+
22+
app.listen(port, () => {
23+
console.log(`Example app listening on port ${port}`);
24+
});

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "microformats-website-note",
3+
"description": "A website written using Node to demonstrate Microformats2 usage",
4+
"version": "1.0.0",
5+
"engines": {
6+
"node": "17.x",
7+
"yarn": "1.x"
8+
},
9+
"scripts": {
10+
"start": "node index.js"
11+
},
12+
"dependencies": {
13+
"ejs": "^3.1.8",
14+
"express": "^4.18.1",
15+
"microformat-node": "^2.0.1",
16+
"querystring": "^0.2.1",
17+
"undici": "^5.6.1"
18+
}
19+
}

views/index.html.ejs

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta
6+
name="viewport"
7+
content="width=device-width, initial-scale=1, shrink-to-fit=no"
8+
/>
9+
10+
<title>Node Microformats Parser</title>
11+
12+
<link
13+
rel="stylesheet"
14+
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css"
15+
integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ"
16+
crossorigin="anonymous"
17+
/>
18+
<style>
19+
form label {
20+
font-weight: bold;
21+
display: block;
22+
}
23+
24+
form textarea,
25+
form input[type="url"] {
26+
font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono",
27+
"Courier New", monospace;
28+
}
29+
30+
form .form-control:disabled {
31+
cursor: default;
32+
background: #efefef;
33+
color: black;
34+
}
35+
36+
.help {
37+
color: #999;
38+
font-weight: normal;
39+
}
40+
41+
#json {
42+
font-size: 0.7em;
43+
}
44+
45+
/* disable bootstrap animations */
46+
.form-control,
47+
.btn {
48+
transition: none;
49+
}
50+
</style>
51+
<link rel="icon" href="favicon.ico" type="image/x-icon" />
52+
</head>
53+
54+
<body>
55+
<main id="mf2" class="container">
56+
<h1 class="mt-5 mb-3">
57+
Microformats Parser (Node) <%- version -%>
58+
</h1>
59+
60+
<form action="/" accept-charset="UTF-8" method="get">
61+
<div class="form-group">
62+
<label for="url">Enter a URL</label>
63+
<input
64+
id="url"
65+
class="form-control form-control-lg"
66+
type="url"
67+
name="url"
68+
placeholder="https://example.com/person.html"
69+
/>
70+
</div>
71+
72+
<button type="submit" class="btn btn-lg btn-success">Parse</button>
73+
</form>
74+
75+
<h2 class="h4 my-5">OR parse just a snippet of HTML</h2>
76+
77+
<form method="post" action="/" class="mb-5">
78+
<div class="form-group">
79+
<label for="html">HTML</label>
80+
<textarea
81+
id="html"
82+
name="html"
83+
rows="6"
84+
class="form-control form-control-lg"
85+
></textarea>
86+
</div>
87+
88+
<div class="form-group">
89+
<label for="url">Base URL</label>
90+
<input
91+
id="url"
92+
name="url"
93+
type="url"
94+
class="form-control form-control-lg"
95+
/>
96+
</div>
97+
98+
<button type="submit" class="btn btn-lg btn-success">Parse</button>
99+
</form>
100+
101+
<footer class="my-5">
102+
<ul>
103+
<li><a href="https://microformats.io">About Microformats</a></li>
104+
<li>
105+
<a
106+
href="https://github.com/microformats/microformats-parser-website-node"
107+
>Source code for this site</a
108+
>
109+
</li>
110+
<li>
111+
<a href="https://github.com/microformats/microformat-node"
112+
>Source code for the Microformats Node Parser</a
113+
>
114+
</li>
115+
116+
<li>
117+
Other Microformats Parser websites:
118+
<a href="https://go.microformats.io">Go</a>,
119+
<a href="https://php.microformats.io">PHP</a>,
120+
<a href="https://python.microformats.io">Python</a>,
121+
<a href="https://ruby.microformats.io">Ruby</a>, and
122+
<a href="https://rust.microformats.io">Rust</a>.
123+
</li>
124+
</ul>
125+
</footer>
126+
</main>
127+
</body>
128+
</html>

0 commit comments

Comments
 (0)