Include dygraphs in Jekyll-run site from R - r

Is it possible to include dygraphs chart or some of other js-object supported by htmlwidgets.org to Jekyll-run site from R?
I've tried different variants (Rmd -> Md or Rmd -> html) with no success. The best outcome I have, dyghraphs is included into html-code but doesn't show up on the page (example: http://quantviews.github.io/dygraphs-test/).
Is there any working examples of Jekyll-run site with dygraphs included from Rmd-files?

I think Jekyll is skipping the "libs" directory that's in your _posts folder. (I'm pretty sure it's designed not to process sub directories under "_posts".) The fix is to move the libs folder up and then update the links to point to the new location. For example:
Move the "_posts/libs" folder up one directory so it's sitting next to "_posts".
Add a "/" to the front of the URLs for all the <script src="libs/... links so they call from the docroot. Should look like: <script src="/libs/....
Add a "/" to the front of the URLs for all the <link href="libs/... links so they call from the docroot. Should look like: <link href="/libs/.....
That's it for the main fix. But, there is another bug too. In the _posts/2015-05-15-dygraphs-test.html file, there is a call to:
<script src="libs/dygraphs-binding-0.4.1/dygraphs.js"></script>
But the version 'dygraphs-binding' version in your current libs directory is 0.4.3. I tried just changing the directory name and that worked for me. (i.e. "/libs/dygraphs-binding-0.4.3/dygraphs.js" becomes "libs/dygraphs-binding-0.4.1/dygraphs.js"). It would probably be better to actually line everything up, but that will at least get you working.

my solution:
render with rmarkdown::html_output, copy dygraph dependencies from header
create a new jekyll layout in _layouts/ with the dygraphs dependencies (changing libs to /libs as mentioned before)
run rmarkdown again, this time with rmarkdown::html_fragment to generate html without header
copy html fragment to _includes/
create a new blog post using layout specified in [2]
include html fragment in body of blog post using {% include html_fragment.html %}

Related

Can Jupyter Notebooks be hosted or otherwise published on 11ty/Eleventy websites?

Has anyone any suggestions on how to embed or host Jupyter notebooks, or Jupyter notebooks saved as .html, on 11ty websites?
I've tried downloading notebooks as .html, storing them in ./src/_includes/ and trying to embed them in a markdown page like this:
{% include "notebook.html" %}
Unfortunately, it publishes as raw code:
/-----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------/
/*
The following CSS variables define the main, public API ...
I tried an iframe shortcode:
eleventyConfig.addShortcode('getNotebook', (arg) => `<iframe src="${arg}">`);
But it seems the system doesn't care for iframes: Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”).
I tried downloading the notebook as markdown but that doesn't work that awfully well - the formatting quickly goes haywire, and interactive graphs are a disaster. If anyone has any suggestions I would greatly appreciate them.
I have found a way around this. It's a bit of a hack, but it works.
My original problem was that using {% include "notebook.html" %} in a markdown file caused the html to render as raw code, rather than html. However, that doesn't happen if the include is in the .njk template, rather than markdown.
So, every notebook I post now has to have its own special template, which is an include directive to an individual notebook. The markdown file contains only the front matter. All the action is in the template, and in a notebooks folder in the src/_includes folder.
It's very McGyver, but as long as it works I'm prepared to live with the loss of elegance.
I would use global data files (i.e. jupyter.js) to fetch the data and create the collection which can then be rendered as html anywhere on the site using any template you fancy.

How can I explicitly link to the `index.html` file in a Quarto Book

I'm used to using bookdown to create books that don't have to be hosted on a webserver to work properly. I usually keep the _book directory and make it available on a shared drive with my team so that when my users click a link from somewhere else, they are taken into the book that lives on the OS file system.
With quarto, just about everything works similar to bookdown in this regard. However, when I try to navigate to the index.html landing page, it seems that quarto is expecting this to live on a webserver so the links don't go to book-name/index.html, they instead go to book-name/. Which throws an error when I'm using this in the file system.
Is there a way to ensure the link to the index page in my table of contents explicitly refers to book-name/index.html?
Here is the link that appears when I hover over the bookdown index link in the table of contents.
Here is the link that appears when I hover over the quarto index link in the table of contents.
But everything else in quarto links explicitly to the page it needs.
Also stumbled across this one. I don't think it's desired behavior. Solved it by setting the link manually in the sidebar.
Simply add the following key to book: in the _book.yml file:
book:
.
.
sidebar:
title: "<a href='/index.html'>Your Book Title</a>"

How do I get theme to apply for Hugo/Netlify website?

Using the hugo-geo theme and RStudio, I've built a website on Netlify. My code is on GitHub (https://github.com/kathryn2/Website).
Issue I'm having: The initial page works great. Hyperlinks on left pane all work as intended. When selecting individual posts from the left pane (e.g., https://k22daugherty.netlify.com/post/how-heavily-armed-is-your-state/), formatting totally craps out. It's as if there's no theme and the site doesn't know what to do. I tried seeing if it's a lack of knitting the markdown pages and when I do that I get errors that the images cannot be found. This is my first stab with Rmarkdown (though I'm used to JupyterNotebook with Python), so any obvious fixes are worth mentioning.
Any help appreciated!
Try the following:
modify this filein the line 23 from
<link rel="stylesheet" href="/css/style.css">
to
<link rel="stylesheet" href="public/css/style.css">
If it does not work please notice that your github repository should be the public folder instead of the whole folder where you create your R project and where you are using blogdown.

how do i solve issues regarding external style sheet link which is not in the same directory of the programming file,but works?

I programmed a page (read index.php) including front end and back end operations,and in between i included a link -<link rel="stylesheet" href="style.css" type="text/css">, but there is no effect on the front end application whether I put this css file in the same directory of index.php or delete it. But when I remove the link from the programming page then the front end page is affected. So, how do I conclude this situation? Please anybody help me. I don't understand how the css file works when it is not in the directory where programming page lies.
Based on the information given it sounds like the file is being included from a cache.
Deleting the file on the server wouldn't affect the page render since there is a locally cached version of the file but deleting the link would prevent the browser from loading the cached version.
Sometimes when working on your localhost you have to put the entire path of the CSS file, not just it's normal location as you do when on a live website. Copy your entire path in the href on the link tag and see if it works.
Normally, if the file is in the same place as your index, you put the href the same way it is written in your example above. If your CSS file is in another folder, you would put ../style.css instead. Writing like that, will move up one folder.

Drupal paths in themes

On certain pages drupal_get_path isn't working correctly (or it is and I've got the wrong function)
The base path is wrong
Example:
Image is supposed to be at
http://domain.com/sites/all/modules/pecapture/images/headline_dontmissout.jpg
But when on
http://domain.com/node/9
The URL is
http://domain.com/node/sites/all/modules/pecapture/images/headline_dontmissout.jpg
The same happens on the page
http://domain.com/admin/build/ and block edit page
How do I get the right path?
added base_path() to beginning of my paths...
base_path (http://api.drupal.org/api/base_path), if you use php code.
In html case, just add "/", like: /sites/all/modules/pecapture/images/headline_dontmissout.jpg
One problem: if you work on subfolder (Drupal installed in internal folder of main site): http://domain.com/subfoldersite, it will not correct, becase will remove "subfoldersite".

Resources