Skip to content

Commit

Permalink
Merge branch 'main' into Iteration-of-ctrlx-landing-page
Browse files Browse the repository at this point in the history
  • Loading branch information
Yndira-E authored Aug 21, 2023
2 parents 1a7b349 + 454384c commit 9084106
Show file tree
Hide file tree
Showing 596 changed files with 7,462 additions and 2,173 deletions.
60 changes: 44 additions & 16 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const util = require("util");
const fs = require("fs");

const { EleventyEdgePlugin } = require("@11ty/eleventy");
const { EleventyRenderPlugin } = require("@11ty/eleventy");

const eleventyImage = require("@11ty/eleventy-img");
const pluginRSS = require("@11ty/eleventy-plugin-rss");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
Expand All @@ -20,6 +22,7 @@ const codeowners = require('codeowners');
const heroGen = require("./lib/post-hero-gen.js");
const imageHandler = require('./lib/image-handler.js')
const site = require("./src/_data/site");
const coreNodeDoc = require("./lib/core-node-docs.js");

const DEV_MODE = process.env.ELEVENTY_RUN_MODE !== "build" // i.e. serve/watch

Expand Down Expand Up @@ -59,6 +62,11 @@ module.exports = function(eleventyConfig) {
return `<span class="ff-tooltip" data-tooltip="${text}">${content}</span><span></span>`
});

eleventyConfig.addFilter("coreNodeName", (name) => { return name.split("-").at(-1) })
eleventyConfig.addAsyncShortcode("coreNodeDoc", async function (category, name) {
return await coreNodeDoc(category, name)
});

