-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 882ac05
Showing
27 changed files
with
2,386 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Fortran.JS Web framework | ||
The best motherfucking web framework for human-driven websites. | ||
|
||
Harness the blazingly fast speed 🚀🚀🚀, simplicity 🪑 and security 🔒 of fortran for your next web development project TODAY. | ||
|
||
## Features | ||
- Blazingly fast speeds 🚀🚀🚀. Fortran.JS is compiled to machine code and executed on demand. | ||
- Simplicity 🪑 Web frameworks have become too bloated and slow, Fortran.JS breathes a sigh of relief to overworked developers looking for yet another new framework. | ||
- Security by obscurity 🔒 Hackers and bad actors don't even know fortran, so how are they going to cause data breaches? | ||
|
||
## Custom web server | ||
The custom web server is written in Node.JS, and has custom developer tools, such as: | ||
- A dev server with automatic building and reloading on changes 🚀🚀🚀 | ||
- A smart compiler that handles everything for you, like compiler options for components. 🚀🚀🚀 | ||
- Support for external files in a /public/ directory 🚀🚀🚀 | ||
- Supports components like in less advanced frameworks like react 🚀🚀🚀 | ||
|
||
|
||
|
||
## Code example: | ||
```fortran | ||
! webapp.f90 | ||
program home | ||
implicit none | ||
character(len=*), parameter :: Head = '<!doctype html>' //& | ||
'<html lang="en">' //& | ||
'<body>' | ||
print '(a)', Head | ||
character(len=*), parameter :: some_dynamic_text = 'Hello, from Fortran!' | ||
print '(a)', '<h1>', some_dynamic_text, '</h1>' | ||
print '(a)', '</body></html>' | ||
end program home | ||
``` | ||
|
||
## Demo | ||
The repository comes with, by default, an advanced demo featuring components and dynamic text in action. | ||
|
||
![Alt text](image.png) | ||
|
||
## Prereqs | ||
- linux computer (no spawn-fcgi on windows) | ||
- [spawn-fcgi](https://github.com/lighttpd/spawn-fcgi) (build from source or install from package manager) | ||
- nodejs and npm | ||
- the [fortran language](https://fortran-lang.org/learn/os_setup/install_gfortran/) | ||
|
||
## Install | ||
1. Don't | ||
2. Install spawn-fcgi, nodejs and fortran for your system | ||
3. Use "npm run dev" to run a development server that'll auto rebuild | ||
4. Use "npm run build" to build the server | ||
5. Use "npm run start" to run the server. | ||
|
||
## Yes this is satire! | ||
I made this as a joke a year or two ago. I am still ashamed. | ||
|
||
## Works cited: | ||
[1] *Observation of Einstein-Podolsky-Rosen Entanglement on Supraquantum Structures by Induction Through Nonlinear Transuranic Crystal of Extremely Long Wavelength (ELW) Pulse from Mode-Locked Source Array* (Freeman, Gordon 1992) | ||
|
||
[2] ![Alt text](/public/proof.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
const fs = require("fs") | ||
const path = require("path"); | ||
const { | ||
exec | ||
} = require("child_process"); | ||
const readline = require('readline'); | ||
|
||
exec("rm -r ./build/") | ||
|
||
async function* walk(dir) { | ||
for await (const d of await fs.promises.opendir(dir)) { | ||
const entry = path.join(dir, d.name); | ||
if (d.isDirectory()) yield* walk(entry); | ||
else if (d.isFile()) yield entry; | ||
} | ||
} | ||
|
||
async function compile(p) { | ||
//p should be formatted as /path/to/file.f90 | ||
|
||
//Return if it's not a fortran file | ||
if (!p.toStringreloading().endsWith(".f90")) return; | ||
|
||
// Default output name | ||
let output = 'index' | ||
|
||
let name = p.split("/").pop() | ||
|
||
let path = p.split("/") | ||
path.pop() | ||
|
||
//Reservered word exemptions | ||
if (name === "404.f90") { | ||
output = "404" | ||
} | ||
|
||
console.log(`Compiling ${name} at ${path.join("/")}....` ) | ||
|
||
let compilerOptions = [""] | ||
|
||
//Spaghetti here | ||
|
||
const fileStream = fs.createReadStream(`./${path.join("/") + "/" + name}`); | ||
|
||
const rl = readline.createInterface({ | ||
input: fileStream, | ||
crlfDelay: Infinity | ||
}); | ||
// Note: we use the crlfDelay option to recognize all instances of CR LF | ||
// ('\r\n') in input.txt as a single line break. | ||
|
||
for await (const line of rl) { | ||
// Each line in input.txt will be successively available here as `line`. | ||
if (line.match(/(USE c)/)) { | ||
|
||
let splitline = line.split("_") | ||
console.log("Importing modules...") | ||
|
||
compilerOptions.push(`./components/${splitline[1]}/${splitline[1]}.f90`) | ||
|
||
|
||
|
||
|
||
} else continue; | ||
|
||
if (line.match(/(character)/)) break; | ||
} | ||
|
||
|
||
console.log("Creating the output directory...") | ||
|
||
|
||
exec(`mkdir -p ./build/${path.join("/")}`, function (err, stdout, stderr) { | ||
if (err) { | ||
console.error("----------------------------\n Error occured while trying to create build directory\n----------------------------\n") | ||
console.error(err) | ||
} | ||
}) | ||
|
||
console.log("Compiling....") | ||
|
||
exec(`gfortran -ffree-form ${compilerOptions.join(" ")} ./${path.join("/") + "/" + name} -o ./build/${path.join("/")}/${output}`, function (err, stdout, stderr) { | ||
if (err) { | ||
console.error("----------------------------\n Error occured while compiling pages\n----------------------------\n") | ||
console.error(err) | ||
} else { | ||
console.log(`${name} compiled successfully!`) | ||
} | ||
}) | ||
} | ||
|
||
async function main() { | ||
|
||
for await (const p of walk('./pages')) { | ||
if (!p.toString().endsWith(".f90")) continue; | ||
|
||
|
||
compile(p) | ||
} | ||
} | ||
|
||
main() | ||
|
||
module.exports = { | ||
compile: compile | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
MODULE c_footer | ||
IMPLICIT NONE | ||
PRIVATE | ||
|
||
PUBLIC :: footer | ||
|
||
CONTAINS | ||
|
||
SUBROUTINE footer() | ||
PRINT '(a)', "<p>Copyright 2022 (C) falsefox</p></body></html>" | ||
END SUBROUTINE footer | ||
|
||
|
||
|
||
END MODULE c_footer |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MODULE c_header | ||
IMPLICIT NONE | ||
PRIVATE | ||
PUBLIC :: header | ||
|
||
|
||
CONTAINS | ||
SUBROUTINE header() | ||
character(len=*), parameter :: HeaderContent = ""//& | ||
"<div id='headerContainer'>"//& | ||
"Webtran <a href='/#'>Home</a> <a href='/docs'>Documentation</a>"//& | ||
"</div>" | ||
|
||
print '(a)', HeaderContent | ||
|
||
END SUBROUTINE header | ||
|
||
|
||
|
||
END MODULE c_header | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const express = require('express') | ||
const app = express() | ||
const fs = require("fs") | ||
const path = require("path"); | ||
const { | ||
exec | ||
} = require("child_process") | ||
//Compile to build | ||
|
||
|
||
const port = 3000 | ||
app.use('/public', express.static('public')); | ||
app.use('/styles', express.static('styles')); | ||
|
||
|
||
function test(req, res, next) { | ||
|
||
exec(`spawn-fcgi -n -a 127.0.0.1 -p 9000 ./build/pages${req.originalUrl}/index`, function (err, stdout, stderr) { | ||
|
||
if (err) { | ||
|
||
exec(`spawn-fcgi -n -a 127.0.0.1 -p 9000 ./build/pages/404`, function (err, stdout2, stderr) { | ||
if (err) { | ||
console.error("----------------------------\n Error occured while fetching 404 page, are your paths set correctly?\n----------------------------\n") | ||
console.error(err) | ||
} | ||
res.send(stdout2) | ||
}) | ||
console.log(err) | ||
|
||
} else { | ||
res.send(stdout) | ||
} | ||
|
||
}) | ||
} | ||
|
||
app.get("/*", test); | ||
|
||
app.listen(port, () => { | ||
console.log(`Webserver is live at localhost:${port}!`) | ||
}) |
Oops, something went wrong.