stephenslab / ipynb-website

Simple data science website using Jupyter notebooks.
https://tinyurl.com/yb7mal2m
MIT License
66 stars 29 forks source link

include_dir: nested subdirectories #9

Closed NathanielDake closed 3 years ago

NathanielDake commented 5 years ago

Hi! I just had a quick question related the functionality of include_dir. Is there a way to have nested subdirectories correctly access the path of the corresponding stylesheets?

For example, my include_dir looks like:

include_dir: ["analysis", "experiments/experiment_1", "experiments/experiment_2",...]

The HTML that is then generated for notebooks inside of experiments/experiment_1 is loading css from the parent directory. For instance, it will be:

<link rel="stylesheet" type="text/css" href="../css/jt.css">
<link rel="stylesheet" type="text/css" href="../css/readable.css">
<link rel="stylesheet" type="text/css" href="../css/toc2.css">

<link href="../site_libs/jqueryui-1.11.4/jquery-ui.css">
<link rel="stylesheet" href="../site_libs/bootstrap-3.3.5/css/readable.min.css" rel="stylesheet" />
<link rel="stylesheet" href="../site_libs/font-awesome-4.5.0/css/font-awesome.min.css" rel="stylesheet" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<script src="../site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="../site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="../site_libs/bootstrap-3.3.5/shim/respond.min.js"></script>

Which in this case, the parent directory is experiments, and it does not contain the necessary assets. I can manually edit the paths to be: <link rel="stylesheet" type="text/css" href="../../css/jt.css">, and so on, but is there a work around concerning this?

Any help or recommendations for where to search next are greatly appreciated!

pcarbo commented 5 years ago

@NathanielDake Thanks for the feedback and feature request. I hope you are finding this resource useful.

We hadn't anticipated nested subdirectories. I agree it is a good idea, but I don't know if this is a feature we will immediately support.

One workaround I can suggest is to add soft links manually inside the docs subdirectories. For example, you could add a soft link (use ln -s ...) to the docs/site-libs folder inside docs/experiments. It is a bit of a hack, but I believe it should work! Let us know either way.

gaow commented 5 years ago

@NathanielDake I agree with @pcarbo 's suggestion that using softlink is the easiest way out. Very much likely we can automatically create those links when nested dirs are detected. We are otherwise engaged this week, though (am out of town) so maybe let's leave this ticket open to revisit next week.

NathanielDake commented 5 years ago

@pcarbo Most definitely finding it useful! It has been great to work with so far. With that said, thanks for the response-the soft links are up and running, and for my purposes it is more than sufficient 👍!

@gaow If you does end up being easy to automatically create the links please let me know, if not no worries though!

gaow commented 3 years ago

Going over some old tickets ... this feature has in fact been implemented but a slightly different solution: when you have

include_dir: ["analysis", "experiments"]

all notebooks under these folders will be converted recursively and be added into the website.

Please checkout the recent release:

https://github.com/stephenslab/ipynb-website/releases/tag/v0.9.8