markdown bbcode and new ranks page

This commit is contained in:
flash 2016-09-10 00:47:14 +02:00
parent 76d9502d57
commit 0a7ef4f87a
8 changed files with 165 additions and 52 deletions

View file

@ -48,6 +48,7 @@ class Parser
Tags\Code::class, Tags\Code::class,
Tags\ListTag::class, Tags\ListTag::class,
Tags\User::class, Tags\User::class,
Tags\Markdown::class,
// Newline must always be last // Newline must always be last
Tags\Newline::class, Tags\Newline::class,

View file

@ -0,0 +1,49 @@
<?php
/**
* Markdown.
* @package Sakura
*/
namespace Sakura\BBCode\Tags;
use Parsedown;
use Sakura\BBCode\TagBase;
/**
* Markdown!
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Markdown extends TagBase
{
/**
* Contains the parser.
* @var Parsedown
*/
private static $parser = null;
/**
* Parses the bbcode.
* @param string $text
* @return string
*/
public static function parse($text)
{
return preg_replace_callback(
'/\[md\](.*?)\[\/md\]/s',
function ($matches) {
if (self::$parser === null) {
self::$parser = new Parsedown;
}
$parsed = self::$parser
->setBreaksEnabled(false)
->setMarkupEscaped(true)
->text($matches[1]);
return "<div class='markdown'>{$parsed}</div>";
},
$text
);
}
}

View file

