Skip to content

Commit 861dd01

Browse files
committed
ajout sujet markdown
1 parent 4adb996 commit 861dd01

10 files changed

+209
-15
lines changed

public/css/custom.css

+11-6
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,28 @@ h2 {
6969
}
7070

7171
/* MARKDOWN CONTENT */
72+
.markdown_content {
73+
font-family: 'Latin Modern Roman', serif;
74+
font-size:17px;
75+
}
76+
7277
.markdown_content h1 {
73-
font-size: 17px;
78+
font-size: 18px;
7479
text-transform: uppercase;
7580
text-align:left;
7681
color:black;
7782
font-weight:bold;
78-
padding:0px 0px 8px 0px;
83+
padding:10px 0px 8px 0px;
7984
margin:0px;
8085
}
8186

8287
.markdown_content h2 {
83-
font-size: 16px;
88+
font-size: 17px;
8489
text-transform: uppercase;
8590
text-align:left;
86-
color: #2c3e50;
91+
color: black;
8792
font-weight:bold;
88-
padding:0px 0px 5px 0px;
93+
padding:10px 0px 5px 0px;
8994
margin:0px;
9095
}
9196

@@ -94,7 +99,7 @@ h2 {
9499
}
95100

96101
.markdown_content pre {
97-
padding:10px;
102+
padding:4px;
98103
border:solid 1px #ced4da;
99104
background-color:#fafcfe;
100105
border-radius:4px;

public/css/easymde-custom.css

+53
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,63 @@
3333
border-radius: 4px;
3434
}
3535

36+
/*
37+
.editor-preview {
38+
font-family: 'Latin Modern Roman', serif;
39+
font-size:16px;
40+
}
41+
42+
.editor-preview h1 {
43+
color:black;
44+
}
45+
46+
.editor-preview h2 {
47+
color:black;
48+
}
49+
3650
.editor-preview pre {
3751
display:block;
3852
border:solid 1px #CED4DA;
3953
background-color:#F8FAFC;
4054
border-radius:4px;
4155
padding:10px;
56+
}
57+
*/
58+
59+
.editor-preview {
60+
font-family: 'Latin Modern Roman', serif;
61+
font-size:17px;
62+
}
63+
64+
.editor-preview h1 {
65+
font-size: 18px;
66+
text-transform: uppercase;
67+
text-align:left;
68+
color:black;
69+
font-weight:bold;
70+
padding:10px 0px 8px 0px;
71+
margin:0px;
72+
}
73+
74+
.editor-preview h2 {
75+
font-size: 17px;
76+
text-transform: uppercase;
77+
text-align:left;
78+
color: black;
79+
font-weight:bold;
80+
padding:10px 0px 5px 0px;
81+
margin:0px;
82+
}
83+
84+
.editor-preview p {
85+
margin: 0px 0px 4px 0px;
86+
}
87+
88+
.editor-preview pre {
89+
padding:4px;
90+
border:solid 1px #ced4da;
91+
background-color:#fafcfe;
92+
border-radius:4px;
93+
/*color:#6c757d;*/
94+
font-size:95%;
4295
}

resources/views/devoirs/devoir-imprimer.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@
182182
//space() { return undefined },
183183
//code() { return undefined },
184184
//fences() { return undefined },
185-
heading() { return undefined },
185+
//heading() { return undefined },
186186
//hr() { return undefined },
187-
blockquote() { return undefined },
187+
//blockquote() { return undefined },
188188
//list() { return undefined },
189189
html() { return undefined },
190190
//def() { return undefined },

resources/views/markdown/inc-markdown-afficher-js.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
//fences() { return undefined },
2626
//heading() { return undefined },
2727
//hr() { return undefined },
28-
blockquote() { return undefined },
28+
//blockquote() { return undefined },
2929
//list() { return undefined },
3030
html() { return undefined },
3131
//def() { return undefined },
@@ -35,7 +35,7 @@
3535
//text() { return undefined },
3636
//escape() { return undefined },
3737
tag() { return undefined },
38-
link() { return undefined },
38+
//link() { return undefined },
3939
reflink() { return undefined },
4040
//emStrong() { return undefined },
4141
//codespan() { return undefined },

