Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwilby committed Apr 8, 2024
0 parents commit b494764
Show file tree
Hide file tree
Showing 22 changed files with 9,174 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build to github pages

on:
workflow_dispatch:
push:
branches: main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check out repo
uses: actions/checkout@v4

- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
- run: |
mkdir build
quarto render index.qmd --output-dir build
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build # The folder the action should deploy.
clean: true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pages/*
build/*
/.quarto/
*.html
*_files/
427 changes: 427 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Template for Quarto Presentations with GitHub Actions

Template repository for Quarto presentations with GitHub actions to build and host the presentation using GitHub pages.

## Using this template
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/80x15.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.

## Rendering the slides locally
These slides are produced using [Quarto](https://quarto.org).

In order to render them locally, you will need to install Quarto from <https://quarto.org/docs/get-started/>.

Quarto documents can be rendered in either:
* VSCode
* RStudio (> 2022.07.1+554)
* Jupyter
* Terminal

Full instructions can be found at the link above, however in brief:
* In RStudio, open `index.qmd`, above the document click `Render`
* In the terminal, run `quarto render` to build the files, or `quarto preview` to spin up the preview server.

## Enabling GitHub actions and GitHub Pages

In your repository settings, enable GitHub Actions (if they aren't already) and Pages.

Once the actions have run once and created the `gh-pages` branch, you can select it as your pages source.

## What's included?

* Everything [quarto](https://quarto.org/) can do!
* Emojis are supported :smile: by using the `markdown+emoji` template.
* A couple of extensions I commonly use:
* [`jmbuhr/qrcode`](https://github.com/jmbuhr/quarto-qrcode) - create QR codes in the source code with `{{< qrcode https://linktoathing.com width=350 height=350 >}}`
* [`quarto-ext/fontawesome`](https://github.com/quarto-ext/fontawesome) - include nice fontawesome symbols, e.g. `https://github.com/quarto-ext/fontawesome`

## Contributing
Contributions and improvements are very welcome! Please fork this repo and make a pull request against the `main` branch.
Please ensure that your document compiles successfully with the instructions above.
6 changes: 6 additions & 0 deletions _extensions/jmbuhr/qrcode/_extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
title: Qrcode
author: Jannik Buhr
version: 0.0.1
contributes:
shortcodes:
- qrcode.lua
614 changes: 614 additions & 0 deletions _extensions/jmbuhr/qrcode/assets/qrcode.js

Large diffs are not rendered by default.

78 changes: 78 additions & 0 deletions _extensions/jmbuhr/qrcode/qrcode.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
-- for development:
local p = quarto.utils.dump

---Format string like in bash or python,
---e.g. f('Hello ${one}', {one = 'world'})
---@param s string The string to format
---@param kwargs {[string]: string} A table with key-value replacemen pairs
---@return string
local function f(s, kwargs)
return (s:gsub('($%b{})', function(w) return kwargs[w:sub(3, -2)] or w end))
end

---Add qrcode js dependencies.
local function addDependencies()
quarto.doc.addHtmlDependency {
name = 'qrcodejs',
version = 'v1.0.0',
scripts = { './assets/qrcode.js' },
}
end

---Merge user provided options with defaults
---@param userOptions table
---@return string JSON string to pass to molstar
local function mergeOptions(url, userOptions)
local defaultOptions = {
text = url,
width = 128,
height = 128,
colorDark = "#000000",
colorLight = "#ffffff",
}
if userOptions == nil then
return quarto.json.encode(defaultOptions)
end

for k, v in pairs(userOptions) do
local value = pandoc.utils.stringify(v)
if value == 'true' then value = true end
if value == 'false' then value = false end
defaultOptions[k] = value
end

return quarto.json.encode(defaultOptions)
end

---@return string
local function wrapInlineDiv(options)
return [[
<div id="${id}" class="qrcode"></div>
<script type="text/javascript">
var qrcode = new QRCode("${id}", ]]
.. options..[[);
</script>
]]
end

return {
['qrcode'] = function(args, kwargs, _)
if not quarto.doc.isFormat("html:js") then
return pandoc.Null()
end
addDependencies()
local url = pandoc.utils.stringify(args[1])
local id = 'qrcode'
local maybeId = args[2]
if maybeId ~= nil then
id = pandoc.utils.stringify(maybeId)
end
local options =mergeOptions(url, kwargs)
local text = wrapInlineDiv(options)
return pandoc.RawBlock(
'html',
f(text, {id=id})
)
end,
}

7 changes: 7 additions & 0 deletions _extensions/quarto-ext/fontawesome/_extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: Font Awesome support
author: Carlos Scheidegger
version: 1.1.0
quarto-required: ">=1.2.269"
contributes:
shortcodes:
- fontawesome.lua
Loading

0 comments on commit b494764

Please sign in to comment.