M includes/app.php +7 -2
@@ 95,12 95,17 @@ function timeAgo($dateString)
return $output;
}
-function site_link($name, $page = null, $value = null)
+function site_url($name, $page = null)
{
$qs = "u=$name";
$page && $qs .= "&p=$page";
+ return URL . "/?$qs";
+}
+
+function site_link($name, $page = null, $value = null)
+{
$label = $value ?: ($page ?: $name);
- return "<a href=\"site.php?$qs\">$label</a>";
+ return '<a href="' . site_url($name, $page) . '">' . $label . '</a>';
}
function edit_link($page)
A => includes/index.php +34 -0
@@ 0,0 1,34 @@
+<?php include 'includes/header.php'; ?>
+
+<h1>tomoni</h1>
+
+<?php if (is_visitor($GLOBALS['User'])): ?>
+ <p class="is-visitor">You account is pending activation. You will be notified by email when activated.</p>
+<?php endif ?>
+
+<table>
+ <tr>
+ <td class="welcome">
+ <p>Tomoki is a little wiki engine. Make it your place to cultivate and grow your digital garden.</p>
+ <p>
+ <a href="register.php" class="link">Register</a><br>
+ <a href="manual.php" class="link">Manual</a><br>
+ <a href="activity.php" class="link">Explore</a>
+ </p>
+ </td>
+ <td class="login">
+ <form action="login.php" method="post">
+ <?php include 'includes/csrf.php' ?>
+ <label for="form-name">Email:</label>
+ <input type="email" name="email" value="" class="form-control" />
+
+ <label for="form-password">Password:</label>
+ <input type="password" name="password" class="form-control" required/>
+
+ <p><input type="submit" value="Login"/> <a href="password-lost.php">Password lost?</a></p>
+ </form>
+ </td>
+ </tr>
+</table>
+
+<?php include 'includes/footer.php'; ?>
M includes/page.php +8 -7
@@ 19,16 19,17 @@
<?php endif; ?>
<?php if (count($related)): ?>
- <nav class="related">
- <span>Related:</span>
- <?php foreach ($related as $r): ?>
- <?= site_link($site_user['name'], $r['slug']) ?>
- <?php endforeach; ?>
- </nav>
+ <aside>
+ <nav>
+ <?php foreach ($related as $r): ?>
+ <?= site_link($site_user['name'], $r['slug']) ?>
+ <?php endforeach; ?>
+ </nav>
+ </aside>
<?php endif; ?>
<?php if ($page && $is_admin): ?>
- <nav class="page-admin">
+ <nav>
<?= edit_link($p) ?>
<?= delete_link($p) ?>
</nav>
M +1 -2
@@ 1,5 1,5 @@
<?php if (is_site_admin($site_user)): ?>
<footer class="site-admin">
<footer>
<nav>
<a href="page_create.php">Add page</a>
<a href="settings.php">Settings</a>
@@ 12,4 12,3 @@
</body>
</html>
M index.php +19 -38
@@ 1,42 1,23 @@
<?php
require 'includes/app.php';
-if (is_member($User)) {
- redirect("site.php?u=$User[name]");
-}
-?>
-
-<?php include 'includes/header.php'; ?>
-
-<h1>tomoni</h1>
-
-<?php if (is_visitor($GLOBALS['User'])): ?>
- <p class="is-visitor">You account is pending activation. You will be notified by email when activated.</p>
-<?php endif ?>
+$u = get_param("u");
+$p = get_param("p");
+$site_user = $App->getUser()->getFromUsername($u);
+$is_admin = is_site_admin($site_user);
-<table>
- <tr>
- <td class="welcome">
- <p>Tomoki is a little wiki engine. Make it your place to cultivate and grow your digital garden.</p>
- <p>
- <a href="register.php" class="link">Register</a><br>
- <a href="manual.php" class="link">Manual</a><br>
- <a href="activity.php" class="link">Explore</a>
- </p>
- </td>
- <td class="login">
- <form action="login.php" method="post">
- <?php include 'includes/csrf.php' ?>
- <label for="form-name">Email:</label>
- <input type="email" name="email" value="" class="form-control" />
-
- <label for="form-password">Password:</label>
- <input type="password" name="password" class="form-control" required/>
-
- <p><input type="submit" value="Login"/> <a href="password-lost.php">Password lost?</a></p>
- </form>
- </td>
- </tr>
-</table>
-
-<?php include 'includes/footer.php'; ?>
+if ($p) {
+ $page = $App->getPage()->get($site_user['id'], $p);
+ $related = $App->getPage()->related($site_user['id'], $p);
+ if ($page) {
+ $content = content_to_html($page['content'], $site_user);
+ }
+ include 'includes/page.php';
+} else if ($u) {
+ $content = content_to_html($site_user['home'], $site_user);
+ include 'includes/home.php';
+} else if (is_member($User)) {
+ redirect(site_url($User["name"]));
+} else {
+ include 'includes/index.php';
+}
M page_update.php +4 -4
@@ 32,10 32,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST
<input type="submit" value="Submit"/>
</form>
+
+ <nav>
+ <?= delete_link($p) ?>
+ </nav>
</main>
-<nav class="page-admin">
- <?= delete_link($p) ?>
-</nav>
-
<?php include 'includes/site_footer.php'; ?>
R site.php => +0 -19
@@ 1,19 0,0 @@
-<?php
-require 'includes/app.php';
-
-$u = get_param("u");
-$p = get_param("p");
-$site_user = $App->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);
- if ($page) {
- $content = content_to_html($page['content'], $site_user);
- }
- include 'includes/page.php';
-} else {
- $content = content_to_html($site_user['home'], $site_user);
- include 'includes/home.php';
-}
No newline at end of file
M style.css +19 -28
@@ 1,12 1,10 @@
body {
- font-family: sans-serif;
- margin: 40px auto;
- padding: 1em;
max-width: 650px;
- line-height: 1.6;
- font-size: 18px;
+ margin: 10px auto;
+ font-family: Verdana;
+ line-height: 1.5;
+ padding: 10px;
background-color: floralwhite;
- border: 1px solid;
}
textarea {
@@ 30,34 28,27 @@ nav > * {
margin-right: 10px;
}
-footer {
- border-top: 1px solid;
- margin-top: 1em;
- padding-top: 1em;
-}
-
-.page-admin {
- padding: 10px;
- background-color: powderblue;
+aside {
+ border: 1px dashed;
+ padding: 1em;
margin-top: 1em;
}
-.related {
- border: 1px dashed midnightblue;
+main > nav {
padding: 1em;
- margin-top: 1em;
+ background-color: thistle;
+ margin-top: 1em
+}
+
+main {
+ margin-bottom: 1em;
+}
+
+footer {
+ padding-top: 1em;
+ border-top: 1px solid;
}
.link::before {
content: "↗ ";
}
-
-.welcome {
- width: 50%;
- padding-right: 1em;
-}
-
-.login {
- border: 1px solid;
- padding: 1em;
-}
No newline at end of file