Switch to useing markdown for user formatted text

This commit is contained in:
Peder Bergebakken Sundt 2018-08-12 03:52:55 +02:00
parent 307eba4218
commit 79e413d194
17 changed files with 120 additions and 47 deletions

View File

@ -1,8 +1,9 @@
{ {
"require": { "require": {
"simplesamlphp/simplesamlphp": "~1" "simplesamlphp/simplesamlphp": "~1",
"erusev/parsedown": "^1.7"
}, },
"require-dev": { "require-dev": {
"ext-pdo_sqlite": "*" "ext-pdo_sqlite": "*"
} }
} }

50
composer.lock generated
View File

@ -1,11 +1,57 @@
{ {
"_readme": [ "_readme": [
"This file locks the dependencies of your project to a known state", "This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "eff76bfaa958c3f30a87781731812450", "content-hash": "892031a2c857679ab79c60de03fccc25",
"packages": [ "packages": [
{
"name": "erusev/parsedown",
"version": "1.7.1",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown.git",
"reference": "92e9c27ba0e74b8b028b111d1b6f956a15c01fc1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/92e9c27ba0e74b8b028b111d1b6f956a15c01fc1",
"reference": "92e9c27ba0e74b8b028b111d1b6f956a15c01fc1",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35"
},
"type": "library",
"autoload": {
"psr-0": {
"Parsedown": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"description": "Parser for Markdown.",
"homepage": "http://parsedown.org",
"keywords": [
"markdown",
"parser"
],
"time": "2018-03-08T01:11:30+00:00"
},
{ {
"name": "gettext/gettext", "name": "gettext/gettext",
"version": "v3.6.1", "version": "v3.6.1",

View File

@ -33,30 +33,28 @@ class BrettspillEvent extends Event {
public function getDescription() { public function getDescription() {
return [ return [
'<p>Er du en hardcore brettspillentusiast eller en nybegynner som har så vidt spilt ludo?' . "\n" . 'Er du en hardcore brettspillentusiast eller en nybegynner som har så vidt spilt ludo?'.
'Da er vår brettspillkveld noe for deg!' . "\n" . 'Da er vår brettspillkveld noe for deg!' .
'Vi tar ut et par spill fra vårt samling of spiller så mye vi orker. Kom innom!', 'Vi tar ut et par spill fra vårt samling of spiller så mye vi orker. Kom innom!',
'',
'<p><a class="btn" href="#b_spill">Vår samling</a>', '## Vår samling',
'',
'<div id="b_spill" class="collapsable">' . "\n" . '* Dominion\*',
'<ul>' . "\n" . '* Three cheers for master',
'<li>Dominion*' . "\n" . '* Avalon',
'<li>Three cheers for master' . "\n" . '* Hanabi',
'<li>Avalon' . "\n" . '* Cards aginst humanity\*',
'<li>Hanabi' . "\n" . '* Citadels',
'<li>Cards aginst humanity*' . "\n" . '* Munchkin\*\*',
'<li>Citadels' . "\n" . '* Exploding kittens\*\*',
'<li>Munchkin**' . "\n" . '* Aye dark overlord',
'<li>Exploding kittens**' . "\n" . '* Settlers of catan\*',
'<li>Aye dark overlord' . "\n" . '* Risk\*\*',
'<li>Settlers of catan*' . "\n" . '* og mange flere...',
'<li>Risk**' . "\n" . '',
'<li>og mange flere...' . "\n" . '\* Vi har flere ekspansjoner til spillet',
'</ul>', '',
'<p>* Vi har flere ekspansjoner til spillet', '\*\* Vi har flere varianter av spillet',
'<p>** Vi har flere varianter av spillet',
'</div>'
]; ];
} }

View File

@ -99,7 +99,7 @@ else {
</div> </div>
</div> </div>
<p class="subtitle">Beskrivelse</p> <p class="subtitle">Beskrivelse (<i>markdown</i>)</p>
<textarea name="desc" rows="8" class="boxinput" placeholder="Beskrivese" required><?= implode($event->getDescription(), "\n"); ?></textarea> <textarea name="desc" rows="8" class="boxinput" placeholder="Beskrivese" required><?= implode($event->getDescription(), "\n"); ?></textarea>

View File

@ -95,7 +95,10 @@ $events = array_values(array_filter(
<p class="subnote"> <p class="subnote">
<?= $event->getStart()->format("(Y-m-d H:i:s)") . " - " . $event->getStop()->format("(Y-m-d H:i:s)"); ?> <?= $event->getStart()->format("(Y-m-d H:i:s)") . " - " . $event->getStop()->format("(Y-m-d H:i:s)"); ?>
</p> </p>
<p><?= implode($event->getDescription(), "<br>"); ?></p> <?php
$Parsedown = new \Parsedown();
echo $Parsedown->text(implode("\n", $event->getDescription()));
?>
</div> </div>
<div class="event-actions"> <div class="event-actions">

View File

@ -53,7 +53,7 @@ $motd = $motdfetcher->getMOTD();
<p class="subnote">Ikke nødvendig</p> <p class="subnote">Ikke nødvendig</p>
<input type="text" name="title" value="<?= $motd['title'] ?>" class="boxinput" style="width:66%;"><br> <input type="text" name="title" value="<?= $motd['title'] ?>" class="boxinput" style="width:66%;"><br>
<p class="subtitle no-chin">Innhold</p> <p class="subtitle no-chin">Innhold (<i>markdown</i>)</p>
<textarea name="content" style="width:100%" rows="8" class="boxinput"><?= implode("\n", $motd["content"]) ?></textarea> <textarea name="content" style="width:100%" rows="8" class="boxinput"><?= implode("\n", $motd["content"]) ?></textarea>
<div style="margin-top: 2em;"> <div style="margin-top: 2em;">

View File

@ -87,7 +87,7 @@ foreach($members as $i => $data){
<p class="subtitle">Tittel</p> <p class="subtitle">Tittel</p>
<?= '<input type="text" name="title" value="' . $project->getName() . '" class="boxinput">' ?><br> <?= '<input type="text" name="title" value="' . $project->getName() . '" class="boxinput">' ?><br>
<p class="subtitle">Beskrivelse</p> <p class="subtitle">Beskrivelse (<i>markdown</i>)</p>
<textarea name="desc" cols="40" rows="5" class="boxinput"><?= implode($project->getDescription(), "\n"); ?></textarea> <textarea name="desc" cols="40" rows="5" class="boxinput"><?= implode($project->getDescription(), "\n"); ?></textarea>
</div> </div>
@ -140,4 +140,4 @@ foreach($members as $i => $data){
</form> </form>
<p> <p>
</main> </main>
</body> </body>

View File

@ -92,7 +92,10 @@ $projects = array_values(array_filter(
<div class="event-info"> <div class="event-info">
<h3 class="no-chin"><?= $project->getName() . " (ID: " . $projectID . ")"; ?></h3> <h3 class="no-chin"><?= $project->getName() . " (ID: " . $projectID . ")"; ?></h3>
<p class="subnote"><?= 'Organisert av: ' . $owner['name']; ?></p> <p class="subnote"><?= 'Organisert av: ' . $owner['name']; ?></p>
<p><?= implode($project->getDescription(), "<br>"); ?></p> <?php
$Parsedown = new \Parsedown();
echo $Parsedown->text(implode("\n", $project->getDescription()));
?>
</div> </div>
<div class="event-actions"> <div class="event-actions">
@ -137,4 +140,4 @@ $projects = array_values(array_filter(
</div> </div>
</main> </main>
</body> </body>

View File

@ -42,7 +42,7 @@ $day = (isset($_GET['day']))
$limit = 0; $limit = 0;
foreach($events as $event) { foreach($events as $event) {
?> ?>
<div> <article>
<h2> <h2>
<?php if ($event->getImageURL()) { ?> <?php if ($event->getImageURL()) { ?>
<img src="<?= $event->getImageURL() ?>"> <img src="<?= $event->getImageURL() ?>">
@ -64,10 +64,12 @@ $day = (isset($_GET['day']))
<?php $description = $event->getDescription(); ?> <?php $description = $event->getDescription(); ?>
<?php if ($limit) array_splice($description, $limit); ?> <?php if ($limit) array_splice($description, $limit); ?>
<?= implode($description, "<br>") ?> <?php
</div> $Parsedown = new \Parsedown();
echo $Parsedown->text(implode("\n", $description));
?>
</article>
<?php if (!$limit || $limit > 4) {$limit = 4;} else $limit = 2; ?>
<?php } ?> <?php } ?>
</main> </main>

View File

@ -38,7 +38,10 @@ $nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
</strong> </strong>
</ul> </ul>
<?= implode($nextEvent->getDescription(), "<p>\n</p>")?> <?php
$Parsedown = new \Parsedown();
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
?>
</article> </article>
</main> </main>

View File

@ -46,7 +46,10 @@ $nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
</strong> </strong>
</ul> </ul>
<?= implode($nextEvent->getDescription(), "<p>\n</p>")?> <?php
$Parsedown = new \Parsedown();
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
?>
</article> </article>
</main> </main>

View File

@ -42,7 +42,11 @@ $translation = ['I dag', 'I morgen', 'Denne uka', 'Neste uke', 'Denne måneden',
<?php $description = $event->getDescription(); ?> <?php $description = $event->getDescription(); ?>
<?php if ($description_paragraphs) array_splice($description, $description_paragraphs); ?> <?php if ($description_paragraphs) array_splice($description, $description_paragraphs); ?>
<p><?= implode("<br>", $description) ?></p>
<?php
$Parsedown = new \Parsedown();
echo $Parsedown->text(implode("\n", $description));
?>
<ul class="subtext"> <ul class="subtext">
<li>Tid: <strong><?= Agenda::getFormattedDate($event->getStart()) ?></strong></li> <li>Tid: <strong><?= Agenda::getFormattedDate($event->getStart()) ?></strong></li>

View File

@ -89,8 +89,9 @@ $motd = $motdfetcher->getMOTD();
echo $title; echo $title;
} }
echo "</h2>"; echo "</h2>";
echo "<p>" . implode($motd["content"], "<br>") . "</p>"; $Parsedown = new Parsedown();
echo $Parsedown->text(implode("\n", $motd["content"]));
?> ?>
</div> </div>
</main> </main>

View File

@ -38,7 +38,10 @@ $nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
</strong> </strong>
</ul> </ul>
<?= implode($nextEvent->getDescription(), "<p>\n</p>")?> <?php
$Parsedown = new Parsedown();
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
?>
</article> </article>
</main> </main>

View File

@ -71,7 +71,7 @@ if($new == 0){
<p class="subnote">Gi prosjektet ditt et passende navn</p> <p class="subnote">Gi prosjektet ditt et passende navn</p>
<input type="text" name="title" value="<?= $project->getName() ?>" class="boxinput" style="width:66%;"><br> <input type="text" name="title" value="<?= $project->getName() ?>" class="boxinput" style="width:66%;"><br>
<p class="subtitle no-chin">Beskrivelse</p> <p class="subtitle no-chin">Beskrivelse (<i style="opacity:0.5;">markdown</i>)</p>
<p class="subnote no-chin">Hva går prosjektet ditt ut ?</p> <p class="subnote no-chin">Hva går prosjektet ditt ut ?</p>
<p class="subnote">De første to linjene blir vist prosjektkortet, prøv å gjøre de til et fint sammendrag eller intro!</p> <p class="subnote">De første to linjene blir vist prosjektkortet, prøv å gjøre de til et fint sammendrag eller intro!</p>
<textarea name="desc" style="width:100%" rows="8" class="boxinput"><?= implode($project->getDescription(), "\n"); ?></textarea> <textarea name="desc" style="width:100%" rows="8" class="boxinput"><?= implode($project->getDescription(), "\n"); ?></textarea>

View File

@ -93,7 +93,10 @@ $projects = $projectManager->getAll();
<a class="nostyle" href="info.php?id=<?= $project->getID() ?>"><div class="project-card"> <a class="nostyle" href="info.php?id=<?= $project->getID() ?>"><div class="project-card">
<div class="card-content"> <div class="card-content">
<h4 class="project-title"><?= $project->getName(); ?></h4> <h4 class="project-title"><?= $project->getName(); ?></h4>
<p><?= implode('<br>',array_slice($project->getDescription(), 0, 2)); ?></p> <?php
$Parsedown = new \Parsedown();
echo $Parsedown->text(implode("\n", array_slice($project->getDescription(), 0, 2)));
?>
</div> </div>
<p class="project-organizer">Organisert av <?= $owner['name']; ?></p> <p class="project-organizer">Organisert av <?= $owner['name']; ?></p>
</div></a> </div></a>

View File

@ -56,7 +56,10 @@ if ($attrs){
<main class="contentsplit"> <main class="contentsplit">
<div class="gridr"> <div class="gridr">
<h2><?= $project->getName(); ?></h2> <h2><?= $project->getName(); ?></h2>
<p><?= implode($project->getDescription(), "<br>"); ?></p> <?php
$Parsedown = new \Parsedown();
echo $Parsedown->text(implode("\n", $project->getDescription()));
?>
</div> </div>
<div class="gridl"> <div class="gridl">