Skip to content

Commit 4b3a112

Browse files
authored
Blog example (#90)
* Re-direct styling to new top-level document * Bring online the blog template * Add disclaimer on RevealJS usage. * Add RevealJS Template * Add blog example * Add gitignores * newline at the end of the file * Add blog case * Add blog render
1 parent 5c2b903 commit 4b3a112

20 files changed

+121
-51
lines changed

.github/workflows/publish-demo.yml

+6
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ jobs:
6868
with:
6969
path: "examples/website"
7070

71+
- name: Render sample deployment blog template
72+
uses: quarto-dev/quarto-actions/render@v2
73+
with:
74+
path: "examples/blog"
75+
7176
- name: Render sample deployment book template
7277
uses: quarto-dev/quarto-actions/render@v2
7378
with:
@@ -86,6 +91,7 @@ jobs:
8691
cp -rp tests/_site/* staging/tests/ && \
8792
cp -rp examples/book/_book staging/examples/book && \
8893
cp -rp examples/website/_site staging/examples/website && \
94+
cp -rp examples/blog/_site staging/examples/blog && \
8995
cp -rp examples/html-document/ staging/examples/html-document && \
9096
cp -rp examples/revealjs/ staging/examples/revealjs && \
9197
cp -rp examples/readme/ staging/examples/readme

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# webR Extension for Quarto
22

3-
This extension enables the [webR](https://docs.r-wasm.org/webr/latest/) code cell within various [Quarto](https://quarto.org/) formats, including [HTML](https://quarto.org/docs/output-formats/html-basics.html), [Websites](https://quarto.org/docs/websites/), and [Books](https://quarto.org/docs/books).
3+
This extension enables the [webR](https://docs.r-wasm.org/webr/latest/) code cell within various [Quarto](https://quarto.org/) formats, including [HTML](https://quarto.org/docs/output-formats/html-basics.html), [Websites](https://quarto.org/docs/websites/), [Blogs](https://quarto.org/docs/websites/website-blog.html), and [Books](https://quarto.org/docs/books).
44

55
![`quarto-webr` Filter in Action](https://i.imgur.com/NCTDwUk.gif)
66

@@ -68,6 +68,8 @@ During the execution, the filter adds two files to the working directory: `webr-
6868

6969
There are many more customization options that are available. Please see the [customization documentation](https://quarto-webr.thecoatlessprofessor.com/qwebr-meta-options.html) for more examples.
7070

71+
For specific deployment usage cases, please see [Templates](https://quarto-webr.thecoatlessprofessor.com/qwebr-deployment-templates.html).
72+
7173
## Help
7274

7375
For troubleshooting help, please see our [troubleshooting page](https://quarto-webr.thecoatlessprofessor.com/qwebr-troubleshooting.html).

docs/index.qmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ filters:
77
- webr
88
---
99

10-
Welcome to the documentation portal for the [`quarto-webr`](https://github.com/coatless/quarto-webr) extension – your key to unlocking the endless possibilities of [webR](https://docs.r-wasm.org/webr/latest/) within various [Quarto](https://quarto.org/) formats, including [HTML](https://quarto.org/docs/output-formats/html-basics.html), [Websites](https://quarto.org/docs/websites/), and [Books](https://quarto.org/docs/books).
10+
Welcome to the documentation portal for the [`quarto-webr`](https://github.com/coatless/quarto-webr) extension – your key to unlocking the endless possibilities of [webR](https://docs.r-wasm.org/webr/latest/) within various [Quarto](https://quarto.org/) formats, including [HTML](https://quarto.org/docs/output-formats/html-basics.html), [Websites](https://quarto.org/docs/websites/), [Blogs](https://quarto.org/docs/websites/website-blog.html), and [Books](https://quarto.org/docs/books).
1111

1212
Ready for an exciting journey into the world of webR's interactive code cells? Click the "Run Code" button below to experience it firsthand:
1313

@@ -19,6 +19,6 @@ model = lm(mpg ~ wt, data = mtcars)
1919
summary(model)
2020
```
2121

22-
At its core, the [quarto-webr extension](https://github.com/coatless/quarto-webr) is designed to empower you to run R code directly in your web browser using familiar reporting tools, all without the need for an external R server. Moreover, the extension abstracts away the need to know HTML or JavaScript to use webR. However, it's worth noting that you can also choose to unlock the full potential of webR and create more complex applications independently by directly using [webR's JavaScript API](https://docs.r-wasm.org/webr/latest/evaluating.html), granting you unparalleled freedom to harness the power of R in innovative ways.
22+
At its core, the [`quarto-webr` extension](https://github.com/coatless/quarto-webr) is designed to empower you to run R code directly in your web browser using familiar reporting tools, all without the need for an external R server. Moreover, the extension abstracts away the need to know HTML or JavaScript to use webR. However, it's worth noting that you can also choose to unlock the full potential of webR and create more complex applications independently by directly using [webR's JavaScript API](https://docs.r-wasm.org/webr/latest/evaluating.html), granting you unparalleled freedom to harness the power of R in innovative ways.
2323

2424
With this in mind, let's dive in and kickstart your journey with interactive code cells by [creating our very first webR-powered Quarto document](qwebr-first-steps.qmd) or [exploring some examples](qwebr-code-cell-demos.qmd)!

docs/qwebr-deployment-templates.qmd

+21-5
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,36 @@ Discover a range of sample deployment templates for the `quarto-webr` extension
1111
This template is designed for creating standalone HTML documents with interactive webR functionality. It's suitable for individual reports or interactive documents.
1212

1313
- **Example**: You can find an example of an HTML document template [here](https://quarto-webr.thecoatlessprofessor.com/examples/html-document/).
14-
- **Source Code**: Access the source code for this template [here](https://github.com/coatless/quarto-webr/tree/main/docs/examples/html-document).
14+
- **Source Code**: Access the source code for this template [here](https://github.com/coatless/quarto-webr/tree/main/examples/html-document).
15+
16+
# RevealJS Presentation Template
17+
18+
This template is designed for creating standalone RevealJS presentations with interactive webR functionality. It's suitable for creating lecture slides.
19+
20+
:::{.callout-important}
21+
This template requires a [**pre-release** version of Quarto](https://quarto.org/docs/download/prerelease) that contains an updated copy of `pandoc`. For more details, please see [Issue #14](https://github.com/coatless/quarto-webr/issues/14).
22+
:::
23+
24+
- **Example**: You can find an example of an HTML document template [here](https://quarto-webr.thecoatlessprofessor.com/examples/revealjs/).
25+
- **Source Code**: Access the source code for this template [here](https://github.com/coatless/quarto-webr/tree/main/examples/revealjs).
1526

1627
# Website Template
1728

18-
This template is meant for building interactive websites with multiple webR-powered pages. It's ideal for creating blog posts, educational platforms, or any web content that requires interactive data analysis.
29+
This template is meant for building interactive websites with multiple webR-powered pages. It's ideal for websites that have multiple piece of web content that requires interactive data analysis at the "top-level".
1930

2031
- **Example**: Explore an example of a website template [here](https://quarto-webr.thecoatlessprofessor.com/examples/website/).
21-
- **Source Code**: Access the source code for this template [here](https://github.com/coatless/quarto-webr/tree/main/docs/examples/website).
32+
- **Source Code**: Access the source code for this template [here](https://github.com/coatless/quarto-webr/tree/main/examples/website).
2233

34+
# Blog Template
35+
36+
For users who want to periodically use webR on their Quarto blog, please use the following template.
37+
38+
- **Example**: Explore an example of a blog website template [here](https://quarto-webr.thecoatlessprofessor.com/examples/blog/).
39+
- **Source Code**: Access the source code for this template [here](https://github.com/coatless/quarto-webr/tree/main/examples/blog).
2340

2441
# Book Template
2542

2643
The book template is designed for creating interactive web-based books or documentation. It allows you to compile a collection of chapters, sections, and interactive content into a cohesive digital book.
2744

2845
- **Example**: You can view an example of a book template [here](https://quarto-webr.thecoatlessprofessor.com/examples/book).
29-
- **Source Code**: Access the source code for this template [here](https://github.com/coatless/quarto-webr/tree/main/docs/examples/book).
30-
46+
- **Source Code**: Access the source code for this template [here](https://github.com/coatless/quarto-webr/tree/main/examples/book).

docs/qwebr-faq.qmd

+1-39
Original file line numberDiff line numberDiff line change
@@ -87,42 +87,4 @@ Error messages, warnings, and other diagnostic information are presented in the
8787

8888
> Q. Is it possible to style the UI elements the quarto-webr extension add to your document? Do they get affected by styling/theme changes so things look coherent?
8989
90-
Certainly! You have the flexibility to style the UI elements added by the `quarto-webr` extension to your document. These elements are categorized into three distinct areas, each of which can be styled individually. They are identifiable by their unique `id` and `class` attributes:
91-
92-
1. **Interactive Code Editor**: This is where you input and edit your R code.
93-
- `id`: `#webr-editor-{{ID}}`
94-
- `class`: `.webr-editor`
95-
96-
2. **Output Area**: This is where the results and output of your R code are displayed.
97-
- `id`: `#webr-code-stdout-{{ID}}`
98-
- `class`: `.webr-code-stdout`
99-
100-
3. **Run Button**: The button that triggers the execution of your R code.
101-
- `id`: `#webr-btn-run-{{ID}}`
102-
- `class`: `.webr-btn-run`
103-
104-
The `{{ID}}` in these identifiers represents the instance of the element on the page, such as the first, second, or nth occurrence. By targeting the specific `id` or `class` attributes in your document's CSS or by including a separate CSS file, you can control their appearance as per your design preferences.
105-
106-
For example, you can insert new CSS elements by using:
107-
108-
````markdown
109-
```{=html}
110-
<style>
111-
.webr-code-stdout {background-color: powderblue;}
112-
.webr-btn-run {color: blue;}
113-
</style>
114-
```
115-
````
116-
117-
Additionally, if you are using a Quarto theme, you can leverage [theme-specific styling options](https://quarto.org/docs/output-formats/html-themes.html#basic-options) to ensure that these UI elements align with the overall theme of your document.
118-
119-
````markdown
120-
---
121-
title: My post
122-
format:
123-
html:
124-
theme:
125-
- cosmo
126-
- custom.scss
127-
---
128-
````
90+
Certainly! You have the flexibility to style the UI elements added by the `quarto-webr` extension to your document. For more details, please see [Theming Elements](qwebr-theming.qmd).

examples/blog/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.quarto/
2+
/_site/*

examples/blog/_extensions

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../_extensions

examples/blog/_quarto.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
project:
2+
type: website
3+
4+
website:
5+
title: "blog"
6+
navbar:
7+
right:
8+
- about.qmd
9+
- icon: github
10+
href: https://github.com/
11+
- icon: twitter
12+
href: https://twitter.com
13+
format:
14+
html:
15+
theme: cosmo
16+
css: styles.css
17+
18+
# Enable webR on all post pages
19+
webr:
20+
channel-type: 'post-message'
21+
filters:
22+
- webr

examples/blog/about.qmd

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: "About"
3+
image: profile.jpg
4+
about:
5+
template: jolla
6+
links:
7+
- icon: github
8+
text: GitHub
9+
href: https://github.com/coatless/quarto-webr
10+
---
11+
12+
This blog is a demo showing how to use the `quarto-webr` extension.

examples/blog/index.qmd

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "blog"
3+
listing:
4+
contents: posts
5+
sort: "date desc"
6+
type: default
7+
categories: true
8+
sort-ui: false
9+
filter-ui: false
10+
page-layout: full
11+
title-block-banner: true
12+
---
13+
14+

examples/blog/posts/_metadata.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# options specified here will apply to all posts in this folder
2+
3+
# freeze computational output
4+
# (see https://quarto.org/docs/projects/code-execution.html#freeze)
5+
freeze: true
6+
7+
# Enable banner style title blocks
8+
title-block-banner: true
40.8 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: "Post With Interactive Code"
3+
author: "James Balamuta"
4+
date: "2023-11-12"
5+
categories: [news, code, analysis]
6+
image: "image.jpg"
7+
---
8+
9+
This is a post with interactive code on a [Quarto Blog](https://quarto.org/docs/websites/website-blog.html) through the [`quarto-webr`](https://github.com/coatless/quarto-webr) extension. The configuration setup for the `quarto-webr` extension is taken care of in the `_quarto.yml` file to avoid needing to re-specify options multiple times.
10+
11+
```{webr-r}
12+
print("Hello blog Quarto world!")
13+
```

examples/blog/profile.jpg

59.1 KB
Loading

examples/blog/styles.css

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* css styles */

examples/book/slide-embed.qmd

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ On this page, we show how we can embed a RevealJS Presentation inside of a Quart
66

77
## Presentation
88

9+
:::{.callout-important}
10+
For `quarto-webr` to work within RevealJS, you must use a [**pre-release** version of Quarto](https://quarto.org/docs/download/prerelease) that contains an updated copy of `pandoc`. For more details, please see [Issue #14](https://github.com/coatless/quarto-webr/issues/14).
11+
:::
12+
913
<div>
1014
```{=html}
1115
<iframe class="slide-deck" src="../revealjs/"></iframe>

examples/html-document/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.quarto/

examples/revealjs/index.qmd

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ filters:
1515

1616
Welcome to a demo RevealJS presentation that uses the [`quarto-webr`](https://github.com/coatless/quarto-webr) extension to generate interactive code cells with [Quarto](https://quarto.org) and [webR](https://docs.r-wasm.org/webr/latest/).
1717

18-
```{webr-r}
19-
print("Hello there! Welcome to a quarto-webR powered revealjs presentation!")
20-
```
18+
:::{.callout-important}
19+
This template requires a [**pre-release** version of Quarto](https://quarto.org/docs/download/prerelease) that contains an updated copy of `pandoc`. For more details, please see [Issue #14](https://github.com/coatless/quarto-webr/issues/14).
20+
:::
2121

22-
Let's go back to the [documentation portal](../../)
22+
Not the right template? Let's go back to the [documentation portal](../../)
2323

2424
## webR in RevealJS
2525

examples/website/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.quarto/
2+
/_site/*

examples/website/slide-embed.qmd

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ On this page, we show how we can embed a RevealJS Presentation inside of a Quart
66

77
## Presentation
88

9+
:::{.callout-important}
10+
For `quarto-webr` to work within RevealJS, you must use a [**pre-release** version of Quarto](https://quarto.org/docs/download/prerelease) that contains an updated copy of `pandoc`. For more details, please see [Issue #14](https://github.com/coatless/quarto-webr/issues/14).
11+
:::
12+
913
<div>
1014
```{=html}
1115
<iframe class="slide-deck" src="../revealjs/"></iframe>

0 commit comments

Comments
 (0)