Skip to content

Instantly share code, notes, and snippets.

@erickr
Created March 20, 2021 16:02
Show Gist options
  • Save erickr/17b6fb6b835fc1117376e704bcb61220 to your computer and use it in GitHub Desktop.
Save erickr/17b6fb6b835fc1117376e704bcb61220 to your computer and use it in GitHub Desktop.
Hämta menyn från skolmaten.se mha nodered för två skolor och returnera en förenklad html-version. Inkluderar kommande 7 dagarnas meny.
[
{
"id": "cff4967.a06be68",
"type": "http in",
"z": "fc02b674.bb5cb8",
"name": "Långbrodalsskolan Skolmat",
"url": "/langbrodalsskolan-skolmat",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 360,
"y": 140,
"wires": [
[
"38f64d5.f9717b2"
]
]
},
{
"id": "38f64d5.f9717b2",
"type": "http request",
"z": "fc02b674.bb5cb8",
"name": "",
"method": "GET",
"ret": "txt",
"url": "https://skolmaten.se/langbrodalsskolan/rss/days/?limit=7",
"tls": "",
"x": 590,
"y": 220,
"wires": [
[
"d0533c66.ec252"
]
],
"outputLabels": [
"payload"
]
},
{
"id": "9074c45f.6551a8",
"type": "inject",
"z": "fc02b674.bb5cb8",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "21600",
"crontab": "",
"once": true,
"x": 110,
"y": 300,
"wires": [
[
"38f64d5.f9717b2",
"aa6c51ec.094a6"
]
]
},
{
"id": "a486866f.5657e8",
"type": "http response",
"z": "fc02b674.bb5cb8",
"name": "",
"statusCode": "",
"headers": {
"Content-Type": "text/html"
},
"x": 1250,
"y": 300,
"wires": []
},
{
"id": "d0533c66.ec252",
"type": "xml",
"z": "fc02b674.bb5cb8",
"name": "",
"attr": "",
"chr": "",
"x": 810,
"y": 300,
"wires": [
[
"563fae51.49ab5"
]
]
},
{
"id": "563fae51.49ab5",
"type": "function",
"z": "fc02b674.bb5cb8",
"name": "",
"func": "\nvar html = '';\n\n\nmsg.payload.rss.channel[0].item.forEach(function(i) {\n html+='<p><h2>'+i.title+'</h2><p>'+i.description+'</p></p>';\n})\n\nmsg.payload = html;\nreturn msg;\n\nreturn {\n payload: html\n};",
"outputs": 1,
"noerr": 0,
"x": 950,
"y": 300,
"wires": [
[
"f4b642b1.c640f"
]
]
},
{
"id": "f4b642b1.c640f",
"type": "template",
"z": "fc02b674.bb5cb8",
"name": "",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "<html>\n<head> \n\n<style type=\"text/css\">\n h2,\n p { \n font-size: 12px;\n font-family: arial; \n \n }\n \n h2 { font-weight: bold; }\n \n \n</style>\n</head>\n<body>\n{{{payload}}}\n\n</body>\n</html>",
"output": "str",
"x": 1110,
"y": 300,
"wires": [
[
"a486866f.5657e8"
]
]
},
{
"id": "aa6c51ec.094a6",
"type": "http request",
"z": "fc02b674.bb5cb8",
"name": "",
"method": "GET",
"ret": "txt",
"url": "https://skolmaten.se/herrangens-skola/rss/days/?limit=7",
"tls": "",
"x": 590,
"y": 380,
"wires": [
[
"d0533c66.ec252"
]
],
"outputLabels": [
"payload"
]
},
{
"id": "fd3844c5.fac068",
"type": "http in",
"z": "fc02b674.bb5cb8",
"name": "Herrängen Skolmat",
"url": "/herrangen-skolmat",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 350,
"y": 440,
"wires": [
[
"aa6c51ec.094a6"
]
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment