Skip to content

Instantly share code, notes, and snippets.

View grantmacken's full-sized avatar
🏠
Working from home

Grant MacKenzie grantmacken

🏠
Working from home
View GitHub Profile
@grantmacken
grantmacken / muURL.xqm
Last active March 8, 2023 00:13
xQuery helper functions for dealing with URLs
xquery version "3.0";
(:~
This module contains helper functions for dealing with URLs.
When receiving webmention the post parameter 'source' is a URL pointing to the
origin of the mention.
Before we get and store a sanitized version of an HTML document the url links to
we want to able to
@grantmacken
grantmacken / xdm-type.xqm
Created September 13, 2022 23:51 — forked from adamretter/xdm-type.xqm
xdm-type.xqm
declare function local:xdm-type($value as item()?) as xs:QName? {
typeswitch($value)
case array(*) return xs:QName("array")
case map(*) return xs:QName("map")
case function(*) return xs:QName("function")
case document-node() return xs:QName("document")
case element() return xs:QName("element")
case attribute() return xs:QName("attribute")
case comment() return xs:QName("comment")
case processing-instruction() return xs:QName("processing-instruction")
@grantmacken
grantmacken / issue.txt
Last active March 13, 2021 21:36
extract front-matter from a markdown file into vars
---
ISSUE_DATE=2015-01-14
ISSUE_LABEL="enhancement"
ISSUE_TITLE="branch selection from issue"
ISSUE_STATE="open"
ISSUE_NUMBER=2
---
A one line *summary* of what we hope to resolve.
- [x] todo task 1
@grantmacken
grantmacken / .env
Last active February 19, 2019 21:54
Use prove to get TAP output from running #existdb unit tests
NAME=newBase60
CONTAINER=exDev
PORT=8282
USE_DC_OVERRIDE=yes
DC_OVERRIDE_NETWORK=www
@grantmacken
grantmacken / archive-trigger.xqm
Last active February 15, 2019 15:32
a existdb trigger which syncs localhost to remotehost ( http://markup.co.nz/archive/2014/02/12/publishing-posts )
xquery version "3.0";
module namespace trigger = "http://exist-db.org/xquery/trigger";
declare namespace xhtml = "http://www.w3.org/1999/xhtml";
declare namespace atom = "http://www.w3.org/2005/Atom";
declare namespace repo="http://exist-db.org/xquery/repo";
import module namespace system = "http://exist-db.org/xquery/system";
import module namespace util = "http://exist-db.org/xquery/util";
import module namespace xmldb = "http://exist-db.org/xquery/xmldb";
@grantmacken
grantmacken / router.t
Last active June 5, 2018 06:53
WIP: for local dev container - running prove in a docker container, use nginx::test to test restXQ routes
use Test::Nginx::Socket 'no_plan';
log_level('debug'); # to ensure any log-level can be outputted
#no_diff();
no_long_string();
run_tests();
__DATA__
=== TEST 1: zie.nz
--- config
@grantmacken
grantmacken / router.xql
Created June 4, 2018 00:53
xqRest router
xquery version "3.1";
(:~ main app routes
@author Grant MacKenzie
@version 0.1
this app is proxied behind openresty/nginx
the data for the app is separate from the app
-------------------------------------------
@grantmacken
grantmacken / home.html
Created May 19, 2018 19:37
Starter eXist Templates : home
<html>
<head>
<title>home page</title>
</head>
<body>
My home page
</body>
</html>
@grantmacken
grantmacken / pre-install.xq
Created December 13, 2017 19:53
xQuery pre-install for xar
xquery version "3.1";
import module namespace xdb="http://exist-db.org/xquery/xmldb";
declare variable $home external;
declare variable $dir external;
declare variable $target external;
declare variable $domain := substring-after( string($target), '/apps/');
declare variable $pages := 'data/' || $domain || '/docs/pages';
declare variable $posts := 'data/' || $domain || '/docs/posts';
declare variable $recycle := 'data/' || $domain || '/docs/recycle';
declare variable $uploads := 'data/' || $domain || '/docs/uploads';
@grantmacken
grantmacken / .gitignore
Last active December 13, 2017 18:44
gitignore for my sites
Makefile
.*
_content
demo.json