Skip to content

Commit fa6a7c1

Browse files
convert website to quarto
1 parent 22d78e8 commit fa6a7c1

File tree

502 files changed

+1874
-217506
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

502 files changed

+1874
-217506
lines changed

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
on:
2+
workflow_dispatch:
3+
push:
4+
branches: main
5+
6+
name: Quarto Publish
7+
8+
jobs:
9+
build-deploy:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- name: Check out repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Quarto
18+
uses: quarto-dev/quarto-actions/setup@v2
19+
20+
- name: Install R
21+
uses: r-lib/actions/setup-r@v2
22+
with:
23+
r-version: '4.4.2'
24+
25+
- name: Install R Dependencies
26+
uses: r-lib/actions/setup-renv@v2
27+
with:
28+
cache-version: 1
29+
30+
- name: Render and Publish
31+
uses: quarto-dev/quarto-actions/publish@v2
32+
with:
33+
target: gh-pages
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test-render.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Test website render
2+
3+
on:
4+
pull_request:
5+
branches: [main, master]
6+
workflow_dispatch:
7+
8+
jobs:
9+
test-render:
10+
runs-on: ubuntu-latest
11+
container: rocker/tidyverse:4.4.2
12+
env:
13+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Install system dependencies
18+
run: |
19+
apt-get update && apt-get install -y --no-install-recommends \
20+
libxt6 libglpk-dev gh curl jq
21+
22+
- name: Set up Quarto
23+
uses: quarto-dev/quarto-actions/setup@v2
24+
with:
25+
tinytex: true
26+
27+
- name: Install packages from renv.lock (with cache)
28+
if: ${{ !env.ACT }}
29+
uses: r-lib/actions/setup-renv@v2
30+
with:
31+
cache-version: 2
32+
33+
- name: Install packages from renv.lock (local, no cache)
34+
if: ${{ env.ACT }}
35+
run: |
36+
renv::restore()
37+
shell: Rscript {0}
38+
39+
- name: Render document
40+
run: quarto render
41+
42+
- name: Deploy to Netlify
43+
uses: nwtgck/[email protected]
44+
with:
45+
publish-dir: './_site'
46+
production-branch: main
47+
github-token: ${{ secrets.GITHUB_TOKEN }}
48+
deploy-message:
49+
'Deploy from GHA: ${{ github.event.pull_request.title || github.event.head_commit.message }} (${{ github.sha }})'
50+
# these default to 'true'
51+
enable-commit-comment: false
52+
enable-github-deployment: false
53+
env:
54+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
55+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.quarto/
2+
3+
/_site/

.gitkeep

Whitespace-only changes.

LICENSE.md

Lines changed: 642 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# RapidSurveys: Open source tools for designing, planning, implementing, and analysing rapid, reliable, and robust health and nutrition surveys. <img src="images/rapidsurveys.png" width="200px" align="right" />
2+
3+
<!-- badges: start -->
4+
<!-- badges: end -->
5+
6+
Open source project that aims to develop software tools and systems for health and nutrition surveys.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
title: Forms
2+
author: Jonathan Graves
3+
version: 1.0.0
4+
quarto-required: ">=1.2.0"
5+
contributes:
6+
shortcodes:
7+
- forms.lua
8+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This is for custom form CSS /*
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
-- Forms.lua
2+
-- Author: Jonathan Graves
3+
4+
-- Helper Functions
5+
6+
local function addHTMLDeps()
7+
-- add the HTML requirements for the library used
8+
quarto.doc.add_html_dependency({
9+
name = 'forms',
10+
stylesheets = {'forms.css'}
11+
})
12+
end
13+
14+
local function isEmpty(s)
15+
return s == '' or s == nil
16+
end
17+
18+
-- Main Form Function Shortcode
19+
20+
return {
21+
22+
["form"] = function(args, kwargs, meta)
23+
24+
25+
if quarto.doc.is_format("html:js") then
26+
-- this will only run for HTML documents
27+
addHTMLDeps()
28+
29+
local submit_text = pandoc.utils.stringify(meta["form.submit"])
30+
local action = pandoc.utils.stringify(meta["form.action"])
31+
local formid = "form"
32+
if not isEmpty(meta["form.id"]) then
33+
form_id = pandoc.utils.stringify(meta["form.id"])
34+
end
35+
36+
-- If the user passes a method, use it, otherwise use GET
37+
if not isEmpty(meta["form.method"]) then
38+
method = pandoc.utils.stringify(meta["form.method"])
39+
else
40+
method = "GET"
41+
end
42+
43+
-- These are the form items
44+
-- action (form.action) describes the handler function for the form submit
45+
local form_start = "<div id = \"" .. formid .. "-div\" class = \"form-wrapper\">\n <form id = \"" .. formid .. "\" action = \"" .. action .. "\" method = \"" .. method .. "\">\n"
46+
local form_end = "</form></div>\n"
47+
48+
-- Fields for the Form --
49+
local fields = meta["form.fields"]
50+
51+
for f = 1, #fields do
52+
53+
local field = fields[f]
54+
55+
local required = ""
56+
if not isEmpty(field.required) and pandoc.utils.stringify(field.required) == "true" then
57+
required = " required"
58+
end
59+
60+
61+
if isEmpty(field.type) and not isEmpty(field.text) then
62+
-- Handle non-fields (i.e. text)
63+
64+
text = pandoc.utils.stringify(field.text)
65+
66+
if text == "" then
67+
form_start = form_start .. "<hr>" .. "\n"
68+
else
69+
form_start = form_start .. "<br><p>" .. text .. "</p>\n"
70+
end
71+
else
72+
-- Handle regular form fields
73+
74+
local name = pandoc.utils.stringify(field.name)
75+
local type = pandoc.utils.stringify(field.type)
76+
local id = pandoc.utils.stringify(field.id)
77+
local label = pandoc.utils.stringify(field.label)
78+
79+
if type == "text" then
80+
-- Handle text fields
81+
82+
form_start = form_start .. "<div class=\"form-group\">\n"
83+
form_start = form_start .. "<label for=\"" .. id .. "\" class = \"form-label mt-4\">" .. label .. "</label>\n"
84+
form_start = form_start .. " <input type = \"text\" id = \"" .. id .. "\" name = \"" .. name .. "\" class = \"form-control\" " .. required .. " >\n"
85+
form_start = form_start .. "</div>\n"
86+
87+
elseif type == "textarea" then
88+
-- Handle textarea fields
89+
local cols = "30"
90+
local rows = "10"
91+
92+
if not isEmpty(field.width) then
93+
cols = pandoc.utils.stringify(field.width)
94+
end
95+
96+
if not isEmpty(field.height) then
97+
rows = pandoc.utils.stringify(field.height)
98+
end
99+
100+
form_start = form_start .. "<div class=\"form-group\">\n"
101+
form_start = form_start .. "<label for =\"" .. id .. "\">" .. label .. "</label class = \"form-label mt-4\">\n"
102+
form_start = form_start .. "<textarea name =\"" .. name .. "\" id = \"" .. id .. "\" rows = \"" .. rows .. "\" cols =\"" .. cols .."\" class = \"form-control\"></textarea>\n"
103+
form_start = form_start .. "</div>\n"
104+
105+
elseif type == "email" then
106+
-- Handle email address inputs
107+
form_start = form_start .. "<div class=\"form-group\">\n"
108+
form_start = form_start .. "<label for=\"" .. id .. "\" class=\"form-label mt-4\">" .. label .. "</label>\n"
109+
form_start = form_start .. "<input type=\"email\" id=\"" .. id .. "\" name=\"" .. "\" class=\"form-control\" " .. required .. ">\n"
110+
form_start = form_start .. "</div>\n"
111+
112+
elseif type == "file" then
113+
-- Handle file form inputs
114+
115+
form_start = form_start .. "<div class=\"form-group\">\n"
116+
form_start = form_start .. "<label for=\"" .. id .. "\" class=\"form-label mt-4\">" .. label .. "</label>\n"
117+
form_start = form_start .. "<input type=\"file\" id = \"" .. id .. "\" name=\"" .. name .. "\" class=\"form-control\" " .. required .. " >\n"
118+
form_start = form_start .. "</div>\n"
119+
120+
elseif type == "select" then
121+
-- Handle selector (drop-downs)
122+
123+
local size = "3"
124+
if not isEmpty(field.size) then
125+
size = pandoc.utils.stringify(field.size)
126+
end
127+
128+
129+
local multiple = ""
130+
if not isEmpty(field.multiple) then
131+
if pandoc.utils.stringify(field.multiple) == "true" then
132+
multiple = "multiple=\"\""
133+
end
134+
end
135+
136+
form_start = form_start .. "<div class=\"form-group\">\n"
137+
form_start = form_start .. "<label for = \"" .. id .. "\" class=\"form-label mt-4\">" .. label .. "</label>\n"
138+
form_start = form_start .. "<select id= \"" .. id .. "\" size = \"" .. size .. "\" " .. multiple .. " " .. required .. " class=\"form-select\">\n"
139+
140+
for v = 1,#field.values do
141+
local value = field.values[v]
142+
local label_t = pandoc.utils.stringify(value.text)
143+
local val = pandoc.utils.stringify(value.value)
144+
145+
form_start = form_start .. " <option value = \"" .. val .. "\">" .. label_t .. "</option>\n"
146+
147+
end
148+
149+
form_start = form_start .. "</select>\n</div>\n"
150+
151+
else
152+
-- Handle radio and checkboxes
153+
154+
local class = ""
155+
local labelclass = ""
156+
local checked = ""
157+
158+
if type == "radio" then
159+
class = "form-check-input"
160+
labelclass = "form-check-label"
161+
checked = "checked=\"\""
162+
elseif type == "checkbox" then
163+
class = "form-check-input"
164+
labelclass = "form-check-label"
165+
end
166+
167+
form_start = form_start .. "<div class=\"form-group\">\n"
168+
form_start = form_start .. "<fieldset class=\"form-group\">\n"
169+
form_start = form_start .. "<p class = \"form-label\">" .. label .. "</p>\n"
170+
for v = 1, #field.values do
171+
172+
local value = field.values[v]
173+
-- multi-option fields need to have a label for each value
174+
local label_t = "&nbsp;" .. pandoc.utils.stringify(value.text)
175+
local val = pandoc.utils.stringify(value.value)
176+
177+
form_start = form_start .. "<div class=\"form-check\">\n"
178+
form_start = form_start .. " <input type = \"" .. type .. "\" id = \"" .. id .. v .. "\" name = \"" .. name .. "\" value =\"" .. val .. "\"" .. " class =\"" .. class .. "\" autocomplete=\"off\" " .. checked .. " " .. required .. " >\n"
179+
form_start = form_start .. " <label for=\"" .. id .. v .. "\" class=\"" .. labelclass .. "\">" .. label_t .. "</label>\n"
180+
form_start = form_start .. "</div>\n"
181+
end
182+
183+
form_start = form_start .. "</fieldset>\n</div>\n"
184+
185+
186+
end
187+
188+
end
189+
end
190+
-- Close the form and submit
191+
form_start = form_start .. "<br>\n<div class=\"form-group\">\n"
192+
form_start = form_start .. " <input type=\"submit\" value = \"" .. submit_text .. "\" class=\"btn btn-primary\">\n</div>\n"
193+
form_start = form_start .. form_end
194+
-- quarto.log.output(form_start)
195+
return pandoc.RawInline("html", form_start)
196+
197+
198+
else
199+
return pandoc.Null()
200+
end
201+
202+
end
203+
204+
}
205+

_quarto.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
project:
2+
type: website
3+
4+
website:
5+
title: RapidSurveys
6+
site-url: https://rapidsurveys.io
7+
navbar:
8+
title: RapidSurveys
9+
logo: images/rapidsurveys_neg.png
10+
logo-alt: RapidSurveys
11+
tools:
12+
- icon: mastodon
13+
aria-label: Mastodon
14+
href: https://fosstodon.org/@katilingban
15+
rel: me
16+
- icon: linkedin
17+
aria-label: LinkedIn
18+
href: https://linkedin.com/company/katilingban
19+
- icon: github
20+
aria-label: GitHub
21+
href: https://github.com/rapidsurveys
22+
left:
23+
- href: index.qmd
24+
text: Home
25+
- text: Packages
26+
href: packages/index.qmd
27+
- text: About
28+
menu:
29+
- href: about/team.qmd
30+
- href: about/contact.qmd
31+
open-graph:
32+
site-name: RapidSurveys
33+
page-footer:
34+
center: "Copyright 2024, Katilingban"
35+
background: light
36+
border: false
37+
reader-mode: true
38+
repo-url: https://github.com/rapidsurveys/rapidsurveys.github.io
39+
repo-actions: [edit, issue]
40+
issue-url: https://github.com/rapidsurveys/rapidsurveys.github.io/issues
41+
cookie-consent:
42+
type: express
43+
style: simple
44+
palette: light
45+
google-analytics:
46+
tracking-id: "G-0T1H0GBVXG"
47+
anonymize-ip: true
48+
49+
format:
50+
html:
51+
theme: [sandstone, custom.scss]
52+
css: styles.css
53+
grid:
54+
sidebar-width: 250px
55+
body-width: 900px
56+
margin-width: 250px
57+
gutter-width: 1.5rem
58+
toc: false

0 commit comments

Comments
 (0)