mirror of
https://github.com/til-schneider/slim-wiki.git
synced 2025-08-06 16:46:31 +02:00
Added buttons to change between modes
This commit is contained in:
@@ -52,5 +52,5 @@
|
||||
//@import "@{bootstrap-src}/carousel.less";
|
||||
|
||||
// Utility classes
|
||||
//@import "@{bootstrap-src}/utilities.less";
|
||||
@import "@{bootstrap-src}/utilities.less";
|
||||
//@import "@{bootstrap-src}/responsive-utilities.less";
|
||||
|
@@ -20,6 +20,16 @@ html, body {
|
||||
}
|
||||
|
||||
.mode-edit {
|
||||
.close-edit-mode {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 50%;
|
||||
|
||||
.btn {
|
||||
margin: 5px (5px + 15px) 0 0; // 15px for scroll bar width
|
||||
}
|
||||
}
|
||||
|
||||
#editor-wrapper {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
|
@@ -8,15 +8,6 @@ body {
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
a, a:visited {
|
||||
color: @colorLink;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover, a:active {
|
||||
color: @colorLinkHover;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
// Views
|
||||
|
||||
.breadcrumbs {
|
||||
@@ -26,6 +17,9 @@ a:hover, a:active {
|
||||
padding: 15px 0;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
.pull-right {
|
||||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
|
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
$i18n = array(
|
||||
'button.cancel' => 'Abbrechen',
|
||||
'button.edit' => 'Bearbeiten',
|
||||
'button.createUser' => 'Benutzer erstellen',
|
||||
'createUser.userName' => 'Benutzername',
|
||||
'createUser.password' => 'Passwort',
|
||||
'createUser.showConfig' => 'Konfiguration anzeigen',
|
||||
|
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
$i18n = array(
|
||||
'button.cancel' => 'Cancel',
|
||||
'button.edit' => 'Edit',
|
||||
'button.createUser' => 'Create user',
|
||||
'createUser.userName' => 'User name',
|
||||
'createUser.password' => 'Password',
|
||||
'createUser.showConfig' => 'Show config',
|
||||
|
@@ -38,7 +38,8 @@ $mode = $data['mode'];
|
||||
if ($mode == 'edit') {
|
||||
?><div id="editor-wrapper">
|
||||
<textarea id="editor"><?php echo str_replace('<', '<', $data['articleMarkdown']); ?></textarea>
|
||||
</div><?php
|
||||
</div>
|
||||
<div class="close-edit-mode"><a class="btn btn-default" href="<?php echo $data['requestPath']; ?>">X</a></div><?php
|
||||
} // if ($mode == 'edit')
|
||||
|
||||
?>
|
||||
@@ -59,6 +60,12 @@ if ($mode == 'edit') {
|
||||
}
|
||||
$isFirst = false;
|
||||
}
|
||||
if ($data['showCreateUserButton']) {
|
||||
?><a class="btn btn-default btn-xs pull-right" href="<?php echo $data['requestPath']; ?>?createUser"><?php echo $i18n['button.createUser']; ?></a><?php
|
||||
}
|
||||
if ($mode == 'view') {
|
||||
?><a class="btn btn-default btn-xs pull-right" href="<?php echo $data['requestPath']; ?>?edit"><?php echo $i18n['button.edit']; ?></a><?php
|
||||
}
|
||||
?></div></nav>
|
||||
<article id="content" class="markdown main-column"><?php echo $data['articleHtml']; ?></article>
|
||||
<?php
|
||||
@@ -76,6 +83,7 @@ if ($mode == 'edit') {
|
||||
<input type="password" class="form-control" id="password" placeholder="<?php echo $i18n['createUser.password']; ?>">
|
||||
</div>
|
||||
<button id="showConfigBtn" class="btn btn-primary"><?php echo $i18n['createUser.showConfig']; ?></button>
|
||||
<a class="btn btn-default pull-right" href="<?php echo $data['requestPath']; ?>"><?php echo $i18n['button.cancel']; ?></a>
|
||||
<div id="result-box" class="markdown">
|
||||
<?php echo $i18n['createUser.addToConfig']; ?>
|
||||
<pre><code id="result"></code></pre>
|
||||
|
@@ -73,10 +73,13 @@ class Main {
|
||||
}
|
||||
|
||||
private function handleGet($baseUrl, $basePath, $requestPathArray, $requestQuery) {
|
||||
$showCreateUserButton = false;
|
||||
if ($requestQuery == 'edit' || $requestQuery == 'createUser') {
|
||||
$mode = $requestQuery;
|
||||
$showCreateUserButton = ($mode == 'edit');
|
||||
} else {
|
||||
$mode = 'view';
|
||||
$showCreateUserButton = ! $this->isUserDefined();
|
||||
}
|
||||
|
||||
if ($mode == 'edit') {
|
||||
@@ -87,6 +90,7 @@ class Main {
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
|
||||
$mode = 'view';
|
||||
$showCreateUserButton = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +112,9 @@ class Main {
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = $this->createBreadcrumbs($requestPathArray, $config['wikiName']);
|
||||
$data['showCreateUserButton'] = $showCreateUserButton;
|
||||
|
||||
$data['requestPath'] = implode('/', $requestPathArray);
|
||||
$data['articleFilename'] = $articleFilename;
|
||||
$articleMarkdown = file_get_contents($this->context->getArticleBaseDir() . $articleFilename);
|
||||
$data['articleMarkdown'] = $articleMarkdown;
|
||||
@@ -118,6 +124,16 @@ class Main {
|
||||
}
|
||||
}
|
||||
|
||||
private function isUserDefined() {
|
||||
$config = $this->context->getConfig();
|
||||
foreach ($config as $key => $value) {
|
||||
if (strpos($key, 'user.') === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function getArticleFilename($requestPathArray) {
|
||||
$articleBaseDir = $this->context->getArticleBaseDir();
|
||||
$articleFilename = implode('/', $requestPathArray);
|
||||
|
Reference in New Issue
Block a user