resources/views/markdown/inc-markdown-editeur-js.blade.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
//space() { return undefined },
2424
//code() { return undefined },
2525
//fences() { return undefined },
26-
heading() { return undefined },
26+
//heading() { return undefined },
2727
//hr() { return undefined },
28-
blockquote() { return undefined },
28+
//blockquote() { return undefined },
2929
//list() { return undefined },
3030
html() { return undefined },
3131
//def() { return undefined },
@@ -65,8 +65,17 @@
6565
var plainText2 = plainText.replace(/\$\$(.+?)\$\$/gs, function(match) {
6666
return match.replace(/\\\\/g, '\\\\\\\\');
6767
});
68+
69+
// Génère le HTML à partir du markdown et le nettoie
6870
preview.innerHTML = DOMPurify.sanitize(marked.parse(plainText2));
71+
72+
// Applique MathJax
6973
MathJax.typeset()
74+
75+
// Applique Highlight.js à chaque bloc de code
76+
preview.querySelectorAll("pre code").forEach((block) => {
77+
hljs.highlightElement(block);
78+
});
7079
}, 10);
7180
return "...";
7281
},

resources/views/sujets/inc-sujet-afficher-js.blade.php

+18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
{{-- == MARKDOWN + LATEX + COLORATION CODE =========== --}}
2+
13
@include('markdown/inc-markdown-afficher-js')
24

5+
{{-- == /MARKDOWN + LATEX + COLORATION CODE ========== --}}
6+
37
@if ($sujet->type == 'exo')
48

59
{{-- ============== --}}
@@ -108,4 +112,18 @@
108112
{{-- ==== /PDF ==== --}}
109113
{{-- ============== --}}
110114

115+
@endif
116+
117+
@if ($sujet->type == 'md')
118+
119+
{{-- ============== --}}
120+
{{-- ==== MD ====== --}}
121+
{{-- ============== --}}
122+
123+
124+
125+
{{-- ============== --}}
126+
{{-- ==== /MD ===== --}}
127+
{{-- ============== --}}
128+
111129
@endif

resources/views/sujets/inc-sujet-afficher.blade.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="p-3" style="border:1px solid #ced4da;border-radius:4px;background-color:white;">
2-
<h2 id="sujet_titre" class="p-0 m-0 text-monospace pb-2">{{ $sujet->titre }}</h2>
2+
<div class="pb-2 text-uppercase font-weight-bold" style="color:black;font-size:20px;font-family: 'Latin Modern Roman', serif;">{{ $sujet->titre }}</div>
33

44
@if ($sujet->type == 'exo')
55

@@ -60,4 +60,20 @@
6060

6161
@endif
6262

63+
@if ($sujet->type == 'md')
64+
65+
{{-- ============== --}}
66+
{{-- ==== MD ====== --}}
67+
{{-- ============== --}}
68+
69+
<!-- ÉNONCÉ -->
70+
<div class="markdown_content">{{ $sujet_json->enonce }}</div>
71+
<!-- /ÉNONCÉ -->
72+
73+
{{-- ============== --}}
74+
{{-- ==== /MD ===== --}}
75+
{{-- ============== --}}
76+
77+
@endif
78+
6379
</div>

resources/views/sujets/sujet-creer.blade.php

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<div class="text-center text-monospace">
3737
<a class="btn btn-dark mr-1" href="/sujet-exo-creer" role="button">Exercice Python</a>
3838
<a class="btn btn-dark ml-1" href="/sujet-pdf-creer" role="button">Sujet au format PDF</a>
39+
<a class="btn btn-dark ml-1" href="/sujet-md-creer" role="button">Sujet au format Markdown</a>
3940
</div>
4041

