Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

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

Open
gucio321 opened this issue Oct 22, 2021 · 2 comments
Open
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@gucio321
Copy link
Owner

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:

  • shared directory which can be soft-linked to assets/shared/data
  • assets/shared needs to have index.md which lists all the content of data dir and prints it in a table
    My first idea is to use JavaScript (js) to do so with raw:: html sphinx instuction.
    Does anyone have any idea, how to do so?
@gucio321 gucio321 added enhancement New feature or request help wanted Extra attention is needed labels Oct 22, 2021
@gucio321
Copy link
Owner Author

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
Copy link
Owner Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant