-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from shgysk8zer0/feature/wfd-mayor-events
Add WF Mayor funcs & other enhancements
- Loading branch information
Showing
9 changed files
with
105 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* @copyright 2023 Chris Zuber <[email protected]> | ||
* @copyright 2023-2024 Chris Zuber <[email protected]> | ||
*/ | ||
import { createIframe } from '../elements.js'; | ||
import { policy, trustedURLs, trustPolicies } from './policy.js'; | ||
|
@@ -122,4 +122,38 @@ export function createWFDEvents({ | |
}); | ||
} | ||
|
||
export function createWFDMayorEvents({ | ||
theme, mayor, heading, address = false, description = true, width, height, loading = 'lazy', | ||
fetchPriority = 'auto', title, id, classList, referrerPolicy = 'no-referrer', | ||
credentialless = true, styles, dataset, slot, part, | ||
} = {}) { | ||
const src = new URL(trustedURLs.wfdMayorEvents.href); | ||
|
||
if (typeof theme === 'string') { | ||
src.searchParams.set('theme', theme); | ||
} | ||
|
||
if (typeof mayor === 'string') { | ||
src.searchParams.set('mayor', mayor); | ||
} | ||
|
||
if (typeof heading === 'string') { | ||
src.searchParams.set('heading', heading); | ||
} | ||
|
||
if (address) { | ||
src.searchParams.set('address', ''); | ||
} | ||
|
||
if (description) { | ||
src.searchParams.set('description', ''); | ||
} | ||
|
||
return createIframe(src.href, { | ||
height, width, referrerPolicy, fetchPriority, loading, title, classList, | ||
id, policy, sandbox: ['allow-scripts', 'allow-popups'], styles, dataset, | ||
slot, part, credentialless, | ||
}); | ||
} | ||
|
||
export { trustPolicies }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
/** | ||
* @copyright 2023 Chris Zuber <[email protected]> | ||
* @copyright 2023-2024 Chris Zuber <[email protected]> | ||
*/ | ||
import { createPolicy } from '../trust.js'; | ||
|
||
export const trustedURLs = { | ||
maps: new URL('/embed', 'https://maps.kernvalley.us'), | ||
events: new URL('/embed/', 'https://events.kernvalley.us'), | ||
wfdEvents: new URL('/embed/', 'https://whiskeyflatdays.com'), | ||
wfdMayorEvents: new URL('/mayors/embed/', 'https://whiskeyflatdays.com'), | ||
}; | ||
|
||
export const policy = createPolicy('krv#embed', { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
/** | ||
* @copyright 2023 Chris Zuber <[email protected]> | ||
* @copyright 2023-2024 Chris Zuber <[email protected]> | ||
*/ | ||
import { getJSON } from '../http.js'; | ||
import { createICalFile, METHOD } from '../iCal.js'; | ||
import { ICAL as ICAL_MIME } from '@shgysk8zer0/consts/mimes.js'; | ||
|
||
export const events = new URL('https://whiskeyflatdays.com/events.json'); | ||
export const mayorEvents = new URL('https://whiskeyflatdays.com/mayors/events.json'); | ||
|
||
export const getEvents = async ({ signal } = {}) => getJSON(events, { signal }); | ||
export const getMayorEvents = async ({ signal } = {}) => getJSON(mayorEvents, { signal }); | ||
|
||
export async function getWFDEventsICalFile({ | ||
filename = 'wfd-events.ics', | ||
|
@@ -28,3 +30,17 @@ export async function getWFDEventsICalFile({ | |
|
||
return createICalFile(events, { filename, method, type }); | ||
} | ||
|
||
export async function getWFDMayorEventsICalFile({ | ||
filename = 'wfd-mayor-events.ics', | ||
method = METHOD.PUBLISH, | ||
type = ICAL_MIME, | ||
signal, | ||
} = {}) { | ||
const events = await getMayorEvents({ signal }) | ||
.then(events => events.map( | ||
({ performer, name, ...rest }) => ({ name: `${performer.name} - ${name}`, ...rest }) | ||
)); | ||
|
||
return createICalFile(events, { filename, method, type }); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr" data-trusted-policies="empty#html empty#script custom#html sanitizer-raw#html blob#script-url youtube#embed"> | ||
<html lang="en" dir="ltr" data-trusted-policies="empty#html empty#script custom#html sanitizer-raw#html blob#script-url youtube#script-url krv#embed"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
|
@@ -13,16 +13,16 @@ | |
style-src 'self' https://unpkg.com/ blob:; | ||
font-src cdn.kernvalley.us; | ||
form-action 'none'; | ||
frame-src https://www.youtube-nocookie.com/embed/ https://calendar.google.com/calendar/embed https://www.google.com/maps/embed; | ||
frame-src https://www.youtube-nocookie.com/embed/ https://calendar.google.com/calendar/embed https://www.google.com/maps/embed https://whiskeyflatdays.com/embed/ https://whiskeyflatdays.com/mayors/embed/; | ||
object-src 'none'; | ||
media-src 'none'; | ||
child-src 'self'; | ||
worker-src 'self'; | ||
frame-ancestors 'none'; | ||
connect-src 'self' https://unpkg.com/ https://api.github.com/users/ https://api.github.com/repos/ https://api.pwnedpasswords.com/range/ https://maps.kernvalley.us/places/ https://events.kernvalley.us/events.json https://events.kernvalley.us/cal/krv-events.ics https://whiskeyflatdays.com/events.json; | ||
connect-src 'self' https://unpkg.com/ https://api.github.com/users/ https://api.github.com/repos/ https://api.pwnedpasswords.com/range/ https://maps.kernvalley.us/places/ https://events.kernvalley.us/events.json https://events.kernvalley.us/cal/krv-events.ics https://whiskeyflatdays.com/events.json https://whiskeyflatdays.com/mayors/events.json; | ||
img-src * data: blob:; | ||
require-trusted-types-for 'script'; | ||
trusted-types empty#html empty#script default sanitizer-raw#html trust-raw#html youtube#script-url github-user#html github-repo#html blob#script-url goog-cal#script-url goog-maps#script-url; | ||
trusted-types empty#html empty#script default sanitizer-raw#html trust-raw#html youtube#script-url github-user#html github-repo#html blob#script-url goog-cal#script-url goog-maps#script-url krv#embed; | ||
upgrade-insecure-requests;" | ||
/> | ||
<title>Kazoo</title> | ||
|
@@ -39,7 +39,7 @@ | |
"@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/[email protected]/", | ||
"@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/[email protected]/http-status.js", | ||
"@shgysk8zer0/components/": "https://unpkg.com/@shgysk8zer0/[email protected]/", | ||
"@kernvalley/components/": "https://unpkg.com/@kernvalley/components@1.0.2/", | ||
"@kernvalley/components/": "https://unpkg.com/@kernvalley/components@1.1.2/", | ||
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/[email protected]/custom-elements.min.js", | ||
"leaflet": "https://unpkg.com/[email protected]/dist/leaflet-src.esm.js", | ||
"firebase/": "https://www.gstatic.com/firebasejs/9.22.2/", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters