diff --git a/hubzilla/addon/dsc01/config.json.template b/hubzilla/addon/dsc01/config.json.template new file mode 100644 index 0000000..328897e --- /dev/null +++ b/hubzilla/addon/dsc01/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/dsc01/dsc01.apd b/hubzilla/addon/dsc01/dsc01.apd new file mode 100644 index 0000000..ec1069c --- /dev/null +++ b/hubzilla/addon/dsc01/dsc01.apd @@ -0,0 +1,7 @@ +version: 2 +url: $baseurl/dsc01 +requires: local_channel +name: DSC Categories +photo: icon:journal-text +categories: Civic Diagnostics +desc: Diagnostic Surface Categories — the legal surfaces where HOA governance disputes manifest, organized from the homeowner's perspective. diff --git a/hubzilla/addon/dsc01/dsc01.php b/hubzilla/addon/dsc01/dsc01.php new file mode 100644 index 0000000..98db1ee --- /dev/null +++ b/hubzilla/addon/dsc01/dsc01.php @@ -0,0 +1,155 @@ + + + + '; +} + +// ---------------------------------------------------------------------------- +// CONTENT +// ---------------------------------------------------------------------------- + +function dsc01_content() { + if (function_exists('head_add_css')) { + head_add_css('/addon/dsc01/view/css/dsc01.css'); + } + if (function_exists('head_add_js')) { + head_add_js('/addon/dsc01/view/js/dsc01.js'); + } + + $access = dsc01_access_state(); + + // dsc01 is public — access wall only gates submission, not reading + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if ($access === 'public' || $access === 'denied') { + return dsc01_access_wall(); + } + // TODO: handle POST submission + return dsc01_access_wall(); + } + + return dsc01_render_main($access); +} + +// ---------------------------------------------------------------------------- +// RENDER +// ---------------------------------------------------------------------------- + +function dsc01_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 dsc01_load_config() { + $path = 'addon/dsc01/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 dsc01_csrf_token() { + if (empty($_SESSION['dsc01_csrf'])) { + $_SESSION['dsc01_csrf'] = bin2hex(random_bytes(16)); + } + return ''; +} + +function dsc01_verify_csrf() { + return isset($_POST['dsc01_csrf'], $_SESSION['dsc01_csrf']) + && hash_equals($_SESSION['dsc01_csrf'], $_POST['dsc01_csrf']); +} diff --git a/hubzilla/addon/dsc01/mod_dsc01.pdl b/hubzilla/addon/dsc01/mod_dsc01.pdl new file mode 100644 index 0000000..596ad25 --- /dev/null +++ b/hubzilla/addon/dsc01/mod_dsc01.pdl @@ -0,0 +1,14 @@ +[template]default[/template] + +[region=aside] +[widget=dsc01][/widget] +[/region] + +[region=content] +$content +[/region] + +[region=right_aside] +[widget=notifications][/widget] +[widget=newmember][/widget] +[/region]