aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/class/application.php6
-rw-r--r--app/class/controllerart.php10
-rw-r--r--app/class/model.php7
-rw-r--r--app/class/modelfont.php1
-rw-r--r--app/class/modelrender.php30
-rw-r--r--app/class/routes.php1
-rw-r--r--app/view/templates/editrightbar.php3
-rw-r--r--app/view/templates/edittabs.php6
-rw-r--r--assets/css/home.css5
9 files changed, 43 insertions, 26 deletions
diff --git a/app/class/application.php b/app/class/application.php
index 79e9563..8e50c19 100644
--- a/app/class/application.php
+++ b/app/class/application.php
@@ -9,7 +9,11 @@ class Application
public function wakeup()
{
if(isset($_POST['configinit'])) {
- Config::createconfig($_POST['configinit']);
+ if(Config::readconfig()) {
+ Config::createconfig($_POST['configinit']);
+ } else {
+ Config::hydrate($_POST['configinit']);
+ }
if(!Config::savejson()) {
echo 'Cant write config file';
exit;
diff --git a/app/class/controllerart.php b/app/class/controllerart.php
index e385201..b990237 100644
--- a/app/class/controllerart.php
+++ b/app/class/controllerart.php
@@ -6,6 +6,7 @@ class Controllerart extends Controller
protected $art;
protected $artmanager;
protected $renderengine;
+ protected $fontmanager;
public function __construct($router)
{
@@ -13,6 +14,7 @@ class Controllerart extends Controller
$this->artmanager = new Modelart();
$this->renderengine = new Modelrender($router);
+ $this->fontmanager = new Modelfont();
}
@@ -97,8 +99,7 @@ class Controllerart extends Controller
$showleftpanel = false;
$showrightpanel = false;
}
- $fontmanager = new Modelfont;
- $fonts = $fontmanager->list();
+ $fonts = [];
$this->showtemplate('edit', ['art' => $this->art, 'artexist' => true, 'tablist' => $tablist, 'artlist' => $artlist, 'showleftpanel' => $showleftpanel, 'showrightpanel' => $showrightpanel, 'fonts' => $fonts]);
} else {
@@ -166,6 +167,11 @@ class Controllerart extends Controller
}
+
+ public function artdirect($id)
+ {
+ $this->routedirect('artread/', ['art' => idclean($id)]);
+ }
}
diff --git a/app/class/model.php b/app/class/model.php
index 6d8aec3..b6e2ee6 100644
--- a/app/class/model.php
+++ b/app/class/model.php
@@ -1,5 +1,5 @@
<?php
-class Model
+abstract class Model
{
const CONFIG_FILE = 'config.json';
@@ -32,13 +32,14 @@ class Model
return DIRECTORY_SEPARATOR . $basepath . Model::CSS_DIR;
}
- public function fontpath()
+ public static function fontpath()
{
$basepath = '';
if(!empty(Config::basepath())) {
$basepath = Config::basepath() . DIRECTORY_SEPARATOR ;
}
- return $basepath . Model::FONT_DIR;
+ $url = DIRECTORY_SEPARATOR . $basepath . Model::FONT_DIR;
+ return $url;
}
diff --git a/app/class/modelfont.php b/app/class/modelfont.php
index 135a3df..11ce6dd 100644
--- a/app/class/modelfont.php
+++ b/app/class/modelfont.php
@@ -4,6 +4,7 @@ class Modelfont extends Model
{
public function list()
{
+ var_dump(Model::fontpath());
if ($handle = opendir(Model::fontpath())) {
$list = [];
while (false !== ($entry = readdir($handle))) {
diff --git a/app/class/modelrender.php b/app/class/modelrender.php
index 2d56f6b..64a07fa 100644
--- a/app/class/modelrender.php
+++ b/app/class/modelrender.php
@@ -51,7 +51,9 @@ class Modelrender extends Modelart
} else {
$text = $art->$element();
}
- $elements[$element] = PHP_EOL . '<' . $element . '>' . PHP_EOL . $this->markdown($text) . PHP_EOL . '</' . $element . '>' . PHP_EOL;
+ $text = $this->article($text);
+ $text = $this->markdown($text);
+ $elements[$element] = PHP_EOL . '<' . $element . '>' . PHP_EOL . $text . PHP_EOL . '</' . $element . '>' . PHP_EOL;
}
@@ -158,8 +160,6 @@ class Modelrender extends Modelart
$text = $this->wurl($text);
$text = $this->wikiurl($text);
- $text = $this->tooltip($art->linkfrom('array'), $text);
-
$text = str_replace('href="http', ' class="external" target="_blank" href="http', $text);
$text = str_replace('<img src="/', '<img src="./media/', $text);
@@ -226,22 +226,18 @@ class Modelrender extends Modelart
-
- public function tooltip(array $linkfrom, string $text)
+ public function article($text)
{
- $descriptions = [];
- $artlist = $this->getlisterid($linkfrom);
- foreach ($artlist as $art) {
- $descriptions[$art->id()] = $art->description();
- }
-
- foreach ($linkfrom as $id) {
- if (isset($descriptions[$id])) {
- $linkfrom = 'href="?id=' . $id . '"';
- $titlelinkfrom = ' title="' . $descriptions[$id] . '" ' . $linkfrom;
- $text = str_replace($linkfrom, $titlelinkfrom, $text);
+ $pattern = '/(\R\R|^\R|^)[=]{3,}([\w-]*)\R\R(.*)(?=\R\R[=]{3,}[\w-]*\R)/sUm';
+ $text = preg_replace_callback($pattern, function($matches) {
+ if(!empty($matches[2])) {
+ $id = ' id="'.$matches[2].'" ';
+ } else {
+ $id = ' ';
}
- }
+ return '<article ' . $id . ' markdown="1" >' . PHP_EOL . PHP_EOL . $matches[3] . PHP_EOL . PHP_EOL . '</article>' . PHP_EOL . PHP_EOL;
+ } , $text);
+ $text = preg_replace('/\R\R[=]{3,}([\w-]*)\R/', '', $text);
return $text;
}
diff --git a/app/class/routes.php b/app/class/routes.php
index f240f6b..dda30d7 100644
--- a/app/class/routes.php
+++ b/app/class/routes.php
@@ -25,6 +25,7 @@ class Routes
['POST', '/[cid:art]/edit', 'Controllerart#update', 'artupdate'],
['GET', '/[cid:art]/delete', 'Controllerart#confirmdelete', 'artconfirmdelete'],
['POST', '/[cid:art]/delete', 'Controllerart#delete', 'artdelete'],
+ ['GET', '/[cid:art]/[*]', 'Controllerart#artdirect', 'artread/etoile'],
]);
$match = $router->match();
diff --git a/app/view/templates/editrightbar.php b/app/view/templates/editrightbar.php
index 74ba1dd..fa249ef 100644
--- a/app/view/templates/editrightbar.php
+++ b/app/view/templates/editrightbar.php
@@ -7,8 +7,7 @@
<?php
foreach ($artlist as $item ) {
?>
- <a href="<?= $this->uart('artedit', $item) ?>"><?= $item ?></a>
- <input type="text" value="[<?= $item ?>](=<?= $item ?>)">
+ <a href="<?= $this->uart('artedit', $item) ?>" target="_blank"><?= $item ?></a>
<?php
}
diff --git a/app/view/templates/edittabs.php b/app/view/templates/edittabs.php
index efb1650..4980354 100644
--- a/app/view/templates/edittabs.php
+++ b/app/view/templates/edittabs.php
@@ -10,7 +10,11 @@ foreach ($tablist as $key => $value) {
}
echo '<label for="tab' . $key . '">' . $key . '</label>';
echo '<div class="content">';
- echo '<textarea name="' . $key . '" id="' . $key . '" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">' . $value . '</textarea>';
+ if ($key == $opentab) {
+ echo '<textarea name="' . $key . '" id="' . $key . '" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus >' . $value . '</textarea>';
+ } else {
+ echo '<textarea name="' . $key . '" id="' . $key . '" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">' . $value . '</textarea>';
+ }
echo '</div>';
echo '</div>';
}
diff --git a/assets/css/home.css b/assets/css/home.css
index 3d57cf0..ca8ad63 100644
--- a/assets/css/home.css
+++ b/assets/css/home.css
@@ -58,4 +58,9 @@ div#massedit {
#options ul {
list-style: none;
padding-inline-start: 0;
+}
+
+th {
+ background-color: darkgrey;
+ color: black;
} \ No newline at end of file