-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.aro
More file actions
executable file
·27 lines (20 loc) · 1016 Bytes
/
storage.aro
File metadata and controls
executable file
·27 lines (20 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(* ============================================================
ARO Web Crawler - File Storage
Saves crawled pages as Markdown files to the output directory
with filenames derived from the URL hash.
============================================================ *)
(Save Page: SavePage Handler) {
(* Extract from event data structure *)
Extract the <url> from the <event: url>.
Extract the <title> from the <event: title>.
Extract the <content> from the <event: content>.
(* Use URL hash as filename *)
Compute the <url-hash: hash> from the <url>.
Create the <file-path> with "./output/${<url-hash>}.md".
Log "Saving: ${<url>} to ${<file-path>}" to the <console> when <env: DEBUG> == "1".
(* Format markdown file with frontmatter *)
Create the <file-content> with "# ${<title>}\n\n**Source:** ${<url>}\n\n---\n\n${<content>}".
(* Write content to file *)
Write the <file-content> to the <file: file-path>.
Return an <OK: status> for the <save>.
}