Skip to content

Instantly share code, notes, and snippets.

View marcus-at-localhost's full-sized avatar
💭
☕

Marcus marcus-at-localhost

💭
☕
View GitHub Profile

As a flat file CMS, Kirby stores all content in folders and files. This is not only true for pages, but also for files and user accounts, which are by default stored in the /site/accounts folder.

But in the same way as you can incorporate content from other sources like spreadsheets, feeds or databases to create (link: text: virtual pages in Kirby), you can also replace users stored in the file system with users stored in a database (or some other source).

In this recipe, we will see how we can achieve this. For this purpose, we will start with a simple read-only solution and then extend this basic setup step-by-step into a solution that lets us create and edit database users from the Panel, including multi-language user content.

Note that using users from a database as described in this recipe will **not** solve potential performance issues with thousands of users.
@marcus-at-localhost
marcus-at-localhost / postman-pre-request.js
Created July 16, 2021 14:10 — forked from bcnzer/postman-pre-request.js
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',
@marcus-at-localhost
marcus-at-localhost / dropbox-php-auth.md
Created June 28, 2021 08:07 — forked from phuze/dropbox-php-auth.md
Dropbox API V2: PHP Authentication Process

Effective September 2021, Dropbox will be deprecating long-lived access tokens.

This GIST generally describes how to authenticate requests to Dropbox API v2, for anyone working on a server-side PHP Dropbox implementation.

It's important to understand three types of codes you'll encounter:

  1. Access Code - this is a one-time code that represents user-granted app access.
  2. Access Token - this is short-lived token that provides access to Dropbox API endpoints.
  3. Refresh Token - this is a long-lived token that allows you to fetch a fresh Access Token.
@marcus-at-localhost
marcus-at-localhost / sticky.css
Last active June 27, 2021 08:21
[Sticky Element with Flexbox] Sticky Position will not work if your parent is using display flex. https://stackoverflow.com/a/66966273/814031
.sticky {
position: sticky;
top: 0;
align-self: flex-start;
height: auto;
}
@marcus-at-localhost
marcus-at-localhost / AuthenticationHandler.php
Created May 29, 2021 06:22
[Authenticated Calls to the AtroPIM API with Guzzle PHP] #guzzle https://marcus-obst.de/blog/query-atropim-api-with-guzzle
<?php
use Psr\Http\Message\RequestInterface;
class AuthenticationHandler
{
private $username;
private $password;
@marcus-at-localhost
marcus-at-localhost / import_trim.gsheet
Last active April 9, 2021 08:09
[Google Sheets Import CSV and Trim] #googlesheets #googlescript
=ARRAYFORMULA(TRIM(IMPORTDATA("https://data.com/table.csv")))
@marcus-at-localhost
marcus-at-localhost / goog-maps-formulas.js
Created April 1, 2021 12:14
[Google Maps Formulas for Google Sheets] #googlescript #googlesheets https://www.labnol.org/google-maps-sheets-200817
/*
*
* Google Maps Formulas for Google Sheets
*
* Written by Amit Agarwal
*
* Web: https://labnol.org/google-maps-formulas-for-sheets-200817
*
*/
@marcus-at-localhost
marcus-at-localhost / script.js
Created April 1, 2021 11:49
[Add Zip Code to City Names in Google Sheets via OpendataSoft API] Use `=geo2zip(E1:E5)` #googlesheets #googlescripts #fetch
// API https://public.opendatasoft.com/explore/dataset/georef-germany-postleitzahl/api/
function geo2zip(a) {
let url = 'https://public.opendatasoft.com/api/records/1.0/search/?dataset=georef-germany-postleitzahl&q=' + a + '&facet=plz_name&facet=lan_name&facet=lan_code';
var response = UrlFetchApp.fetch(url);
var res = JSON.parse(response.getContentText());
return res.records[0].fields.plz_name_long;
//console.log(a,url, res.records[0].fields.plz_name_long);
//var auth = JSON.parse(response.getContentText());
document.addEventListener("visibilitychange", () => {
const state = document.visibilityState;
if (state === "hidden") {
// your PWA is now in the background
}
if (state === "visible") {
// your PWA is now in the foreground
refreshData();
}
@marcus-at-localhost
marcus-at-localhost / _offline-and-connection-detection-and-web-component.markdown
Last active January 31, 2023 17:02
Offline and Connection Detection and Web Component