-2

So I noticed when you put the path of your folder in a browser you get a default file manager.

enter image description here

I wanted to ask how could I manipulate the default changes in the path? Not just only the file manager but also the paths of other files, so I could parse them through a .md parser.

I tried fetching the data of the API that looked like a lot of work and I think there is a easier way to do this, because if there is a default way it generates the file manager I can just modify that.

BHEET
  • 1
  • 3
  • 2
    Whether or not the folders of the webserver can be publicly enumerated is a configurable option, and the UI that's displayed is set by the webserver outside of your control. That being said, having the contents of your folders being publicly accessible is generally ***an incredibly bad idea***. If you want to present files to your users, write some software to control this, including some level of permissions and RBAC. – Rory McCrossan Nov 05 '22 at 14:32
  • It would be just a blog so I wouldnt mind it, what's RBAC? I guess its just basic HTTPS methods – BHEET Nov 05 '22 at 16:33
  • Then use Wordpress or some other blogging platform. What you're asking to do here is not the way you should be doing anything. – Rory McCrossan Nov 05 '22 at 16:38
  • Im not exposting my whole directory though, if I am understanding it directly? Maybe I used the wrong words I just want to change the CSS of the picture you see but thats not in my power as you said i guess. – BHEET Nov 05 '22 at 16:41
  • Also I'm hosting this on Github so not a actual server. – BHEET Nov 26 '22 at 15:40

1 Answers1

0

In the end I couldn't really change the design of the main file system so I just extracted the elements and appended it to the the main HTML file.

  fetch(`./Posts/`)
  .then((response) => response.text())
  .then((data) => {

    //Parse the data to html
    var parser = new DOMParser();
    var posts = parser.parseFromString(data, "text/html");

    // Get the files
    var files = posts.querySelector("ul");
    var li = files.querySelectorAll("li");
    var content = document.querySelector("main");

    //Seperate titles and push them in a array
    var list = [];
    for (var i = 0; i < li.length; i++) {
      var text = li[i].innerText;

      //split the innerText from ".md"
      var titles = text.split(".md");
      var title = titles[0];
      list.push(title);
      var name = li[i].getElementsByClassName("name");

      //change the innerHTML of the "name" span's
      name.item(0).innerHTML = title;
      content.append(li[i]);
      }
   });
BHEET
  • 1
  • 3