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": {
"simplesamlphp/simplesamlphp": "~1"
"simplesamlphp/simplesamlphp": "~1",
"erusev/parsedown": "^1.7"
},
"require-dev": {
"ext-pdo_sqlite": "*"
}
}
}

50
composer.lock generated
View File

@ -1,11 +1,57 @@
{
"_readme": [
"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"
],
"content-hash": "eff76bfaa958c3f30a87781731812450",
"content-hash": "892031a2c857679ab79c60de03fccc25",
"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",
"version": "v3.6.1",

View File

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

View File

@ -99,7 +99,7 @@ else {
</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>

View File

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

View File

@ -53,7 +53,7 @@ $motd = $motdfetcher->getMOTD();
<p class="subnote">Ikke nødvendig</p>
<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>
<div style="margin-top: 2em;">

View File

@ -87,7 +87,7 @@ foreach($members as $i => $data){
<p class="subtitle">Tittel</p>
<?= '<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>
</div>
@ -140,4 +140,4 @@ foreach($members as $i => $data){
</form>
<p>
</main>
</body>
</body>

View File

@ -92,7 +92,10 @@ $projects = array_values(array_filter(
<div class="event-info">
<h3 class="no-chin"><?= $project->getName() . " (ID: " . $projectID . ")"; ?></h3>
<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 class="event-actions">
@ -137,4 +140,4 @@ $projects = array_values(array_filter(
</div>
</main>
</body>
</body>

View File

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

View File

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

View File

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

View File

@ -42,7 +42,11 @@ $translation = ['I dag', 'I morgen', 'Denne uka', 'Neste uke', 'Denne måneden',
<?php $description = $event->getDescription(); ?>
<?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">
<li>Tid: <strong><?= Agenda::getFormattedDate($event->getStart()) ?></strong></li>

View File

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

View File

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

View File

@ -71,7 +71,7 @@ if($new == 0){
<p class="subnote">Gi prosjektet ditt et passende navn</p>
<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">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>

View File

@ -93,7 +93,10 @@ $projects = $projectManager->getAll();
<a class="nostyle" href="info.php?id=<?= $project->getID() ?>"><div class="project-card">
<div class="card-content">
<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>
<p class="project-organizer">Organisert av <?= $owner['name']; ?></p>
</div></a>

View File

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