gucio321 / fizyka

Physics exercises for High School students.
https://gucio321.github.io/fizyka
GNU General Public License v3.0
1 stars 0 forks source link

list files in directory in JavaScript and print them on the page #4

Open gucio321 opened 3 years ago

gucio321 commented 3 years ago

Hi everyone! Welcome to my physic-exercises website! I've a plan, to add a section when I can add and share certain files. It could look as follows:

gucio321 commented 3 years ago

the other solution is using PHP, but currenlty no idea, how to use it with sphinx

here is the php code:

<?php
   $dir = "./path/to/directory";
   $cdir = scandir($dir);
   foreach ($cdir as $key => $value)
   {
     print "<h1><a href=\"" . $dir . "/" .  $value . "\" download=\"" . $value . "\" > #" . $value . "</a></h1><hr>";
   }

   return $result;
?>
gucio321 commented 3 years ago

well, lets drop this PHP idea. IIRC php would work on gh, but it will make local development much more difficult.

Atm, I can imagine, that

var fs = require('fs');
var files = fs.readdirSync('/path/to/directory');

may work, however (as long as require is node.js command) we cannot use it. For now I found this repo: https://github.com/jvilk/BrowserFS and will work on introduction.