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