4142
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
3+
header("Cache-Control: post-check=0, pre-check=0", false);
4+
header("Pragma: no-cache");
5+
6+
if (isset($sujet_id)) {
7+
$sujet = App\Models\Sujet::find(Crypt::decryptString($sujet_id));
8+
if (!isset($sujet)) {
9+
echo "<pre>Ce sujet n'existe pas.</pre>";
10+
exit();
11+
} else {
12+
if ($sujet->user_id !== 0 && (!Auth::check() || (Auth::check() && Auth::id() !== $sujet->user_id))) {
13+
echo "<pre>Vous ne pouvez pas accéder à ce sujet.</pre>";
14+
exit();
15+
}
16+
$sujet_json = json_decode($sujet->sujet);
17+
}
18+
}
19+
?>
20+
<!doctype html>
21+
<html lang="fr">
22+
<head>
23+
@include('inc-meta')
24+
@include('markdown/inc-markdown-css')
25+
<title>SUJET MARKDOWN | CRÉER / MODIFIER</title>
26+
</head>
27+
<body>
28+
29+
@if(Auth::check())
30+
@include('inc-nav-console')
31+
@else
32+
@include('inc-nav')
33+
@endif
34+
35+
<div class="container mt-4 mb-5">
36+
37+
<div class="row">
38+
39+
<div class="col-md-2 text-right mt-1">
40+
@if(Auth::check())
41+
<a class="btn btn-light btn-sm" href="/console/sujets" role="button"><i class="fas fa-arrow-left"></i></a>
42+
@else
43+
@if (isset($jeton_secret))
44+
<a class="btn btn-light btn-sm" href="/sujet-console/{{ $jeton_secret }}" role="button"><i class="fas fa-arrow-left"></i></a>
45+
@else
46+
<a class="btn btn-light btn-sm" href="/sujet-creer" role="button"><i class="fas fa-arrow-left"></i></a>
47+
@endif
48+
<div class="mt-3 small text-monospace text-muted">Vous pouvez <a href="/creer-un-compte" target="_blank">créer un compte</a> pour regrouper, gérer et partager vos sujets.</div>
49+
@endif
50+
</div>
51+
52+
<div class="col-md-10 pl-4 pr-4">
53+
54+
<h1 class="mb-0">{{__('sujet')}}</h1>
55+
<div class="mb-4 text-muted">Au format Markdown</div>
56+
57+
<form id="sujet_form" method="POST" action="{{ route('sujet-md-creer-post') }}" enctype="multipart/form-data">
58+
59+
@csrf
60+
61+
<!-- TITRE -->
62+
<div class="text-monospace">{{strtoupper(__('titre'))}}<sup class="ml-1 text-danger small">*</sup></div>
63+
<input id="titre" type="text" class="form-control @error('titre') is-invalid @enderror" name="titre" value="{{ $sujet->titre ?? '' }}" autofocus>
64+
<div id="error_titre" class="mt-1 text-danger text-monospace" style="font-size:70%" role="alert">&nbsp;</div>
65+
<!-- /TITRE -->
66+
67+
<!-- ÉNONCÉ -->
68+
<div class="mt-4 text-monospace">{{strtoupper(__('ÉNONCÉ'))}}<sup class="ml-1 text-danger small">*</sup></div>
69+
<textarea id="markdown_content" class="form-control" name="enonce" rows="6">{{ $sujet_json->enonce ?? '' }}</textarea>
70+
<!-- /ÉNONCÉ -->
71+
72+
@if(isset($sujet_id))
73+
<input type="hidden" name="sujet_id" value="{{Crypt::encryptString($sujet->id)}}" />
74+
@endif
75+
76+
@if(isset($dupliquer))
77+
<input type="hidden" name="dupliquer" value="true" />
78+
@endif
79+
80+
<button type="submit" id="dropzone_submit" class="btn btn-primary mt-3 mb-5 pl-4 pr-4"><i class="fas fa-check"></i></button>
81+
82+
</form>
83+
84+
</div>
85+
</div><!-- /row -->
86+
</div><!-- /container -->
87+
88+
@include('inc-bottom-js')
89+
@include('markdown/inc-markdown-editeur-js')
90+
91+
</body>
92+
</html>

routes/web.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@
281281
Route::post('/sujet-pdf-creer', [App\Http\Controllers\SujetController::class, 'sujet_pdf_creer_post'])->name('sujet-pdf-creer-post');
282282

283283
// md
284-
//Route::get('/sujet-creer/{jeton_secret}/md', [App\Http\Controllers\SujetController::class, 'sujet_creer_md_get'])->name('sujet-creer-md-get');
285-
//Route::post('/sujet-creer/{jeton_secret}/md', [App\Http\Controllers\SujetController::class, 'sujet_creer_md_post'])->name('sujet-creer-md-post');
284+
Route::get('/sujet-md-creer/{sujet_id?}/{dupliquer?}', [App\Http\Controllers\SujetController::class, 'sujet_md_creer_get'])->name('sujet-md-creer-get');
285+
Route::post('/sujet-md-creer', [App\Http\Controllers\SujetController::class, 'sujet_md_creer_post'])->name('sujet-md-creer-post');
286286

287287
// console
288288
Route::any('/sujet-console/{jeton_secret}', [App\Http\Controllers\SujetController::class, 'sujet_console'])->name('sujet-console');

0 commit comments

Comments
 (0)