fixed the way to display correctly the posts
parent
21d9d25215
commit
cbc88b34b8
|
@ -7,6 +7,7 @@ pub mod schema;
|
|||
extern crate rocket;
|
||||
#[macro_use]
|
||||
extern crate diesel;
|
||||
extern crate comrak;
|
||||
extern crate dotenv;
|
||||
extern crate rand;
|
||||
extern crate rocket_contrib;
|
||||
|
@ -14,6 +15,7 @@ extern crate tera;
|
|||
|
||||
use self::diesel::prelude::*;
|
||||
use self::models::*;
|
||||
use comrak::{markdown_to_html, ComrakOptions};
|
||||
use diesel::pg::PgConnection;
|
||||
use dotenv::dotenv;
|
||||
use rand::Rng;
|
||||
|
@ -94,7 +96,9 @@ fn show_post(title: String) -> Template {
|
|||
let title_fmt = TITLES[rng.gen_range(0, TITLES.len())];
|
||||
let title = str::replace(title_fmt, "{}", "CódigoComentado");
|
||||
|
||||
let post = get_post(id);
|
||||
let mut post = get_post(id);
|
||||
let content = markdown_to_html(&post.content, &ComrakOptions::default());
|
||||
post.content = content;
|
||||
|
||||
context.insert("title", &title);
|
||||
context.insert("post", &post);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{% extends "base" %}
|
||||
{% block title %}{% endblock title %}
|
||||
{% block title %}CódigoComentado - {{post.title}}{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
<h1><strong>Title: </strong>{{ post.title }}</h1>
|
||||
<strong>Content:</strong>
|
||||
<article>
|
||||
{{ post.content | split(pat="\n") | join(sep="----------") }}
|
||||
{{ post.content | safe }}
|
||||
</article>
|
||||
|
||||
{% endblock content %}
|
||||
|
|
Loading…
Reference in New Issue