# HG changeset patch # User m15o # Date 1684774592 -7200 # Mon May 22 18:56:32 2023 +0200 # Node ID 6fd928ef2e8034bb6f8a4e7039dbce85c7f118e8 # Parent df3d286bf38d2e6d777ab0b1ff2d3c7032d1c17b adding site.php diff --git a/includes/app.php b/includes/app.php --- a/includes/app.php +++ b/includes/app.php @@ -131,9 +131,13 @@ return "$slug"; } -function get_link2($username, $slug) +function get_link2($username, $slug = null) { - return "$slug"; + if (isset($slug)) { + return "$slug"; + } else { + return "$username"; + } } function home_link($user_id, $name) diff --git a/home.php b/includes/home.php copy from home.php copy to includes/home.php --- a/home.php +++ b/includes/home.php @@ -1,11 +1,4 @@ -getUser()->getFromUsername(get_user()) or page_not_found(); -$content = content_to_html2($site_user['home'], $site_user); -?> - - +
@@ -16,10 +9,10 @@
- + - \ No newline at end of file + \ No newline at end of file diff --git a/page.php b/includes/page.php copy from page.php copy to includes/page.php --- a/page.php +++ b/includes/page.php @@ -1,25 +1,16 @@ -getUser()->getFromUsername(get_user()) or page_not_found(); -$page = $GLOBALS['app']->getPage()->get($site_user['id'], $slug); -$related = $GLOBALS['app']->getPage()->related($site_user['id'], $slug); -?> - - +
- +

Not found

- -

Create page for ?

+ +

Create page for ?

- @@ -39,11 +30,11 @@ - + - + diff --git a/includes/site_header.php b/includes/site_header.php --- a/includes/site_header.php +++ b/includes/site_header.php @@ -14,7 +14,7 @@
diff --git a/index.php b/index.php --- a/index.php +++ b/index.php @@ -2,7 +2,7 @@ require 'includes/app.php'; if (is_member($user)) { - redirect("home.php?u=$user[name]"); + redirect("site.php?u=$user[name]"); } ?> diff --git a/site.php b/site.php new file mode 100644 --- /dev/null +++ b/site.php @@ -0,0 +1,17 @@ +getUser()->getFromUsername($u) or page_not_found(); +$is_admin = is_site_admin($site_user); + +if ($p) { + $page = $app->getPage()->get($site_user['id'], $p); + $related = $app->getPage()->related($site_user['id'], $p); + $content = content_to_html2($page['content'], $site_user); + include 'includes/page.php'; +} else { + $content = content_to_html2($site_user['home'], $site_user); + include 'includes/home.php'; +} \ No newline at end of file