From 9214b17aece927311c4f46ad224059d773209a2d Mon Sep 17 00:00:00 2001 From: TheRON Date: Fri, 5 Jun 2026 15:39:31 -0400 Subject: [PATCH] Initial push --- hubzilla/addon/scn01/config.json.template | 6 + hubzilla/addon/scn01/mod_scn01.pdl | 14 ++ hubzilla/addon/scn01/scn01.apd | 7 + hubzilla/addon/scn01/scn01.php | 155 ++++++++++++++++++++++ 4 files changed, 182 insertions(+) create mode 100644 hubzilla/addon/scn01/config.json.template create mode 100644 hubzilla/addon/scn01/mod_scn01.pdl create mode 100644 hubzilla/addon/scn01/scn01.apd create mode 100644 hubzilla/addon/scn01/scn01.php diff --git a/hubzilla/addon/scn01/config.json.template b/hubzilla/addon/scn01/config.json.template new file mode 100644 index 0000000..328897e --- /dev/null +++ b/hubzilla/addon/scn01/config.json.template @@ -0,0 +1,6 @@ +{ + "_note": "Copy to config.json. Do not commit config.json — it contains secrets and installation-specific values.", + "corpus_builder_group_id": 0, + "listings_file": "REPLACE — absolute path to listings.json on the host", + "directory_default_tab": "core" +} diff --git a/hubzilla/addon/scn01/mod_scn01.pdl b/hubzilla/addon/scn01/mod_scn01.pdl new file mode 100644 index 0000000..28f1924 --- /dev/null +++ b/hubzilla/addon/scn01/mod_scn01.pdl @@ -0,0 +1,14 @@ +[template]default[/template] + +[region=aside] +[widget=scn01][/widget] +[/region] + +[region=content] +$content +[/region] + +[region=right_aside] +[widget=notifications][/widget] +[widget=newmember][/widget] +[/region] diff --git a/hubzilla/addon/scn01/scn01.apd b/hubzilla/addon/scn01/scn01.apd new file mode 100644 index 0000000..ca43bc0 --- /dev/null +++ b/hubzilla/addon/scn01/scn01.apd @@ -0,0 +1,7 @@ +version: 2 +url: $baseurl/scn01 +requires: local_channel +name: Scenarios +photo: icon:person-lines-fill +categories: Civic Diagnostics +desc: Participant intake — browse diagnostic scenarios, submit your account in your own words. diff --git a/hubzilla/addon/scn01/scn01.php b/hubzilla/addon/scn01/scn01.php new file mode 100644 index 0000000..06ae1d5 --- /dev/null +++ b/hubzilla/addon/scn01/scn01.php @@ -0,0 +1,155 @@ + + + + '; +} + +// ---------------------------------------------------------------------------- +// CONTENT +// ---------------------------------------------------------------------------- + +function scn01_content() { + if (function_exists('head_add_css')) { + head_add_css('/addon/scn01/view/css/scn01.css'); + } + if (function_exists('head_add_js')) { + head_add_js('/addon/scn01/view/js/scn01.js'); + } + + $access = scn01_access_state(); + + // scn01 is public — access wall only gates submission, not reading + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if ($access === 'public' || $access === 'denied') { + return scn01_access_wall(); + } + // TODO: handle POST submission + return scn01_access_wall(); + } + + return scn01_render_main($access); +} + +// ---------------------------------------------------------------------------- +// RENDER +// ---------------------------------------------------------------------------- + +function scn01_render_main($access) { + $out = '
'; + $out .= '
'; + $out .= '

Vital Signs

'; + $out .= '

The ten structural preconditions of an HOA association.

'; + $out .= '
'; + + // TODO: render the ten Vital Signs + + $out .= '
Content forthcoming.
'; + $out .= '
'; + + return $out; +} + +// ---------------------------------------------------------------------------- +// CONFIG +// ---------------------------------------------------------------------------- + +function scn01_load_config() { + $path = 'addon/scn01/config.json'; + $raw = @file_get_contents($path); + if ($raw === false) return []; + $data = json_decode($raw, true); + return (json_last_error() === JSON_ERROR_NONE) ? $data : []; +} + +// ---------------------------------------------------------------------------- +// CSRF +// ---------------------------------------------------------------------------- + +function scn01_csrf_token() { + if (empty($_SESSION['scn01_csrf'])) { + $_SESSION['scn01_csrf'] = bin2hex(random_bytes(16)); + } + return ''; +} + +function scn01_verify_csrf() { + return isset($_POST['scn01_csrf'], $_SESSION['scn01_csrf']) + && hash_equals($_SESSION['scn01_csrf'], $_POST['scn01_csrf']); +}