// Custom filters
eleventyConfig.addFilter("json", (content) => {
return JSON.stringify(content)
Expand All @@ -71,13 +79,14 @@ module.exports = function(eleventyConfig) {
return array.slice(0, n);
});

eleventyConfig.addFilter("limit", (arr, limit) => arr.slice(0, limit + 1));
eleventyConfig.addFilter("limit", (arr, limit) => arr.slice(0, limit ));

eleventyConfig.addFilter('console', function(value) {
const str = util.inspect(value, {showHidden: false, depth: null});
eleventyConfig.addFilter('console', function (value) {
const str = util.inspect(value, { showHidden: false, depth: null });
return `<div style="white-space: pre-wrap;">${unescape(str)}</div>;`
});


eleventyConfig.addFilter('dictsortBy', function(val, reverse, attr) {
let array = [];
for (let k in val) {
Expand All @@ -95,7 +104,7 @@ module.exports = function(eleventyConfig) {
});

eleventyConfig.addFilter('shortDate', dateObj => {
return spacetime(dateObj).format('{date} {month-short}, {year}')
return spacetime(new Date(dateObj)).format('{date} {month-short}, {year}')
});

eleventyConfig.addFilter('duration', mins => {
Expand Down Expand Up @@ -166,8 +175,8 @@ module.exports = function(eleventyConfig) {
return new URL(url, site.baseURL).href;
})

eleventyConfig.addFilter("handbookBreadcrumbs", (str) => {
const parts = str.split("/");
eleventyConfig.addFilter("handbookBreadcrumbs", (url) => {
const parts = url.split("/");
parts.shift();
if (parts[parts.length-1] === "index") {
parts.pop();
Expand Down Expand Up @@ -260,7 +269,7 @@ module.exports = function(eleventyConfig) {
});

eleventyConfig.addShortcode("renderTeamMember", function(teamMember) {
// When the author is no longer at FlowForge
// When the author is no longer at FlowFuse
if (typeof teamMember === "undefined") {
return ""
}
Expand All @@ -283,6 +292,10 @@ module.exports = function(eleventyConfig) {
return data.toString('utf8');
}

eleventyConfig.addFilter("templateExists", function(name){
return fs.existsSync(name)
})

eleventyConfig.addShortcode("ffIconLg", function(icon, isSolid) {
const svg = loadSVG(icon)
if (!isSolid) {
Expand Down Expand Up @@ -339,28 +352,42 @@ module.exports = function(eleventyConfig) {

createNav('handbook')
createNav('docs')
createNav('core-nodes')

function createNav(tag) {
const groupOrder = {
docs: [
'Overview',
'Device Agent',
'Running FlowFuse'
]
}

function createNav (tag) {
collection.getAll().filter((page) => {
return page.data.tags?.includes(tag) && !page.url.includes('README')
// url.indexOf('/handbook') === 0
collection.getFilteredByTag(tag).filter((page) => {
return !page.url.includes('README')
}).sort((a, b) => {
// sort by depth, so we catch all the correct index.md routes
const hierarchyA = a.url.split('/').filter(n => n)
const hierarchyB = b.url.split('/').filter(n => n)
return hierarchyA.length - hierarchyB.length
}).forEach((page) => {
let url = page.url
if (tag == "core-nodes") {
url = page.url.replace("/node-red", "")
}

// work out ToC Hierarchy
// split the folder URI/URL, as this defines our TOC Hierarchy
const hierarchy = page.url.split('/').filter(n => n)
const hierarchy = url.split('/').filter(n => n)
// recursively parse the folder hierarchy and created our collection object
// pass nav = {} as the first accumulator - build up hierarchy map of TOC
hierarchy.reduce((accumulator, currentValue, i) => {
// create a nested object detailing the full handbook hierarchy
if (!accumulator[currentValue]) {
accumulator[currentValue] = {
'name': currentValue,
'url': page.url,
'url': page.data.redirect || page.url,
'order': page.data.navOrder || Number.MAX_SAFE_INTEGER,
'children': {}
}
if (page.data.navTitle) {
Expand Down Expand Up @@ -401,7 +428,7 @@ module.exports = function(eleventyConfig) {
let groups = {
'Other': {
name: 'Other',
order: -1, // always render last
order: Number.MAX_SAFE_INTEGER, // always render last
children: []
}
}
Expand All @@ -414,7 +441,7 @@ module.exports = function(eleventyConfig) {
if (!groups[group]) {
groups[group] = {
name: group,
order: 0,
order: groupOrder[tag] && groupOrder[tag].includes(group) ? groupOrder[tag].indexOf(group) : Number.MAX_SAFE_INTEGER,
children: []
}
}
Expand All @@ -427,7 +454,7 @@ module.exports = function(eleventyConfig) {

function sortChildren (a, b) {
// sort children by 'order', then alphabetical
return b.order - a.order || a.name.localeCompare(b.name)
return (a.order - b.order) || a.name.localeCompare(b.name)
}

nav[tag].groups = Object.values(groups).sort(sortChildren)
Expand All @@ -449,6 +476,7 @@ module.exports = function(eleventyConfig) {
});

// Plugins
eleventyConfig.addPlugin(EleventyRenderPlugin)
eleventyConfig.addPlugin(pluginRSS)
eleventyConfig.addPlugin(syntaxHighlight)
eleventyConfig.addPlugin(codeClipboard)
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/03-story.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ body:
multiple: false
options:
- I have provided an initial effort estimate
- I am not a FlowForge team member
- I am not a FlowFuse team member
- I can not provide an initial effort estimate
validations:
required: true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/04-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ body:
multiple: false
options:
- I have provided an initial effort estimate
- I am not a FlowForge team member
- I am not a FlowFuse team member
- I can not provide an initial effort estimate
validations:
required: true
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/05-bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 🐜 Report a bug
description: File a bug on the FlowForge platform
description: File a bug on the FlowFuse platform
labels: [needs-triage]
body:
- type: textarea
Expand Down Expand Up @@ -38,7 +38,7 @@ body:
multiple: false
options:
- I have provided an initial effort estimate
- I am not a FlowForge team member
- I am not a FlowFuse team member
- I can not provide an initial effort estimate
validations:
required: true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/06-ab-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ body:
Example success metrics could be:
- "Clicks of a certain button"
- "$pageview events of a certain URL"
- Number of Instances spun up on FlowForge
- Number of Instances spun up on FlowFuse
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- main
schedule:
- cron: "30 1 * * 5"
jobs:
build_deploy:
if: ${{ github.repository == 'flowforge/website' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/calibreapp-image-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jobs:
title: Auto Compress Images
branch-suffix: timestamp
commit-message: Compress Images
body: ${{ steps.calibre.outputs.markdown }}
body: ${{ steps.calibre.outputs.markdown }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ package-lock.json
# Eleventy Edge Build Data files
netlify/edge-functions/_generated/

.env
.env

# Cache for assets
.cache
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# FlowForge Website
# FlowFuse Website

[![Build Site](https://github.com/flowforge/website/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/flowforge/website/actions/workflows/build.yml)

This repository contains the source of the FlowForge website.
This repository contains the source of the FlowFuse website.

It is built using [Tailwind CSS](https://tailwindcss.com/) and [Eleventy](https://www.11ty.dev/).
It is hosted on GitHub Pages and every commit to the `main` branch is automatically
Expand Down Expand Up @@ -54,11 +54,11 @@ A new VS Code settings file will be created at /Users/joepavitt/Documents/flowfo
It is recommended to response `y` to both of these questions.


### Running FlowForge Documentation
### Running FlowFuse Documentation

Much like our Handbook, the documentation for FlowForge are also maintained in a separate repository. Our docs are maintained in the core [FlowForge repo](https://github.com/flowforge/flowforge).
Much like our Handbook, the documentation for FlowFuse are also maintained in a separate repository. Our docs are maintained in the core [FlowFuse repo](https://github.com/flowforge/flowforge).

If you want to run a local version of the documentation, you'll need to clone the FlowForge repository alongside the website, e.g.:
If you want to run a local version of the documentation, you'll need to clone the FlowFuse repository alongside the website, e.g.:

```
/<parent_directory>
Expand All @@ -84,7 +84,7 @@ authors: ["nick-oleary"]

The `authors` list should correspond to an entry under `src/_data/team`.

## Updating the FlowForge Documentation
## Updating the FlowFuse Documentation

When the website is built via GitHub Action, it will include the documentation
from the `maintenance` branch of the [flowforge/flowforge](https://github.com/flowforge/flowforge)
Expand All @@ -110,4 +110,4 @@ This setup was inspired by:

### `This edge function has crashed`

If you see this error, and it is the first ever time you ahve run the website, this [is expected](https://github.com/flowforge/website/pull/577#issuecomment-1491934272). You can stop the web server (`ctrl + c` from the terminal) and restart it. Following which, it should work.
If you see this error, and it is the first ever time you have run the website, this [is expected](https://github.com/flowforge/website/pull/577#issuecomment-1491934272). You can stop the web server (`ctrl + c` from the terminal) and restart it. Following which, it should work.
25 changes: 25 additions & 0 deletions lib/core-node-docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const EleventyFetch = require("@11ty/eleventy-fetch");
const xpath = require('xpath');
const dom = require('xmldom').DOMParser;

module.exports = async function (cat, nodeName) {
let page = "";
try {
const url = `https://raw.githubusercontent.com/node-red/node-red/master/packages/node_modules/%40node-red/nodes/locales/en-US/${cat}/${nodeName}.html`
let data = await EleventyFetch(url, { type: "text" });

const doc = new dom({
locator: {},
errorHandler: {
warning: function (w) { },
error: function (e) { },
fatalError: function (e) { console.error(e) }
}
}).parseFromString(data.toString());

return xpath.select("/script[@data-help-name]/*", doc).join(" ")
} catch (e) {
console.error(e);
return null;
}
};
31 changes: 30 additions & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
[[redirects]]
from = "http://flowforge.com/*"
to = "http://flowfuse.com/:splat"
status = 301
force = true

[[redirects]]
from = "https://flowforge.com/*"
to = "https://flowfuse.com/:splat"
status = 301
force = true

[[redirects]]
from = "http://flowfuze.com/*"
to = "http://flowfuse.com/:splat"
status = 301
force = true

[[redirects]]
from = "https://flowfuze.com/*"
to = "https://flowfuse.com/:splat"
status = 301
force = true

[dev]
port = 8080
framework = "#static"
Expand All @@ -13,7 +37,12 @@ package = "@algolia/netlify-plugin-crawler"
[plugins.inputs]
branches = ['main', 'live']
template = "hierarchical"

[[plugins]]
package = "netlify-plugin-cache"
[plugins.inputs]
paths = [ ".cache" ]

[[edge_functions]]
function = "eleventy-edge"
path = "/*"
path = "/*"
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
"license": "Apache-2.0",
"author": "Nick O'Leary",
"scripts": {
"clean": "cross-env npx del-cli '_site/' && cross-env npx mkdirp '_site/js'",
"clean:dev": "cross-env npx del-cli '_site/!(img)' && cross-env npx mkdirp '_site/js'",
"start": "npm-run-all clean:dev build:js --parallel dev:*",
"build": "cross-env NODE_ENV=production npm-run-all clean build:js --parallel prod:*",
"test": "mocha",
"build:js": "terser -c -m -o _site/js/cc.min.js node_modules/vanilla-cookieconsent/dist/cookieconsent.js src/js/cookies.js",
"docs": "node scripts/copy_docs.js",
"build": "cross-env NODE_ENV=production npm-run-all clean build:js --parallel prod:*",
"clean:dev": "cross-env npx del-cli '_site/!(img)' 'src/docs/**/*.md' && cross-env npx mkdirp '_site/js'",
"clean": "cross-env npx del-cli '_site/' && cross-env mkdir -p '_site/js'",
"dev:docs": "node scripts/dirExists ../flowforge/docs && nodemon -w ../flowforge/docs -e md --exec \"npm run docs\" || echo \"docs not found - skipping...\"",
"dev:netlify": "npx netlify dev",
"dev:postcss": "cross-env TAILWIND_MODE=watch npx postcss ./src/css/style.css -o ./_site/css/style.css --config ./postcss.config.js -w",
"prod:postcss": "postcss ./src/css/style.css -o ./_site/css/style.css --config ./postcss.config.js",
"docs": "node scripts/copy_docs.js",
"old_dev:eleventy": "cross-env NODE_ENV=development ELEVENTY_ENV=development npx @11ty/eleventy --serve --quiet",
"prod:eleventy": "npx @11ty/eleventy",
"dev:netlify": "npx netlify dev",
"test": "mocha"
"prod:postcss": "postcss ./src/css/style.css -o ./_site/css/style.css --config ./postcss.config.js"
},
"devDependencies": {
"@11ty/eleventy": "^2.0.1",
Expand All @@ -38,7 +38,8 @@
"markdown-it-anchor": "^8.6.7",
"markdown-it-footnote": "^3.0.3",
"mocha": "^10.2.0",
"netlify-cli": "^15.0.2",
"netlify-cli": "^15.8.0",
"netlify-plugin-cache": "^1.0.3",
"nodemon": "^2.0.20",
"npm-run-all": "^4.1.5",
"postcss": "^8.3.11",
Expand All @@ -55,6 +56,7 @@
"xpath": "^0.0.32"
},
"dependencies": {
"@11ty/eleventy-fetch": "^4.0.0",
"codeowners": "^5.1.1",
"markdown-it-attrs": "^4.1.6"
}
Expand Down
Loading

0 comments on commit 9084106

Please sign in to comment.