Skip to content

Commit cf6de3c

Browse files
committed
starters
1 parent 1dc4e2e commit cf6de3c

10 files changed

Lines changed: 6858 additions & 8 deletions

File tree

‎data/workflowy_2025-09-21.md‎

Lines changed: 6660 additions & 0 deletions
Large diffs are not rendered by default.

‎docs/TODO.md‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Consumer for Semem
22

3-
## Phase 1 : Link Consumer
3+
## Phase 1 : link-consumer for markdown
44

5-
1. read
5+
* read data/workflowy_2025-09-21.md : FileReader
6+
* parse links : new, src/processors/markup/MarkdownToLinks.js
7+
* for each link : src/processors/flow/ForEach
8+
* do a GET, record HTTP status, response type : src/processors/http/HttpClient.js
9+
* apply SPARQL template & upload to store
10+
11+
src/apps/md-to-sparqlstore
12+
13+
processors/util/ResourceMinter.js - mint URI, W3CDTF datetime, agent
14+
properties : baseURI, agentURI
15+
16+
## Phase 2 : set of files link-consumer

‎src/apps/link-consumer/about.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
`src/apps/example-application/about.md`
2+
3+
# Example Application `about.md`
4+
5+
## Runner
6+
7+
```sh
8+
cd ~/hyperdata/transmissions # my local path
9+
./trans example-application
10+
```
11+
12+
## Description
13+
14+
---

‎src/apps/link-consumer/about.ttl‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
2+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
3+
4+
@prefix : <http://purl.org/stuff/transmissions/> .