@ -54,9 +54,6 @@ class Controller extends BaseController
$nav["Friends"]["Requests"] = route('settings.friends.requests'); $nav["Friends"]["Requests"] = route('settings.friends.requests');
} }
// Notifications
$nav["Notifications"]["History"] = route('settings.notifications.history');
// Appearance // Appearance
if (CurrentSession::$user->permission(Site::CHANGE_AVATAR)) { if (CurrentSession::$user->permission(Site::CHANGE_AVATAR)) {
$nav["Appearance"]["Avatar"] = route('settings.appearance.avatar'); $nav["Appearance"]["Avatar"] = route('settings.appearance.avatar');

View file

@ -19,7 +19,8 @@
"nesbot/carbon": "^1.21", "nesbot/carbon": "^1.21",
"swiftmailer/swiftmailer": "^5.4", "swiftmailer/swiftmailer": "^5.4",
"corneltek/cliframework": "^3.0", "corneltek/cliframework": "^3.0",
"illuminate/filesystem": "^5.2" "illuminate/filesystem": "^5.2",
"erusev/parsedown": "^1.6"
}, },
"autoload": { "autoload": {
"classmap": [ "classmap": [

43
composer.lock generated
View file

@ -4,8 +4,8 @@
"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#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "54f46a3b04683e9c4a3a7e8ecda23612", "hash": "b52ed9a48bc73bde0940da07200c9f92",
"content-hash": "82a4dc685e1ed81d5b76869d9946899f", "content-hash": "ee30eebf11e0d54fe7b19abbd4f134ea",
"packages": [ "packages": [
{ {
"name": "corneltek/class-template", "name": "corneltek/class-template",
@ -725,6 +725,45 @@
], ],
"time": "2014-09-09 13:34:57" "time": "2014-09-09 13:34:57"
}, },
{
"name": "erusev/parsedown",
"version": "1.6.0",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown.git",
"reference": "3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7",
"reference": "3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7",
"shasum": ""
},
"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": "2015-10-04 16:44:32"
},
{ {
"name": "illuminate/container", "name": "illuminate/container",
"version": "v5.2.37", "version": "v5.2.37",

View file

@ -1689,7 +1689,17 @@ a.default:active {
text-align: center; text-align: center;
} }
.settings .friends-list > div:not(:last-child) { .settings .friends-list button {
background: transparent;
border: 0;
cursor: pointer;
display: block;
box-sizing: border-box;
width: 100%;
}
.settings .friends-list > div:not(:last-child),
.settings .friends-list > form {
display: inline-block; display: inline-block;
border: 1px solid #9475B2; border: 1px solid #9475B2;
text-align: center; text-align: center;
@ -1701,28 +1711,42 @@ a.default:active {
transition: background .2s, box-shadow .2s; transition: background .2s, box-shadow .2s;
} }
.settings .friends-list > div:not(:last-child):hover { .settings .friends-list > div:not(:last-child):hover,
.settings .friends-list > form:hover {
margin-bottom: 6px; margin-bottom: 6px;
background: #C2AFFE; background: #C2AFFE;
box-shadow: inset 0 0 2px #9475B2; box-shadow: inset 0 0 2px #9475B2;
} }
.settings .friends-list > div > .friends-list-data { .settings .friends-list > form:hover {
margin-bottom: 4px;
}
.settings .friends-list > .active {
background: #C2AFFE;
box-shadow: inset 0 0 2px #9475B2;
}
.settings .friends-list > div > .friends-list-data,
.settings .friends-list > form > .friends-list-data {
display: block; display: block;
} }
.settings .friends-list > div > .friends-list-data > .friends-list-name { .settings .friends-list > div > .friends-list-data > .friends-list-name,
.settings .friends-list > form > .friends-list-data > .friends-list-name {
font-size: 1.2em; font-size: 1.2em;
line-height: 1.5em; line-height: 1.5em;
padding-bottom: 4px; padding-bottom: 4px;
} }
.settings .friends-list > div > .friends-list-actions { .settings .friends-list > div > .friends-list-actions,
.settings .friends-list > form > .friends-list-actions {
display: none; display: none;
background: linear-gradient(0deg, #9475B2, transparent) transparent; background: linear-gradient(0deg, #9475B2, transparent) transparent;
} }
.settings .friends-list > div > .friends-list-actions > a { .settings .friends-list > div > .friends-list-actions > a,
.settings .friends-list > form > .friends-list-actions > button {
color: #222; color: #222;
font-size: 2em; font-size: 2em;
line-height: 1em; line-height: 1em;
@ -1732,31 +1756,38 @@ a.default:active {
float: left; float: left;
} }
.settings .friends-list > div:hover > .friends-list-actions { .settings .friends-list > div:hover > .friends-list-actions,
.settings .friends-list > form:hover > .friends-list-actions {
display: block; display: block;
} }
.settings .friends-list > div > .friends-list-actions > .remove:hover { .settings .friends-list > div > .friends-list-actions > .remove:hover,
.settings .friends-list > form > .friends-list-actions > .remove:hover {
color: #D00; color: #D00;
} }
.settings .friends-list > div > .friends-list-actions > .remove:active { .settings .friends-list > div > .friends-list-actions > .remove:active,
.settings .friends-list > form > .friends-list-actions > .remove:active {
color: #A00; color: #A00;
} }
.settings .friends-list > div > .friends-list-actions > .add:hover { .settings .friends-list > div > .friends-list-actions > .add:hover,
.settings .friends-list > form > .friends-list-actions > .add:hover {
color: #0D0; color: #0D0;
} }
.settings .friends-list > div > .friends-list-actions > .add:active { .settings .friends-list > div > .friends-list-actions > .add:active,
.settings .friends-list > form > .friends-list-actions > .add:active {
color: #0A0; color: #0A0;
} }
.settings .friends-list > div > .friends-list-actions > a { .settings .friends-list > div > .friends-list-actions > a,
.settings .friends-list > form > .friends-list-actions > button {
width: 50%; width: 50%;
} }
.settings .friends-list > div > .friends-list-actions > .fill { .settings .friends-list > div > .friends-list-actions > .fill,
.settings .friends-list > form > .friends-list-actions > .fill {
width: 100%; width: 100%;
} }
@ -1766,7 +1797,12 @@ a.default:active {
margin-bottom: 6px; margin-bottom: 6px;
} }
.settings .friends-list > div > .friends-list-actions { .settings .friends-list > form {
margin-bottom: 4px;
}
.settings .friends-list > div > .friends-list-actions,
.settings .friends-list > form > .friends-list-actions {
display: block; display: block;
} }

View file

@ -7,23 +7,19 @@
{% endblock %} {% endblock %}
{% block settingsContent %} {% block settingsContent %}
<table class="settings-table"> <div class="friends-list">
<tbody>
{% for rank in user.ranks %} {% for rank in user.ranks %}
<tr {% if rank.id == user.mainRankId %} class="current-session" {% endif %}> <form method="post" action="{{ route('settings.account.ranks') }}" class="friend-container {% if rank.id == user.mainRankId %}active{% endif %}">
<td style="font-weight: bold; color: {{ rank.colour }}; text-shadow: 0 0 7px {{ rank.colour }}; text-align: left;">
<a href="{{ route('members.rank', rank.id) }}" class="clean">{{ rank.name }}</a>
</td>
<td style="width: 90px;">
<form method="post" action="{{ route('settings.account.ranks') }}">
<input type="hidden" name="session" value="{{ session_id() }}"> <input type="hidden" name="session" value="{{ session_id() }}">
<input type="hidden" name="rank" value="{{ rank.id }}"> <input type="hidden" name="rank" value="{{ rank.id }}">
<button class="inputStyling small" name="mode" value="main">Set as main</button> <button class="friends-list-data clean" name="mode" value="main">
<button class="inputStyling small" name="mode" value="remove" {% if rank.id in locked %}disabled="disabled"{% endif %}>Remove</button> <div class="friends-list-name" style="color: {{ rank.colour }};">{{ rank.name }}</div>
</button>
<div class="friends-list-actions">
<button title="{% if rank.id in locked %}You can't leave this rank{% else %}Leave rank{% endif %}" class="remove fill fa fa-{% if rank.id in locked %}shield{% else %}remove{% endif %}" name="mode" value="remove" {% if rank.id in locked %}disabled{% endif %}></button>
<div class="clear"></div>
</div>
</form> </form>
</td>
</tr>
{% endfor %} {% endfor %}
</tbody> </div>
</table>
{% endblock %} {% endblock %}

View file

@ -9,22 +9,18 @@ namespace Sakura;
// Check if logged out // Check if logged out
Router::filter('logoutCheck', function () { Router::filter('logoutCheck', function () {
if (CurrentSession::$user->isActive()) { if (CurrentSession::$user->isActive()) {
$message = "You must be logged out to do that!"; return view('global/information', [
'message' => "You must be logged out to do that!",
Template::vars(compact('message')); ]);
return Template::render('global/information');
} }
}); });
// Check if logged in // Check if logged in
Router::filter('loginCheck', function () { Router::filter('loginCheck', function () {
if (!CurrentSession::$user->isActive()) { if (!CurrentSession::$user->isActive()) {
$message = "You must be logged in to do that!"; return view('global/information', [
'message' => "You must be logged in to do that!",
Template::vars(compact('message')); ]);
return Template::render('global/information');
} }
}); });
@ -32,10 +28,8 @@ Router::filter('loginCheck', function () {
Router::filter('maintenance', function () { Router::filter('maintenance', function () {
if (config('general.maintenance')) { if (config('general.maintenance')) {
CurrentSession::stop(); CurrentSession::stop();
http_response_code(503); http_response_code(503);
return view('global/maintenance');
return Template::render('global/maintenance');
} }
}); });