Skip to content

Commit

Permalink
markdown text editor changed
Browse files Browse the repository at this point in the history
  • Loading branch information
jeansordes committed Jul 26, 2017
1 parent b8fa517 commit 5832aa7
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 67 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"slim/slim": "^3.0",
"slim/twig-view": "^2.2",
"mrclay/minify": "~3.0.0",
"michelf/php-markdown": "^1.7"
"erusev/parsedown": "^1.6"
},
"autoload": {
"psr-4": {
Expand Down
103 changes: 54 additions & 49 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function user_can_do ($action_name, $project_type) {
$filter = new Twig_SimpleFilter('is_allowed_for', function ($action_name, $project_type) { return user_can_do($action_name, $project_type); });
$twig->addFilter($filter);

$filter = new Twig_SimpleFilter('markdown', function ($text) { return Michelf\Markdown::defaultTransform($text); });
$filter = new Twig_SimpleFilter('markdown', function ($text) { return Parsedown::instance()->text($text); });
$twig->addFilter($filter);

$filter = new Twig_SimpleFilter('timeago', function ($datetime) {
Expand Down Expand Up @@ -186,6 +186,7 @@ function user_can_do ($action_name, $project_type) {
exec("touch " . __DIR__ . "/src/templates/twig_cache/.gitkeep");
exec("git pull", $result);
foreach ($result as $line) $output .= $line."\n";
exec("php composer.phar update -o");
return "<pre>" . $output . "</pre>";
});
$app->get('/get_last_posted_on/{project_id}/{last_time}', function ($request, $response, $args) {
Expand Down
2 changes: 2 additions & 0 deletions public/perso/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ $(function(){
function scrollTo (el){ $('html, body').animate( { scrollTop: $(el).offset().top }, 500); }

if (document.getElementsByClassName('.drawing-board-import')[0]){
var simplemde = new SimpleMDE({ element: document.getElementsByClassName('textarea-js')[0] });

$('.drawing-board-import').on('change', handleImage);
function handleImage(e){
var postId = event.target.getAttribute('data-postid');
Expand Down
1 change: 1 addition & 0 deletions public/perso/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ $(function(){
var mainBoard;
function resetBoard (elId, returnBoard){
if (document.getElementById(elId) != null){
var simplemde = new SimpleMDE({ element: document.getElementById(elId).parentNode.parentNode.parentNode.getElementsByClassName('textarea-js')[0] });
document.getElementById(elId).innerHTML = '';
mainBoard = new DrawingBoard.Board(elId, {
controls: [
Expand Down
16 changes: 15 additions & 1 deletion src/templates/post/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-blue.min.css">
<link rel="stylesheet" href="https://opensource.keycdn.com/fontawesome/4.7.0/font-awesome.min.css">
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>

<link rel="stylesheet" href="/min/?f=/public/perso/project.css,/public/drawingboard/drawingboard.min.css"/>
<script src="/min/?f=/public/unveil.js,/public/drawingboard/drawingboard.min.js,/public/treant/vendor/raphael.js"></script>
Expand Down Expand Up @@ -83,7 +85,19 @@
<h3>Proposer une modification</h3>
<div class="mdl-grid">
<div class="text-center">
{% include "post/post-more/add-text.html" %}
<form class="list-inline text-center" action="/add-post" method="post">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<label class="mdl-textfield__label">Envoyez du texte</label>
<input id="{{ post.id }}-text-form" class="mdl-textfield__input" type="text" name="content" data-postid="{{ post.id }}">
</div>
<div>
<button class="mdl-button mdl-js-button mdl-button--raised">Envoyer</button>
</div>

<input type="hidden" name="is_an_edit" value="{% if current_page_is_edit_page %}true{% else %}false{% endif %}">
<input type="hidden" name="parent_id" value="{{ post.id }}">
</form>
<div class="text-help text-center">Attention seul les balises suivantes sont acceptés :<br><code><strong>&lt;strong&gt;</strong><em>&lt;em&gt;</em><del>&lt;del&gt;</del>&lt;span&gt;&lt;div&gt;</code>
</div>
</div>
{% else %}
Expand Down
13 changes: 11 additions & 2 deletions src/templates/post/post-more/add-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<span>|</span>
<a href="#{{ post.id }}-file-form" class="text-no-decoration" data-scroll><i class="fa fa-file-image-o fa-fw"></i> Envoyez une image</a>
<span>|</span>
<label for="{{ post.id }}-text-form" class="text-primary text-click"><i class="fa fa-font fa-fw"></i> Envoyez du texte</label>
<a href="#{{ post.id }}-text-form" class="text-no-decoration" data-scroll><i class="fa fa-font fa-fw"></i> Envoyez du texte</a>
</div>
<hr>
<h6 id="{{ post.id }}-drawing-form">Dessiner</h6>
Expand Down Expand Up @@ -51,5 +51,14 @@ <h6 id="{{ post.id }}-file-form">Envoyez une image</h6>
</form>
<div class="text-help text-center">Formats acceptés : <code>.jpg .jpeg .png .svg .gif</code></div>
<h6>Envoyez du texte</h6>
{% include 'post/post-more/add-text.html' %}
<form id="{{ post.id }}-text-form" action="/add-post" method="post">
<textarea class="textarea-js" type="text" name="content" data-postid="{{ post.id }}" rows= "2"></textarea>
<div>
<button class="mdl-button mdl-js-button mdl-button--raised">Envoyer</button>
</div>

<input type="hidden" name="is_an_edit" value="{% if current_page_is_edit_page %}true{% else %}false{% endif %}">
<input type="hidden" name="parent_id" value="{{ post.id }}">
</form>
<div class="text-help text-center">Nous supportons <a target="_blank" href="http://tifod.com/blog/markdown">la syntaxe Markdown</a></div>
</div>
13 changes: 0 additions & 13 deletions src/templates/post/post-more/add-text.html

This file was deleted.

2 changes: 2 additions & 0 deletions src/templates/post/project-player.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-blue.min.css">
<link rel="stylesheet" href="https://opensource.keycdn.com/fontawesome/4.7.0/font-awesome.min.css">
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>

<link rel="stylesheet" href="/min/?f=/public/perso/project.css,/public/treant/Treant.css,/public/drawingboard/drawingboard.min.css"/>
<script src="/min/?f=/public/unveil.js,/public/drawingboard/drawingboard.min.js,/public/treant/vendor/raphael.js,/public/treant/Treant.js,/public/perso/project.js"></script>
Expand Down

0 comments on commit 5832aa7

Please sign in to comment.