‎src/apps/link-consumer/config.ttl‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# src/apps/example-application/config.ttl
2+
3+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
4+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
5+
6+
@prefix : <http://purl.org/stuff/transmissions/> . # for custom terms & instances
7+
8+
:exampleSettings1 a :ConfigSet ;
9+
:me "exampleSettings1" ;
10+
:common "common from 1" ;
11+
:something1 "something1 from config" .
12+
13+
:exampleSettings2 a :ConfigSet ;
14+
:me "exampleSettings2" ;
15+
:common "common from 2" ;
16+
:something2 "something2 from config" ;
17+
:added " added from exampleSettings2" .
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
# https://schema.org/BookmarkAction
3+
4+
PREFIX schema: <http://schema.org/>
5+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
6+
PREFIX : <http://purl.org/stuff/transmissions/>
7+
8+
INSERT DATA {
9+
<{{url}}> a schema:URL .
10+
<{{actionURI}}> a schema:BookmarkAction ;
11+
schema:url <{{url}}> ;
12+
schema:dateCreated "{{dates.created}}"^^xsd:dateTime ;
13+
schema:label <{{text}}> ;
14+
schema:agent <{{agent}}> .
15+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# src/apps/example-application/transmissions.ttl
2+
3+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
4+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
5+
6+
@prefix : <http://purl.org/stuff/transmissions/> .
7+
8+
##################################################################
9+
# Utility Processors : insert into pipe for debugging #
10+
# #
11+
:SM a :ShowMessage . # verbose report, continues pipe #
12+
:SC a :ShowConfig . # verbose report, continues pipe #
13+
:DE a :DeadEnd . # ends the current pipe quietly #
14+
:H a :Halt . # kills everything #
15+
:N a :NOP . # no operation (except for showing stage in pipe) #
16+
:UF a :Unfork . # collapses all pipes but one #
17+
##################################################################
18+
19+
:example a :Transmission ;
20+
:pipe (:p10 :N :p20 :p30) .
21+
22+
:p10 a :Example ;
23+
:settings :exampleSettings1 .
24+
25+
:p20 a :Example ;
26+
:settings :exampleSettings2 .
27+
28+
:p30 a :ShowMessage .

‎src/processors/example-group/Example.js‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
// src/processors/example-group/Example.js
2+
3+
import logger from '../../utils/Logger.js'
4+
import ns from '../../utils/ns.js'
5+
import Processor from '../../model/Processor.js'
6+
27
/**
38
* @class Example
49
* @extends Processor
@@ -42,12 +47,6 @@
4247
*
4348
* Use this as a template when creating new processors.
4449
*/
45-
46-
import logger from '../../utils/Logger.js'
47-
import ns from '../../utils/ns.js'
48-
import Processor from '../../model/Processor.js'
49-
50-
5150
class Example extends Processor {
5251
/**
5352
* Creates a new Example processor instance.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// @ts-nocheck
2+
// src/processors/markup/MarkdownToLinks.js
3+
4+
import logger from '../../utils/Logger.js'
5+
import ns from '../../utils/ns.js'
6+
import Processor from '../../model/Processor.js'
7+
8+
/**
9+
* @class MarkdownToLinks
10+
* @extends Processor
11+
* @classdesc
12+
* **a Transmissions Processor**
13+
*
14+
* MarkdownToLinks processor demonstrating basic processor structure and property handling.
15+
*
16+
* ### Processor Signature
17+
*
18+
* #### __*Settings*__
19+
* * **`ns.trn.me`** - Identifier for the processor instance
20+
* * **`ns.trn.common`** - Common value to be added to the message
21+
* * **`ns.trn.something1`** - First value to be processed
22+
* * **`ns.trn.something2`** - Second value to be processed
23+
* * **`ns.trn.added`** - Optional string to append to something1
24+
* * **`ns.trn.notavalue`** - Fallback value if not provided in config
25+
*
26+
* #### __*Input*__
27+
* * **`message`** - The message object to be processed
28+
*
29+
* #### __*Output*__
30+
* * **`message`** - The modified message object with added/updated fields
31+
*
32+
* #### __*Behavior*__
33+
* * Forwards message immediately if `message.done` is true
34+
* * Retrieves and processes configuration properties
35+
* * Appends optional values to message fields
36+
* * Handles fallback values for missing properties
37+
*
38+
* #### __*Side Effects*__
39+
* * Modifies the input message object
40+
* * Logs processing information
41+
*
42+
* #### __*Notes*__
43+
* This is an MarkdownToLinks implementation demonstrating:
44+
* - Basic processor structure
45+
* - Property retrieval with fallbacks
46+
* - Message modification
47+
* - Logging
48+
*
49+
* Use this as a template when creating new processors.
50+
*/
51+
class MarkdownToLinks extends Processor {
52+
/**
53+
* Creates a new MarkdownToLinks processor instance.
54+
* @param {Object} config - Processor configuration object
55+
*/
56+
constructor(config) {
57+
super(config)
58+
}
59+
60+
/**
61+
* Processes the message by applying property transformations.
62+
* @param {Object} message - The message to process
63+
* @returns {Promise<boolean>} Resolves when processing is complete
64+
*/
65+
async process(message) {
66+
logger.debug(`\n\nMarkdownToLinks.process`)
67+
68+
// TODO figure this out better
69+
// may be needed if preceded by a spawning processor, eg. fs/DirWalker
70+
if (message.done) {
71+
return this.emit('message', message)
72+
// or simply return
73+
}
74+
75+
message.links = markdownToLinks(message.content)
76+
77+
return this.emit('message', message)
78+
}
79+
80+
81+
82+
markdownToLinks(markdown) {
83+
// Regex to find markdown links: [text](url)
84+
const regex = /\[([^\]]+)\]\(([^)]+)\)/g;
85+
const result = [];
86+
let match;
87+
while ((match = regex.exec(markdown)) !== null) {
88+
result.push({ url: match[2], text: match[1] });
89+
}
90+
return result;
91+
}
92+
93+
// Example usage
94+
const markdownText = "This is a [link to Google](https://google.com) and here is [another link](https://example.com).";
95+
console.log(markdownToLinks(markdownText));
96+
97+
}
98+
export default MarkdownToLinks

‎src/processors/markup/MarkupProcessorsFactory.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import ns from '../../utils/ns.js'
44
import MetadataExtractor from './MetadataExtractor.js'
55
import LinkFinder from './LinkFinder.js'
66
import MarkdownToHTML from './MarkdownToHTML.js'
7+
import MarkdownToLinks from './MarkdownToLinks.js'
78

89
class MarkupProcessorsFactory {
910
static createProcessor(type, config) {
@@ -15,6 +16,9 @@ class MarkupProcessorsFactory {
1516
}
1617
if (type.equals(ns.trn.LinkFinder)) {
1718
return new LinkFinder(config)
19+
}
20+
if (type.equals(ns.trn.MarkdownToLinks)) {
21+
return new MarkdownToLinks(config)
1822
}
1923
return false
2024
}

0 commit comments

Comments
 (0)